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