Mercurial > mplayer.hg
annotate libmenu/menu.c @ 8849:9476ccf6a41d
another pan example by Anders
author | diego |
---|---|
date | Thu, 09 Jan 2003 09:32:28 +0000 |
parents | 41a1e5dbb552 |
children | 6c2c74adaebe |
rev | line source |
---|---|
8197 | 1 |
2 #include "../config.h" | |
3 | |
4 #include <stdlib.h> | |
5 #include <stdio.h> | |
6 #include <string.h> | |
8604
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
7 #include <fcntl.h> |
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
8 #include <unistd.h> |
8197 | 9 |
10 #include "../libvo/osd.h" | |
11 #include "../libvo/font_load.h" | |
12 #include "../linux/keycodes.h" | |
13 #include "../asxparser.h" | |
14 #include "../libmpdemux/stream.h" | |
15 | |
16 #include "img_format.h" | |
17 #include "mp_image.h" | |
18 #include "../m_option.h" | |
19 #include "../m_struct.h" | |
20 #include "menu.h" | |
21 | |
22 extern menu_info_t menu_info_cmdlist; | |
23 extern menu_info_t menu_info_pt; | |
24 extern menu_info_t menu_info_filesel; | |
25 extern menu_info_t menu_info_txt; | |
26 extern menu_info_t menu_info_console; | |
27 extern menu_info_t menu_info_pref; | |
28 | |
29 menu_info_t* menu_info_list[] = { | |
30 &menu_info_pt, | |
31 &menu_info_cmdlist, | |
32 &menu_info_filesel, | |
33 &menu_info_txt, | |
34 &menu_info_console, | |
35 &menu_info_pref, | |
36 NULL | |
37 }; | |
38 | |
39 typedef struct menu_def_st { | |
40 char* name; | |
41 menu_info_t* type; | |
42 void* cfg; | |
43 char* args; | |
44 } menu_def_t; | |
45 | |
46 static menu_def_t* menu_list = NULL; | |
47 static int mcount = 0; | |
48 | |
49 | |
50 static int menu_parse_config(char* buffer) { | |
51 char *element,*body, **attribs, *name; | |
52 menu_info_t* minfo = NULL; | |
53 int r,i; | |
54 ASX_Parser_t* parser = asx_parser_new(); | |
55 | |
56 while(1) { | |
57 r = asx_get_element(parser,&buffer,&element,&body,&attribs); | |
58 if(r < 0) { | |
59 printf("Syntax error at line %d\n",parser->line); | |
60 asx_parser_free(parser); | |
61 return 0; | |
62 } else if(r == 0) { | |
63 asx_parser_free(parser); | |
64 return 1; | |
65 } | |
66 // Has it a name ? | |
67 name = asx_get_attrib("name",attribs); | |
68 if(!name) { | |
69 printf("Menu definitions need a name attrib (line %d)\n",parser->line); | |
70 free(element); | |
71 if(body) free(body); | |
72 asx_free_attribs(attribs); | |
73 continue; | |
74 } | |
75 | |
76 // Try to find this menu type in our list | |
77 for(i = 0, minfo = NULL ; menu_info_list[i] ; i++) { | |
78 if(strcasecmp(element,menu_info_list[i]->name) == 0) { | |
79 minfo = menu_info_list[i]; | |
80 break; | |
81 } | |
82 } | |
83 // Got it : add this to our list | |
84 if(minfo) { | |
85 menu_list = realloc(menu_list,(mcount+2)*sizeof(menu_def_t)); | |
86 menu_list[mcount].name = name; | |
87 menu_list[mcount].type = minfo; | |
88 menu_list[mcount].cfg = m_struct_alloc(&minfo->priv_st); | |
89 menu_list[mcount].args = body; | |
90 // Setup the attribs | |
91 for(i = 0 ; attribs[2*i] ; i++) { | |
92 if(strcasecmp(attribs[2*i],"name") == 0) continue; | |
93 if(!m_struct_set(&minfo->priv_st,menu_list[mcount].cfg,attribs[2*i], attribs[2*i+1])) | |
94 printf("Bad attrib %s=%s in menu %s at line %d\n",attribs[2*i],attribs[2*i+1], | |
95 name,parser->line); | |
96 } | |
97 mcount++; | |
98 memset(&menu_list[mcount],0,sizeof(menu_def_t)); | |
99 } else { | |
100 printf("Unknow menu type %s at line %d\n",element,parser->line); | |
101 free(name); | |
102 if(body) free(body); | |
103 } | |
104 | |
105 free(element); | |
106 asx_free_attribs(attribs); | |
107 } | |
108 | |
109 } | |
110 | |
111 | |
112 /// This will build the menu_defs list from the cfg file | |
113 #define BUF_STEP 1024 | |
114 #define BUF_MIN 128 | |
115 #define BUF_MAX BUF_STEP*1024 | |
116 int menu_init(char* cfg_file) { | |
117 char* buffer = NULL; | |
118 int bl = BUF_STEP, br = 0; | |
119 int f; | |
8604
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
120 int fd = open(cfg_file, O_RDONLY); |
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
121 if(fd < 0) { |
8197 | 122 printf("Can't open menu config file: %s\n",cfg_file); |
123 return 0; | |
124 } | |
125 buffer = malloc(bl); | |
126 while(1) { | |
127 int r; | |
128 if(bl - br < BUF_MIN) { | |
129 if(bl >= BUF_MAX) { | |
130 printf("Menu config file is too big (> %d KB)\n",BUF_MAX/1024); | |
8604
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
131 close(fd); |
8197 | 132 free(buffer); |
133 return 0; | |
134 } | |
135 bl += BUF_STEP; | |
136 buffer = realloc(buffer,bl); | |
137 } | |
8604
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
138 r = read(fd,buffer+br,bl-br); |
8197 | 139 if(r == 0) break; |
140 br += r; | |
141 } | |
142 if(!br) { | |
143 printf("Menu config file is empty\n"); | |
144 return 0; | |
145 } | |
146 buffer[br-1] = '\0'; | |
147 | |
8604
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
148 close(fd); |
41a1e5dbb552
This patch fixes the reading of the menu.conf, because stream_open()
arpi
parents:
8251
diff
changeset
|
149 |
8197 | 150 f = menu_parse_config(buffer); |
151 free(buffer); | |
152 return f; | |
153 } | |
154 | |
155 // Destroy all this stuff | |
156 void menu_unint(void) { | |
157 int i; | |
158 for(i = 0 ; menu_list && menu_list[i].name ; i++) { | |
159 free(menu_list[i].name); | |
160 m_struct_free(&menu_list[i].type->priv_st,menu_list[i].cfg); | |
161 if(menu_list[i].args) free(menu_list[i].args); | |
162 } | |
163 free(menu_list); | |
164 mcount = 0; | |
165 } | |
166 | |
167 /// Default read_key function | |
168 void menu_dflt_read_key(menu_t* menu,int cmd) { | |
169 switch(cmd) { | |
170 case KEY_UP: | |
171 menu->read_cmd(menu,MENU_CMD_UP); | |
172 break; | |
173 case KEY_DOWN: | |
174 menu->read_cmd(menu,MENU_CMD_DOWN); | |
175 break; | |
176 case KEY_LEFT: | |
177 case KEY_ESC: | |
178 menu->read_cmd(menu,MENU_CMD_CANCEL); | |
179 break; | |
180 case KEY_RIGHT: | |
181 case KEY_ENTER: | |
182 menu->read_cmd(menu,MENU_CMD_OK); | |
183 break; | |
184 } | |
185 } | |
186 | |
187 menu_t* menu_open(char *name) { | |
188 menu_t* m; | |
189 int i; | |
190 | |
191 for(i = 0 ; menu_list[i].name != NULL ; i++) { | |
192 if(strcmp(name,menu_list[i].name) == 0) | |
193 break; | |
194 } | |
195 if(menu_list[i].name == NULL) { | |
196 printf("Menu %s not found\n",name); | |
197 return NULL; | |
198 } | |
199 m = calloc(1,sizeof(menu_t)); | |
200 m->priv_st = &(menu_list[i].type->priv_st); | |
201 m->priv = m_struct_copy(m->priv_st,menu_list[i].cfg); | |
202 if(menu_list[i].type->open(m,menu_list[i].args)) | |
203 return m; | |
204 if(m->priv) | |
205 m_struct_free(m->priv_st,m->priv); | |
206 free(m); | |
207 printf("Menu %s: init failed\n",name); | |
208 return NULL; | |
209 } | |
210 | |
211 void menu_draw(menu_t* menu,mp_image_t* mpi) { | |
212 if(menu->show && menu->draw) | |
213 menu->draw(menu,mpi); | |
214 } | |
215 | |
216 void menu_read_cmd(menu_t* menu,int cmd) { | |
217 if(menu->read_cmd) | |
218 menu->read_cmd(menu,cmd); | |
219 } | |
220 | |
221 void menu_close(menu_t* menu) { | |
222 if(menu->close) | |
223 menu->close(menu); | |
224 if(menu->priv) | |
225 m_struct_free(menu->priv_st,menu->priv); | |
226 free(menu); | |
227 } | |
228 | |
229 void menu_read_key(menu_t* menu,int cmd) { | |
230 if(menu->read_key) | |
231 menu->read_key(menu,cmd); | |
232 else | |
233 menu_dflt_read_key(menu,cmd); | |
234 } | |
235 | |
236 ///////////////////////////// Helpers //////////////////////////////////// | |
237 | |
238 typedef void (*draw_alpha_f)(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); | |
239 | |
240 inline static draw_alpha_f get_draw_alpha(uint32_t fmt) { | |
241 switch(fmt) { | |
242 case IMGFMT_BGR15: | |
243 case IMGFMT_RGB15: | |
244 return vo_draw_alpha_rgb15; | |
245 case IMGFMT_BGR16: | |
246 case IMGFMT_RGB16: | |
247 return vo_draw_alpha_rgb16; | |
248 case IMGFMT_BGR24: | |
249 case IMGFMT_RGB24: | |
250 return vo_draw_alpha_rgb24; | |
251 case IMGFMT_BGR32: | |
252 case IMGFMT_RGB32: | |
253 return vo_draw_alpha_rgb32; | |
254 case IMGFMT_YV12: | |
255 case IMGFMT_I420: | |
256 case IMGFMT_IYUV: | |
257 case IMGFMT_YVU9: | |
258 case IMGFMT_IF09: | |
259 case IMGFMT_Y800: | |
260 case IMGFMT_Y8: | |
261 return vo_draw_alpha_yv12; | |
262 case IMGFMT_YUY2: | |
263 return vo_draw_alpha_yuy2; | |
264 } | |
265 | |
266 return NULL; | |
267 } | |
268 | |
8224
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
269 // return the real height of a char: |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
270 static inline int get_height(int c,int h){ |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
271 int font; |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
272 if ((font=vo_font->font[c])>=0) |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
273 if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h; |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
274 return h; |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
275 } |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
276 |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
277 #ifdef HAVE_FREETYPE |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
278 #define render_txt(t) { char* p = t; while(*p) render_one_glyph(vo_font,*p++); } |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
279 #else |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
280 #define render_txt(t) |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
281 #endif |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
282 |
8197 | 283 |
284 void menu_draw_text(mp_image_t* mpi,char* txt, int x, int y) { | |
285 draw_alpha_f draw_alpha = get_draw_alpha(mpi->imgfmt); | |
286 int font; | |
287 | |
288 if(!draw_alpha) { | |
289 printf("Unsupported outformat !!!!\n"); | |
290 return; | |
291 } | |
292 | |
8224
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
293 render_txt(txt); |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
294 |
8197 | 295 while (*txt) { |
296 unsigned char c=*txt++; | |
297 if ((font=vo_font->font[c])>=0 && (x + vo_font->width[c] <= mpi->w) && (y + vo_font->pic_a[font]->h <= mpi->h)) | |
298 draw_alpha(vo_font->width[c], vo_font->pic_a[font]->h, | |
299 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
300 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
301 vo_font->pic_a[font]->w, | |
302 mpi->planes[0] + y * mpi->stride[0] + x * (mpi->bpp>>3), | |
303 mpi->stride[0]); | |
304 x+=vo_font->width[c]+vo_font->charspace; | |
305 } | |
306 | |
307 } | |
308 | |
309 void menu_draw_text_full(mp_image_t* mpi,char* txt, | |
310 int x, int y,int w, int h, | |
311 int vspace, int warp, int align, int anchor) { | |
312 int need_w,need_h; | |
313 int sy, ymin, ymax; | |
314 int sx, xmin, xmax, xmid, xrmin; | |
315 int ll = 0; | |
316 int font; | |
317 draw_alpha_f draw_alpha = get_draw_alpha(mpi->imgfmt); | |
318 | |
319 if(!draw_alpha) { | |
320 printf("Unsupported outformat !!!!\n"); | |
321 return; | |
322 } | |
323 | |
8224
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
324 render_txt(txt); |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
325 |
8197 | 326 if(x > mpi->w || y > mpi->h) |
327 return; | |
328 | |
329 if(anchor & MENU_TEXT_VCENTER) { | |
330 if(h <= 0) h = mpi->h; | |
331 ymin = y - h/2; | |
332 ymax = y + h/2; | |
333 } else if(anchor & MENU_TEXT_BOT) { | |
334 if(h <= 0) h = mpi->h - y; | |
335 ymin = y - h; | |
336 ymax = y; | |
337 } else { | |
338 if(h <= 0) h = mpi->h - y; | |
339 ymin = y; | |
340 ymax = y + h; | |
341 } | |
342 | |
343 if(anchor & MENU_TEXT_HCENTER) { | |
344 if(w <= 0) w = mpi->w; | |
345 xmin = x - w/2; | |
346 xmax = x + w/2; | |
347 } else if(anchor & MENU_TEXT_RIGHT) { | |
348 if(w <= 0) w = mpi->w -x; | |
349 xmin = x - w; | |
350 xmax = x; | |
351 } else { | |
352 if(w <= 0) w = mpi->w -x; | |
353 xmin = x; | |
354 xmax = x + w; | |
355 } | |
356 | |
357 // How many space do we need to draw this ? | |
358 menu_text_size(txt,w,vspace,warp,&need_w,&need_h); | |
359 | |
360 // Find the first line | |
361 if(align & MENU_TEXT_VCENTER) | |
362 sy = ymin + ((h - need_h)/2); | |
363 else if(align & MENU_TEXT_BOT) | |
8232 | 364 sy = ymax - need_h - 1; |
8197 | 365 else |
366 sy = y; | |
367 | |
368 #if 0 | |
369 // Find the first col | |
370 if(align & MENU_TEXT_HCENTER) | |
371 sx = xmin + ((w - need_w)/2); | |
372 else if(align & MENU_TEXT_RIGHT) | |
373 sx = xmax - need_w; | |
374 #endif | |
375 | |
376 xmid = xmin + (xmax - xmin) / 2; | |
377 xrmin = xmin; | |
378 // Clamp the bb to the mpi size | |
379 if(ymin < 0) ymin = 0; | |
380 if(xmin < 0) xmin = 0; | |
381 if(ymax > mpi->h) ymax = mpi->h; | |
382 if(xmax > mpi->w) xmax = mpi->w; | |
383 | |
384 // Jump some the beginnig text if needed | |
385 while(sy < ymin && *txt) { | |
386 unsigned char c=*txt++; | |
387 if(c == '\n' || (warp && ll + vo_font->width[c] > w)) { | |
388 ll = 0; | |
389 sy += vo_font->height + vspace; | |
390 if(c == '\n') continue; | |
391 } | |
392 ll += vo_font->width[c]+vo_font->charspace; | |
393 } | |
394 if(*txt == '\0') // Nothing left to draw | |
395 return; | |
396 | |
397 while(sy < ymax && *txt) { | |
398 char* line_end = NULL; | |
399 int n; | |
400 | |
401 if(txt[0] == '\n') { // New line | |
402 sy += vo_font->height + vspace; | |
403 txt++; | |
404 continue; | |
405 } | |
406 | |
407 // Get the length and end of this line | |
408 for(n = 0, ll = 0 ; txt[n] != '\0' && txt[n] != '\n' ; n++) { | |
409 unsigned char c = txt[n]; | |
410 if(warp && ll + vo_font->width[c] > w) break; | |
411 ll += vo_font->width[c]+vo_font->charspace; | |
412 } | |
413 line_end = &txt[n]; | |
414 ll -= vo_font->charspace; | |
415 | |
416 | |
417 if(align & (MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)) { | |
418 // Too long line | |
419 if(ll > xmax-xmin) { | |
420 if(align & MENU_TEXT_HCENTER) { | |
421 int mid = ll/2; | |
422 // Find the middle point | |
423 for(n--, ll = 0 ; n <= 0 ; n--) { | |
424 ll += vo_font->width[(int)txt[n]]+vo_font->charspace; | |
425 if(ll - vo_font->charspace > mid) break; | |
426 } | |
427 ll -= vo_font->charspace; | |
428 sx = xmid + mid - ll; | |
429 } else// MENU_TEXT_RIGHT) | |
430 sx = xmax + vo_font->charspace; | |
431 | |
432 // We are after the start point -> go back | |
433 if(sx > xmin) { | |
434 for(n-- ; n <= 0 ; n--) { | |
435 unsigned char c = txt[n]; | |
436 if(sx - vo_font->width[c] - vo_font->charspace < xmin) break; | |
437 sx -= vo_font->width[c]+vo_font->charspace; | |
438 } | |
439 } else { // We are before the start point -> go forward | |
440 for( ; sx < xmin && (&txt[n]) != line_end ; n++) { | |
441 unsigned char c = txt[n]; | |
442 sx += vo_font->width[c]+vo_font->charspace; | |
443 } | |
444 } | |
445 txt = &txt[n]; // Jump to the new start char | |
446 } else { | |
447 if(align & MENU_TEXT_HCENTER) | |
448 sx = xmid - ll/2; | |
449 else | |
8232 | 450 sx = xmax - 1 - ll; |
8197 | 451 } |
452 } else { | |
453 for(sx = xrmin ; sx < xmin && txt != line_end ; txt++) { | |
454 unsigned char c = txt[n]; | |
455 sx += vo_font->width[c]+vo_font->charspace; | |
456 } | |
457 } | |
458 | |
459 while(sx < xmax && txt != line_end) { | |
460 unsigned char c = *txt++; | |
461 font = vo_font->font[c]; | |
8232 | 462 if(font >= 0) { |
463 int cs = (vo_font->pic_a[font]->h - vo_font->height) / 2; | |
464 if ((sx + vo_font->width[c] < xmax) && (sy + vo_font->height < ymax) ) | |
465 draw_alpha(vo_font->width[c], vo_font->height, | |
466 vo_font->pic_b[font]->bmp+vo_font->start[c] + | |
467 cs * vo_font->pic_a[font]->w, | |
468 vo_font->pic_a[font]->bmp+vo_font->start[c] + | |
469 cs * vo_font->pic_a[font]->w, | |
470 vo_font->pic_a[font]->w, | |
471 mpi->planes[0] + sy * mpi->stride[0] + sx * (mpi->bpp>>3), | |
472 mpi->stride[0]); | |
473 // else | |
474 //printf("Can't draw '%c'\n",c); | |
475 } | |
8197 | 476 sx+=vo_font->width[c]+vo_font->charspace; |
477 } | |
478 txt = line_end; | |
479 if(txt[0] == '\0') break; | |
480 sy += vo_font->height + vspace; | |
481 } | |
482 } | |
483 | |
484 int menu_text_length(char* txt) { | |
485 int l = 0; | |
8224
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
486 render_txt(txt); |
8197 | 487 while (*txt) { |
488 unsigned char c=*txt++; | |
489 l += vo_font->width[c]+vo_font->charspace; | |
490 } | |
491 return l - vo_font->charspace; | |
492 } | |
493 | |
494 void menu_text_size(char* txt,int max_width, int vspace, int warp, int* _w, int* _h) { | |
495 int l = 1, i = 0; | |
496 int w = 0; | |
8224
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
497 |
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
498 render_txt(txt); |
8197 | 499 while (*txt) { |
500 unsigned char c=*txt++; | |
501 if(c == '\n' || (warp && i + vo_font->width[c] >= max_width)) { | |
502 if(*txt) | |
503 l++; | |
504 i = 0; | |
505 if(c == '\n') continue; | |
506 } | |
507 i += vo_font->width[c]+vo_font->charspace; | |
508 if(i > w) w = i; | |
509 } | |
510 | |
511 *_w = w; | |
512 *_h = (l-1) * (vo_font->height + vspace) + vo_font->height; | |
513 } | |
514 | |
515 | |
516 int menu_text_num_lines(char* txt, int max_width) { | |
517 int l = 1, i = 0; | |
8224
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
518 render_txt(txt); |
8197 | 519 while (*txt) { |
520 unsigned char c=*txt++; | |
521 if(c == '\n' || i + vo_font->width[c] > max_width) { | |
522 l++; | |
523 i = 0; | |
524 if(c == '\n') continue; | |
525 } | |
526 i += vo_font->width[c]+vo_font->charspace; | |
527 } | |
528 return l; | |
529 } | |
530 | |
531 char* menu_text_get_next_line(char* txt, int max_width) { | |
532 int i = 0; | |
8224
fefc56153615
Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents:
8197
diff
changeset
|
533 render_txt(txt); |
8197 | 534 while (*txt) { |
535 unsigned char c=*txt; | |
536 if(c == '\n') { | |
537 txt++; | |
538 break; | |
539 } | |
540 i += vo_font->width[c]; | |
541 if(i >= max_width) | |
542 break; | |
543 i += vo_font->charspace; | |
544 } | |
545 return txt; | |
546 } |