comparison gui/skin/skin.c @ 32873:cf385b1901cb

Cosmetic: Format to MPlayer coding style.
author ib
date Thu, 24 Feb 2011 15:00:29 +0000
parents 559e0f6d9d8b
children 440e617c116b
comparison
equal deleted inserted replaced
32872:e91f07a9d5cd 32873:cf385b1901cb
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., 15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */ 17 */
18 18
19 #include <stdio.h> 19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h> 20 #include <string.h>
22 21
22 #include "skin.h"
23 #include "cut.h" 23 #include "cut.h"
24 #include "font.h" 24 #include "font.h"
25 #include "skin.h" 25 #include "gui/mplayer/widgets.h"
26 #include "gui/app.h"
27 26
28 #include "config.h" 27 #include "config.h"
28 #include "help_mp.h"
29 #include "libavutil/avstring.h"
29 #include "mp_msg.h" 30 #include "mp_msg.h"
30 #include "help_mp.h" 31
31 #include "gui/mplayer/widgets.h" 32 typedef struct {
32 #include "libavutil/avstring.h" 33 const char *name;
33 34 int (*func)(char *in);
34 //#define MSGL_DBG2 MSGL_STATUS 35 } _item;
35 36
36 listItems * skinAppMPlayer = &appMPlayer; 37 listItems *skinAppMPlayer = &appMPlayer;
37 38 static listItems *defList = NULL;
38 // --- 39
39 40 static int linenumber;
40 static int linenumber; 41 static unsigned char path[512];
41 42 static unsigned char window_name[32] = "";
42 static unsigned char path[512]; 43
43 44 static wItem *currSection = NULL;
44 static listItems * defList = NULL; 45 static int *currSubItem = NULL;
45 static unsigned char window_name[32] = ""; 46 static wItem *currSubItems = NULL;
46 47
47 static wItem * currSection = NULL; 48 static void ERRORMESSAGE(const char *format, ...)
48 static int * currSubItem = NULL; 49 {
49 static wItem * currSubItems = NULL; 50 char p[512];
50 51 char tmp[512];
51 #include <stdarg.h> 52 va_list ap;
52 53
53 static void ERRORMESSAGE( const char * format, ... ) 54 va_start(ap, format);
54 { 55 vsnprintf(p, sizeof(p), format, ap);
55 char p[512]; 56 va_end(ap);
56 char tmp[512]; 57
57 va_list ap; 58 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_SKIN_ERRORMESSAGE, linenumber, p);
58 va_start( ap,format ); 59 snprintf(tmp, sizeof(tmp), MSGTR_SKIN_ERRORMESSAGE, linenumber, p);
59 vsnprintf( p,sizeof(p),format,ap ); 60 gtkMessageBox(GTK_MB_FATAL, tmp);
60 va_end( ap ); 61 }
61 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_ERRORMESSAGE,linenumber,p ); 62
62 snprintf( tmp,sizeof(tmp),MSGTR_SKIN_ERRORMESSAGE,linenumber,p ); 63 #define CHECKDEFLIST(str) \
63 gtkMessageBox( GTK_MB_FATAL,tmp ); 64 { \
64 } 65 if (defList == NULL) \
65 66 { \
66 #define CHECKDEFLIST( str ) \ 67 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_SKIN_WARNING1, linenumber, str); \
67 { \ 68 return 1; \
68 if ( defList == NULL ) \ 69 } \
69 { \ 70 }
70 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING1,linenumber,str ); \ 71
71 return 1; \ 72 #define CHECKWINLIST(str) \
72 } \ 73 { \
73 } 74 if (!window_name[0]) \
74 75 { \
75 #define CHECKWINLIST( str ) \ 76 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_SKIN_WARNING2, linenumber, str); \
76 { \ 77 return 1; \
77 if ( !window_name[0] ) \ 78 } \
78 { \ 79 }
79 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING2,linenumber,str ); \ 80
80 return 1; \ 81 #define CHECK(name) \
81 } \ 82 { \
82 } 83 if (!strcmp(window_name, name)) \
83 84 { \
84 #define CHECK( name ) \ 85 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_SKIN_WARNING3, linenumber, name); \
85 { \ 86 return 1; \
86 if ( !strcmp( window_name,name ) ) \ 87 } \
87 { \ 88 }
88 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING3,linenumber,name ); \ 89
89 return 1; \ 90 static char *strlower(char *in)
90 } \ 91 {
91 } 92 char *p = in;
92 93
93 static char * strlower( char * in ) 94 while (*p) {
94 { 95 if (*p >= 'A' && *p <= 'Z')
95 char *p = in; 96 *p += ' ';
96 while (*p) 97
97 { 98 p++;
98 if (*p >= 'A' && *p <= 'Z') *p += ' '; 99 }
99 p++; 100
100 } 101 return in;
101 return in; 102 }
102 } 103
103 104 int skinBPRead(char *fname, txSample *bf)
104 int skinBPRead( char * fname, txSample * bf ) 105 {
105 { 106 int i = bpRead(fname, bf);
106 int i=bpRead( fname,bf ); 107
107 switch ( i ) 108 switch (i) {
108 { 109 case -1:
109 case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit,fname ); break; 110 ERRORMESSAGE(MSGTR_SKIN_BITMAP_16bit, fname);
110 case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound,fname ); break; 111 break;
111 case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError,fname ); break; 112
112 case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError,fname ); break; 113 case -2:
113 case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError,fname ); break; 114 ERRORMESSAGE(MSGTR_SKIN_BITMAP_FileNotFound, fname);
114 case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported,fname ); break; 115 break;
115 case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType,fname ); break; 116
116 case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConversionError,fname ); break; 117 case -3:
117 } 118 ERRORMESSAGE(MSGTR_SKIN_BITMAP_BMPReadError, fname);
118 return i; 119 break;
119 } 120
120 121 case -4:
121 static int cmd_section( char * in ) 122 ERRORMESSAGE(MSGTR_SKIN_BITMAP_TGAReadError, fname);
122 { 123 break;
123 strlower( in ); 124
124 defList=NULL; 125 case -5:
125 if ( !strcmp( in,"movieplayer" ) ) defList=skinAppMPlayer; 126 ERRORMESSAGE(MSGTR_SKIN_BITMAP_PNGReadError, fname);
126 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] sectionname: %s\n",in ); 127 break;
127 return 0; 128
128 } 129 case -6:
129 130 ERRORMESSAGE(MSGTR_SKIN_BITMAP_RLENotSupported, fname);
130 static int cmd_end( char * in ) 131 break;
131 { 132
132 if ( strlen( window_name ) ) { window_name[0]=0; currSection=NULL; currSubItem=NULL; currSubItems=NULL; } 133 case -7:
133 else defList=NULL; 134 ERRORMESSAGE(MSGTR_SKIN_BITMAP_UnknownFileType, fname);
134 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] end section\n" ); 135 break;
135 return 0; 136
136 } 137 case -8:
137 138 ERRORMESSAGE(MSGTR_SKIN_BITMAP_ConversionError, fname);
138 static int cmd_window( char * in ) 139 break;
139 { 140 }
140 CHECKDEFLIST( "window" ); 141
141 142 return i;
142 av_strlcpy( window_name,strlower( in ),sizeof( window_name ) ); 143 }
143 if ( !strncmp( in,"main",4 ) ) { currSection=&skinAppMPlayer->main; currSubItem=&skinAppMPlayer->NumberOfItems; currSubItems=skinAppMPlayer->Items; } 144
144 else if ( !strncmp( in,"sub",3 ) ) currSection=&skinAppMPlayer->sub; 145 // section=movieplayer
145 else if ( !strncmp( in,"playbar",7 ) ) { currSection=&skinAppMPlayer->bar; currSubItem=&skinAppMPlayer->NumberOfBarItems; currSubItems=skinAppMPlayer->barItems; } 146 static int cmd_section(char *in)
146 else if ( !strncmp( in,"menu",4 ) ) { currSection=&skinAppMPlayer->menuBase; currSubItem=&skinAppMPlayer->NumberOfMenuItems; currSubItems=skinAppMPlayer->MenuItems; } 147 {
147 else ERRORMESSAGE( MSGTR_UNKNOWNWINDOWTYPE ); 148 strlower(in);
148 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window: %s\n",window_name ); 149 defList = NULL;
149 return 0; 150
150 } 151 if (!strcmp(in, "movieplayer"))
151 152 defList = skinAppMPlayer;
152 static int cmd_base( char * in ) 153
153 { 154 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] sectionname: %s\n", in);
154 unsigned char fname[512]; 155
155 unsigned char tmp[512]; 156 return 0;
156 int x,y; 157 }
157 int sx=0,sy=0; 158
158 159 // end
159 CHECKDEFLIST( "base" ); 160 static int cmd_end(char *in)
160 CHECKWINLIST( "base" ); 161 {
161 162 (void)in;
162 cutItem( in,fname,',',0 ); 163
163 x=cutItemToInt( in,',',1 ); 164 if (strlen(window_name)) {
164 y=cutItemToInt( in,',',2 ); 165 window_name[0] = 0;
165 sx=cutItemToInt( in,',',3 ); 166 currSection = NULL;
166 sy=cutItemToInt( in,',',4 ); 167 currSubItem = NULL;
167 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] base: %s x: %d y: %d ( %dx%d )\n",fname,x,y,sx,sy ); 168 currSubItems = NULL;
168 if ( !strcmp( window_name,"main" ) ) 169 } else
169 { 170 defList = NULL;
170 defList->main.x=x; 171
171 defList->main.y=y; 172 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] end section\n");
172 defList->main.type=itBase; 173
173 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp )); 174 return 0;
174 if ( skinBPRead( tmp,&defList->main.Bitmap ) != 0 ) return 1; 175 }
175 defList->main.width=defList->main.Bitmap.Width; 176
176 defList->main.height=defList->main.Bitmap.Height; 177 // window=main|sub|playbar|menu
178 static int cmd_window(char *in)
179 {
180 CHECKDEFLIST("window");
181
182 av_strlcpy(window_name, strlower(in), sizeof(window_name));
183
184 if (!strncmp(in, "main", 4)) {
185 currSection = &skinAppMPlayer->main;
186 currSubItem = &skinAppMPlayer->NumberOfItems;
187 currSubItems = skinAppMPlayer->Items;
188 } else if (!strncmp(in, "sub", 3))
189 currSection = &skinAppMPlayer->sub;
190 else if (!strncmp(in, "playbar", 7)) {
191 currSection = &skinAppMPlayer->bar;
192 currSubItem = &skinAppMPlayer->NumberOfBarItems;
193 currSubItems = skinAppMPlayer->barItems;
194 } else if (!strncmp(in, "menu", 4)) {
195 currSection = &skinAppMPlayer->menuBase;
196 currSubItem = &skinAppMPlayer->NumberOfMenuItems;
197 currSubItems = skinAppMPlayer->MenuItems;
198 } else
199 ERRORMESSAGE(MSGTR_UNKNOWNWINDOWTYPE);
200
201 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] window: %s\n", window_name);
202
203 return 0;
204 }
205
206 // base=image,x,y[,width,height]
207 static int cmd_base(char *in)
208 {
209 unsigned char fname[512];
210 unsigned char tmp[512];
211 int x, y;
212 int sx = 0, sy = 0;
213
214 CHECKDEFLIST("base");
215 CHECKWINLIST("base");
216
217 cutItem(in, fname, ',', 0);
218 x = cutItemToInt(in, ',', 1);
219 y = cutItemToInt(in, ',', 2);
220 sx = cutItemToInt(in, ',', 3);
221 sy = cutItemToInt(in, ',', 4);
222
223 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] base: %s x: %d y: %d ( %dx%d )\n", fname, x, y, sx, sy);
224
225 if (!strcmp(window_name, "main")) {
226 defList->main.x = x;
227 defList->main.y = y;
228 defList->main.type = itBase;
229
230 av_strlcpy(tmp, path, sizeof(tmp));
231 av_strlcat(tmp, fname, sizeof(tmp));
232
233 if (skinBPRead(tmp, &defList->main.Bitmap) != 0)
234 return 1;
235
236 defList->main.width = defList->main.Bitmap.Width;
237 defList->main.height = defList->main.Bitmap.Height;
238
177 #ifdef CONFIG_XSHAPE 239 #ifdef CONFIG_XSHAPE
178 Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff ); 240 Convert32to1(&defList->main.Bitmap, &defList->main.Mask, 0x00ff00ff);
179 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->main.Mask.Width,defList->main.Mask.Height ); 241 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %dx%d\n", defList->main.Mask.Width, defList->main.Mask.Height);
180 #else 242 #else
181 defList->main.Mask.Image=NULL; 243 defList->main.Mask.Image = NULL;
182 #endif 244 #endif
183 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->main.width,defList->main.height ); 245
184 } 246 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->main.width, defList->main.height);
185 if ( !strcmp( window_name,"sub" ) ) 247 }
186 { 248
187 defList->sub.type=itBase; 249 if (!strcmp(window_name, "sub")) {
188 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp )); 250 defList->sub.type = itBase;
189 if ( skinBPRead( tmp,&defList->sub.Bitmap ) != 0 ) return 1; 251
190 defList->sub.x=x; 252 av_strlcpy(tmp, path, sizeof(tmp));
191 defList->sub.y=y; 253 av_strlcat(tmp, fname, sizeof(tmp));
192 defList->sub.width=defList->sub.Bitmap.Width; 254
193 defList->sub.height=defList->sub.Bitmap.Height; 255 if (skinBPRead(tmp, &defList->sub.Bitmap) != 0)
194 if ( sx && sy ) 256 return 1;
195 { 257
196 defList->sub.width=sx; 258 defList->sub.x = x;
197 defList->sub.height=sy; 259 defList->sub.y = y;
198 } 260 defList->sub.width = defList->sub.Bitmap.Width;
199 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] %d,%d %dx%d\n",defList->sub.x,defList->sub.y,defList->sub.width,defList->sub.height ); 261 defList->sub.height = defList->sub.Bitmap.Height;
200 } 262
201 if ( !strcmp( window_name,"menu" ) ) 263 if (sx && sy) {
202 { 264 defList->sub.width = sx;
203 defList->menuIsPresent=1; 265 defList->sub.height = sy;
204 defList->menuBase.type=itBase; 266 }
205 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp )); 267
206 if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) != 0 ) return 1; 268 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %d,%d %dx%d\n", defList->sub.x, defList->sub.y, defList->sub.width, defList->sub.height);
207 defList->menuBase.width=defList->menuBase.Bitmap.Width; 269 }
208 defList->menuBase.height=defList->menuBase.Bitmap.Height; 270
271 if (!strcmp(window_name, "menu")) {
272 defList->menuIsPresent = 1;
273 defList->menuBase.type = itBase;
274
275 av_strlcpy(tmp, path, sizeof(tmp));
276 av_strlcat(tmp, fname, sizeof(tmp));
277
278 if (skinBPRead(tmp, &defList->menuBase.Bitmap) != 0)
279 return 1;
280
281 defList->menuBase.width = defList->menuBase.Bitmap.Width;
282 defList->menuBase.height = defList->menuBase.Bitmap.Height;
283
209 #ifdef CONFIG_XSHAPE 284 #ifdef CONFIG_XSHAPE
210 Convert32to1( &defList->menuBase.Bitmap,&defList->menuBase.Mask,0x00ff00ff ); 285 Convert32to1(&defList->menuBase.Bitmap, &defList->menuBase.Mask, 0x00ff00ff);
211 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->menuBase.Mask.Width,defList->menuBase.Mask.Height ); 286 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %dx%d\n", defList->menuBase.Mask.Width, defList->menuBase.Mask.Height);
212 #else 287 #else
213 defList->menuBase.Mask.Image=NULL; 288 defList->menuBase.Mask.Image = NULL;
214 #endif 289 #endif
215 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuBase.width,defList->menuBase.height ); 290
216 } 291 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->menuBase.width, defList->menuBase.height);
217 if ( !strcmp( window_name,"playbar" ) ) 292 }
218 { 293
219 defList->barIsPresent=1; 294 if (!strcmp(window_name, "playbar")) {
220 defList->bar.x=x; 295 defList->barIsPresent = 1;
221 defList->bar.y=y; 296 defList->bar.x = x;
222 defList->bar.type=itBase; 297 defList->bar.y = y;
223 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp )); 298 defList->bar.type = itBase;
224 if ( skinBPRead( tmp,&defList->bar.Bitmap ) != 0 ) return 1; 299
225 defList->bar.width=defList->bar.Bitmap.Width; 300 av_strlcpy(tmp, path, sizeof(tmp));
226 defList->bar.height=defList->bar.Bitmap.Height; 301 av_strlcat(tmp, fname, sizeof(tmp));
302
303 if (skinBPRead(tmp, &defList->bar.Bitmap) != 0)
304 return 1;
305
306 defList->bar.width = defList->bar.Bitmap.Width;
307 defList->bar.height = defList->bar.Bitmap.Height;
308
227 #ifdef CONFIG_XSHAPE 309 #ifdef CONFIG_XSHAPE
228 Convert32to1( &defList->bar.Bitmap,&defList->bar.Mask,0x00ff00ff ); 310 Convert32to1(&defList->bar.Bitmap, &defList->bar.Mask, 0x00ff00ff);
229 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->bar.Mask.Width,defList->bar.Mask.Height ); 311 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %dx%d\n", defList->bar.Mask.Width, defList->bar.Mask.Height);
230 #else 312 #else
231 defList->bar.Mask.Image=NULL; 313 defList->bar.Mask.Image = NULL;
232 #endif 314 #endif
233 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->bar.width,defList->bar.height ); 315
234 } 316 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->bar.width, defList->bar.height);
235 return 0; 317 }
236 } 318
237 319 return 0;
238 static int cmd_background( char * in ) 320 }
239 { 321
240 CHECKDEFLIST( "background" ); 322 // background=R,G,B
241 CHECKWINLIST( "background" ); 323 static int cmd_background(char *in)
242 324 {
243 CHECK( "menu" ); 325 CHECKDEFLIST("background");
244 CHECK( "main" ); 326 CHECKWINLIST("background");
245 327
246 currSection->R=cutItemToInt( in,',',0 ); 328 CHECK("menu");
247 currSection->G=cutItemToInt( in,',',1 ); 329 CHECK("main");
248 currSection->B=cutItemToInt( in,',',2 ); 330
249 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] background color is #%x%x%x.\n",currSection->R,currSection->G,currSection->B ); 331 currSection->R = cutItemToInt(in, ',', 0);
250 332 currSection->G = cutItemToInt(in, ',', 1);
251 return 0; 333 currSection->B = cutItemToInt(in, ',', 2);
252 } 334
253 335 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] background color is #%x%x%x.\n", currSection->R, currSection->G, currSection->B);
254 static int cmd_button( char * in ) 336
255 { 337 return 0;
256 unsigned char fname[512]; 338 }
257 unsigned char tmp[512]; 339
258 int x,y,sx,sy; 340 // button=image,x,y,width,height,message
259 char msg[32]; 341 static int cmd_button(char *in)
260 342 {
261 CHECKDEFLIST( "button" ); 343 unsigned char fname[512];
262 CHECKWINLIST( "button" ); 344 unsigned char tmp[512];
263 345 int x, y, sx, sy;
264 CHECK( "sub" ); 346 char msg[32];
265 CHECK( "menu" ); 347
266 348 CHECKDEFLIST("button");
267 cutItem( in,fname,',',0 ); 349 CHECKWINLIST("button");
268 x=cutItemToInt( in,',',1 ); 350
269 y=cutItemToInt( in,',',2 ); 351 CHECK("sub");
270 sx=cutItemToInt( in,',',3 ); 352 CHECK("menu");
271 sy=cutItemToInt( in,',',4 ); 353
272 cutItem( in,msg,',',5 ); 354 cutItem(in, fname, ',', 0);
273 355 x = cutItemToInt(in, ',', 1);
274 (*currSubItem)++; 356 y = cutItemToInt(in, ',', 2);
275 currSubItems[ *currSubItem ].type=itButton; 357 sx = cutItemToInt(in, ',', 3);
276 currSubItems[ *currSubItem ].x=x; 358 sy = cutItemToInt(in, ',', 4);
277 currSubItems[ *currSubItem ].y=y; 359 cutItem(in, msg, ',', 5);
278 currSubItems[ *currSubItem ].width=sx; 360
279 currSubItems[ *currSubItem ].height=sy; 361 (*currSubItem)++;
280 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] button: fname: %s\n",fname ); 362 currSubItems[*currSubItem].type = itButton;
281 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); 363 currSubItems[*currSubItem].x = x;
282 364 currSubItems[*currSubItem].y = y;
283 if ( ( currSubItems[ *currSubItem ].msg=appFindMessage( msg ) ) == -1 ) 365 currSubItems[*currSubItem].width = sx;
284 { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,msg ); return 0; } 366 currSubItems[*currSubItem].height = sy;
285 currSubItems[ *currSubItem ].pressed=btnReleased; 367
286 if ( currSubItems[ *currSubItem ].msg == evPauseSwitchToPlay ) currSubItems[ *currSubItem ].pressed=btnDisabled; 368 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] button: fname: %s\n", fname);
287 currSubItems[ *currSubItem ].tmp=1; 369 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] x: %d y: %d sx: %d sy: %d\n", x, y, sx, sy);
288 370
289 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",currSubItems[ *currSubItem ].msg ); 371 if ((currSubItems[*currSubItem].msg = appFindMessage(msg)) == -1) {
290 372 ERRORMESSAGE(MSGTR_SKIN_BITMAP_UnknownMessage, msg);
291 currSubItems[ *currSubItem ].Bitmap.Image=NULL; 373 return 0;
292 if ( strcmp( fname,"NULL" ) != 0 ) 374 }
293 { 375
294 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp )); 376 currSubItems[*currSubItem].pressed = btnReleased;
295 if ( skinBPRead( tmp,&currSubItems[ *currSubItem ].Bitmap ) != 0 ) return 1; 377
296 } 378 if (currSubItems[*currSubItem].msg == evPauseSwitchToPlay)
297 379 currSubItems[*currSubItem].pressed = btnDisabled;
298 return 0; 380
299 } 381 currSubItems[*currSubItem].tmp = 1;
300 382
301 static int cmd_selected( char * in ) 383 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %d\n", currSubItems[*currSubItem].msg);
302 { 384
303 unsigned char fname[512]; 385 currSubItems[*currSubItem].Bitmap.Image = NULL;
304 unsigned char tmp[512]; 386
305 387 if (strcmp(fname, "NULL") != 0) {
306 CHECKDEFLIST( "selected" ); 388 av_strlcpy(tmp, path, sizeof(tmp));
307 CHECKWINLIST( "selected" ); 389 av_strlcat(tmp, fname, sizeof(tmp));
308 390
309 CHECK( "main" ); 391 if (skinBPRead(tmp, &currSubItems[*currSubItem].Bitmap) != 0)
310 CHECK( "sub" ); 392 return 1;
311 CHECK( "playbar" ); 393 }
312 394
313 cutItem( in,fname,',',0 ); 395 return 0;
314 defList->menuSelected.type=itBase; 396 }
315 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp )); 397
316 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname ); 398 // selected=image
317 if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) != 0 ) return 1; 399 static int cmd_selected(char *in)
318 defList->menuSelected.width=defList->menuSelected.Bitmap.Width; 400 {
319 defList->menuSelected.height=defList->menuSelected.Bitmap.Height; 401 unsigned char fname[512];
320 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height ); 402 unsigned char tmp[512];
321 return 0; 403
322 } 404 CHECKDEFLIST("selected");
323 405 CHECKWINLIST("selected");
324 static int cmd_menu( char * in ) 406
325 { // menu = number,x,y,sx,sy,msg 407 CHECK("main");
326 int x,y,sx,sy,msg; 408 CHECK("sub");
327 unsigned char tmp[64]; 409 CHECK("playbar");
328 410
329 CHECKDEFLIST( "menu" ); 411 cutItem(in, fname, ',', 0);
330 CHECKWINLIST( "menu" ); 412
331 413 defList->menuSelected.type = itBase;
332 CHECK( "main" ); 414
333 CHECK( "sub" ); 415 av_strlcpy(tmp, path, sizeof(tmp));
334 CHECK( "playbar" ); 416 av_strlcat(tmp, fname, sizeof(tmp));
335 417
336 x=cutItemToInt( in,',',0 ); 418 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] selected: %s\n", fname);
337 y=cutItemToInt( in,',',1 ); 419
338 sx=cutItemToInt( in,',',2 ); 420 if (skinBPRead(tmp, &defList->menuSelected.Bitmap) != 0)
339 sy=cutItemToInt( in,',',3 ); 421 return 1;
340 cutItem( in,tmp,',',4 ); msg=appFindMessage( tmp ); 422
341 423 defList->menuSelected.width = defList->menuSelected.Bitmap.Width;
342 defList->NumberOfMenuItems++; 424 defList->menuSelected.height = defList->menuSelected.Bitmap.Height;
343 defList->MenuItems[ defList->NumberOfMenuItems ].x=x; 425
344 defList->MenuItems[ defList->NumberOfMenuItems ].y=y; 426 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->menuSelected.width, defList->menuSelected.height);
345 defList->MenuItems[ defList->NumberOfMenuItems ].width=sx; 427
346 defList->MenuItems[ defList->NumberOfMenuItems ].height=sy; 428 return 0;
347 429 }
348 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems ); 430
349 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); 431 // menu=x,y,width,height,message
350 432 static int cmd_menu(char *in)
351 if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 ) 433 {
352 ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,tmp ); 434 int x, y, sx, sy, msg;
353 435 unsigned char tmp[64];
354 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg ); 436
355 437 CHECKDEFLIST("menu");
356 defList->MenuItems[ defList->NumberOfMenuItems ].Bitmap.Image=NULL; 438 CHECKWINLIST("menu");
357 return 0; 439
358 } 440 CHECK("main");
359 441 CHECK("sub");
360 static int cmd_hpotmeter( char * in ) 442 CHECK("playbar");
361 { // hpotmeter=buttonbitmaps,sx,sy,phasebitmaps,phases,default value,x,y,sx,sy,msg 443
362 int x,y,psx,psy,ph,sx,sy,msg,d; 444 x = cutItemToInt(in, ',', 0);
363 unsigned char tmp[512]; 445 y = cutItemToInt(in, ',', 1);
364 unsigned char pfname[512]; 446 sx = cutItemToInt(in, ',', 2);
365 unsigned char phfname[512]; 447 sy = cutItemToInt(in, ',', 3);
366 wItem * item; 448 cutItem(in, tmp, ',', 4);
367 449
368 CHECKDEFLIST( "hpotmeter" ); 450 msg = appFindMessage(tmp);
369 CHECKWINLIST( "hpotmeter" ); 451
370 452 defList->NumberOfMenuItems++;
371 CHECK( "sub" ); 453 defList->MenuItems[defList->NumberOfMenuItems].x = x;
372 CHECK( "menu" ); 454 defList->MenuItems[defList->NumberOfMenuItems].y = y;
373 455 defList->MenuItems[defList->NumberOfMenuItems].width = sx;
374 cutItem( in,pfname,',',0 ); 456 defList->MenuItems[defList->NumberOfMenuItems].height = sy;
375 psx=cutItemToInt( in,',',1 ); 457
376 psy=cutItemToInt( in,',',2 ); 458 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] menuitem: %d\n", defList->NumberOfMenuItems);
377 cutItem( in,phfname,',',3 ); 459 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] x: %d y: %d sx: %d sy: %d\n", x, y, sx, sy);
378 ph=cutItemToInt( in,',',4 ); 460
379 d=cutItemToInt( in,',',5 ); 461 if ((defList->MenuItems[defList->NumberOfMenuItems].msg = msg) == -1)
380 x=cutItemToInt( in,',',6 ); 462 ERRORMESSAGE(MSGTR_SKIN_BITMAP_UnknownMessage, tmp);
381 y=cutItemToInt( in,',',7 ); 463
382 sx=cutItemToInt( in,',',8 ); 464 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %d\n", defList->Items[defList->NumberOfItems].msg);
383 sy=cutItemToInt( in,',',9 ); 465
384 cutItem( in,tmp,',',10 ); msg=appFindMessage( tmp ); 466 defList->MenuItems[defList->NumberOfMenuItems].Bitmap.Image = NULL;
385 467 return 0;
386 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] h/v potmeter: pointer filename: '%s'\n",pfname ); 468 }
387 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pointer size is %dx%d\n",psx,psy ); 469
388 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phasebitmaps filename: '%s'\n",phfname ); 470 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message
389 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy ); 471 static int cmd_hpotmeter(char *in)
390 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d ); 472 {
391 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg ); 473 int x, y, psx, psy, ph, sx, sy, msg, d;
392 474 unsigned char tmp[512];
393 (*currSubItem)++; 475 unsigned char pfname[512];
394 item=&currSubItems[ *currSubItem ]; 476 unsigned char phfname[512];
395 477 wItem *item;
396 item->type=itHPotmeter; 478
397 item->x=x; item->y=y; item->width=sx; item->height=sy; 479 CHECKDEFLIST("hpotmeter");
398 item->phases=ph; 480 CHECKWINLIST("hpotmeter");
399 item->psx=psx; item->psy=psy; 481
400 item->msg=msg; 482 CHECK("sub");
401 item->value=(float)d; 483 CHECK("menu");
402 item->pressed=btnReleased; 484
403 485 cutItem(in, pfname, ',', 0);
404 item->Bitmap.Image=NULL; 486 psx = cutItemToInt(in, ',', 1);
405 if ( strcmp( phfname,"NULL" ) != 0 ) 487 psy = cutItemToInt(in, ',', 2);
406 { 488 cutItem(in, phfname, ',', 3);
407 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, phfname, sizeof( tmp )); 489 ph = cutItemToInt(in, ',', 4);
408 if ( skinBPRead( tmp,&item->Bitmap ) != 0 ) return 1; 490 d = cutItemToInt(in, ',', 5);
409 } 491 x = cutItemToInt(in, ',', 6);
410 492 y = cutItemToInt(in, ',', 7);
411 item->Mask.Image=NULL; 493 sx = cutItemToInt(in, ',', 8);
412 if ( strcmp( pfname,"NULL" ) != 0 ) 494 sy = cutItemToInt(in, ',', 9);
413 { 495 cutItem(in, tmp, ',', 10);
414 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, pfname, sizeof( tmp )); 496
415 if ( skinBPRead( tmp,&item->Mask ) != 0 ) return 1; 497 msg = appFindMessage(tmp);
416 } 498
417 return 0; 499 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] h/v potmeter: pointer filename: '%s'\n", pfname);
418 } 500 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pointer size is %dx%d\n", psx, psy);
419 501 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] phasebitmaps filename: '%s'\n", phfname);
420 static int cmd_vpotmeter( char * in ) 502 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] position: %d,%d %dx%d\n", x, y, sx, sy);
421 { 503 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] default value: %d\n", d);
422 int r = cmd_hpotmeter( in ); 504 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %d\n", msg);
423 wItem * item; 505
424 506 (*currSubItem)++;
425 item=&currSubItems[ *currSubItem ]; 507 item = &currSubItems[*currSubItem];
426 item->type=itVPotmeter; 508 item->type = itHPotmeter;
427 return r; 509 item->x = x;
428 } 510 item->y = y;
429 511 item->width = sx;
430 static int cmd_potmeter( char * in ) 512 item->height = sy;
431 { // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg 513 item->phases = ph;
432 int x,y,ph,sx,sy,msg,d; 514 item->psx = psx;
433 unsigned char tmp[512]; 515 item->psy = psy;
434 unsigned char phfname[512]; 516 item->msg = msg;
435 wItem * item; 517 item->value = (float)d;
436 518 item->pressed = btnReleased;
437 CHECKDEFLIST( "potmeter" ); 519 item->Bitmap.Image = NULL;
438 CHECKWINLIST( "potmeter" ); 520
439 521 if (strcmp(phfname, "NULL") != 0) {
440 CHECK( "sub" ); 522 av_strlcpy(tmp, path, sizeof(tmp));
441 CHECK( "menu" ); 523 av_strlcat(tmp, phfname, sizeof(tmp));
442 524
443 cutItem( in,phfname,',',0 ); 525 if (skinBPRead(tmp, &item->Bitmap) != 0)
444 ph=cutItemToInt( in,',',1 ); 526 return 1;
445 d=cutItemToInt( in,',',2 ); 527 }
446 x=cutItemToInt( in,',',3 ); 528
447 y=cutItemToInt( in,',',4 ); 529 item->Mask.Image = NULL;
448 sx=cutItemToInt( in,',',5 ); 530
449 sy=cutItemToInt( in,',',6 ); 531 if (strcmp(pfname, "NULL") != 0) {
450 cutItem( in,tmp,',',7 ); msg=appFindMessage( tmp ); 532 av_strlcpy(tmp, path, sizeof(tmp));
451 533 av_strlcat(tmp, pfname, sizeof(tmp));
452 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] potmeter: phases filename: '%s'\n",phfname ); 534
453 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy ); 535 if (skinBPRead(tmp, &item->Mask) != 0)
454 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phases: %d\n",ph ); 536 return 1;
455 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d ); 537 }
456 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg ); 538
457 539 return 0;
458 (*currSubItem)++; 540 }
459 item=&currSubItems[ *currSubItem ]; 541
460 542 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message
461 item->type=itPotmeter; 543 static int cmd_vpotmeter(char *in)
462 item->x=x; item->y=y; 544 {
463 item->width=sx; item->height=sy; 545 int r = cmd_hpotmeter(in);
464 item->phases=ph; 546 wItem *item;
465 item->msg=msg; 547
466 item->value=(float)d; 548 item = &currSubItems[*currSubItem];
467 549 item->type = itVPotmeter;
468 item->Bitmap.Image=NULL; 550 return r;
469 if ( strcmp( phfname,"NULL" ) != 0 ) 551 }
470 { 552
471 av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, phfname, sizeof( tmp )); 553 // potmeter=phases,numphases,default,x,y,width,height,message
472 if ( skinBPRead( tmp,&item->Bitmap ) != 0 ) return 1; 554 static int cmd_potmeter(char *in)
473 } 555 {
474 return 0; 556 int x, y, ph, sx, sy, msg, d;
475 } 557 unsigned char tmp[512];
476 558 unsigned char phfname[512];
477 static int cmd_font( char * in ) 559 wItem *item;
478 { // font=fontname 560
479 char name[512]; 561 CHECKDEFLIST("potmeter");
480 wItem * item; 562 CHECKWINLIST("potmeter");
481 563
482 CHECKDEFLIST( "font" ); 564 CHECK("sub");
483 CHECKWINLIST( "font" ); 565 CHECK("menu");
484 566
485 CHECK( "sub" ); 567 cutItem(in, phfname, ',', 0);
486 CHECK( "menu" ); 568 ph = cutItemToInt(in, ',', 1);
487 569 d = cutItemToInt(in, ',', 2);
488 cutItem( in,name,',',0 ); 570 x = cutItemToInt(in, ',', 3);
489 571 y = cutItemToInt(in, ',', 4);
490 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] font\n" ); 572 sx = cutItemToInt(in, ',', 5);
491 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] name: %s\n",name ); 573 sy = cutItemToInt(in, ',', 6);
492 574 cutItem(in, tmp, ',', 7);
493 (*currSubItem)++; 575
494 item=&currSubItems[ *currSubItem ]; 576 msg = appFindMessage(tmp);
495 577
496 item->type=itFont; 578 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] potmeter: phases filename: '%s'\n", phfname);
497 item->fontid=fntRead( path,name ); 579 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] position: %d,%d %dx%d\n", x, y, sx, sy);
498 switch ( item->fontid ) 580 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] phases: %d\n", ph);
499 { 581 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] default value: %d\n", d);
500 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; 582 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %d\n", msg);
501 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1; 583
502 case -3: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1; 584 (*currSubItem)++;
503 case -4: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1; 585 item = &currSubItems[*currSubItem];
504 } 586 item->type = itPotmeter;
505 return 0; 587 item->x = x;
506 } 588 item->y = y;
507 589 item->width = sx;
508 static int cmd_slabel( char * in ) 590 item->height = sy;
509 { 591 item->phases = ph;
510 char tmp[512]; 592 item->msg = msg;
511 char sid[64]; 593 item->value = (float)d;
512 int x,y,id; 594 item->Bitmap.Image = NULL;
513 wItem * item; 595
514 596 if (strcmp(phfname, "NULL") != 0) {
515 CHECKDEFLIST( "slabel" ); 597 av_strlcpy(tmp, path, sizeof(tmp));
516 CHECKWINLIST( "slabel" ); 598 av_strlcat(tmp, phfname, sizeof(tmp));
517 599
518 CHECK( "sub" ); 600 if (skinBPRead(tmp, &item->Bitmap) != 0)
519 CHECK( "menu" ); 601 return 1;
520 602 }
521 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] slabel\n" ); 603
522 604 return 0;
523 x=cutItemToInt( in,',',0 ); 605 }
524 y=cutItemToInt( in,',',1 ); 606
525 cutItem( in,sid,',',2 ); id=fntFindID( sid ); 607 // font=fontfile
526 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } 608 static int cmd_font(char *in)
527 cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 ); 609 {
528 610 char name[512];
529 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d\n",x,y ); 611 wItem *item;
530 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id ); 612
531 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp ); 613 CHECKDEFLIST("font");
532 614 CHECKWINLIST("font");
533 (*currSubItem)++; 615
534 item=&currSubItems[ *currSubItem ]; 616 CHECK("sub");
535 617 CHECK("menu");
536 item->type=itSLabel; 618
537 item->fontid=id; 619 cutItem(in, name, ',', 0);
538 item->x=x; item->y=y; 620
539 item->width=-1; item->height=-1; 621 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] font\n");
540 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } 622 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] name: %s\n", name);
541 strcpy( item->label,tmp ); 623
542 624 (*currSubItem)++;
543 return 0; 625 item = &currSubItems[*currSubItem];
544 } 626 item->type = itFont;
545 627 item->fontid = fntRead(path, name);
546 static int cmd_dlabel( char * in ) 628
547 { // dlabel=x,y,sx,align,fontfile,string ... 629 switch (item->fontid) {
548 char tmp[512]; 630 case -1:
549 char sid[64]; 631 ERRORMESSAGE(MSGTR_SKIN_FONT_NotEnoughtMemory);
550 int x,y,sx,id,a; 632 return 1;
551 wItem * item; 633
552 634 case -2:
553 CHECKDEFLIST( "dlabel" ); 635 ERRORMESSAGE(MSGTR_SKIN_FONT_TooManyFontsDeclared);
554 CHECKWINLIST( "dlabel" ); 636 return 1;
555 637
556 CHECK( "sub" ); 638 case -3:
557 CHECK( "menu" ); 639 ERRORMESSAGE(MSGTR_SKIN_FONT_FontFileNotFound);
558 640 return 1;
559 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] dlabel\n" ); 641
560 642 case -4:
561 x=cutItemToInt( in,',',0 ); 643 ERRORMESSAGE(MSGTR_SKIN_FONT_FontImageNotFound);
562 y=cutItemToInt( in,',',1 ); 644 return 1;
563 sx=cutItemToInt( in,',',2 ); 645 }
564 a=cutItemToInt( in,',',3 ); 646
565 cutItem( in,sid,',',4 ); id=fntFindID( sid ); 647 return 0;
566 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } 648 }
567 cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 ); 649
568 650 // slabel=x,y,fontfile,"text"
569 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a ); 651 static int cmd_slabel(char *in)
570 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id ); 652 {
571 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp ); 653 char tmp[512];
572 654 char sid[64];
573 (*currSubItem)++; 655 int x, y, id;
574 item=&currSubItems[ *currSubItem ]; 656 wItem *item;
575 657
576 item->type=itDLabel; 658 CHECKDEFLIST("slabel");
577 item->fontid=id; item->align=a; 659 CHECKWINLIST("slabel");
578 item->x=x; item->y=y; 660
579 item->width=sx; item->height=-1; 661 CHECK("sub");
580 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } 662 CHECK("menu");
581 strcpy( item->label,tmp ); 663
582 664 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] slabel\n");
583 return 0; 665
584 } 666 x = cutItemToInt(in, ',', 0);
585 667 y = cutItemToInt(in, ',', 1);
586 static int cmd_decoration( char * in ) 668 cutItem(in, sid, ',', 2);
587 { 669
588 char tmp[512]; 670 id = fntFindID(sid);
589 671
590 CHECKDEFLIST( "decoration" ); 672 if (id < 0) {
591 CHECKWINLIST( "decoration" ); 673 ERRORMESSAGE(MSGTR_SKIN_FONT_NonExistentFontID, sid);
592 674 return 1;
593 CHECK( "sub" ); 675 }
594 CHECK( "menu" ); 676
595 CHECK( "playbar" ); 677 cutItem(in, tmp, ',', 3);
596 678 cutItem(tmp, tmp, '"', 1);
597 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",in ); 679
598 strlower( in ); 680 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y);
599 cutItem( in,tmp,',',0 ); 681 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] id: %s ( %d )\n", sid, id);
600 if ( strcmp( tmp,"enable" ) != 0&&strcmp( tmp,"disable" ) != 0 ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; } 682 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] str: '%s'\n", tmp);
601 if ( strcmp( tmp,"enable" ) != 0 ) defList->mainDecoration=0; 683
602 else defList->mainDecoration=1; 684 (*currSubItem)++;
603 685 item = &currSubItems[*currSubItem];
604 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") ); 686 item->type = itSLabel;
605 return 0; 687 item->fontid = id;
606 } 688 item->x = x;
607 689 item->y = y;
608 typedef struct 690 item->width = -1;
609 { 691 item->height = -1;
610 const char * name; 692
611 int (*func)( char * in ); 693 if ((item->label = malloc(strlen(tmp) + 1)) == NULL) {
612 } _item; 694 ERRORMESSAGE(MSGTR_SKIN_FONT_NotEnoughtMemory);
613 695 return 1;
614 _item skinItem[] = 696 }
615 { 697
616 { "section", cmd_section }, 698 strcpy(item->label, tmp);
617 { "end", cmd_end }, 699
618 { "window", cmd_window }, 700 return 0;
619 { "base", cmd_base }, 701 }
620 { "button", cmd_button }, 702
621 { "selected", cmd_selected }, 703 // dlabel=x,y,length,align,fontfile,"text"
622 { "background", cmd_background }, 704 static int cmd_dlabel(char *in)
623 { "vpotmeter", cmd_vpotmeter }, 705 {
624 { "hpotmeter", cmd_hpotmeter }, 706 char tmp[512];
625 { "potmeter", cmd_potmeter }, 707 char sid[64];
626 { "font", cmd_font }, 708 int x, y, sx, id, a;
627 { "slabel", cmd_slabel }, 709 wItem *item;
628 { "dlabel", cmd_dlabel }, 710
629 { "decoration", cmd_decoration }, 711 CHECKDEFLIST("dlabel");
630 { "menu", cmd_menu } 712 CHECKWINLIST("dlabel");
631 }; 713
632 714 CHECK("sub");
633 #define ITEMS (int)( sizeof( skinItem )/sizeof( _item ) ) 715 CHECK("menu");
634 716
635 char * strswap( char * in,char what,char whereof ) 717 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] dlabel\n");
636 { 718
637 int i; 719 x = cutItemToInt(in, ',', 0);
638 if ( strlen( in ) == 0 ) return NULL; 720 y = cutItemToInt(in, ',', 1);
639 for ( i=0;i<(int)strlen( in );i++ ) 721 sx = cutItemToInt(in, ',', 2);
640 if ( in[i] == what ) in[i]=whereof; 722 a = cutItemToInt(in, ',', 3);
641 return in; 723 cutItem(in, sid, ',', 4);
642 } 724
643 725 id = fntFindID(sid);
644 char * trim( char * in ) 726
645 { 727 if (id < 0) {
646 int c = 0,i = 0,id = 0; 728 ERRORMESSAGE(MSGTR_SKIN_FONT_NonExistentFontID, sid);
647 if ( strlen( in ) == 0 ) return NULL; 729 return 1;
648 while ( c != (int)strlen( in ) ) 730 }
649 { 731
650 if ( in[c] == '"' ) id=!id; 732 cutItem(in, tmp, ',', 5);
651 if ( ( in[c] == ' ' )&&( !id ) ) 733 cutItem(tmp, tmp, '"', 1);
652 { 734
653 for ( i=0;i<(int)strlen( in ) - c; i++ ) in[c+i]=in[c+i+1]; 735 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d width: %d align: %d\n", x, y, sx, a);
654 continue; 736 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] id: %s ( %d )\n", sid, id);
655 } 737 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] str: '%s'\n", tmp);
656 c++; 738
657 } 739 (*currSubItem)++;
658 return in; 740 item = &currSubItems[*currSubItem];
659 } 741 item->type = itDLabel;
660 742 item->fontid = id;
661 static char *setname( char * item1, char * item2 ) 743 item->align = a;
662 { 744 item->x = x;
663 static char fn[512]; 745 item->y = y;
664 746 item->width = sx;
665 av_strlcpy(fn, item1, sizeof( fn )); 747 item->height = -1;
666 av_strlcat(fn, "/", sizeof( fn )); av_strlcat(fn, item2, sizeof( fn )); 748
667 av_strlcpy(path, fn, sizeof( path )); av_strlcat(path, "/", sizeof( path )); 749 if ((item->label = malloc(strlen(tmp) + 1)) == NULL) {
668 av_strlcat(fn, "/skin", sizeof( fn )); 750 ERRORMESSAGE(MSGTR_SKIN_FONT_NotEnoughtMemory);
669 751 return 1;
670 return fn; 752 }
671 } 753
672 754 strcpy(item->label, tmp);
673 int skinRead( char * dname ) 755
674 { 756 return 0;
675 char * fn; 757 }
676 FILE * skinFile; 758
677 unsigned char tmp[256]; 759 // decoration=enable|disable
678 unsigned char * ptmp; 760 static int cmd_decoration(char *in)
679 unsigned char command[32]; 761 {
680 unsigned char param[256]; 762 char tmp[512];
681 int i; 763
682 764 CHECKDEFLIST("decoration");
683 fn = setname( skinDirInHome,dname ); 765 CHECKWINLIST("decoration");
684 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) 766
685 { 767 CHECK("sub");
686 fn = setname( skinMPlayerDir,dname ); 768 CHECK("menu");
687 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) 769 CHECK("playbar");
688 { 770
689 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_SkinFileNotFound,fn ); 771 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] window decoration is %s\n", in);
690 return -1; 772
691 } 773 strlower(in);
692 } 774 cutItem(in, tmp, ',', 0);
693 775
694 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] file: %s\n",fn ); 776 if (strcmp(tmp, "enable") != 0 && strcmp(tmp, "disable") != 0) {
695 777 ERRORMESSAGE(MSGTR_SKIN_UnknownParameter, tmp);
696 appInitStruct( skinAppMPlayer ); 778 return 1;
697 779 }
698 linenumber=0; 780
699 while (fgets(tmp, sizeof(tmp), skinFile)) 781 if (strcmp(tmp, "enable") != 0)
700 { 782 defList->mainDecoration = 0;
701 linenumber++; 783 else
702 784 defList->mainDecoration = 1;
703 // remove any kind of newline, if any 785
704 tmp[strcspn(tmp, "\n\r")] = 0; 786 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] window decoration is %s\n", (defList->mainDecoration ? "enabled" : "disabled"));
705 strswap( tmp,'\t',' ' ); 787
706 trim( tmp ); 788 return 0;
707 ptmp = strchr(tmp, ';'); 789 }
708 if (ptmp) *ptmp = 0; 790
709 if (!*tmp) continue; 791 _item skinItem[] = {
710 cutItem( tmp,command,'=',0 ); cutItem( tmp,param,'=',1 ); 792 { "section", cmd_section },
711 strlower( command ); 793 { "end", cmd_end },
712 for( i=0;i<ITEMS;i++ ) 794 { "window", cmd_window },
713 if ( !strcmp( command,skinItem[i].name ) ) 795 { "base", cmd_base },
714 if ( skinItem[i].func( param ) != 0 ) return -2; 796 { "button", cmd_button },
715 } 797 { "selected", cmd_selected },
716 if (linenumber == 0) { 798 { "background", cmd_background },
717 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SkinFileNotReadable, fn); 799 { "vpotmeter", cmd_vpotmeter },
718 return -1; 800 { "hpotmeter", cmd_hpotmeter },
719 } 801 { "potmeter", cmd_potmeter },
720 return 0; 802 { "font", cmd_font },
721 } 803 { "slabel", cmd_slabel },
804 { "dlabel", cmd_dlabel },
805 { "decoration", cmd_decoration },
806 { "menu", cmd_menu }
807 };
808
809 #define ITEMS (int)(sizeof(skinItem) / sizeof(_item))
810
811 char *strswap(char *in, char what, char whereof)
812 {
813 int i;
814
815 if (strlen(in) == 0)
816 return NULL;
817
818 for (i = 0; i < (int)strlen(in); i++)
819 if (in[i] == what)
820 in[i] = whereof;
821
822 return in;
823 }
824
825 char *trim(char *in)
826 {
827 int c = 0, id = 0, i;
828
829 if (strlen(in) == 0)
830 return NULL;
831
832 while (c != (int)strlen(in)) {
833 if (in[c] == '"')
834 id = !id;
835
836 if ((in[c] == ' ') && (!id)) {
837 for (i = 0; i < (int)strlen(in) - c; i++)
838 in[c + i] = in[c + i + 1];
839 continue;
840 }
841
842 c++;
843 }
844
845 return in;
846 }
847
848 static char *setname(char *item1, char *item2)
849 {
850 static char fn[512];
851
852 av_strlcpy(fn, item1, sizeof(fn));
853 av_strlcat(fn, "/", sizeof(fn));
854 av_strlcat(fn, item2, sizeof(fn));
855 av_strlcpy(path, fn, sizeof(path));
856 av_strlcat(path, "/", sizeof(path));
857 av_strlcat(fn, "/skin", sizeof(fn));
858
859 return fn;
860 }
861
862 int skinRead(char *dname)
863 {
864 char *fn;
865 FILE *skinFile;
866 unsigned char tmp[256];
867 unsigned char *ptmp;
868 unsigned char command[32];
869 unsigned char param[256];
870 int i;
871
872 fn = setname(skinDirInHome, dname);
873
874 if ((skinFile = fopen(fn, "rt")) == NULL) {
875 fn = setname(skinMPlayerDir, dname);
876
877 if ((skinFile = fopen(fn, "rt")) == NULL) {
878 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_SKIN_SkinFileNotFound, fn);
879 return -1;
880 }
881 }
882
883 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] file: %s\n", fn);
884
885 appInitStruct(skinAppMPlayer);
886
887 linenumber = 0;
888
889 while (fgets(tmp, sizeof(tmp), skinFile)) {
890 linenumber++;
891
892 tmp[strcspn(tmp, "\n\r")] = 0; // remove any kind of newline, if any
893 strswap(tmp, '\t', ' ');
894 trim(tmp);
895 ptmp = strchr(tmp, ';');
896
897 if (ptmp)
898 *ptmp = 0;
899
900 if (!*tmp)
901 continue;
902
903 cutItem(tmp, command, '=', 0);
904 cutItem(tmp, param, '=', 1);
905 strlower(command);
906
907 for (i = 0; i < ITEMS; i++)
908 if (!strcmp(command, skinItem[i].name))
909 if (skinItem[i].func(param) != 0)
910 return -2;
911 }
912
913 if (linenumber == 0) {
914 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SkinFileNotReadable, fn);
915 return -1;
916 }
917
918 return 0;
919 }