Mercurial > mplayer.hg
annotate Gui/skin/skin.c @ 3145:78e11396f431
runtime cpu detection
author | michael |
---|---|
date | Mon, 26 Nov 2001 21:55:22 +0000 |
parents | 182163807172 |
children | 2704448de713 |
rev | line source |
---|---|
1729 | 1 |
1693 | 2 #include <stdio.h> |
3 #include <stdlib.h> | |
4 #include <string.h> | |
5 | |
6 #include "cut.h" | |
7 #include "error.h" | |
8 #include "font.h" | |
9 #include "../app.h" | |
10 #include "../../config.h" | |
1884 | 11 #include "../../help_mp.h" |
1693 | 12 |
13 listItems * skinAppMPlayer = &appMPlayer; | |
14 | |
15 int linenumber; | |
16 | |
17 unsigned char path[512],fn[512]; | |
18 | |
19 listItems * defList = NULL; | |
20 unsigned char winList[32] = ""; | |
21 | |
22 #include <stdarg.h> | |
23 | |
24 void ERRORMESSAGE( const char * format, ... ) | |
25 { | |
26 char p[512]; | |
27 va_list ap; | |
28 va_start( ap,format ); | |
29 vsnprintf( p,512,format,ap ); | |
30 va_end( ap ); | |
1884 | 31 // message( False,"[skin] error in skin config file on line %d: %s",linenumber,p ); |
32 message( False,MSGTR_SKIN_ERRORMESSAGE,linenumber,p ); | |
1693 | 33 } |
34 | |
1884 | 35 #define CHECKDEFLIST( str ) \ |
36 { \ | |
37 if ( defList == NULL ) \ | |
38 { \ | |
39 message( False,MSGTR_SKIN_WARNING1,linenumber,str ); \ | |
40 return 1; \ | |
41 } \ | |
42 } | |
43 | |
44 #define CHECKWINLIST( str ) \ | |
45 { \ | |
46 if ( !strlen( winList ) ) \ | |
47 { \ | |
48 message( False,MSGTR_SKIN_WARNING2,linenumber,str ); \ | |
49 return 1; \ | |
50 } \ | |
51 } | |
1693 | 52 |
53 char * strlower( char * in ) | |
54 { | |
55 int i; | |
56 for( i=0;i<strlen( in );i++ ) in[i]=( in[i] >= 'A' ? ( in[i] <= 'Z' ? in[i]+='A' : in[i] ) : in[i] ); | |
57 return in; | |
58 } | |
59 | |
60 int skinBPRead( char * fname, txSample * bf ) | |
61 { | |
62 int i=bpRead( fname,bf ); | |
63 switch ( i ) | |
64 { | |
1884 | 65 case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit,fname ); break; |
66 case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound,fname ); break; | |
67 case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError,fname ); break; | |
68 case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError,fname ); break; | |
69 case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError,fname ); break; | |
70 case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported,fname ); break; | |
71 case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType,fname ); break; | |
72 case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConvertError,fname ); break; | |
1693 | 73 } |
74 return i; | |
75 } | |
76 | |
77 int __section( char * in ) | |
78 { | |
79 strlower( in ); | |
80 defList=NULL; | |
81 if ( !strcmp( in,"movieplayer" ) ) defList=skinAppMPlayer; | |
82 #ifdef DEBUG | |
83 dbprintf( 3,"\n[skin] sectionname: %s\n",in ); | |
84 #endif | |
85 return 0; | |
86 } | |
87 | |
88 int __end( char * in ) | |
89 { | |
90 if ( strlen( winList ) ) winList[0]=0; | |
91 else defList=NULL; | |
92 #ifdef DEBUG | |
93 dbprintf( 3,"\n[skin] end section\n" ); | |
94 #endif | |
95 return 0; | |
96 } | |
97 | |
98 int __window( char * in ) | |
99 { | |
100 CHECKDEFLIST( "window" ); | |
101 | |
102 strlower( in ); | |
103 strcpy( winList,in ); | |
104 #ifdef DEBUG | |
105 dbprintf( 3,"\n[skin] window: %s\n",winList ); | |
106 #endif | |
107 return 0; | |
108 } | |
109 | |
110 int __base( char * in ) | |
111 { | |
112 unsigned char fname[512]; | |
113 unsigned char tmp[512]; | |
114 int x,y; | |
3080 | 115 int sx=0,sy=0; |
1693 | 116 |
117 CHECKDEFLIST( "base" ); | |
118 CHECKWINLIST( "base" ); | |
119 | |
120 cutItem( in,fname,',',0 ); | |
1852 | 121 x=cutItemToInt( in,',',1 ); |
122 y=cutItemToInt( in,',',2 ); | |
3080 | 123 sx=cutItemToInt( in,',',3 ); |
124 sy=cutItemToInt( in,',',4 ); | |
1693 | 125 #ifdef DEBUG |
3080 | 126 dbprintf( 3,"\n[skin] base: %s x: %d y: %d ( %dx%d )\n",fname,x,y,sx,sy ); |
1693 | 127 #endif |
128 if ( !strcmp( winList,"main" ) ) | |
129 { | |
130 defList->main.x=x; | |
131 defList->main.y=y; | |
132 defList->main.type=itBase; | |
133 strcpy( tmp,path ); strcat( tmp,fname ); | |
134 if ( skinBPRead( tmp,&defList->main.Bitmap ) ) return 1; | |
135 defList->main.width=defList->main.Bitmap.Width; | |
136 defList->main.height=defList->main.Bitmap.Height; | |
137 #ifdef HAVE_XSHAPE | |
2717 | 138 Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff ); |
2781 | 139 #if 0 |
2717 | 140 { |
141 if ( defList->main.Mask.Image != NULL ) | |
142 { | |
143 txSample d; | |
144 Convert1to32( &defList->main.Mask,&d ); | |
145 tgaWriteTexture( "debug.tga",&d ); | |
146 } | |
1693 | 147 } |
2781 | 148 #endif |
1693 | 149 #ifdef DEBUG |
1852 | 150 dbprintf( 3,"[skin] mask: %dx%d\n",defList->main.Mask.Width,defList->main.Mask.Height ); |
1693 | 151 #endif |
152 #else | |
153 defList->main.Mask.Image=NULL; | |
154 #endif | |
155 #ifdef DEBUG | |
156 dbprintf( 3,"[skin] width: %d height: %d\n",defList->main.width,defList->main.height ); | |
157 #endif | |
158 } | |
159 if ( !strcmp( winList,"sub" ) ) | |
160 { | |
161 defList->sub.type=itBase; | |
162 strcpy( tmp,path ); strcat( tmp,fname ); | |
163 if ( skinBPRead( tmp,&defList->sub.Bitmap ) ) return 1; | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1884
diff
changeset
|
164 defList->sub.x=x; |
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1884
diff
changeset
|
165 defList->sub.y=y; |
1693 | 166 defList->sub.width=defList->sub.Bitmap.Width; |
167 defList->sub.height=defList->sub.Bitmap.Height; | |
3080 | 168 if ( sx && sy ) |
169 { | |
170 defList->sub.width=sx; | |
171 defList->sub.height=sy; | |
172 } | |
1693 | 173 #ifdef DEBUG |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1884
diff
changeset
|
174 dbprintf( 3,"[skin] %d,%d %dx%d\n",defList->sub.x,defList->sub.y,defList->sub.width,defList->sub.height ); |
1693 | 175 #endif |
176 } | |
177 /* | |
178 if ( !strcmp( winList,"eq" ) ) | |
179 { | |
180 defList->eq.x=x; | |
181 defList->eq.y=y; | |
182 defList->eq.type=itBase; | |
183 strcpy( tmp,path ); strcat( tmp,fname ); | |
184 if ( skinBPRead( tmp,&defList->eq.Bitmap ) ) return 1; | |
185 defList->eq.width=defList->eq.Bitmap.Width; | |
186 defList->eq.height=defList->eq.Bitmap.Height; | |
187 #ifdef DEBUG | |
188 dbprintf( 3,"[skin] width: %d height: %d\n",defList->eq.width,defList->eq.height ); | |
189 #endif | |
190 } | |
191 */ | |
192 if ( !strcmp( winList,"menu" ) ) | |
193 { | |
194 defList->menuBase.type=itBase; | |
195 strcpy( tmp,path ); strcat( tmp,fname ); | |
196 if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) ) return 1; | |
197 defList->menuBase.width=defList->menuBase.Bitmap.Width; | |
198 defList->menuBase.height=defList->menuBase.Bitmap.Height; | |
199 #ifdef DEBUG | |
200 dbprintf( 3,"[skin] width: %d height: %d\n",defList->menuBase.width,defList->menuBase.height ); | |
201 #endif | |
202 } | |
203 return 0; | |
204 } | |
205 | |
206 int __background( char * in ) | |
207 { | |
208 CHECKDEFLIST( "background" ); | |
209 CHECKWINLIST( "background" ); | |
210 | |
211 if ( !strcmp( winList,"sub" ) ) | |
212 { | |
1852 | 213 defList->subR=cutItemToInt( in,',',0 ); |
214 defList->subG=cutItemToInt( in,',',1 ); | |
215 defList->subB=cutItemToInt( in,',',2 ); | |
1693 | 216 #ifdef DEBUG |
217 dbprintf( 3,"\n[skin] subwindow background color is #%x%x%x.\n",defList->subR,defList->subG,defList->subB ); | |
218 #endif | |
219 } | |
220 return 0; | |
221 } | |
222 | |
223 int __button( char * in ) | |
224 { | |
225 unsigned char fname[512]; | |
226 unsigned char tmp[512]; | |
227 int x,y,sx,sy; | |
228 unsigned char msg[32]; | |
229 | |
230 CHECKDEFLIST( "button" ); | |
231 CHECKWINLIST( "button" ); | |
232 | |
233 cutItem( in,fname,',',0 ); | |
1852 | 234 x=cutItemToInt( in,',',1 ); |
235 y=cutItemToInt( in,',',2 ); | |
236 sx=cutItemToInt( in,',',3 ); | |
237 sy=cutItemToInt( in,',',4 ); | |
1693 | 238 cutItem( in,msg,',',5 ); |
239 | |
240 defList->NumberOfItems++; | |
241 defList->Items[ defList->NumberOfItems ].type=itButton; | |
242 defList->Items[ defList->NumberOfItems ].x=x; | |
243 defList->Items[ defList->NumberOfItems ].y=y; | |
244 defList->Items[ defList->NumberOfItems ].width=sx; | |
245 defList->Items[ defList->NumberOfItems ].height=sy; | |
246 #ifdef DEBUG | |
247 dbprintf( 3,"\n[skin] button: fname: %s\n",fname ); | |
248 dbprintf( 3,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); | |
249 #endif | |
250 | |
251 if ( ( defList->Items[ defList->NumberOfItems ].msg=appFindMessage( msg ) ) == -1 ) | |
1884 | 252 { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,msg ); return 1; } |
1693 | 253 defList->Items[ defList->NumberOfItems ].pressed=btnReleased; |
254 if ( defList->Items[ defList->NumberOfItems ].msg == evPauseSwitchToPlay ) defList->Items[ defList->NumberOfItems ].pressed=btnDisabled; | |
255 defList->Items[ defList->NumberOfItems ].tmp=1; | |
256 | |
257 #ifdef DEBUG | |
258 dbprintf( 3,"[skin] message: %d\n", | |
259 defList->Items[ defList->NumberOfItems ].msg ); | |
260 #endif | |
261 | |
262 defList->Items[ defList->NumberOfItems ].Bitmap.Image=NULL; | |
263 if ( strcmp( fname,"NULL" ) ) | |
264 { | |
265 strcpy( tmp,path ); strcat( tmp,fname ); | |
266 if ( skinBPRead( tmp,&defList->Items[ defList->NumberOfItems ].Bitmap ) ) return 1; | |
267 } | |
268 return 0; | |
269 } | |
270 | |
271 int __selected( char * in ) | |
272 { | |
273 unsigned char fname[512]; | |
274 unsigned char tmp[512]; | |
275 | |
276 CHECKDEFLIST( "selected" ); | |
277 CHECKWINLIST( "selected" ); | |
278 | |
279 cutItem( in,fname,',',0 ); | |
280 defList->menuSelected.type=itBase; | |
281 strcpy( tmp,path ); strcat( tmp,fname ); | |
282 #ifdef DEBUG | |
283 dbprintf( 3,"\n[skin] selected: %s\n",fname ); | |
284 #endif | |
285 if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1; | |
286 defList->menuSelected.width=defList->menuSelected.Bitmap.Width; | |
287 defList->menuSelected.height=defList->menuSelected.Bitmap.Height; | |
288 #ifdef DEBUG | |
289 dbprintf( 3,"[skin] width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height ); | |
290 #endif | |
291 return 0; | |
292 } | |
293 | |
294 int __menu( char * in ) | |
295 { // menu = number,x,y,sx,sy,msg | |
296 int x,y,sx,sy,msg; | |
297 unsigned char tmp[64]; | |
298 | |
299 CHECKDEFLIST( "menu" ); | |
300 CHECKWINLIST( "menu" ); | |
301 | |
1852 | 302 x=cutItemToInt( in,',',0 ); |
303 y=cutItemToInt( in,',',1 ); | |
304 sx=cutItemToInt( in,',',2 ); | |
305 sy=cutItemToInt( in,',',3 ); | |
1693 | 306 cutItem( in,tmp,',',4 ); msg=appFindMessage( tmp ); |
307 | |
308 defList->NumberOfMenuItems++; | |
309 defList->MenuItems[ defList->NumberOfMenuItems ].x=x; | |
310 defList->MenuItems[ defList->NumberOfMenuItems ].y=y; | |
311 defList->MenuItems[ defList->NumberOfMenuItems ].width=sx; | |
312 defList->MenuItems[ defList->NumberOfMenuItems ].height=sy; | |
313 | |
314 #ifdef DEBUG | |
315 dbprintf( 3,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems ); | |
316 dbprintf( 3,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); | |
317 #endif | |
318 | |
319 if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 ) | |
1884 | 320 ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,tmp ); |
1693 | 321 |
322 #ifdef DEBUG | |
323 dbprintf( 3,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg ); | |
324 #endif | |
325 | |
326 defList->MenuItems[ defList->NumberOfMenuItems ].Bitmap.Image=NULL; | |
327 return 0; | |
328 } | |
329 | |
330 int __hpotmeter( char * in ) | |
331 { // hpotmeter=buttonbitmaps,sx,sy,phasebitmaps,phases,default value,x,y,sx,sy,msg | |
332 int x,y,psx,psy,ph,sx,sy,msg,d; | |
333 unsigned char tmp[512]; | |
334 unsigned char pfname[512]; | |
335 unsigned char phfname[512]; | |
336 wItem * item; | |
337 | |
338 CHECKDEFLIST( "hpotmeter" ); | |
339 CHECKWINLIST( "hpotmeter" ); | |
340 | |
341 cutItem( in,pfname,',',0 ); | |
1852 | 342 psx=cutItemToInt( in,',',1 ); |
343 psy=cutItemToInt( in,',',2 ); | |
1693 | 344 cutItem( in,phfname,',',3 ); |
1852 | 345 ph=cutItemToInt( in,',',4 ); |
346 d=cutItemToInt( in,',',5 ); | |
347 x=cutItemToInt( in,',',6 ); | |
348 y=cutItemToInt( in,',',7 ); | |
349 sx=cutItemToInt( in,',',8 ); | |
350 sy=cutItemToInt( in,',',9 ); | |
1693 | 351 cutItem( in,tmp,',',10 ); msg=appFindMessage( tmp ); |
352 | |
353 #ifdef DEBUG | |
354 dbprintf( 3,"\n[skin] hpotmeter: pointer filename: '%s'\n",pfname ); | |
355 dbprintf( 3, "[skin] pointer size is %dx%d\n",psx,psy ); | |
356 dbprintf( 3, "[skin] phasebitmaps filename: '%s'\n",phfname ); | |
357 dbprintf( 3, "[skin] position: %d,%d %dx%d\n",x,y,sx,sy ); | |
358 dbprintf( 3, "[skin] default value: %d\n",d ); | |
359 dbprintf( 3, "[skin] message: %d\n",msg ); | |
360 #endif | |
361 | |
362 defList->NumberOfItems++; | |
363 item=&defList->Items[ defList->NumberOfItems ]; | |
364 item->type=itHPotmeter; | |
365 item->x=x; item->y=y; item->width=sx; item->height=sy; | |
366 item->phases=ph; | |
367 item->psx=psx; item->psy=psy; | |
368 item->msg=msg; | |
369 item->value=(float)d; | |
370 item->pressed=btnReleased; | |
371 | |
372 item->Bitmap.Image=NULL; | |
373 if ( strcmp( phfname,"NULL" ) ) | |
374 { | |
375 strcpy( tmp,path ); strcat( tmp,phfname ); | |
376 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; | |
377 } | |
378 | |
379 item->Mask.Image=NULL; | |
380 if ( strcmp( pfname,"NULL" ) ) | |
381 { | |
382 strcpy( tmp,path ); strcat( tmp,pfname ); | |
383 if ( skinBPRead( tmp,&item->Mask ) ) return 1; | |
384 } | |
385 | |
386 return 0; | |
387 } | |
388 | |
389 int __potmeter( char * in ) | |
390 { // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg | |
391 int x,y,ph,sx,sy,msg,d; | |
392 unsigned char tmp[512]; | |
393 unsigned char phfname[512]; | |
394 wItem * item; | |
395 | |
396 CHECKDEFLIST( "potmeter" ); | |
397 CHECKWINLIST( "potmeter" ); | |
398 | |
399 cutItem( in,phfname,',',0 ); | |
1852 | 400 ph=cutItemToInt( in,',',1 ); |
401 d=cutItemToInt( in,',',2 ); | |
402 x=cutItemToInt( in,',',3 ); | |
403 y=cutItemToInt( in,',',4 ); | |
404 sx=cutItemToInt( in,',',5 ); | |
405 sy=cutItemToInt( in,',',6 ); | |
1693 | 406 cutItem( in,tmp,',',7 ); msg=appFindMessage( tmp ); |
407 | |
408 #ifdef DEBUG | |
409 dbprintf( 3,"\n[skin] potmeter: phases filename: '%s'\n",phfname ); | |
410 dbprintf( 3, "[skin] position: %d,%d %dx%d\n",x,y,sx,sy ); | |
411 dbprintf( 3, "[skin] phases: %d\n",ph ); | |
412 dbprintf( 3, "[skin] default value: %d\n",d ); | |
413 dbprintf( 3, "[skin] message: %d\n",msg ); | |
414 #endif | |
415 | |
416 defList->NumberOfItems++; | |
417 item=&defList->Items[ defList->NumberOfItems ]; | |
418 item->type=itPotmeter; | |
419 item->x=x; item->y=y; | |
420 item->width=sx; item->height=sy; | |
421 item->phases=ph; | |
422 item->msg=msg; | |
423 item->value=(float)d; | |
424 | |
425 item->Bitmap.Image=NULL; | |
426 if ( strcmp( phfname,"NULL" ) ) | |
427 { | |
428 strcpy( tmp,path ); strcat( tmp,phfname ); | |
429 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; | |
430 } | |
431 return 0; | |
432 } | |
433 | |
434 int __font( char * in ) | |
435 { // font=fontname,fontid | |
436 char name[512]; | |
437 char id[512]; | |
438 wItem * item; | |
439 | |
440 CHECKDEFLIST( "font" ); | |
441 CHECKWINLIST( "font" ); | |
442 | |
443 cutItem( in,name,',',0 ); | |
444 cutItem( in,id,',',1 ); | |
445 | |
446 #ifdef DEBUG | |
447 dbprintf( 3,"\n[skin] font\n" ); | |
448 dbprintf( 3, "[skin] name: %s\n",name ); | |
449 #endif | |
450 | |
451 defList->NumberOfItems++; | |
452 item=&defList->Items[ defList->NumberOfItems ]; | |
453 item->type=itFont; | |
454 item->fontid=fntAddNewFont( name ); | |
455 switch ( item->fontid ) | |
456 { | |
1884 | 457 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; |
458 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1; | |
1693 | 459 } |
460 | |
461 #ifdef DEBUG | |
462 dbprintf( 3, "[skin] id: %s ( %d )\n",id,item->fontid ); | |
463 #endif | |
464 | |
465 switch ( fntRead( path,name,item->fontid ) ) | |
466 { | |
1884 | 467 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1; |
468 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1; | |
1693 | 469 } |
470 | |
471 return 0; | |
472 } | |
473 | |
474 int __slabel( char * in ) | |
475 { | |
476 char tmp[512]; | |
477 char sid[63]; | |
478 int x,y,id; | |
479 wItem * item; | |
480 | |
481 CHECKDEFLIST( "slabel" ); | |
482 CHECKWINLIST( "slabel" ); | |
483 | |
484 #ifdef DEBUG | |
485 dbprintf( 3,"\n[skin] slabel\n" ); | |
486 #endif | |
487 | |
1852 | 488 x=cutItemToInt( in,',',0 ); |
489 y=cutItemToInt( in,',',1 ); | |
1693 | 490 cutItem( in,sid,',',2 ); id=fntFindID( sid ); |
1884 | 491 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } |
1693 | 492 cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 ); |
493 | |
494 #ifdef DEBUG | |
495 dbprintf( 3, "[skin] pos: %d,%d\n",x,y ); | |
496 dbprintf( 3, "[skin] id: %s ( %d )\n",sid,id ); | |
497 dbprintf( 3, "[skin] str: '%s'\n",tmp ); | |
498 #endif | |
499 | |
500 defList->NumberOfItems++; | |
501 item=&defList->Items[ defList->NumberOfItems ]; | |
502 item->type=itSLabel; | |
503 item->fontid=id; | |
504 item->x=x; item->y=y; | |
505 item->width=-1; item->height=-1; | |
1884 | 506 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } |
1693 | 507 strcpy( item->label,tmp ); |
508 | |
509 return 0; | |
510 } | |
511 | |
512 int __dlabel( char * in ) | |
513 { // dlabel=x,y,sx,align,fontid,string ... | |
514 char tmp[512]; | |
515 char sid[63]; | |
516 int x,y,sx,id,a; | |
517 wItem * item; | |
518 | |
519 CHECKDEFLIST( "dlabel" ); | |
520 CHECKWINLIST( "dlabel" ); | |
521 | |
522 #ifdef DEBUG | |
523 dbprintf( 3,"\n[skin] dlabel\n" ); | |
524 #endif | |
525 | |
1852 | 526 x=cutItemToInt( in,',',0 ); |
527 y=cutItemToInt( in,',',1 ); | |
528 sx=cutItemToInt( in,',',2 ); | |
529 a=cutItemToInt( in,',',3 ); | |
1693 | 530 cutItem( in,sid,',',4 ); id=fntFindID( sid ); |
1884 | 531 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } |
1693 | 532 cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 ); |
533 | |
534 #ifdef DEBUG | |
535 dbprintf( 3,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a ); | |
536 dbprintf( 3,"[skin] id: %s ( %d )\n",sid,id ); | |
537 dbprintf( 3,"[skin] str: '%s'\n",tmp ); | |
538 #endif | |
539 | |
540 defList->NumberOfItems++; | |
541 item=&defList->Items[ defList->NumberOfItems ]; | |
542 item->type=itDLabel; | |
543 item->fontid=id; item->align=a; | |
544 item->x=x; item->y=y; | |
545 item->width=sx; item->height=-1; | |
1884 | 546 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } |
1693 | 547 strcpy( item->label,tmp ); |
548 | |
549 return 0; | |
550 } | |
551 | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
552 int __decoration( char * in ) |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
553 { |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
554 char tmp[512]; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
555 |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
556 CHECKDEFLIST( "decoration" ); |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
557 CHECKWINLIST( "decoration" ); |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
558 |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
559 #ifdef DEBUG |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
560 dbprintf( 0,"\n[skin] window decoration is %s\n",in ); |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
561 #endif |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
562 cutItem( in,tmp,',',0 ); |
1884 | 563 if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; } |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
564 if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
565 else defList->mainDecoration=1; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
566 |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
567 #ifdef DEBUG |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
568 dbprintf( 3,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") ); |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
569 #endif |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
570 return 0; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
571 } |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
572 |
1693 | 573 typedef struct |
574 { | |
575 char * name; | |
576 int (*func)( char * in ); | |
577 } _item; | |
578 | |
579 _item skinItem[] = | |
580 { | |
581 { "section", __section }, | |
582 { "end", __end }, | |
583 { "window", __window }, | |
584 { "base", __base }, | |
585 { "button", __button }, | |
586 { "selected", __selected }, | |
587 { "background", __background }, | |
588 { "hpotmeter", __hpotmeter }, | |
589 { "potmeter", __potmeter }, | |
590 { "font", __font }, | |
591 { "slabel", __slabel }, | |
592 { "dlabel", __dlabel }, | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
593 { "decoration", __decoration }, |
1693 | 594 { "menu", __menu } |
595 }; | |
596 | |
597 #define ITEMS ( sizeof( skinItem )/sizeof( _item ) ) | |
598 | |
599 char * strdelspacesbeforecommand( char * in ) | |
600 { | |
601 int c = 0; | |
602 char * out; | |
603 if ( strlen( in ) == 0 ) return NULL; | |
604 while ( in[c] == ' ' ) c++; | |
605 if ( c != 0 ) | |
606 { | |
607 out=malloc( strlen( in ) - c + 1 ); | |
608 memcpy( out,&in[c],strlen( in ) - c + 1 ); | |
609 } | |
610 else out=in; | |
611 return out; | |
612 } | |
613 | |
614 char * strswap( char * in,char what,char whereof ) | |
615 { | |
616 int i; | |
617 if ( strlen( in ) == 0 ) return NULL; | |
618 for ( i=0;i<strlen( in );i++ ) | |
619 if ( in[i] == what ) in[i]=whereof; | |
620 return in; | |
621 } | |
622 | |
623 char * strdelspaces( char * in ) | |
624 { | |
625 int c = 0,i = 0,id = 0; | |
626 if ( strlen( in ) == 0 ) return NULL; | |
627 while ( c != strlen( in ) ) | |
628 { | |
629 if ( in[c] == '"' ) id=!id; | |
630 if ( ( in[c] == ' ' )&&( !id ) ) | |
631 { | |
632 for ( i=0;i<strlen( in ) - c; i++ ) in[c+i]=in[c+i+1]; | |
633 continue; | |
634 } | |
635 c++; | |
636 } | |
637 return in; | |
638 } | |
639 | |
640 FILE * skinFile; | |
641 | |
642 void setname( char * item1, char * item2 ) | |
643 { strcpy( fn,item1 ); strcat( fn,"/" ); strcat( fn,item2 ); strcpy( path,fn ); strcat( path,"/" ); strcat( fn,"/skin" ); } | |
644 | |
645 int skinRead( char * dname ) | |
646 { | |
647 unsigned char tmp[255]; | |
648 unsigned char * ptmp; | |
649 unsigned char command[32]; | |
650 unsigned char param[256]; | |
651 int c,i; | |
652 | |
653 setname( skinMPlayerDir,dname ); | |
654 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) | |
655 { | |
656 setname( skinDirInHome,dname ); | |
657 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) | |
658 { | |
659 dbprintf( 3,"[skin] file ( %s ) not found.\n",fn ); | |
660 return -1; | |
661 } | |
662 } | |
663 | |
664 #ifdef DEBUG | |
665 dbprintf( 3,"[skin] file: %s\n",fn ); | |
666 #endif | |
667 | |
668 appInitStruct( &appMPlayer ); | |
669 | |
670 linenumber=0; | |
671 while ( !feof( skinFile ) ) | |
672 { | |
673 fgets( tmp,255,skinFile ); linenumber++; | |
674 | |
675 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
676 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
677 for ( c=0;c<strlen( tmp );c++ ) | |
678 if ( tmp[c] == ';' ) | |
679 { | |
680 tmp[c]=0; | |
681 break; | |
682 } | |
683 if ( strlen( tmp ) == 0 ) continue; | |
684 ptmp=strdelspacesbeforecommand( tmp ); | |
685 if ( strlen( ptmp ) == 0 ) continue; | |
686 ptmp=strswap( ptmp,'\t',' ' ); | |
687 ptmp=strdelspaces( ptmp ); | |
688 | |
689 cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 ); | |
690 strlower( command ); | |
691 for( i=0;i<ITEMS;i++ ) | |
692 if ( !strcmp( command,skinItem[i].name ) ) | |
693 if ( skinItem[i].func( param ) ) return -2; | |
694 } | |
695 return 0; | |
696 } | |
697 | |
698 void btnModify( int event,float state ) | |
699 { | |
700 int j; | |
701 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ ) | |
702 if ( appMPlayer.Items[j].msg == event ) | |
703 { | |
1729 | 704 if ( appMPlayer.Items[j].used ) continue; |
1693 | 705 switch ( appMPlayer.Items[j].type ) |
706 { | |
707 case itButton: | |
708 appMPlayer.Items[j].pressed=(int)state; | |
709 break; | |
710 case itPotmeter: | |
711 case itHPotmeter: | |
712 if ( state < 0.0f ) state=0.0f; | |
713 if ( state > 100.f ) state=100.0f; | |
714 appMPlayer.Items[j].value=state; | |
715 break; | |
716 } | |
717 } | |
718 } | |
719 | |
1729 | 720 float btnGetValue( int event ) |
1693 | 721 { |
722 int j; | |
723 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ ) | |
724 if ( appMPlayer.Items[j].msg == event ) return appMPlayer.Items[j].value; | |
725 return 0; | |
726 } |