23077
|
1
|
|
2 #include <stdio.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <string.h>
|
|
5
|
|
6 #include "cut.h"
|
|
7 #include "font.h"
|
|
8 #include "app.h"
|
|
9
|
|
10 #include "../config.h"
|
|
11 #include "../mp_msg.h"
|
|
12 #include "../help_mp.h"
|
|
13 #include "mplayer/widgets.h"
|
|
14
|
|
15 //#define MSGL_DBG2 MSGL_STATUS
|
|
16
|
|
17 listItems * skinAppMPlayer = &appMPlayer;
|
|
18
|
|
19 // ---
|
|
20
|
|
21 static int linenumber;
|
|
22
|
|
23 static unsigned char path[512],fn[512];
|
|
24
|
|
25 static listItems * defList = NULL;
|
|
26 static unsigned char window_name[32] = "";
|
|
27
|
|
28 static wItem * currSection = NULL;
|
|
29 static int * currSubItem = NULL;
|
|
30 static wItem * currSubItems = NULL;
|
|
31
|
|
32 #include <stdarg.h>
|
|
33
|
|
34 void ERRORMESSAGE( const char * format, ... )
|
|
35 {
|
|
36 char p[512];
|
|
37 char tmp[512];
|
|
38 va_list ap;
|
|
39 va_start( ap,format );
|
|
40 vsnprintf( p,512,format,ap );
|
|
41 va_end( ap );
|
|
42 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_ERRORMESSAGE,linenumber,p );
|
|
43 snprintf( tmp,512,MSGTR_SKIN_ERRORMESSAGE,linenumber,p );
|
|
44 gtkMessageBox( GTK_MB_FATAL,tmp );
|
|
45 }
|
|
46
|
|
47 #define CHECKDEFLIST( str ) \
|
|
48 { \
|
|
49 if ( defList == NULL ) \
|
|
50 { \
|
|
51 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING1,linenumber,str ); \
|
|
52 return 1; \
|
|
53 } \
|
|
54 }
|
|
55
|
|
56 #define CHECKWINLIST( str ) \
|
|
57 { \
|
|
58 if ( !window_name[0] ) \
|
|
59 { \
|
|
60 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING2,linenumber,str ); \
|
|
61 return 1; \
|
|
62 } \
|
|
63 }
|
|
64
|
|
65 #define CHECK( name ) \
|
|
66 { \
|
|
67 if ( !strcmp( window_name,name ) ) \
|
|
68 { \
|
|
69 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING3,linenumber,name ); \
|
|
70 return 1; \
|
|
71 } \
|
|
72 }
|
|
73
|
|
74 static char * strlower( char * in )
|
|
75 {
|
|
76 int i;
|
|
77 for( i=0;i<(int)strlen( in );i++ ) in[i]=( in[i] >= 'A' ? ( in[i] <= 'Z' ? in[i]+='A' : in[i] ) : in[i] );
|
|
78 return in;
|
|
79 }
|
|
80
|
|
81 int skinBPRead( char * fname, txSample * bf )
|
|
82 {
|
|
83 int i=bpRead( fname,bf );
|
|
84 switch ( i )
|
|
85 {
|
|
86 case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit,fname ); break;
|
|
87 case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound,fname ); break;
|
|
88 case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError,fname ); break;
|
|
89 case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError,fname ); break;
|
|
90 case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError,fname ); break;
|
|
91 case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported,fname ); break;
|
|
92 case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType,fname ); break;
|
|
93 case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConversionError,fname ); break;
|
|
94 }
|
|
95 return i;
|
|
96 }
|
|
97
|
|
98 int cmd_section( char * in )
|
|
99 {
|
|
100 strlower( in );
|
|
101 defList=NULL;
|
|
102 if ( !strcmp( in,"movieplayer" ) ) defList=skinAppMPlayer;
|
|
103 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] sectionname: %s\n",in );
|
|
104 return 0;
|
|
105 }
|
|
106
|
|
107 int cmd_end( char * in )
|
|
108 {
|
|
109 if ( strlen( window_name ) ) { window_name[0]=0; currSection=NULL; currSubItem=NULL; currSubItems=NULL; }
|
|
110 else defList=NULL;
|
|
111 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] end section\n" );
|
|
112 return 0;
|
|
113 }
|
|
114
|
|
115 int cmd_window( char * in )
|
|
116 {
|
|
117 CHECKDEFLIST( "window" );
|
|
118
|
|
119 strlcpy( window_name,strlower( in ),sizeof( window_name ) );
|
|
120 if ( !strncmp( in,"main",4 ) ) { currSection=&skinAppMPlayer->main; currSubItem=&skinAppMPlayer->NumberOfItems; currSubItems=skinAppMPlayer->Items; }
|
|
121 else if ( !strncmp( in,"sub",3 ) ) currSection=&skinAppMPlayer->sub;
|
|
122 else if ( !strncmp( in,"playbar",7 ) ) { currSection=&skinAppMPlayer->bar; currSubItem=&skinAppMPlayer->NumberOfBarItems; currSubItems=skinAppMPlayer->barItems; }
|
|
123 else if ( !strncmp( in,"menu",4 ) ) { currSection=&skinAppMPlayer->menuBase; currSubItem=&skinAppMPlayer->NumberOfMenuItems; currSubItems=skinAppMPlayer->MenuItems; }
|
|
124 else ERRORMESSAGE( MSGTR_UNKNOWNWINDOWTYPE );
|
|
125 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window: %s\n",window_name );
|
|
126 return 0;
|
|
127 }
|
|
128
|
|
129 int cmd_base( char * in )
|
|
130 {
|
|
131 unsigned char fname[512];
|
|
132 unsigned char tmp[512];
|
|
133 int x,y;
|
|
134 int sx=0,sy=0;
|
|
135
|
|
136 CHECKDEFLIST( "base" );
|
|
137 CHECKWINLIST( "base" );
|
|
138
|
|
139 cutItem( in,fname,',',0 );
|
|
140 x=cutItemToInt( in,',',1 );
|
|
141 y=cutItemToInt( in,',',2 );
|
|
142 sx=cutItemToInt( in,',',3 );
|
|
143 sy=cutItemToInt( in,',',4 );
|
|
144 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] base: %s x: %d y: %d ( %dx%d )\n",fname,x,y,sx,sy );
|
|
145 if ( !strcmp( window_name,"main" ) )
|
|
146 {
|
|
147 defList->main.x=x;
|
|
148 defList->main.y=y;
|
|
149 defList->main.type=itBase;
|
|
150 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
|
|
151 if ( skinBPRead( tmp,&defList->main.Bitmap ) ) return 1;
|
|
152 defList->main.width=defList->main.Bitmap.Width;
|
|
153 defList->main.height=defList->main.Bitmap.Height;
|
|
154 #ifdef HAVE_XSHAPE
|
|
155 Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff );
|
|
156 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->main.Mask.Width,defList->main.Mask.Height );
|
|
157 #else
|
|
158 defList->main.Mask.Image=NULL;
|
|
159 #endif
|
|
160 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->main.width,defList->main.height );
|
|
161 }
|
|
162 if ( !strcmp( window_name,"sub" ) )
|
|
163 {
|
|
164 defList->sub.type=itBase;
|
|
165 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
|
|
166 if ( skinBPRead( tmp,&defList->sub.Bitmap ) ) return 1;
|
|
167 defList->sub.x=x;
|
|
168 defList->sub.y=y;
|
|
169 defList->sub.width=defList->sub.Bitmap.Width;
|
|
170 defList->sub.height=defList->sub.Bitmap.Height;
|
|
171 if ( sx && sy )
|
|
172 {
|
|
173 defList->sub.width=sx;
|
|
174 defList->sub.height=sy;
|
|
175 }
|
|
176 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] %d,%d %dx%d\n",defList->sub.x,defList->sub.y,defList->sub.width,defList->sub.height );
|
|
177 }
|
|
178 if ( !strcmp( window_name,"menu" ) )
|
|
179 {
|
|
180 defList->menuIsPresent=1;
|
|
181 defList->menuBase.type=itBase;
|
|
182 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
|
|
183 if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) ) return 1;
|
|
184 defList->menuBase.width=defList->menuBase.Bitmap.Width;
|
|
185 defList->menuBase.height=defList->menuBase.Bitmap.Height;
|
|
186 #ifdef HAVE_XSHAPE
|
|
187 Convert32to1( &defList->menuBase.Bitmap,&defList->menuBase.Mask,0x00ff00ff );
|
|
188 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->menuBase.Mask.Width,defList->menuBase.Mask.Height );
|
|
189 #else
|
|
190 defList->menuBase.Mask.Image=NULL;
|
|
191 #endif
|
|
192 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuBase.width,defList->menuBase.height );
|
|
193 }
|
|
194 if ( !strcmp( window_name,"playbar" ) )
|
|
195 {
|
|
196 defList->barIsPresent=1;
|
|
197 defList->bar.x=x;
|
|
198 defList->bar.y=y;
|
|
199 defList->bar.type=itBase;
|
|
200 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
|
|
201 if ( skinBPRead( tmp,&defList->bar.Bitmap ) ) return 1;
|
|
202 defList->bar.width=defList->bar.Bitmap.Width;
|
|
203 defList->bar.height=defList->bar.Bitmap.Height;
|
|
204 #ifdef HAVE_XSHAPE
|
|
205 Convert32to1( &defList->bar.Bitmap,&defList->bar.Mask,0x00ff00ff );
|
|
206 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->bar.Mask.Width,defList->bar.Mask.Height );
|
|
207 #else
|
|
208 defList->bar.Mask.Image=NULL;
|
|
209 #endif
|
|
210 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->bar.width,defList->bar.height );
|
|
211 }
|
|
212 return 0;
|
|
213 }
|
|
214
|
|
215 int cmd_background( char * in )
|
|
216 {
|
|
217 CHECKDEFLIST( "background" );
|
|
218 CHECKWINLIST( "background" );
|
|
219
|
|
220 CHECK( "menu" );
|
|
221 CHECK( "main" );
|
|
222
|
|
223 currSection->R=cutItemToInt( in,',',0 );
|
|
224 currSection->G=cutItemToInt( in,',',1 );
|
|
225 currSection->B=cutItemToInt( in,',',2 );
|
|
226 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] background color is #%x%x%x.\n",currSection->R,currSection->G,currSection->B );
|
|
227
|
|
228 return 0;
|
|
229 }
|
|
230
|
|
231 int cmd_button( char * in )
|
|
232 {
|
|
233 unsigned char fname[512];
|
|
234 unsigned char tmp[512];
|
|
235 int x,y,sx,sy;
|
|
236 char msg[32];
|
|
237
|
|
238 CHECKDEFLIST( "button" );
|
|
239 CHECKWINLIST( "button" );
|
|
240
|
|
241 CHECK( "sub" );
|
|
242 CHECK( "menu" );
|
|
243
|
|
244 cutItem( in,fname,',',0 );
|
|
245 x=cutItemToInt( in,',',1 );
|
|
246 y=cutItemToInt( in,',',2 );
|
|
247 sx=cutItemToInt( in,',',3 );
|
|
248 sy=cutItemToInt( in,',',4 );
|
|
249 cutItem( in,msg,',',5 );
|
|
250
|
|
251 (*currSubItem)++;
|
|
252 currSubItems[ *currSubItem ].type=itButton;
|
|
253 currSubItems[ *currSubItem ].x=x;
|
|
254 currSubItems[ *currSubItem ].y=y;
|
|
255 currSubItems[ *currSubItem ].width=sx;
|
|
256 currSubItems[ *currSubItem ].height=sy;
|
|
257 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] button: fname: %s\n",fname );
|
|
258 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy );
|
|
259
|
|
260 if ( ( currSubItems[ *currSubItem ].msg=appFindMessage( msg ) ) == -1 )
|
|
261 { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,msg ); return 0; }
|
|
262 currSubItems[ *currSubItem ].pressed=btnReleased;
|
|
263 if ( currSubItems[ *currSubItem ].msg == evPauseSwitchToPlay ) currSubItems[ *currSubItem ].pressed=btnDisabled;
|
|
264 currSubItems[ *currSubItem ].tmp=1;
|
|
265
|
|
266 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",currSubItems[ *currSubItem ].msg );
|
|
267
|
|
268 currSubItems[ *currSubItem ].Bitmap.Image=NULL;
|
|
269 if ( strcmp( fname,"NULL" ) )
|
|
270 {
|
|
271 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
|
|
272 if ( skinBPRead( tmp,&currSubItems[ *currSubItem ].Bitmap ) ) return 1;
|
|
273 }
|
|
274
|
|
275 return 0;
|
|
276 }
|
|
277
|
|
278 int cmd_selected( char * in )
|
|
279 {
|
|
280 unsigned char fname[512];
|
|
281 unsigned char tmp[512];
|
|
282
|
|
283 CHECKDEFLIST( "selected" );
|
|
284 CHECKWINLIST( "selected" );
|
|
285
|
|
286 CHECK( "main" );
|
|
287 CHECK( "sub" );
|
|
288 CHECK( "playbar" );
|
|
289
|
|
290 cutItem( in,fname,',',0 );
|
|
291 defList->menuSelected.type=itBase;
|
|
292 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
|
|
293 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname );
|
|
294 if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1;
|
|
295 defList->menuSelected.width=defList->menuSelected.Bitmap.Width;
|
|
296 defList->menuSelected.height=defList->menuSelected.Bitmap.Height;
|
|
297 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height );
|
|
298 return 0;
|
|
299 }
|
|
300
|
|
301 int cmd_menu( char * in )
|
|
302 { // menu = number,x,y,sx,sy,msg
|
|
303 int x,y,sx,sy,msg;
|
|
304 unsigned char tmp[64];
|
|
305
|
|
306 CHECKDEFLIST( "menu" );
|
|
307 CHECKWINLIST( "menu" );
|
|
308
|
|
309 CHECK( "main" );
|
|
310 CHECK( "sub" );
|
|
311 CHECK( "playbar" );
|
|
312
|
|
313 x=cutItemToInt( in,',',0 );
|
|
314 y=cutItemToInt( in,',',1 );
|
|
315 sx=cutItemToInt( in,',',2 );
|
|
316 sy=cutItemToInt( in,',',3 );
|
|
317 cutItem( in,tmp,',',4 ); msg=appFindMessage( tmp );
|
|
318
|
|
319 defList->NumberOfMenuItems++;
|
|
320 defList->MenuItems[ defList->NumberOfMenuItems ].x=x;
|
|
321 defList->MenuItems[ defList->NumberOfMenuItems ].y=y;
|
|
322 defList->MenuItems[ defList->NumberOfMenuItems ].width=sx;
|
|
323 defList->MenuItems[ defList->NumberOfMenuItems ].height=sy;
|
|
324
|
|
325 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems );
|
|
326 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy );
|
|
327
|
|
328 if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 )
|
|
329 ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,tmp );
|
|
330
|
|
331 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg );
|
|
332
|
|
333 defList->MenuItems[ defList->NumberOfMenuItems ].Bitmap.Image=NULL;
|
|
334 return 0;
|
|
335 }
|
|
336
|
|
337 int cmd_hpotmeter( char * in )
|
|
338 { // hpotmeter=buttonbitmaps,sx,sy,phasebitmaps,phases,default value,x,y,sx,sy,msg
|
|
339 int x,y,psx,psy,ph,sx,sy,msg,d;
|
|
340 unsigned char tmp[512];
|
|
341 unsigned char pfname[512];
|
|
342 unsigned char phfname[512];
|
|
343 wItem * item;
|
|
344
|
|
345 CHECKDEFLIST( "hpotmeter" );
|
|
346 CHECKWINLIST( "hpotmeter" );
|
|
347
|
|
348 CHECK( "sub" );
|
|
349 CHECK( "menu" );
|
|
350
|
|
351 cutItem( in,pfname,',',0 );
|
|
352 psx=cutItemToInt( in,',',1 );
|
|
353 psy=cutItemToInt( in,',',2 );
|
|
354 cutItem( in,phfname,',',3 );
|
|
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 );
|
|
361 cutItem( in,tmp,',',10 ); msg=appFindMessage( tmp );
|
|
362
|
|
363 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] h/v potmeter: pointer filename: '%s'\n",pfname );
|
|
364 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pointer size is %dx%d\n",psx,psy );
|
|
365 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phasebitmaps filename: '%s'\n",phfname );
|
|
366 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy );
|
|
367 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d );
|
|
368 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg );
|
|
369
|
|
370 (*currSubItem)++;
|
|
371 item=&currSubItems[ *currSubItem ];
|
|
372
|
|
373 item->type=itHPotmeter;
|
|
374 item->x=x; item->y=y; item->width=sx; item->height=sy;
|
|
375 item->phases=ph;
|
|
376 item->psx=psx; item->psy=psy;
|
|
377 item->msg=msg;
|
|
378 item->value=(float)d;
|
|
379 item->pressed=btnReleased;
|
|
380
|
|
381 item->Bitmap.Image=NULL;
|
|
382 if ( strcmp( phfname,"NULL" ) )
|
|
383 {
|
|
384 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, phfname, sizeof( tmp ));
|
|
385 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1;
|
|
386 }
|
|
387
|
|
388 item->Mask.Image=NULL;
|
|
389 if ( strcmp( pfname,"NULL" ) )
|
|
390 {
|
|
391 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, pfname, sizeof( tmp ));
|
|
392 if ( skinBPRead( tmp,&item->Mask ) ) return 1;
|
|
393 }
|
|
394 return 0;
|
|
395 }
|
|
396
|
|
397 int cmd_vpotmeter( char * in )
|
|
398 {
|
|
399 int r = cmd_hpotmeter( in );
|
|
400 wItem * item;
|
|
401
|
|
402 item=&currSubItems[ *currSubItem ];
|
|
403 item->type=itVPotmeter;
|
|
404 return r;
|
|
405 }
|
|
406
|
|
407 int cmd_potmeter( char * in )
|
|
408 { // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg
|
|
409 int x,y,ph,sx,sy,msg,d;
|
|
410 unsigned char tmp[512];
|
|
411 unsigned char phfname[512];
|
|
412 wItem * item;
|
|
413
|
|
414 CHECKDEFLIST( "potmeter" );
|
|
415 CHECKWINLIST( "potmeter" );
|
|
416
|
|
417 CHECK( "sub" );
|
|
418 CHECK( "menu" );
|
|
419
|
|
420 cutItem( in,phfname,',',0 );
|
|
421 ph=cutItemToInt( in,',',1 );
|
|
422 d=cutItemToInt( in,',',2 );
|
|
423 x=cutItemToInt( in,',',3 );
|
|
424 y=cutItemToInt( in,',',4 );
|
|
425 sx=cutItemToInt( in,',',5 );
|
|
426 sy=cutItemToInt( in,',',6 );
|
|
427 cutItem( in,tmp,',',7 ); msg=appFindMessage( tmp );
|
|
428
|
|
429 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] potmeter: phases filename: '%s'\n",phfname );
|
|
430 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy );
|
|
431 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phases: %d\n",ph );
|
|
432 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d );
|
|
433 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg );
|
|
434
|
|
435 (*currSubItem)++;
|
|
436 item=&currSubItems[ *currSubItem ];
|
|
437
|
|
438 item->type=itPotmeter;
|
|
439 item->x=x; item->y=y;
|
|
440 item->width=sx; item->height=sy;
|
|
441 item->phases=ph;
|
|
442 item->msg=msg;
|
|
443 item->value=(float)d;
|
|
444
|
|
445 item->Bitmap.Image=NULL;
|
|
446 if ( strcmp( phfname,"NULL" ) )
|
|
447 {
|
|
448 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, phfname, sizeof( tmp ));
|
|
449 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1;
|
|
450 }
|
|
451 return 0;
|
|
452 }
|
|
453
|
|
454 int cmd_font( char * in )
|
|
455 { // font=fontname,fontid
|
|
456 char name[512];
|
|
457 char id[512];
|
|
458 wItem * item;
|
|
459
|
|
460 CHECKDEFLIST( "font" );
|
|
461 CHECKWINLIST( "font" );
|
|
462
|
|
463 CHECK( "sub" );
|
|
464 CHECK( "menu" );
|
|
465
|
|
466 cutItem( in,name,',',0 );
|
|
467 cutItem( in,id,',',1 );
|
|
468
|
|
469 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] font\n" );
|
|
470 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] name: %s\n",name );
|
|
471
|
|
472 (*currSubItem)++;
|
|
473 item=&currSubItems[ *currSubItem ];
|
|
474
|
|
475 item->type=itFont;
|
|
476 item->fontid=fntRead( path,name );
|
|
477 switch ( item->fontid )
|
|
478 {
|
|
479 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1;
|
|
480 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1;
|
|
481 case -3: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1;
|
|
482 case -4: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1;
|
|
483 }
|
|
484 return 0;
|
|
485 }
|
|
486
|
|
487 int cmd_slabel( char * in )
|
|
488 {
|
|
489 char tmp[512];
|
|
490 char sid[63];
|
|
491 int x,y,id;
|
|
492 wItem * item;
|
|
493
|
|
494 CHECKDEFLIST( "slabel" );
|
|
495 CHECKWINLIST( "slabel" );
|
|
496
|
|
497 CHECK( "sub" );
|
|
498 CHECK( "menu" );
|
|
499
|
|
500 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] slabel\n" );
|
|
501
|
|
502 x=cutItemToInt( in,',',0 );
|
|
503 y=cutItemToInt( in,',',1 );
|
|
504 cutItem( in,sid,',',2 ); id=fntFindID( sid );
|
|
505 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; }
|
|
506 cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 );
|
|
507
|
|
508 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d\n",x,y );
|
|
509 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id );
|
|
510 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp );
|
|
511
|
|
512 (*currSubItem)++;
|
|
513 item=&currSubItems[ *currSubItem ];
|
|
514
|
|
515 item->type=itSLabel;
|
|
516 item->fontid=id;
|
|
517 item->x=x; item->y=y;
|
|
518 item->width=-1; item->height=-1;
|
|
519 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; }
|
|
520 strcpy( item->label,tmp );
|
|
521
|
|
522 return 0;
|
|
523 }
|
|
524
|
|
525 int cmd_dlabel( char * in )
|
|
526 { // dlabel=x,y,sx,align,fontid,string ...
|
|
527 char tmp[512];
|
|
528 char sid[63];
|
|
529 int x,y,sx,id,a;
|
|
530 wItem * item;
|
|
531
|
|
532 CHECKDEFLIST( "dlabel" );
|
|
533 CHECKWINLIST( "dlabel" );
|
|
534
|
|
535 CHECK( "sub" );
|
|
536 CHECK( "menu" );
|
|
537
|
|
538 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] dlabel\n" );
|
|
539
|
|
540 x=cutItemToInt( in,',',0 );
|
|
541 y=cutItemToInt( in,',',1 );
|
|
542 sx=cutItemToInt( in,',',2 );
|
|
543 a=cutItemToInt( in,',',3 );
|
|
544 cutItem( in,sid,',',4 ); id=fntFindID( sid );
|
|
545 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; }
|
|
546 cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 );
|
|
547
|
|
548 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a );
|
|
549 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id );
|
|
550 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp );
|
|
551
|
|
552 (*currSubItem)++;
|
|
553 item=&currSubItems[ *currSubItem ];
|
|
554
|
|
555 item->type=itDLabel;
|
|
556 item->fontid=id; item->align=a;
|
|
557 item->x=x; item->y=y;
|
|
558 item->width=sx; item->height=-1;
|
|
559 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; }
|
|
560 strcpy( item->label,tmp );
|
|
561
|
|
562 return 0;
|
|
563 }
|
|
564
|
|
565 int cmd_decoration( char * in )
|
|
566 {
|
|
567 char tmp[512];
|
|
568
|
|
569 CHECKDEFLIST( "decoration" );
|
|
570 CHECKWINLIST( "decoration" );
|
|
571
|
|
572 CHECK( "sub" );
|
|
573 CHECK( "menu" );
|
|
574 CHECK( "playbar" );
|
|
575
|
|
576 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",in );
|
|
577 strlower( in );
|
|
578 cutItem( in,tmp,',',0 );
|
|
579 if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; }
|
|
580 if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0;
|
|
581 else defList->mainDecoration=1;
|
|
582
|
|
583 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") );
|
|
584 return 0;
|
|
585 }
|
|
586
|
|
587 typedef struct
|
|
588 {
|
|
589 const char * name;
|
|
590 int (*func)( char * in );
|
|
591 } _item;
|
|
592
|
|
593 _item skinItem[] =
|
|
594 {
|
|
595 { "section", cmd_section },
|
|
596 { "end", cmd_end },
|
|
597 { "window", cmd_window },
|
|
598 { "base", cmd_base },
|
|
599 { "button", cmd_button },
|
|
600 { "selected", cmd_selected },
|
|
601 { "background", cmd_background },
|
|
602 { "vpotmeter", cmd_vpotmeter },
|
|
603 { "hpotmeter", cmd_hpotmeter },
|
|
604 { "potmeter", cmd_potmeter },
|
|
605 { "font", cmd_font },
|
|
606 { "slabel", cmd_slabel },
|
|
607 { "dlabel", cmd_dlabel },
|
|
608 { "decoration", cmd_decoration },
|
|
609 { "menu", cmd_menu }
|
|
610 };
|
|
611
|
|
612 #define ITEMS (int)( sizeof( skinItem )/sizeof( _item ) )
|
|
613
|
|
614 char * trimleft( char * in )
|
|
615 {
|
|
616 int c = 0;
|
|
617 char * out;
|
|
618 if ( strlen( in ) == 0 ) return NULL;
|
|
619 while ( in[c] == ' ' ) c++;
|
|
620 if ( c != 0 )
|
|
621 {
|
|
622 out=malloc( strlen( in ) - c + 1 );
|
|
623 memcpy( out,&in[c],strlen( in ) - c + 1 );
|
|
624 }
|
|
625 else out=in;
|
|
626 return out;
|
|
627 }
|
|
628
|
|
629 char * strswap( char * in,char what,char whereof )
|
|
630 {
|
|
631 int i;
|
|
632 if ( strlen( in ) == 0 ) return NULL;
|
|
633 for ( i=0;i<(int)strlen( in );i++ )
|
|
634 if ( in[i] == what ) in[i]=whereof;
|
|
635 return in;
|
|
636 }
|
|
637
|
|
638 char * trim( char * in )
|
|
639 {
|
|
640 int c = 0,i = 0,id = 0;
|
|
641 if ( strlen( in ) == 0 ) return NULL;
|
|
642 while ( c != (int)strlen( in ) )
|
|
643 {
|
|
644 if ( in[c] == '"' ) id=!id;
|
|
645 if ( ( in[c] == ' ' )&&( !id ) )
|
|
646 {
|
|
647 for ( i=0;i<(int)strlen( in ) - c; i++ ) in[c+i]=in[c+i+1];
|
|
648 continue;
|
|
649 }
|
|
650 c++;
|
|
651 }
|
|
652 return in;
|
|
653 }
|
|
654
|
|
655 FILE * skinFile;
|
|
656
|
|
657 void setname( char * item1, char * item2 )
|
|
658 {
|
|
659 strlcpy(fn, item1, sizeof( fn ));
|
|
660 strlcat(fn, "/", sizeof( fn )); strlcat(fn, item2, sizeof( fn ));
|
|
661 strlcpy(path, fn, sizeof( path )); strlcat(path, "/", sizeof( path ));
|
|
662 strlcat(fn, "/skin", sizeof( fn ));
|
|
663 }
|
|
664
|
|
665 int skinRead( char * dname )
|
|
666 {
|
|
667 unsigned char tmp[255];
|
|
668 unsigned char * ptmp;
|
|
669 unsigned char command[32];
|
|
670 unsigned char param[256];
|
|
671 int c,i;
|
|
672
|
|
673 setname( skinDirInHome,dname );
|
|
674 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )
|
|
675 {
|
|
676 setname( skinMPlayerDir,dname );
|
|
677 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )
|
|
678 {
|
|
679 setname( skinDirInHome_obsolete,dname );
|
|
680 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )
|
|
681 {
|
|
682 setname( skinMPlayerDir_obsolete,dname );
|
|
683 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )
|
|
684 {
|
|
685 setname( skinMPlayerDir,dname );
|
|
686 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_SkinFileNotFound,fn );
|
|
687 return -1;
|
|
688 }
|
|
689 }
|
|
690 }
|
|
691 }
|
|
692
|
|
693 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] file: %s\n",fn );
|
|
694
|
|
695 appInitStruct( skinAppMPlayer );
|
|
696
|
|
697 linenumber=0;
|
|
698 while (fgets(tmp, 255, skinFile))
|
|
699 {
|
|
700 linenumber++;
|
|
701
|
|
702 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
|
|
703 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
|
|
704 for ( c=0;c<(int)strlen( tmp );c++ )
|
|
705 if ( tmp[c] == ';' )
|
|
706 {
|
|
707 tmp[c]=0;
|
|
708 break;
|
|
709 }
|
|
710 if ( strlen( tmp ) == 0 ) continue;
|
|
711 ptmp=trimleft( tmp );
|
|
712 if ( strlen( ptmp ) == 0 ) continue;
|
|
713 ptmp=strswap( ptmp,'\t',' ' );
|
|
714 ptmp=trim( ptmp );
|
|
715
|
|
716 cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );
|
|
717 strlower( command );
|
|
718 for( i=0;i<ITEMS;i++ )
|
|
719 if ( !strcmp( command,skinItem[i].name ) )
|
|
720 if ( skinItem[i].func( param ) ) return -2;
|
|
721 }
|
|
722 if (linenumber == 0) {
|
|
723 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SkinFileNotReadable, fn);
|
|
724 return -1;
|
|
725 }
|
|
726 return 0;
|
|
727 }
|