2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "gui/mplayer/widgets.h"
31 #include "libavutil/avstring.h"
33 //#define MSGL_DBG2 MSGL_STATUS
35 listItems
* skinAppMPlayer
= &appMPlayer
;
39 static int linenumber
;
41 static unsigned char path
[512],fn
[512];
43 static listItems
* defList
= NULL
;
44 static unsigned char window_name
[32] = "";
46 static wItem
* currSection
= NULL
;
47 static int * currSubItem
= NULL
;
48 static wItem
* currSubItems
= NULL
;
52 void ERRORMESSAGE( const char * format
, ... )
57 va_start( ap
,format
);
58 vsnprintf( p
,512,format
,ap
);
60 mp_msg( MSGT_GPLAYER
,MSGL_STATUS
,MSGTR_SKIN_ERRORMESSAGE
,linenumber
,p
);
61 snprintf( tmp
,512,MSGTR_SKIN_ERRORMESSAGE
,linenumber
,p
);
62 gtkMessageBox( GTK_MB_FATAL
,tmp
);
65 #define CHECKDEFLIST( str ) \
67 if ( defList == NULL ) \
69 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING1,linenumber,str ); \
74 #define CHECKWINLIST( str ) \
76 if ( !window_name[0] ) \
78 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING2,linenumber,str ); \
83 #define CHECK( name ) \
85 if ( !strcmp( window_name,name ) ) \
87 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING3,linenumber,name ); \
92 static char * strlower( char * in
)
95 for( i
=0;i
<(int)strlen( in
);i
++ ) in
[i
]=( in
[i
] >= 'A' ? ( in
[i
] <= 'Z' ? in
[i
]+='A' : in
[i
] ) : in
[i
] );
99 int skinBPRead( char * fname
, txSample
* bf
)
101 int i
=bpRead( fname
,bf
);
104 case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit
,fname
); break;
105 case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound
,fname
); break;
106 case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError
,fname
); break;
107 case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError
,fname
); break;
108 case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError
,fname
); break;
109 case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported
,fname
); break;
110 case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType
,fname
); break;
111 case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConversionError
,fname
); break;
116 int cmd_section( char * in
)
120 if ( !strcmp( in
,"movieplayer" ) ) defList
=skinAppMPlayer
;
121 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] sectionname: %s\n",in
);
125 int cmd_end( char * in
)
127 if ( strlen( window_name
) ) { window_name
[0]=0; currSection
=NULL
; currSubItem
=NULL
; currSubItems
=NULL
; }
129 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] end section\n" );
133 int cmd_window( char * in
)
135 CHECKDEFLIST( "window" );
137 av_strlcpy( window_name
,strlower( in
),sizeof( window_name
) );
138 if ( !strncmp( in
,"main",4 ) ) { currSection
=&skinAppMPlayer
->main
; currSubItem
=&skinAppMPlayer
->NumberOfItems
; currSubItems
=skinAppMPlayer
->Items
; }
139 else if ( !strncmp( in
,"sub",3 ) ) currSection
=&skinAppMPlayer
->sub
;
140 else if ( !strncmp( in
,"playbar",7 ) ) { currSection
=&skinAppMPlayer
->bar
; currSubItem
=&skinAppMPlayer
->NumberOfBarItems
; currSubItems
=skinAppMPlayer
->barItems
; }
141 else if ( !strncmp( in
,"menu",4 ) ) { currSection
=&skinAppMPlayer
->menuBase
; currSubItem
=&skinAppMPlayer
->NumberOfMenuItems
; currSubItems
=skinAppMPlayer
->MenuItems
; }
142 else ERRORMESSAGE( MSGTR_UNKNOWNWINDOWTYPE
);
143 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] window: %s\n",window_name
);
147 int cmd_base( char * in
)
149 unsigned char fname
[512];
150 unsigned char tmp
[512];
154 CHECKDEFLIST( "base" );
155 CHECKWINLIST( "base" );
157 cutItem( in
,fname
,',',0 );
158 x
=cutItemToInt( in
,',',1 );
159 y
=cutItemToInt( in
,',',2 );
160 sx
=cutItemToInt( in
,',',3 );
161 sy
=cutItemToInt( in
,',',4 );
162 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] base: %s x: %d y: %d ( %dx%d )\n",fname
,x
,y
,sx
,sy
);
163 if ( !strcmp( window_name
,"main" ) )
167 defList
->main
.type
=itBase
;
168 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
169 if ( skinBPRead( tmp
,&defList
->main
.Bitmap
) ) return 1;
170 defList
->main
.width
=defList
->main
.Bitmap
.Width
;
171 defList
->main
.height
=defList
->main
.Bitmap
.Height
;
173 Convert32to1( &defList
->main
.Bitmap
,&defList
->main
.Mask
,0x00ff00ff );
174 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] mask: %dx%d\n",defList
->main
.Mask
.Width
,defList
->main
.Mask
.Height
);
176 defList
->main
.Mask
.Image
=NULL
;
178 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->main
.width
,defList
->main
.height
);
180 if ( !strcmp( window_name
,"sub" ) )
182 defList
->sub
.type
=itBase
;
183 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
184 if ( skinBPRead( tmp
,&defList
->sub
.Bitmap
) ) return 1;
187 defList
->sub
.width
=defList
->sub
.Bitmap
.Width
;
188 defList
->sub
.height
=defList
->sub
.Bitmap
.Height
;
191 defList
->sub
.width
=sx
;
192 defList
->sub
.height
=sy
;
194 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] %d,%d %dx%d\n",defList
->sub
.x
,defList
->sub
.y
,defList
->sub
.width
,defList
->sub
.height
);
196 if ( !strcmp( window_name
,"menu" ) )
198 defList
->menuIsPresent
=1;
199 defList
->menuBase
.type
=itBase
;
200 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
201 if ( skinBPRead( tmp
,&defList
->menuBase
.Bitmap
) ) return 1;
202 defList
->menuBase
.width
=defList
->menuBase
.Bitmap
.Width
;
203 defList
->menuBase
.height
=defList
->menuBase
.Bitmap
.Height
;
205 Convert32to1( &defList
->menuBase
.Bitmap
,&defList
->menuBase
.Mask
,0x00ff00ff );
206 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] mask: %dx%d\n",defList
->menuBase
.Mask
.Width
,defList
->menuBase
.Mask
.Height
);
208 defList
->menuBase
.Mask
.Image
=NULL
;
210 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->menuBase
.width
,defList
->menuBase
.height
);
212 if ( !strcmp( window_name
,"playbar" ) )
214 defList
->barIsPresent
=1;
217 defList
->bar
.type
=itBase
;
218 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
219 if ( skinBPRead( tmp
,&defList
->bar
.Bitmap
) ) return 1;
220 defList
->bar
.width
=defList
->bar
.Bitmap
.Width
;
221 defList
->bar
.height
=defList
->bar
.Bitmap
.Height
;
223 Convert32to1( &defList
->bar
.Bitmap
,&defList
->bar
.Mask
,0x00ff00ff );
224 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] mask: %dx%d\n",defList
->bar
.Mask
.Width
,defList
->bar
.Mask
.Height
);
226 defList
->bar
.Mask
.Image
=NULL
;
228 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->bar
.width
,defList
->bar
.height
);
233 int cmd_background( char * in
)
235 CHECKDEFLIST( "background" );
236 CHECKWINLIST( "background" );
241 currSection
->R
=cutItemToInt( in
,',',0 );
242 currSection
->G
=cutItemToInt( in
,',',1 );
243 currSection
->B
=cutItemToInt( in
,',',2 );
244 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] background color is #%x%x%x.\n",currSection
->R
,currSection
->G
,currSection
->B
);
249 int cmd_button( char * in
)
251 unsigned char fname
[512];
252 unsigned char tmp
[512];
256 CHECKDEFLIST( "button" );
257 CHECKWINLIST( "button" );
262 cutItem( in
,fname
,',',0 );
263 x
=cutItemToInt( in
,',',1 );
264 y
=cutItemToInt( in
,',',2 );
265 sx
=cutItemToInt( in
,',',3 );
266 sy
=cutItemToInt( in
,',',4 );
267 cutItem( in
,msg
,',',5 );
270 currSubItems
[ *currSubItem
].type
=itButton
;
271 currSubItems
[ *currSubItem
].x
=x
;
272 currSubItems
[ *currSubItem
].y
=y
;
273 currSubItems
[ *currSubItem
].width
=sx
;
274 currSubItems
[ *currSubItem
].height
=sy
;
275 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] button: fname: %s\n",fname
);
276 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] x: %d y: %d sx: %d sy: %d\n",x
,y
,sx
,sy
);
278 if ( ( currSubItems
[ *currSubItem
].msg
=appFindMessage( msg
) ) == -1 )
279 { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage
,msg
); return 0; }
280 currSubItems
[ *currSubItem
].pressed
=btnReleased
;
281 if ( currSubItems
[ *currSubItem
].msg
== evPauseSwitchToPlay
) currSubItems
[ *currSubItem
].pressed
=btnDisabled
;
282 currSubItems
[ *currSubItem
].tmp
=1;
284 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",currSubItems
[ *currSubItem
].msg
);
286 currSubItems
[ *currSubItem
].Bitmap
.Image
=NULL
;
287 if ( strcmp( fname
,"NULL" ) )
289 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
290 if ( skinBPRead( tmp
,&currSubItems
[ *currSubItem
].Bitmap
) ) return 1;
296 int cmd_selected( char * in
)
298 unsigned char fname
[512];
299 unsigned char tmp
[512];
301 CHECKDEFLIST( "selected" );
302 CHECKWINLIST( "selected" );
308 cutItem( in
,fname
,',',0 );
309 defList
->menuSelected
.type
=itBase
;
310 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, fname
, sizeof( tmp
));
311 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] selected: %s\n",fname
);
312 if ( skinBPRead( tmp
,&defList
->menuSelected
.Bitmap
) ) return 1;
313 defList
->menuSelected
.width
=defList
->menuSelected
.Bitmap
.Width
;
314 defList
->menuSelected
.height
=defList
->menuSelected
.Bitmap
.Height
;
315 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] width: %d height: %d\n",defList
->menuSelected
.width
,defList
->menuSelected
.height
);
319 int cmd_menu( char * in
)
320 { // menu = number,x,y,sx,sy,msg
322 unsigned char tmp
[64];
324 CHECKDEFLIST( "menu" );
325 CHECKWINLIST( "menu" );
331 x
=cutItemToInt( in
,',',0 );
332 y
=cutItemToInt( in
,',',1 );
333 sx
=cutItemToInt( in
,',',2 );
334 sy
=cutItemToInt( in
,',',3 );
335 cutItem( in
,tmp
,',',4 ); msg
=appFindMessage( tmp
);
337 defList
->NumberOfMenuItems
++;
338 defList
->MenuItems
[ defList
->NumberOfMenuItems
].x
=x
;
339 defList
->MenuItems
[ defList
->NumberOfMenuItems
].y
=y
;
340 defList
->MenuItems
[ defList
->NumberOfMenuItems
].width
=sx
;
341 defList
->MenuItems
[ defList
->NumberOfMenuItems
].height
=sy
;
343 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] menuitem: %d\n",defList
->NumberOfMenuItems
);
344 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] x: %d y: %d sx: %d sy: %d\n",x
,y
,sx
,sy
);
346 if ( ( defList
->MenuItems
[ defList
->NumberOfMenuItems
].msg
=msg
) == -1 )
347 ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage
,tmp
);
349 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",defList
->Items
[ defList
->NumberOfItems
].msg
);
351 defList
->MenuItems
[ defList
->NumberOfMenuItems
].Bitmap
.Image
=NULL
;
355 int cmd_hpotmeter( char * in
)
356 { // hpotmeter=buttonbitmaps,sx,sy,phasebitmaps,phases,default value,x,y,sx,sy,msg
357 int x
,y
,psx
,psy
,ph
,sx
,sy
,msg
,d
;
358 unsigned char tmp
[512];
359 unsigned char pfname
[512];
360 unsigned char phfname
[512];
363 CHECKDEFLIST( "hpotmeter" );
364 CHECKWINLIST( "hpotmeter" );
369 cutItem( in
,pfname
,',',0 );
370 psx
=cutItemToInt( in
,',',1 );
371 psy
=cutItemToInt( in
,',',2 );
372 cutItem( in
,phfname
,',',3 );
373 ph
=cutItemToInt( in
,',',4 );
374 d
=cutItemToInt( in
,',',5 );
375 x
=cutItemToInt( in
,',',6 );
376 y
=cutItemToInt( in
,',',7 );
377 sx
=cutItemToInt( in
,',',8 );
378 sy
=cutItemToInt( in
,',',9 );
379 cutItem( in
,tmp
,',',10 ); msg
=appFindMessage( tmp
);
381 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] h/v potmeter: pointer filename: '%s'\n",pfname
);
382 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] pointer size is %dx%d\n",psx
,psy
);
383 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] phasebitmaps filename: '%s'\n",phfname
);
384 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] position: %d,%d %dx%d\n",x
,y
,sx
,sy
);
385 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] default value: %d\n",d
);
386 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",msg
);
389 item
=&currSubItems
[ *currSubItem
];
391 item
->type
=itHPotmeter
;
392 item
->x
=x
; item
->y
=y
; item
->width
=sx
; item
->height
=sy
;
394 item
->psx
=psx
; item
->psy
=psy
;
396 item
->value
=(float)d
;
397 item
->pressed
=btnReleased
;
399 item
->Bitmap
.Image
=NULL
;
400 if ( strcmp( phfname
,"NULL" ) )
402 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, phfname
, sizeof( tmp
));
403 if ( skinBPRead( tmp
,&item
->Bitmap
) ) return 1;
406 item
->Mask
.Image
=NULL
;
407 if ( strcmp( pfname
,"NULL" ) )
409 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, pfname
, sizeof( tmp
));
410 if ( skinBPRead( tmp
,&item
->Mask
) ) return 1;
415 int cmd_vpotmeter( char * in
)
417 int r
= cmd_hpotmeter( in
);
420 item
=&currSubItems
[ *currSubItem
];
421 item
->type
=itVPotmeter
;
425 int cmd_potmeter( char * in
)
426 { // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg
427 int x
,y
,ph
,sx
,sy
,msg
,d
;
428 unsigned char tmp
[512];
429 unsigned char phfname
[512];
432 CHECKDEFLIST( "potmeter" );
433 CHECKWINLIST( "potmeter" );
438 cutItem( in
,phfname
,',',0 );
439 ph
=cutItemToInt( in
,',',1 );
440 d
=cutItemToInt( in
,',',2 );
441 x
=cutItemToInt( in
,',',3 );
442 y
=cutItemToInt( in
,',',4 );
443 sx
=cutItemToInt( in
,',',5 );
444 sy
=cutItemToInt( in
,',',6 );
445 cutItem( in
,tmp
,',',7 ); msg
=appFindMessage( tmp
);
447 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] potmeter: phases filename: '%s'\n",phfname
);
448 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] position: %d,%d %dx%d\n",x
,y
,sx
,sy
);
449 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] phases: %d\n",ph
);
450 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] default value: %d\n",d
);
451 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] message: %d\n",msg
);
454 item
=&currSubItems
[ *currSubItem
];
456 item
->type
=itPotmeter
;
457 item
->x
=x
; item
->y
=y
;
458 item
->width
=sx
; item
->height
=sy
;
461 item
->value
=(float)d
;
463 item
->Bitmap
.Image
=NULL
;
464 if ( strcmp( phfname
,"NULL" ) )
466 av_strlcpy(tmp
, path
, sizeof( tmp
)); av_strlcat(tmp
, phfname
, sizeof( tmp
));
467 if ( skinBPRead( tmp
,&item
->Bitmap
) ) return 1;
472 int cmd_font( char * in
)
473 { // font=fontname,fontid
478 CHECKDEFLIST( "font" );
479 CHECKWINLIST( "font" );
484 cutItem( in
,name
,',',0 );
485 cutItem( in
,id
,',',1 );
487 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] font\n" );
488 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] name: %s\n",name
);
491 item
=&currSubItems
[ *currSubItem
];
494 item
->fontid
=fntRead( path
,name
);
495 switch ( item
->fontid
)
497 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory
); return 1;
498 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared
); return 1;
499 case -3: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound
); return 1;
500 case -4: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound
); return 1;
505 int cmd_slabel( char * in
)
512 CHECKDEFLIST( "slabel" );
513 CHECKWINLIST( "slabel" );
518 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] slabel\n" );
520 x
=cutItemToInt( in
,',',0 );
521 y
=cutItemToInt( in
,',',1 );
522 cutItem( in
,sid
,',',2 ); id
=fntFindID( sid
);
523 if ( id
< 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID
,sid
); return 1; }
524 cutItem( in
,tmp
,',',3 ); cutItem( tmp
,tmp
,'"',1 );
526 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] pos: %d,%d\n",x
,y
);
527 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] id: %s ( %d )\n",sid
,id
);
528 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] str: '%s'\n",tmp
);
531 item
=&currSubItems
[ *currSubItem
];
535 item
->x
=x
; item
->y
=y
;
536 item
->width
=-1; item
->height
=-1;
537 if ( ( item
->label
=malloc( strlen( tmp
) + 1 ) ) == NULL
) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory
); return 1; }
538 strcpy( item
->label
,tmp
);
543 int cmd_dlabel( char * in
)
544 { // dlabel=x,y,sx,align,fontid,string ...
550 CHECKDEFLIST( "dlabel" );
551 CHECKWINLIST( "dlabel" );
556 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] dlabel\n" );
558 x
=cutItemToInt( in
,',',0 );
559 y
=cutItemToInt( in
,',',1 );
560 sx
=cutItemToInt( in
,',',2 );
561 a
=cutItemToInt( in
,',',3 );
562 cutItem( in
,sid
,',',4 ); id
=fntFindID( sid
);
563 if ( id
< 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID
,sid
); return 1; }
564 cutItem( in
,tmp
,',',5 ); cutItem( tmp
,tmp
,'"',1 );
566 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] pos: %d,%d width: %d align: %d\n",x
,y
,sx
,a
);
567 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] id: %s ( %d )\n",sid
,id
);
568 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] str: '%s'\n",tmp
);
571 item
=&currSubItems
[ *currSubItem
];
574 item
->fontid
=id
; item
->align
=a
;
575 item
->x
=x
; item
->y
=y
;
576 item
->width
=sx
; item
->height
=-1;
577 if ( ( item
->label
=malloc( strlen( tmp
) + 1 ) ) == NULL
) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory
); return 1; }
578 strcpy( item
->label
,tmp
);
583 int cmd_decoration( char * in
)
587 CHECKDEFLIST( "decoration" );
588 CHECKWINLIST( "decoration" );
594 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] window decoration is %s\n",in
);
596 cutItem( in
,tmp
,',',0 );
597 if ( strcmp( tmp
,"enable" )&&strcmp( tmp
,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter
,tmp
); return 1; }
598 if ( strcmp( tmp
,"enable" ) ) defList
->mainDecoration
=0;
599 else defList
->mainDecoration
=1;
601 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"\n[skin] window decoration is %s\n",(defList
->mainDecoration
?"enabled":"disabled") );
608 int (*func
)( char * in
);
613 { "section", cmd_section
},
615 { "window", cmd_window
},
616 { "base", cmd_base
},
617 { "button", cmd_button
},
618 { "selected", cmd_selected
},
619 { "background", cmd_background
},
620 { "vpotmeter", cmd_vpotmeter
},
621 { "hpotmeter", cmd_hpotmeter
},
622 { "potmeter", cmd_potmeter
},
623 { "font", cmd_font
},
624 { "slabel", cmd_slabel
},
625 { "dlabel", cmd_dlabel
},
626 { "decoration", cmd_decoration
},
630 #define ITEMS (int)( sizeof( skinItem )/sizeof( _item ) )
632 char * trimleft( char * in
)
636 if ( strlen( in
) == 0 ) return NULL
;
637 while ( in
[c
] == ' ' ) c
++;
640 out
=malloc( strlen( in
) - c
+ 1 );
641 memcpy( out
,&in
[c
],strlen( in
) - c
+ 1 );
647 char * strswap( char * in
,char what
,char whereof
)
650 if ( strlen( in
) == 0 ) return NULL
;
651 for ( i
=0;i
<(int)strlen( in
);i
++ )
652 if ( in
[i
] == what
) in
[i
]=whereof
;
656 char * trim( char * in
)
658 int c
= 0,i
= 0,id
= 0;
659 if ( strlen( in
) == 0 ) return NULL
;
660 while ( c
!= (int)strlen( in
) )
662 if ( in
[c
] == '"' ) id
=!id
;
663 if ( ( in
[c
] == ' ' )&&( !id
) )
665 for ( i
=0;i
<(int)strlen( in
) - c
; i
++ ) in
[c
+i
]=in
[c
+i
+1];
675 void setname( char * item1
, char * item2
)
677 av_strlcpy(fn
, item1
, sizeof( fn
));
678 av_strlcat(fn
, "/", sizeof( fn
)); av_strlcat(fn
, item2
, sizeof( fn
));
679 av_strlcpy(path
, fn
, sizeof( path
)); av_strlcat(path
, "/", sizeof( path
));
680 av_strlcat(fn
, "/skin", sizeof( fn
));
683 int skinRead( char * dname
)
685 unsigned char tmp
[255];
686 unsigned char * ptmp
;
687 unsigned char command
[32];
688 unsigned char param
[256];
691 setname( skinDirInHome
,dname
);
692 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
694 setname( skinMPlayerDir
,dname
);
695 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
697 setname( skinDirInHome_obsolete
,dname
);
698 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
700 setname( skinMPlayerDir_obsolete
,dname
);
701 if ( ( skinFile
= fopen( fn
,"rt" ) ) == NULL
)
703 setname( skinMPlayerDir
,dname
);
704 mp_msg( MSGT_GPLAYER
,MSGL_STATUS
,MSGTR_SKIN_SkinFileNotFound
,fn
);
711 mp_dbg( MSGT_GPLAYER
,MSGL_DBG2
,"[skin] file: %s\n",fn
);
713 appInitStruct( skinAppMPlayer
);
716 while (fgets(tmp
, 255, skinFile
))
720 c
=tmp
[ strlen( tmp
) - 1 ]; if ( c
== '\n' || c
== '\r' ) tmp
[ strlen( tmp
) - 1 ]=0;
721 c
=tmp
[ strlen( tmp
) - 1 ]; if ( c
== '\n' || c
== '\r' ) tmp
[ strlen( tmp
) - 1 ]=0;
722 for ( c
=0;c
<(int)strlen( tmp
);c
++ )
728 if ( strlen( tmp
) == 0 ) continue;
729 ptmp
=trimleft( tmp
);
730 if ( strlen( ptmp
) == 0 ) continue;
731 ptmp
=strswap( ptmp
,'\t',' ' );
734 cutItem( ptmp
,command
,'=',0 ); cutItem( ptmp
,param
,'=',1 );
736 for( i
=0;i
<ITEMS
;i
++ )
737 if ( !strcmp( command
,skinItem
[i
].name
) )
738 if ( skinItem
[i
].func( param
) ) return -2;
740 if (linenumber
== 0) {
741 mp_msg(MSGT_GPLAYER
, MSGL_FATAL
, MSGTR_SKIN_SkinFileNotReadable
, fn
);