Atrinik Client  4.0
text.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
30 #ifndef TEXT_H
31 #define TEXT_H
32 
34 typedef struct font_struct {
36  char *key;
37 
39  char *name;
40 
42  uint8_t size;
43 
45  TTF_Font *font;
46 
48  int height;
49 
51  unsigned int ref;
52 
54  time_t last_used;
55 
57  UT_hash_handle hh;
58 } font_struct;
59 
63 #define FONT(font_name, font_size) font_get_weak(font_name, font_size)
64 
67 #define FONT_INCREF(font) (font)->ref++;
68 
73 #define FONT_DECREF(font) (font)->ref--;
74 
79 #define FONT_GC_MAX_TIME 100000
80 
83 #define FONT_GC_CHANCE 500
84 
88 #define FONT_GC_FREE_TIME 60 * 30
89 
90 #define FONT_SANS7 FONT("sans", 7)
91 #define FONT_SANS8 FONT("sans", 8)
92 #define FONT_SANS9 FONT("sans", 9)
93 #define FONT_SANS10 FONT("sans", 10)
94 #define FONT_SANS11 FONT("sans", 11)
95 #define FONT_SANS12 FONT("sans", 12)
96 #define FONT_SANS13 FONT("sans", 13)
97 #define FONT_SANS14 FONT("sans", 14)
98 #define FONT_SANS15 FONT("sans", 15)
99 #define FONT_SANS16 FONT("sans", 16)
100 #define FONT_SANS18 FONT("sans", 18)
101 #define FONT_SANS20 FONT("sans", 20)
102 
103 #define FONT_SERIF8 FONT("serif", 8)
104 #define FONT_SERIF10 FONT("serif", 10)
105 #define FONT_SERIF12 FONT("serif", 12)
106 #define FONT_SERIF14 FONT("serif", 14)
107 #define FONT_SERIF16 FONT("serif", 16)
108 #define FONT_SERIF18 FONT("serif", 18)
109 #define FONT_SERIF20 FONT("serif", 20)
110 #define FONT_SERIF22 FONT("serif", 22)
111 #define FONT_SERIF24 FONT("serif", 24)
112 #define FONT_SERIF26 FONT("serif", 26)
113 #define FONT_SERIF28 FONT("serif", 28)
114 #define FONT_SERIF30 FONT("serif", 30)
115 #define FONT_SERIF32 FONT("serif", 32)
116 #define FONT_SERIF34 FONT("serif", 34)
117 #define FONT_SERIF36 FONT("serif", 36)
118 #define FONT_SERIF38 FONT("serif", 38)
119 #define FONT_SERIF40 FONT("serif", 40)
120 
121 #define FONT_MONO8 FONT("mono", 8)
122 #define FONT_MONO9 FONT("mono", 9)
123 #define FONT_MONO10 FONT("mono", 10)
124 #define FONT_MONO12 FONT("mono", 12)
125 #define FONT_MONO14 FONT("mono", 14)
126 #define FONT_MONO16 FONT("mono", 16)
127 #define FONT_MONO18 FONT("mono", 18)
128 #define FONT_MONO20 FONT("mono", 20)
129 
130 #define FONT_ARIAL8 FONT("arial", 8)
131 #define FONT_ARIAL10 FONT("arial", 10)
132 #define FONT_ARIAL11 FONT("arial", 11)
133 #define FONT_ARIAL12 FONT("arial", 12)
134 #define FONT_ARIAL13 FONT("arial", 13)
135 #define FONT_ARIAL14 FONT("arial", 14)
136 #define FONT_ARIAL15 FONT("arial", 15)
137 #define FONT_ARIAL16 FONT("arial", 16)
138 #define FONT_ARIAL18 FONT("arial", 18)
139 #define FONT_ARIAL20 FONT("arial", 20)
140 
145 typedef struct text_info_struct {
147  const char *anchor_tag;
148 
150  char anchor_action[HUGE_BUF];
151 
153  SDL_Color outline_color;
154 
156  uint8_t outline_show;
157 
159  uint8_t in_book_title;
160 
162  uint8_t used_alpha;
163 
165  uint8_t in_bold;
166 
168  uint8_t in_italic;
169 
171  uint8_t in_underline;
172 
175 
180  uint8_t obscured;
181 
183  uint8_t calc_bold;
184 
190 
195 
196  int height;
197 
198  int start_x;
199 
200  int start_y;
201 
202  uint8_t highlight;
203 
204  uint8_t flip;
205 
206  SDL_Rect highlight_rect;
207 
208  SDL_Color highlight_color;
209 
210  char tooltip_text[MAX_BUF * 2];
211 
212  font_struct *tooltip_font;
213 
214  uint32_t tooltip_delay;
215 
216  int tooltip_width;
218 
224 #define TEXT_MARKUP 1
225 
226 #define TEXT_WORD_WRAP 2
227 
228 #define TEXT_SOLID 4
229 
230 #define TEXT_ALIGN_CENTER 8
231 
241 #define TEXT_HEIGHT 16
242 
246 #define TEXT_VALIGN_CENTER 32
247 
250 #define TEXT_NO_COLOR_CHANGE 64
251 
255 #define TEXT_OUTLINE 128
256 
259 #define TEXT_LINES_CALC 256
260 
263 #define TEXT_LINES_SKIP 512
264 
267 #define TEXT_NO_FONT_CHANGE 1024
268 
272 #define TEXT_WIDTH 2048
273 
277 #define TEXT_MAX_WIDTH 4096
278 
280 #define TEXT_FLIP_HORIZONTAL 1
281 #define TEXT_FLIP_VERTICAL 2
282 #define TEXT_FLIP_BOTH (TEXT_FLIP_HORIZONTAL | TEXT_FLIP_VERTICAL)
283 
289 #define COLOR_WHITE "ffffff"
290 
291 #define COLOR_ORANGE "ff9900"
292 
293 #define COLOR_NAVY "00ffff"
294 
295 #define COLOR_RED "ff3030"
296 
297 #define COLOR_GREEN "00ff00"
298 
299 #define COLOR_BLUE "0080ff"
300 
301 #define COLOR_GRAY "999999"
302 
303 #define COLOR_BROWN "c07f40"
304 
305 #define COLOR_PURPLE "cc66ff"
306 
307 #define COLOR_PINK "ff9999"
308 
309 #define COLOR_YELLOW "ffff33"
310 
311 #define COLOR_DK_NAVY "00c4c2"
312 
313 #define COLOR_DK_GREEN "006600"
314 
315 #define COLOR_DK_ORANGE "ff6600"
316 
317 #define COLOR_BRIGHT_PURPLE "ff66ff"
318 
319 #define COLOR_HGOLD "d4d553"
320 
321 #define COLOR_DGOLD "999900"
322 
323 #define COLOR_BLACK "000000"
324 
327 #define FONT_HEIGHT(font) ((font)->height)
328 
329 #define FONT_TRY_INFO(_font, _info, _surface) ((_info).calc_font != NULL && !(_surface) && !(_info).obscured ? (_info).calc_font : (_font))
330 
348 typedef int (*text_anchor_handle_func)(const char *anchor_action, const char *buf, size_t len, void *custom_data);
349 
350 #endif
int(* text_anchor_handle_func)(const char *anchor_action, const char *buf, size_t len, void *custom_data)
Definition: text.h:348
char anchor_action[HUGE_BUF]
Definition: text.h:150
uint8_t obscured
Definition: text.h:180
uint8_t in_book_title
Definition: text.h:159
SDL_Color outline_color
Definition: text.h:153
char * name
Definition: text.h:39
int height
Definition: text.h:48
const char * anchor_tag
Definition: text.h:147
uint8_t in_strikethrough
Definition: text.h:174
uint8_t outline_show
Definition: text.h:156
font_struct * calc_font
Definition: text.h:189
uint8_t calc_bold
Definition: text.h:183
uint8_t size
Definition: text.h:42
uint8_t in_bold
Definition: text.h:165
UT_hash_handle hh
Definition: text.h:57
uint8_t used_alpha
Definition: text.h:162
struct font_struct font_struct
uint8_t in_italic
Definition: text.h:168
uint8_t in_underline
Definition: text.h:171
TTF_Font * font
Definition: text.h:45
char * key
Definition: text.h:36
int hcenter_y
Definition: text.h:194
unsigned int ref
Definition: text.h:51
time_t last_used
Definition: text.h:54
struct text_info_struct text_info_struct