Debian Codegraph @

lib/textaux.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/lib/textaux.h $
21 * $Revision: 4 $
22 * $Date: 11/03/98 7:04p $
23 * $Author: Samir $
24 *
25 * Auxillary Text functions (helper function, not necessarily belonging to grtext)
26 *
27 * $Log: /DescentIII/Main/lib/textaux.h $
28 *
29 * 4 11/03/98 7:04p Samir
30 * made Grtext_spacing global so word wrapper could access it.
31 *
32 * 3 7/14/98 2:47p Jeff
33 * added textaux_ClipString
34 *
35 * 2 7/14/98 11:53a Samir
36 * moved textaux to it's own libtary again.
37 *
38 * 1 7/13/98 4:41p Samir
39 *
40 * 2 7/11/98 9:14p Jeff
41 * initial creation (moved from TelCom)
42 *
43 * $NoKeywords: $
44 */
45
46 #ifndef TEXTAUX_H
47 #define TEXTAUX_H
48
49 // textaux_WordWrap
50 //
51 // Given a buffer of text, and an empty buffer of same size
52 // it will break the source buffer up into lines (seperated by /n) of size width or smaller (in pixels).
53 // All /n within the source buffer are preserved. Source buffer is also not changed.
54 void textaux_WordWrap(const char *src, char *dest, int width, int font);
55
56 // textaux_CopyTextLine
57 //
58 // This function goes hand-in-hand with textaux_WordWrap(). Given a buffer of data it will fill in
59 // the dest buffer until it hits a /n or /0. It returns a pointer to the start position of the next line,
60 // or NULL if it's done with the buffer (it hit a /0).
61 //
62 // Example of use:
63 //
64 // char *nextline;
65 // char linebuffer[256];
66 // int y = INITIAL_Y;
67 // int x = INITIAL_X;
68 //
69 // nextline = textaux_CopyTextLine(buffer,linebuffer);
70 //
71 // while((nextline)&&((y+font_height)<max_height) )
72 // {
73 // grtext_Printf(x,y,linebuffer);
74 // y += font_height;
75 // nextline = CopyTextLine(nextline,linebuffer);
76 // }
77 // grtext_Printf(x,y,linebuffer);
78 const char *textaux_CopyTextLine(const char *src, char *dest);
79
80 // textaux_ClipString
81 // Given a width (in pixels), and a string, this function will truncate the string
82 // to at most width pixels. If the end parameter is not 0, then that char is attached to
83 // the end of the string if it has to clip(the char's width is taken into consideration).
84 // It is based off the current font. if horizont_ratio is given it is used to correct for
85 // possible different sized hud fonts. For instance, if this string is going to be printed on
86 // the hud, then you should always pass (DEFAULT_HUD_WIDTH/((float)*Game_window_w)) as the
87 // horizont_ratio paramter.
88 void textaux_ClipString(int width, char *string, float horizont_ratio = 1, char end = 0);
89
90 #endif