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