comparison gui/skin/skin.c @ 32980:2bfd000bb789

Cosmetic: Rename pointers handling current window and items. That way, the naming is more consistent and self-explanatory.
author ib
date Thu, 10 Mar 2011 15:43:08 +0000
parents 4905f5a87357
children 9abc0dbd6314
comparison
equal deleted inserted replaced
32979:4905f5a87357 32980:2bfd000bb789
38 38
39 static guiItems *skin; 39 static guiItems *skin;
40 40
41 static int linenumber; 41 static int linenumber;
42 static unsigned char path[512]; 42 static unsigned char path[512];
43 static unsigned char window_name[32]; 43
44 44 static unsigned char currWinName[32];
45 static wItem *currSection; 45 static wItem *currWin;
46 static int *currSubItem; 46 static int *currWinItemIdx;
47 static wItem *currSubItems; 47 static wItem *currWinItems;
48 48
49 static void ERRORMESSAGE(const char *format, ...) 49 static void ERRORMESSAGE(const char *format, ...)
50 { 50 {
51 char p[512]; 51 char p[512];
52 char tmp[512]; 52 char tmp[512];
73 } \ 73 } \
74 } 74 }
75 75
76 #define CHECKWINLIST(str) \ 76 #define CHECKWINLIST(str) \
77 { \ 77 { \
78 if (!window_name[0]) \ 78 if (!currWinName[0]) \
79 { \ 79 { \
80 ERRORMESSAGE(MSGTR_SKIN_ERROR_WINDOW, str); \ 80 ERRORMESSAGE(MSGTR_SKIN_ERROR_WINDOW, str); \
81 return 1; \ 81 return 1; \
82 } \ 82 } \
83 } 83 }
84 84
85 #define CHECK(name) \ 85 #define CHECK(name) \
86 { \ 86 { \
87 if (!strcmp(window_name, name)) \ 87 if (!strcmp(currWinName, name)) \
88 { \ 88 { \
89 ERRORMESSAGE(MSGTR_SKIN_ERROR_IN_WINDOW, name); \ 89 ERRORMESSAGE(MSGTR_SKIN_ERROR_IN_WINDOW, name); \
90 return 1; \ 90 return 1; \
91 } \ 91 } \
92 } 92 }
164 static int cmd_end(char *in) 164 static int cmd_end(char *in)
165 { 165 {
166 #ifdef MP_DEBUG 166 #ifdef MP_DEBUG
167 char *space, *name; 167 char *space, *name;
168 168
169 if (window_name[0]) { 169 if (currWinName[0]) {
170 space = " "; 170 space = " ";
171 name = window_name; 171 name = currWinName;
172 } else { 172 } else {
173 space = ""; 173 space = "";
174 name = "section"; 174 name = "section";
175 } 175 }
176 #endif 176 #endif
177 177
178 (void)in; 178 (void)in;
179 179
180 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %send (%s)\n", space, name); 180 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %send (%s)\n", space, name);
181 181
182 if (window_name[0]) { 182 if (currWinName[0]) {
183 window_name[0] = 0; 183 currWinName[0] = 0;
184 currSection = NULL; 184 currWin = NULL;
185 currSubItem = NULL; 185 currWinItemIdx = NULL;
186 currSubItems = NULL; 186 currWinItems = NULL;
187 } else 187 } else
188 skin = NULL; 188 skin = NULL;
189 189
190 return 0; 190 return 0;
191 } 191 }
193 // window=main|sub|playbar|menu 193 // window=main|sub|playbar|menu
194 static int cmd_window(char *in) 194 static int cmd_window(char *in)
195 { 195 {
196 CHECKDEFLIST("window"); 196 CHECKDEFLIST("window");
197 197
198 av_strlcpy(window_name, strlower(in), sizeof(window_name)); 198 av_strlcpy(currWinName, strlower(in), sizeof(currWinName));
199 199
200 if (!strncmp(in, "main", 4)) { 200 if (!strncmp(in, "main", 4)) {
201 currSection = &appMPlayer.main; 201 currWin = &appMPlayer.main;
202 currSubItem = &appMPlayer.IndexOfMainItems; 202 currWinItemIdx = &appMPlayer.IndexOfMainItems;
203 currSubItems = appMPlayer.mainItems; 203 currWinItems = appMPlayer.mainItems;
204 } else if (!strncmp(in, "sub", 3)) 204 } else if (!strncmp(in, "sub", 3))
205 currSection = &appMPlayer.sub; 205 currWin = &appMPlayer.sub;
206 else if (!strncmp(in, "playbar", 7)) { 206 else if (!strncmp(in, "playbar", 7)) {
207 currSection = &appMPlayer.bar; 207 currWin = &appMPlayer.bar;
208 currSubItem = &appMPlayer.IndexOfBarItems; 208 currWinItemIdx = &appMPlayer.IndexOfBarItems;
209 currSubItems = appMPlayer.barItems; 209 currWinItems = appMPlayer.barItems;
210 } else if (!strncmp(in, "menu", 4)) { 210 } else if (!strncmp(in, "menu", 4)) {
211 currSection = &appMPlayer.menuBase; 211 currWin = &appMPlayer.menuBase;
212 currSubItem = &appMPlayer.IndexOfMenuItems; 212 currWinItemIdx = &appMPlayer.IndexOfMenuItems;
213 currSubItems = appMPlayer.menuItems; 213 currWinItems = appMPlayer.menuItems;
214 } else 214 } else
215 ERRORMESSAGE(MSGTR_UNKNOWNWINDOWTYPE); 215 ERRORMESSAGE(MSGTR_UNKNOWNWINDOWTYPE);
216 216
217 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] window: %s\n", window_name); 217 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] window: %s\n", currWinName);
218 218
219 return 0; 219 return 0;
220 } 220 }
221 221
222 // base=image,x,y[,width,height] 222 // base=image,x,y[,width,height]
234 x = cutItemToInt(in, ',', 1); 234 x = cutItemToInt(in, ',', 1);
235 y = cutItemToInt(in, ',', 2); 235 y = cutItemToInt(in, ',', 2);
236 sx = cutItemToInt(in, ',', 3); 236 sx = cutItemToInt(in, ',', 3);
237 sy = cutItemToInt(in, ',', 4); 237 sy = cutItemToInt(in, ',', 4);
238 238
239 if (!strcmp(window_name, "main")) { 239 if (!strcmp(currWinName, "main")) {
240 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); 240 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y);
241 241
242 skin->main.x = x; 242 skin->main.x = x;
243 skin->main.y = y; 243 skin->main.y = y;
244 skin->main.type = itBase; 244 skin->main.type = itBase;
260 #else 260 #else
261 skin->main.Mask.Image = NULL; 261 skin->main.Mask.Image = NULL;
262 #endif 262 #endif
263 } 263 }
264 264
265 if (!strcmp(window_name, "sub")) { 265 if (!strcmp(currWinName, "sub")) {
266 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); 266 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y);
267 267
268 skin->sub.type = itBase; 268 skin->sub.type = itBase;
269 269
270 av_strlcpy(tmp, path, sizeof(tmp)); 270 av_strlcpy(tmp, path, sizeof(tmp));
284 } 284 }
285 285
286 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->sub.width, skin->sub.height); 286 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->sub.width, skin->sub.height);
287 } 287 }
288 288
289 if (!strcmp(window_name, "menu")) { 289 if (!strcmp(currWinName, "menu")) {
290 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s\n", fname); 290 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s\n", fname);
291 291
292 skin->menuIsPresent = 1; 292 skin->menuIsPresent = 1;
293 skin->menuBase.type = itBase; 293 skin->menuBase.type = itBase;
294 294
309 #else 309 #else
310 skin->menuBase.Mask.Image = NULL; 310 skin->menuBase.Mask.Image = NULL;
311 #endif 311 #endif
312 } 312 }
313 313
314 if (!strcmp(window_name, "playbar")) { 314 if (!strcmp(currWinName, "playbar")) {
315 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); 315 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y);
316 316
317 skin->barIsPresent = 1; 317 skin->barIsPresent = 1;
318 skin->bar.x = x; 318 skin->bar.x = x;
319 skin->bar.y = y; 319 skin->bar.y = y;
348 CHECKWINLIST("background"); 348 CHECKWINLIST("background");
349 349
350 CHECK("menu"); 350 CHECK("menu");
351 CHECK("main"); 351 CHECK("main");
352 352
353 currSection->R = cutItemToInt(in, ',', 0); 353 currWin->R = cutItemToInt(in, ',', 0);
354 currSection->G = cutItemToInt(in, ',', 1); 354 currWin->G = cutItemToInt(in, ',', 1);
355 currSection->B = cutItemToInt(in, ',', 2); 355 currWin->B = cutItemToInt(in, ',', 2);
356 356
357 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currSection->R, currSection->G, currSection->B); 357 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B);
358 358
359 return 0; 359 return 0;
360 } 360 }
361 361
362 // button=image,x,y,width,height,message 362 // button=image,x,y,width,height,message
378 y = cutItemToInt(in, ',', 2); 378 y = cutItemToInt(in, ',', 2);
379 sx = cutItemToInt(in, ',', 3); 379 sx = cutItemToInt(in, ',', 3);
380 sy = cutItemToInt(in, ',', 4); 380 sy = cutItemToInt(in, ',', 4);
381 cutItem(in, msg, ',', 5); 381 cutItem(in, msg, ',', 5);
382 382
383 (*currSubItem)++; 383 (*currWinItemIdx)++;
384 currSubItems[*currSubItem].type = itButton; 384 currWinItems[*currWinItemIdx].type = itButton;
385 currSubItems[*currSubItem].x = x; 385 currWinItems[*currWinItemIdx].x = x;
386 currSubItems[*currSubItem].y = y; 386 currWinItems[*currWinItemIdx].y = y;
387 currSubItems[*currSubItem].width = sx; 387 currWinItems[*currWinItemIdx].width = sx;
388 currSubItems[*currSubItem].height = sy; 388 currWinItems[*currWinItemIdx].height = sy;
389 389
390 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y); 390 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y);
391 391
392 if ((currSubItems[*currSubItem].message = appFindMessage(msg)) == -1) { 392 if ((currWinItems[*currWinItemIdx].message = appFindMessage(msg)) == -1) {
393 ERRORMESSAGE(MSGTR_SKIN_BITMAP_UnknownMessage, msg); 393 ERRORMESSAGE(MSGTR_SKIN_BITMAP_UnknownMessage, msg);
394 return 0; 394 return 0;
395 } 395 }
396 396
397 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, currSubItems[*currSubItem].message); 397 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, currWinItems[*currWinItemIdx].message);
398 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", sx, sy); 398 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", sx, sy);
399 399
400 currSubItems[*currSubItem].pressed = btnReleased; 400 currWinItems[*currWinItemIdx].pressed = btnReleased;
401 401
402 if (currSubItems[*currSubItem].message == evPauseSwitchToPlay) 402 if (currWinItems[*currWinItemIdx].message == evPauseSwitchToPlay)
403 currSubItems[*currSubItem].pressed = btnDisabled; 403 currWinItems[*currWinItemIdx].pressed = btnDisabled;
404 404
405 currSubItems[*currSubItem].tmp = 1; 405 currWinItems[*currWinItemIdx].tmp = 1;
406 406
407 currSubItems[*currSubItem].Bitmap.Image = NULL; 407 currWinItems[*currWinItemIdx].Bitmap.Image = NULL;
408 408
409 if (strcmp(fname, "NULL") != 0) { 409 if (strcmp(fname, "NULL") != 0) {
410 av_strlcpy(tmp, path, sizeof(tmp)); 410 av_strlcpy(tmp, path, sizeof(tmp));
411 av_strlcat(tmp, fname, sizeof(tmp)); 411 av_strlcat(tmp, fname, sizeof(tmp));
412 412
413 if (skinBPRead(tmp, &currSubItems[*currSubItem].Bitmap) != 0) 413 if (skinBPRead(tmp, &currWinItems[*currWinItemIdx].Bitmap) != 0)
414 return 1; 414 return 1;
415 415
416 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", currSubItems[*currSubItem].Bitmap.Width, currSubItems[*currSubItem].Bitmap.Height); 416 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", currWinItems[*currWinItemIdx].Bitmap.Width, currWinItems[*currWinItemIdx].Bitmap.Height);
417 } 417 }
418 418
419 return 0; 419 return 0;
420 } 420 }
421 421
522 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy); 522 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy);
523 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); 523 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight);
524 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); 524 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d);
525 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message); 525 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message);
526 526
527 (*currSubItem)++; 527 (*currWinItemIdx)++;
528 item = &currSubItems[*currSubItem]; 528 item = &currWinItems[*currWinItemIdx];
529 item->type = itHPotmeter; 529 item->type = itHPotmeter;
530 item->x = x; 530 item->x = x;
531 item->y = y; 531 item->y = y;
532 item->width = sx; 532 item->width = sx;
533 item->height = sy; 533 item->height = sy;
568 static int cmd_vpotmeter(char *in) 568 static int cmd_vpotmeter(char *in)
569 { 569 {
570 int r = cmd_hpotmeter(in); 570 int r = cmd_hpotmeter(in);
571 wItem *item; 571 wItem *item;
572 572
573 item = &currSubItems[*currSubItem]; 573 item = &currWinItems[*currWinItemIdx];
574 item->type = itVPotmeter; 574 item->type = itVPotmeter;
575 return r; 575 return r;
576 } 576 }
577 577
578 // potmeter=phases,numphases,default,x,y,width,height,message 578 // potmeter=phases,numphases,default,x,y,width,height,message
602 602
603 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy); 603 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy);
604 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); 604 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d);
605 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message); 605 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message);
606 606
607 (*currSubItem)++; 607 (*currWinItemIdx)++;
608 item = &currSubItems[*currSubItem]; 608 item = &currWinItems[*currWinItemIdx];
609 item->type = itPotmeter; 609 item->type = itPotmeter;
610 item->x = x; 610 item->x = x;
611 item->y = y; 611 item->y = y;
612 item->width = sx; 612 item->width = sx;
613 item->height = sy; 613 item->height = sy;
641 CHECK("sub"); 641 CHECK("sub");
642 CHECK("menu"); 642 CHECK("menu");
643 643
644 cutItem(in, name, ',', 0); 644 cutItem(in, name, ',', 0);
645 645
646 (*currSubItem)++; 646 (*currWinItemIdx)++;
647 item = &currSubItems[*currSubItem]; 647 item = &currWinItems[*currWinItemIdx];
648 item->type = itFont; 648 item->type = itFont;
649 item->fontid = fntRead(path, name); 649 item->fontid = fntRead(path, name);
650 650
651 switch (item->fontid) { 651 switch (item->fontid) {
652 case -1: 652 case -1:
701 return 1; 701 return 1;
702 } 702 }
703 703
704 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id); 704 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id);
705 705
706 (*currSubItem)++; 706 (*currWinItemIdx)++;
707 item = &currSubItems[*currSubItem]; 707 item = &currWinItems[*currWinItemIdx];
708 item->type = itSLabel; 708 item->type = itSLabel;
709 item->fontid = id; 709 item->fontid = id;
710 item->x = x; 710 item->x = x;
711 item->y = y; 711 item->y = y;
712 item->width = -1; 712 item->width = -1;
754 return 1; 754 return 1;
755 } 755 }
756 756
757 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id); 757 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id);
758 758
759 (*currSubItem)++; 759 (*currWinItemIdx)++;
760 item = &currSubItems[*currSubItem]; 760 item = &currWinItems[*currWinItemIdx];
761 item->type = itDLabel; 761 item->type = itDLabel;
762 item->fontid = id; 762 item->fontid = id;
763 item->align = a; 763 item->align = a;
764 item->x = x; 764 item->x = x;
765 item->y = y; 765 item->y = y;