10 #include "../config.h"
11 #include "../mp_msg.h"
12 #include "../help_mp.h"
13 #include "mplayer/widgets.h"
14 #include "libavutil/avstring.h"
16 //#define MSGL_DBG2 MSGL_STATUS
18 listItems
* skinAppMPlayer
= &appMPlayer
;
22 static int linenumber
;
24 static unsigned char path
[512],fn
[512];
26 static listItems
* defList
= NULL
;
27 static unsigned char window_name
[32] = "";
29 static wItem
* currSection
= NULL
;
30 static int * currSubItem
= NULL
;
31 static wItem
* currSubItems
= NULL
;
35 void ERRORMESSAGE( const char * format
, ... )
40 va_start( ap
,format
);
41 vsnprintf( p
,512,format
,ap
);
43 mp_msg( MSGT_GPLAYER
,MSGL_STATUS
,MSGTR_SKIN_ERRORMESSAGE
,linenumber
,p
);
44 snprintf( tmp
,512,MSGTR_SKIN_ERRORMESSAGE
,linenumber
,p
);
45 gtkMessageBox( GTK_MB_FATAL
,tmp
);
48 #define CHECKDEFLIST( str ) \
50 if ( defList == NULL ) \
52 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING1,linenumber,str ); \
57 #define CHECKWINLIST( str ) \
59 if ( !window_name[0] ) \
61 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING2,linenumber,str ); \
66 #define CHECK( name ) \
68 if ( !strcmp( window_name,name ) ) \
70 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING3,linenumber,name ); \
75 static char * strlower( char * in
)
78 for( i
=0;i
<(int)strlen( in
);i
++ ) in
[i
]=( in
[i
] >= 'A' ? ( in
[i
] <= 'Z' ? in
[i
]+='A' : in
[i
] ) : in
[i
] );
82 int skinBPRead( char * fname
, txSample
* bf
)
84 int i
=bpRead( fname
,bf
);
87 case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit
,fname
); break;
88 case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound
,fname
); break;
89 case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError
,fname
); break;
90 case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError
,fname
); break;
91 case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError
,fname
); break;
92 case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported
,fname
); break;
93 case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType
,fname
); break;
94 case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConversionError
,fname
); break;
99 int cmd_section( char * in
)
103 if ( !strcmp( in
,"movieplayer" ) ) defList
=skinAppMPlayer
;
104 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] sectionname: %s\n",in
);
108 int cmd_end( char * in
)
110 if ( strlen( window_name
) ) { window_name
[0]=0; currSection
=NULL
; currSubItem
=NULL
; currSubItems
=NULL
; }
112 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] end section\n" );
116 int cmd_window( char * in
)
118 CHECKDEFLIST( "window" );
120 av_strlcpy( window_name
,strlower( in
),sizeof( window_name
) );
121 if ( !strncmp( in
,"main",4 ) ) { currSection
=&skinAppMPlayer
->main
; currSubItem
=&skinAppMPlayer
->NumberOfItems
; currSubItems
=skinAppMPlayer
->Items
; }
122 else if ( !strncmp( in
,"sub",3 ) ) currSection
=&skinAppMPlayer
->sub
;
123 else if ( !strncmp( in
,"playbar",7 ) ) { currSection
=&skinAppMPlayer
->bar
; currSubItem
=&skinAppMPlayer
->NumberOfBarItems
; currSubItems
=skinAppMPlayer
->barItems
; }
124 else if ( !strncmp( in
,"menu",4 ) ) { currSection
=&skinAppMPlayer
->menuBase
; currSubItem
=&skinAppMPlayer
->NumberOfMenuItems
; currSubItems
=skinAppMPlayer
->MenuItems
; }
125 else ERRORMESSAGE( MSGTR_UNKNOWNWINDOWTYPE
);
126 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] window: %s\n",window_name
);
130 int cmd_base( char * in
)
132 unsigned char fname
[512];
133 unsigned char tmp
[512];
137 CHECKDEFLIST( "base" );
138 CHECKWINLIST( "base" );
140 cutItem( in
,fname
,',',0 );
141 x
=cutItemToInt( in
,',',1 );
142 y
=cutItemToInt( in
,',',2 );
143 sx
=cutItemToInt( in
,',',3 );
144 sy
=cutItemToInt( in
,',',4 );
145 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] base: %s x: %d y: %d ( %dx%d )\n",fname
,x
,y
,sx
,sy
);
146 if ( !strcmp( window_name
,"main" ) )
150 defList
->main
.type
=itBase
;
151 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
152 if ( skinBPRead( tmp
,&defList
->main
.Bitmap
) ) return 1;
153 defList
->main
.width
=defList
->main
.Bitmap
.Width
;
154 defList
->main
.height
=defList
->main
.Bitmap
.Height
;
156 Convert32to1( &defList
->main
.Bitmap
,&defList
->main
.Mask
,0x00ff00ff );
157 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] mask: %dx%d\n",defList
->main
.Mask
.Width
,defList
->main
.Mask
.Height
);
159 defList
->main
.Mask
.Image
=NULL
;
161 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->main
.width
,defList
->main
.height
);
163 if ( !strcmp( window_name
,"sub" ) )
165 defList
->sub
.type
=itBase
;
166 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
167 if ( skinBPRead( tmp
,&defList
->sub
.Bitmap
) ) return 1;
170 defList
->sub
.width
=defList
->sub
.Bitmap
.Width
;
171 defList
->sub
.height
=defList
->sub
.Bitmap
.Height
;
174 defList
->sub
.width
=sx
;
175 defList
->sub
.height
=sy
;
177 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] %d,%d %dx%d\n",defList
->sub
.x
,defList
->sub
.y
,defList
->sub
.width
,defList
->sub
.height
);
179 if ( !strcmp( window_name
,"menu" ) )
181 defList
->menuIsPresent
=1;
182 defList
->menuBase
.type
=itBase
;
183 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
184 if ( skinBPRead( tmp
,&defList
->menuBase
.Bitmap
) ) return 1;
185 defList
->menuBase
.width
=defList
->menuBase
.Bitmap
.Width
;
186 defList
->menuBase
.height
=defList
->menuBase
.Bitmap
.Height
;
188 Convert32to1( &defList
->menuBase
.Bitmap
,&defList
->menuBase
.Mask
,0x00ff00ff );
189 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] mask: %dx%d\n",defList
->menuBase
.Mask
.Width
,defList
->menuBase
.Mask
.Height
);
191 defList
->menuBase
.Mask
.Image
=NULL
;
193 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->menuBase
.width
,defList
->menuBase
.height
);
195 if ( !strcmp( window_name
,"playbar" ) )
197 defList
->barIsPresent
=1;
200 defList
->bar
.type
=itBase
;
201 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
202 if ( skinBPRead( tmp
,&defList
->bar
.Bitmap
) ) return 1;
203 defList
->bar
.width
=defList
->bar
.Bitmap
.Width
;
204 defList
->bar
.height
=defList
->bar
.Bitmap
.Height
;
206 Convert32to1( &defList
->bar
.Bitmap
,&defList
->bar
.Mask
,0x00ff00ff );
207 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] mask: %dx%d\n",defList
->bar
.Mask
.Width
,defList
->bar
.Mask
.Height
);
209 defList
->bar
.Mask
.Image
=NULL
;
211 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->bar
.width
,defList
->bar
.height
);
216 int cmd_background( char * in
)
218 CHECKDEFLIST( "background" );
219 CHECKWINLIST( "background" );
224 currSection
->R
=cutItemToInt( in
,',',0 );
225 currSection
->G
=cutItemToInt( in
,',',1 );
226 currSection
->B
=cutItemToInt( in
,',',2 );
227 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] background color is #%x%x%x.\n",currSection
->R
,currSection
->G
,currSection
->B
);
232 int cmd_button( char * in
)
234 unsigned char fname
[512];
235 unsigned char tmp
[512];
239 CHECKDEFLIST( "button" );
240 CHECKWINLIST( "button" );
245 cutItem( in
,fname
,',',0 );
246 x
=cutItemToInt( in
,',',1 );
247 y
=cutItemToInt( in
,',',2 );
248 sx
=cutItemToInt( in
,',',3 );
249 sy
=cutItemToInt( in
,',',4 );
250 cutItem( in
,msg
,',',5 );
253 currSubItems
[ *currSubItem
].type
=itButton
;
254 currSubItems
[ *currSubItem
].x
=x
;
255 currSubItems
[ *currSubItem
].y
=y
;
256 currSubItems
[ *currSubItem
].width
=sx
;
257 currSubItems
[ *currSubItem
].height
=sy
;
258 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] button: fname: %s\n",fname
);
259 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] x: %d y: %d sx: %d sy: %d\n",x
,y
,sx
,sy
);
261 if ( ( currSubItems
[ *currSubItem
].msg
=appFindMessage( msg
) ) == -1 )
262 { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage
,msg
); return 0; }
263 currSubItems
[ *currSubItem
].pressed
=btnReleased
;
264 if ( currSubItems
[ *currSubItem
].msg
== evPauseSwitchToPlay
) currSubItems
[ *currSubItem
].pressed
=btnDisabled
;
265 currSubItems
[ *currSubItem
].tmp
=1;
267 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",currSubItems
[ *currSubItem
].msg
);
269 currSubItems
[ *currSubItem
].Bitmap
.Image
=NULL
;
270 if ( strcmp( fname
,"NULL" ) )
272 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
273 if ( skinBPRead( tmp
,&currSubItems
[ *currSubItem
].Bitmap
) ) return 1;
279 int cmd_selected( char * in
)
281 unsigned char fname
[512];
282 unsigned char tmp
[512];
284 CHECKDEFLIST( "selected" );
285 CHECKWINLIST( "selected" );
291 cutItem( in
,fname
,',',0 );
292 defList
->menuSelected
.type
=itBase
;
293 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
294 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] selected: %s\n",fname
);
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 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->menuSelected
.width
,defList
->menuSelected
.height
);
302 int cmd_menu( char * in
)
303 { // menu = number,x,y,sx,sy,msg
305 unsigned char tmp
[64];
307 CHECKDEFLIST( "menu" );
308 CHECKWINLIST( "menu" );
314 x
=cutItemToInt( in
,',',0 );
315 y
=cutItemToInt( in
,',',1 );
316 sx
=cutItemToInt( in
,',',2 );
317 sy
=cutItemToInt( in
,',',3 );
318 cutItem( in
,tmp
,',',4 ); msg
=appFindMessage( tmp
);
320 defList
->NumberOfMenuItems
++;
321 defList
->MenuItems
[ defList
->NumberOfMenuItems
].x
=x
;
322 defList
->MenuItems
[ defList
->NumberOfMenuItems
].y
=y
;
323 defList
->MenuItems
[ defList
->NumberOfMenuItems
].width
=sx
;
324 defList
->MenuItems
[ defList
->NumberOfMenuItems
].height
=sy
;
326 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] menuitem: %d\n",defList
->NumberOfMenuItems
);
327 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] x: %d y: %d sx: %d sy: %d\n",x
,y
,sx
,sy
);
329 if ( ( defList
->MenuItems
[ defList
->NumberOfMenuItems
].msg
=msg
) == -1 )
330 ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage
,tmp
);
332 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",defList
->Items
[ defList
->NumberOfItems
].msg
);
334 defList
->MenuItems
[ defList
->NumberOfMenuItems
].Bitmap
.Image
=NULL
;
338 int cmd_hpotmeter( char * in
)
339 { // hpotmeter=buttonbitmaps,sx,sy,phasebitmaps,phases,default value,x,y,sx,sy,msg
340 int x
,y
,psx
,psy
,ph
,sx
,sy
,msg
,d
;
341 unsigned char tmp
[512];
342 unsigned char pfname
[512];
343 unsigned char phfname
[512];
346 CHECKDEFLIST( "hpotmeter" );
347 CHECKWINLIST( "hpotmeter" );
352 cutItem( in
,pfname
,',',0 );
353 psx
=cutItemToInt( in
,',',1 );
354 psy
=cutItemToInt( in
,',',2 );
355 cutItem( in
,phfname
,',',3 );
356 ph
=cutItemToInt( in
,',',4 );
357 d
=cutItemToInt( in
,',',5 );
358 x
=cutItemToInt( in
,',',6 );
359 y
=cutItemToInt( in
,',',7 );
360 sx
=cutItemToInt( in
,',',8 );
361 sy
=cutItemToInt( in
,',',9 );
362 cutItem( in
,tmp
,',',10 ); msg
=appFindMessage( tmp
);
364 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] h/v potmeter: pointer filename: '%s'\n",pfname
);
365 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] pointer size is %dx%d\n",psx
,psy
);
366 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] phasebitmaps filename: '%s'\n",phfname
);
367 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] position: %d,%d %dx%d\n",x
,y
,sx
,sy
);
368 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] default value: %d\n",d
);
369 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",msg
);
372 item
=&currSubItems
[ *currSubItem
];
374 item
->type
=itHPotmeter
;
375 item
->x
=x
; item
->y
=y
; item
->width
=sx
; item
->height
=sy
;
377 item
->psx
=psx
; item
->psy
=psy
;
379 item
->value
=(float)d
;
380 item
->pressed
=btnReleased
;
382 item
->Bitmap
.Image
=NULL
;
383 if ( strcmp( phfname
,"NULL" ) )
385 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, phfname
, sizeof( tmp
));
386 if ( skinBPRead( tmp
,&item
->Bitmap
) ) return 1;
389 item
->Mask
.Image
=NULL
;
390 if ( strcmp( pfname
,"NULL" ) )
392 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, pfname
, sizeof( tmp
));
393 if ( skinBPRead( tmp
,&item
->Mask
) ) return 1;
398 int cmd_vpotmeter( char * in
)
400 int r
= cmd_hpotmeter( in
);
403 item
=&currSubItems
[ *currSubItem
];
404 item
->type
=itVPotmeter
;
408 int cmd_potmeter( char * in
)
409 { // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg
410 int x
,y
,ph
,sx
,sy
,msg
,d
;
411 unsigned char tmp
[512];
412 unsigned char phfname
[512];
415 CHECKDEFLIST( "potmeter" );
416 CHECKWINLIST( "potmeter" );
421 cutItem( in
,phfname
,',',0 );
422 ph
=cutItemToInt( in
,',',1 );
423 d
=cutItemToInt( in
,',',2 );
424 x
=cutItemToInt( in
,',',3 );
425 y
=cutItemToInt( in
,',',4 );
426 sx
=cutItemToInt( in
,',',5 );
427 sy
=cutItemToInt( in
,',',6 );
428 cutItem( in
,tmp
,',',7 ); msg
=appFindMessage( tmp
);
430 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] potmeter: phases filename: '%s'\n",phfname
);
431 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] position: %d,%d %dx%d\n",x
,y
,sx
,sy
);
432 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] phases: %d\n",ph
);
433 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] default value: %d\n",d
);
434 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",msg
);
437 item
=&currSubItems
[ *currSubItem
];
439 item
->type
=itPotmeter
;
440 item
->x
=x
; item
->y
=y
;
441 item
->width
=sx
; item
->height
=sy
;
444 item
->value
=(float)d
;
446 item
->Bitmap
.Image
=NULL
;
447 if ( strcmp( phfname
,"NULL" ) )
449 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, phfname
, sizeof( tmp
));
450 if ( skinBPRead( tmp
,&item
->Bitmap
) ) return 1;
455 int cmd_font( char * in
)
456 { // font=fontname,fontid
461 CHECKDEFLIST( "font" );
462 CHECKWINLIST( "font" );
467 cutItem( in
,name
,',',0 );
468 cutItem( in
,id
,',',1 );
470 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] font\n" );
471 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] name: %s\n",name
);
474 item
=&currSubItems
[ *currSubItem
];
477 item
->fontid
=fntRead( path
,name
);
478 switch ( item
->fontid
)
480 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory
); return 1;
481 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared
); return 1;
482 case -3: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound
); return 1;
483 case -4: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound
); return 1;
488 int cmd_slabel( char * in
)
495 CHECKDEFLIST( "slabel" );
496 CHECKWINLIST( "slabel" );
501 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] slabel\n" );
503 x
=cutItemToInt( in
,',',0 );
504 y
=cutItemToInt( in
,',',1 );
505 cutItem( in
,sid
,',',2 ); id
=fntFindID( sid
);
506 if ( id
< 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID
,sid
); return 1; }
507 cutItem( in
,tmp
,',',3 ); cutItem( tmp
,tmp
,'"',1 );
509 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] pos: %d,%d\n",x
,y
);
510 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] id: %s ( %d )\n",sid
,id
);
511 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] str: '%s'\n",tmp
);
514 item
=&currSubItems
[ *currSubItem
];
518 item
->x
=x
; item
->y
=y
;
519 item
->width
=-1; item
->height
=-1;
520 if ( ( item
->label
=malloc( strlen( tmp
) + 1 ) ) == NULL
) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory
); return 1; }
521 strcpy( item
->label
,tmp
);
526 int cmd_dlabel( char * in
)
527 { // dlabel=x,y,sx,align,fontid,string ...
533 CHECKDEFLIST( "dlabel" );
534 CHECKWINLIST( "dlabel" );
539 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] dlabel\n" );
541 x
=cutItemToInt( in
,',',0 );
542 y
=cutItemToInt( in
,',',1 );
543 sx
=cutItemToInt( in
,',',2 );
544 a
=cutItemToInt( in
,',',3 );
545 cutItem( in
,sid
,',',4 ); id
=fntFindID( sid
);
546 if ( id
< 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID
,sid
); return 1; }
547 cutItem( in
,tmp
,',',5 ); cutItem( tmp
,tmp
,'"',1 );
549 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] pos: %d,%d width: %d align: %d\n",x
,y
,sx
,a
);
550 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] id: %s ( %d )\n",sid
,id
);
551 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] str: '%s'\n",tmp
);
554 item
=&currSubItems
[ *currSubItem
];
557 item
->fontid
=id
; item
->align
=a
;
558 item
->x
=x
; item
->y
=y
;
559 item
->width
=sx
; item
->height
=-1;
560 if ( ( item
->label
=malloc( strlen( tmp
) + 1 ) ) == NULL
) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory
); return 1; }
561 strcpy( item
->label
,tmp
);
566 int cmd_decoration( char * in
)
570 CHECKDEFLIST( "decoration" );
571 CHECKWINLIST( "decoration" );
577 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] window decoration is %s\n",in
);
579 cutItem( in
,tmp
,',',0 );
580 if ( strcmp( tmp
,"enable" )&&strcmp( tmp
,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter
,tmp
); return 1; }
581 if ( strcmp( tmp
,"enable" ) ) defList
->mainDecoration
=0;
582 else defList
->mainDecoration
=1;
584 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] window decoration is %s\n",(defList
->mainDecoration
?"enabled":"disabled") );
591 int (*func
)( char * in
);
596 { "section", cmd_section
},
598 { "window", cmd_window
},
599 { "base", cmd_base
},
600 { "button", cmd_button
},
601 { "selected", cmd_selected
},
602 { "background", cmd_background
},
603 { "vpotmeter", cmd_vpotmeter
},
604 { "hpotmeter", cmd_hpotmeter
},
605 { "potmeter", cmd_potmeter
},
606 { "font", cmd_font
},
607 { "slabel", cmd_slabel
},
608 { "dlabel", cmd_dlabel
},
609 { "decoration", cmd_decoration
},
613 #define ITEMS (int)( sizeof( skinItem )/sizeof( _item ) )
615 char * trimleft( char * in
)
619 if ( strlen( in
) == 0 ) return NULL
;
620 while ( in
[c
] == ' ' ) c
++;
623 out
=malloc( strlen( in
) - c
+ 1 );
624 memcpy( out
,&in
[c
],strlen( in
) - c
+ 1 );
630 char * strswap( char * in
,char what
,char whereof
)
633 if ( strlen( in
) == 0 ) return NULL
;
634 for ( i
=0;i
<(int)strlen( in
);i
++ )
635 if ( in
[i
] == what
) in
[i
]=whereof
;
639 char * trim( char * in
)
641 int c
= 0,i
= 0,id
= 0;
642 if ( strlen( in
) == 0 ) return NULL
;
643 while ( c
!= (int)strlen( in
) )
645 if ( in
[c
] == '"' ) id
=!id
;
646 if ( ( in
[c
] == ' ' )&&( !id
) )
648 for ( i
=0;i
<(int)strlen( in
) - c
; i
++ ) in
[c
+i
]=in
[c
+i
+1];
658 void setname( char * item1
, char * item2
)
660 av_strlcpy(fn
, item1
, sizeof( fn
));
661 av_strlcat(fn
, "/", sizeof( fn
)); av_strlcat(fn
, item2
, sizeof( fn
));
662 av_strlcpy(path
, fn
, sizeof( path
)); av_strlcat(path
, "/", sizeof( path
));
663 av_strlcat(fn
, "/skin", sizeof( fn
));
666 int skinRead( char * dname
)
668 unsigned char tmp
[255];
669 unsigned char * ptmp
;
670 unsigned char command
[32];
671 unsigned char param
[256];
674 setname( skinDirInHome
,dname
);
675 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
677 setname( skinMPlayerDir
,dname
);
678 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
680 setname( skinDirInHome_obsolete
,dname
);
681 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
683 setname( skinMPlayerDir_obsolete
,dname
);
684 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
686 setname( skinMPlayerDir
,dname
);
687 mp_msg( MSGT_GPLAYER
,MSGL_STATUS
,MSGTR_SKIN_SkinFileNotFound
,fn
);
694 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] file: %s\n",fn
);
696 appInitStruct( skinAppMPlayer
);
699 while (fgets(tmp
, 255, skinFile
))
703 c
=tmp
[ strlen( tmp
) - 1 ]; if ( c
== '\n' || c
== '\r' ) tmp
[ strlen( tmp
) - 1 ]=0;
704 c
=tmp
[ strlen( tmp
) - 1 ]; if ( c
== '\n' || c
== '\r' ) tmp
[ strlen( tmp
) - 1 ]=0;
705 for ( c
=0;c
<(int)strlen( tmp
);c
++ )
711 if ( strlen( tmp
) == 0 ) continue;
712 ptmp
=trimleft( tmp
);
713 if ( strlen( ptmp
) == 0 ) continue;
714 ptmp
=strswap( ptmp
,'\t',' ' );
717 cutItem( ptmp
,command
,'=',0 ); cutItem( ptmp
,param
,'=',1 );
719 for( i
=0;i
<ITEMS
;i
++ )
720 if ( !strcmp( command
,skinItem
[i
].name
) )
721 if ( skinItem
[i
].func( param
) ) return -2;
723 if (linenumber
== 0) {
724 mp_msg(MSGT_GPLAYER
, MSGL_FATAL
, MSGTR_SKIN_SkinFileNotReadable
, fn
);