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