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