Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 33749:d8f49edf8f25
Remove skin related variables from interface.[ch].
Move them to skin.[ch] instead.
author | ib |
---|---|
date | Thu, 07 Jul 2011 14:20:35 +0000 |
parents | 520fb0f7544c |
children | 253620911a2e |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
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. | |
8 * | |
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. | |
13 * | |
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. | |
17 */ | |
23077 | 18 |
19 #include <stdio.h> | |
20 #include <string.h> | |
21 | |
32873 | 22 #include "skin.h" |
23077 | 23 #include "font.h" |
32893 | 24 #include "gui/app.h" |
33023 | 25 #include "gui/interface.h" |
33556 | 26 #include "gui/ui/widgets.h" |
33046 | 27 #include "gui/util/cut.h" |
33048 | 28 #include "gui/util/string.h" |
23077 | 29 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
30 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
31 #include "help_mp.h" |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23077
diff
changeset
|
32 #include "libavutil/avstring.h" |
32944 | 33 #include "libavutil/common.h" |
32873 | 34 #include "mp_msg.h" |
23077 | 35 |
32873 | 36 typedef struct { |
37 const char *name; | |
38 int (*func)(char *in); | |
39 } _item; | |
23077 | 40 |
33749 | 41 char *skinDirInHome; |
42 char *skinMPlayerDir; | |
43 | |
32937 | 44 static guiItems *skin; |
23077 | 45 |
32873 | 46 static int linenumber; |
47 static unsigned char path[512]; | |
23077 | 48 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
49 static unsigned char currWinName[32]; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
50 static wItem *currWin; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
51 static int *currWinItemIdx; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
52 static wItem *currWinItems; |
23077 | 53 |
33022 | 54 static void skin_error(const char *format, ...) |
23077 | 55 { |
32873 | 56 char p[512]; |
57 va_list ap; | |
58 | |
59 va_start(ap, format); | |
60 vsnprintf(p, sizeof(p), format, ap); | |
61 va_end(ap); | |
62 | |
33023 | 63 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_ERRORMESSAGE, linenumber, p); |
23077 | 64 } |
65 | |
33106 | 66 static int section_item(char *item) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
67 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
68 if (!skin) { |
33106 | 69 skin_error(MSGTR_SKIN_ERROR_SECTION, item); |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
70 return 0; |
32873 | 71 } |
72 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
73 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
74 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
75 |
33106 | 76 static int window_item(char *item) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
77 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
78 if (!currWinName[0]) { |
33106 | 79 skin_error(MSGTR_SKIN_ERROR_WINDOW, item); |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
80 return 0; |
32873 | 81 } |
23077 | 82 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
83 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
84 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
85 |
33058 | 86 static int in_window(char *name) |
87 { | |
88 if (strcmp(currWinName, name) == 0) { | |
33062 | 89 skin_error(MSGTR_SKIN_ERROR_ITEM, name); |
33058 | 90 return 1; |
32873 | 91 } |
92 | |
33058 | 93 return 0; |
94 } | |
95 | |
33555 | 96 int skinBPRead(char *fname, guiImage *bf) |
32873 | 97 { |
98 int i = bpRead(fname, bf); | |
99 | |
100 switch (i) { | |
101 case -1: | |
33022 | 102 skin_error(MSGTR_SKIN_BITMAP_16bit, fname); |
32873 | 103 break; |
104 | |
105 case -2: | |
33022 | 106 skin_error(MSGTR_SKIN_BITMAP_FileNotFound, fname); |
32873 | 107 break; |
108 | |
109 case -5: | |
33022 | 110 skin_error(MSGTR_SKIN_BITMAP_PNGReadError, fname); |
32873 | 111 break; |
112 | |
113 case -8: | |
33022 | 114 skin_error(MSGTR_SKIN_BITMAP_ConversionError, fname); |
32873 | 115 break; |
116 } | |
117 | |
118 return i; | |
23077 | 119 } |
120 | |
33098 | 121 static wItem *next_item(void) |
122 { | |
123 wItem *item = NULL; | |
124 | |
125 if (*currWinItemIdx < MAX_ITEMS - 1) { | |
126 (*currWinItemIdx)++; | |
127 item = &currWinItems[*currWinItemIdx]; | |
128 } else | |
129 skin_error(MSGTR_SKIN_TooManyItemsDeclared); | |
130 | |
131 return item; | |
132 } | |
133 | |
32873 | 134 // section=movieplayer |
33106 | 135 static int item_section(char *in) |
23077 | 136 { |
33064 | 137 if (skin) { |
138 skin_error(MSGTR_SKIN_ERROR_ITEM, "section"); | |
139 return 1; | |
140 } | |
141 | |
33055 | 142 if (!strcmp(strlower(in), "movieplayer")) |
33555 | 143 skin = &guiApp; |
33067 | 144 else { |
145 skin_error(MSGTR_SKIN_UNKNOWN_NAME, in); | |
146 return 1; | |
147 } | |
32873 | 148 |
32951 | 149 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] section: %s\n", in); |
32873 | 150 |
151 return 0; | |
23077 | 152 } |
153 | |
32873 | 154 // end |
33106 | 155 static int item_end(char *in) |
23077 | 156 { |
32951 | 157 char *space, *name; |
158 | |
33357 | 159 #ifdef MP_DEBUG |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
160 if (currWinName[0]) { |
32951 | 161 space = " "; |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
162 name = currWinName; |
32951 | 163 } else { |
164 space = ""; | |
165 name = "section"; | |
166 } | |
32958 | 167 #endif |
168 | |
169 (void)in; | |
32951 | 170 |
33106 | 171 if (!section_item("end")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
172 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
173 |
32951 | 174 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %send (%s)\n", space, name); |
175 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
176 if (currWinName[0]) { |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
177 currWinName[0] = 0; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
178 currWin = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
179 currWinItemIdx = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
180 currWinItems = NULL; |
32873 | 181 } else |
32937 | 182 skin = NULL; |
32873 | 183 |
184 return 0; | |
23077 | 185 } |
186 | |
32873 | 187 // window=main|sub|playbar|menu |
33106 | 188 static int item_window(char *in) |
23077 | 189 { |
33106 | 190 if (!section_item("window")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
191 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
192 |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
193 if (currWinName[0]) { |
33062 | 194 skin_error(MSGTR_SKIN_ERROR_ITEM, "window"); |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
195 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
196 } |
32873 | 197 |
33083 | 198 strlower(in); |
23077 | 199 |
33083 | 200 if (strcmp(in, "main") == 0) { |
33095 | 201 currWin = &skin->main; |
202 currWinItemIdx = &skin->IndexOfMainItems; | |
203 currWinItems = skin->mainItems; | |
33083 | 204 } else if (strcmp(in, "sub") == 0) { |
33095 | 205 currWin = &skin->sub; |
33083 | 206 currWinItemIdx = NULL; |
207 currWinItems = NULL; | |
208 } else if (strcmp(in, "playbar") == 0) { | |
33555 | 209 currWin = &skin->playbar; |
210 currWinItemIdx = &skin->IndexOfPlaybarItems; | |
211 currWinItems = skin->playbarItems; | |
33083 | 212 } else if (strcmp(in, "menu") == 0) { |
33095 | 213 currWin = &skin->menu; |
214 currWinItemIdx = &skin->IndexOfMenuItems; | |
215 currWinItems = skin->menuItems; | |
33066 | 216 } else { |
33065 | 217 skin_error(MSGTR_SKIN_UNKNOWN_NAME, in); |
33066 | 218 return 1; |
219 } | |
32873 | 220 |
33083 | 221 av_strlcpy(currWinName, in, sizeof(currWinName)); |
222 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
223 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] window: %s\n", currWinName); |
32873 | 224 |
225 return 0; | |
23077 | 226 } |
227 | |
32873 | 228 // base=image,x,y[,width,height] |
33106 | 229 static int item_base(char *in) |
23077 | 230 { |
33090 | 231 unsigned char fname[256]; |
33089 | 232 unsigned char file[512]; |
32873 | 233 int x, y; |
33089 | 234 int w = 0, h = 0; |
33104 | 235 int is_sub, is_bar, is_menu; |
32873 | 236 |
33106 | 237 if (!window_item("base")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
238 return 1; |
23077 | 239 |
33104 | 240 is_sub = (strcmp(currWinName, "sub") == 0); |
241 is_bar = (strcmp(currWinName, "playbar") == 0); | |
242 is_menu = (strcmp(currWinName, "menu") == 0); | |
243 | |
32873 | 244 cutItem(in, fname, ',', 0); |
33089 | 245 x = cutItemToInt(in, ',', 1); |
246 y = cutItemToInt(in, ',', 2); | |
247 w = cutItemToInt(in, ',', 3); | |
248 h = cutItemToInt(in, ',', 4); | |
32873 | 249 |
33105 | 250 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s", fname); |
23077 | 251 |
33105 | 252 currWin->type = itBase; |
33104 | 253 |
33105 | 254 if (!is_menu) { |
255 currWin->x = x; | |
256 currWin->y = y; | |
32873 | 257 |
33105 | 258 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, " %d,%d", x, y); |
259 } | |
32951 | 260 |
33105 | 261 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n"); |
32873 | 262 |
33105 | 263 av_strlcpy(file, path, sizeof(file)); |
264 av_strlcat(file, fname, sizeof(file)); | |
32873 | 265 |
33105 | 266 if (skinBPRead(file, &currWin->Bitmap) != 0) |
267 return 1; | |
32873 | 268 |
33105 | 269 currWin->width = currWin->Bitmap.Width; |
270 currWin->height = currWin->Bitmap.Height; | |
32873 | 271 |
33105 | 272 if (is_sub) { |
33089 | 273 if (w && h) { |
33096 | 274 currWin->width = w; |
275 currWin->height = h; | |
32873 | 276 } |
33105 | 277 } |
32873 | 278 |
33105 | 279 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
32951 | 280 |
33105 | 281 if (!is_sub) { |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
282 #ifdef CONFIG_XSHAPE |
33555 | 283 if (!bpRenderMask(&currWin->Bitmap, &currWin->Mask)) { |
33114 | 284 skin_error(MSGTR_SKIN_NotEnoughMemory); |
285 return 1; | |
286 } | |
33096 | 287 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); |
23077 | 288 #else |
33096 | 289 currWin->Mask.Image = NULL; |
23077 | 290 #endif |
33105 | 291 } |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
292 |
33105 | 293 if (is_bar) |
33555 | 294 skin->playbarIsPresent = 1; |
33105 | 295 if (is_menu) |
296 skin->menuIsPresent = 1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
297 |
32873 | 298 return 0; |
23077 | 299 } |
300 | |
32873 | 301 // background=R,G,B |
33106 | 302 static int item_background(char *in) |
23077 | 303 { |
33106 | 304 if (!window_item("background")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
305 return 1; |
23077 | 306 |
33058 | 307 if (in_window("main")) |
308 return 1; | |
33088 | 309 if (in_window("playbar")) |
310 return 1; | |
33058 | 311 if (in_window("menu")) |
312 return 1; | |
23077 | 313 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
314 currWin->R = cutItemToInt(in, ',', 0); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
315 currWin->G = cutItemToInt(in, ',', 1); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
316 currWin->B = cutItemToInt(in, ',', 2); |
23077 | 317 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
318 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B); |
23077 | 319 |
32873 | 320 return 0; |
23077 | 321 } |
322 | |
32873 | 323 // button=image,x,y,width,height,message |
33106 | 324 static int item_button(char *in) |
23077 | 325 { |
33090 | 326 unsigned char fname[256]; |
33089 | 327 unsigned char file[512]; |
328 int x, y, w, h, message; | |
32873 | 329 char msg[32]; |
33098 | 330 wItem *item; |
32873 | 331 |
33106 | 332 if (!window_item("button")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
333 return 1; |
32873 | 334 |
33058 | 335 if (in_window("sub")) |
336 return 1; | |
337 if (in_window("menu")) | |
338 return 1; | |
23077 | 339 |
32873 | 340 cutItem(in, fname, ',', 0); |
33089 | 341 x = cutItemToInt(in, ',', 1); |
342 y = cutItemToInt(in, ',', 2); | |
343 w = cutItemToInt(in, ',', 3); | |
344 h = cutItemToInt(in, ',', 4); | |
32873 | 345 cutItem(in, msg, ',', 5); |
346 | |
33071 | 347 message = appFindMessage(msg); |
348 | |
349 if (message == -1) { | |
350 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
351 return 1; | |
352 } | |
353 | |
33102
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
354 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y); |
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
355 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
356 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", w, h); |
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
357 |
33098 | 358 item = next_item(); |
359 | |
360 if (!item) | |
361 return 1; | |
362 | |
363 item->type = itButton; | |
364 item->x = x; | |
365 item->y = y; | |
366 item->width = w; | |
367 item->height = h; | |
368 item->message = message; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
369 item->pressed = btnReleased; |
23077 | 370 |
33098 | 371 if (item->message == evPauseSwitchToPlay) |
372 item->pressed = btnDisabled; | |
23077 | 373 |
33098 | 374 item->Bitmap.Image = NULL; |
32873 | 375 |
376 if (strcmp(fname, "NULL") != 0) { | |
33089 | 377 av_strlcpy(file, path, sizeof(file)); |
378 av_strlcat(file, fname, sizeof(file)); | |
32873 | 379 |
33098 | 380 if (skinBPRead(file, &item->Bitmap) != 0) |
32873 | 381 return 1; |
32951 | 382 |
33098 | 383 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 384 } |
385 | |
386 return 0; | |
23077 | 387 } |
388 | |
32873 | 389 // selected=image |
33106 | 390 static int item_selected(char *in) |
32873 | 391 { |
33089 | 392 unsigned char file[512]; |
33096 | 393 wItem *currItem; |
32873 | 394 |
33106 | 395 if (!window_item("selected")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
396 return 1; |
32873 | 397 |
33058 | 398 if (in_window("main")) |
399 return 1; | |
400 if (in_window("sub")) | |
401 return 1; | |
402 if (in_window("playbar")) | |
403 return 1; | |
32873 | 404 |
33102
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
405 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image selected: %s\n", in); |
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
406 |
33096 | 407 currItem = &skin->menuSelected; |
408 currItem->type = itBase; | |
32873 | 409 |
33089 | 410 av_strlcpy(file, path, sizeof(file)); |
33091 | 411 av_strlcat(file, in, sizeof(file)); |
32873 | 412 |
33096 | 413 if (skinBPRead(file, &currItem->Bitmap) != 0) |
32873 | 414 return 1; |
415 | |
33096 | 416 currItem->width = currItem->Bitmap.Width; |
417 currItem->height = currItem->Bitmap.Height; | |
32873 | 418 |
33096 | 419 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currItem->width, currItem->height); |
32873 | 420 |
421 return 0; | |
422 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
423 |
32873 | 424 // menu=x,y,width,height,message |
33106 | 425 static int item_menu(char *in) |
32873 | 426 { |
33089 | 427 int x, y, w, h, message; |
33071 | 428 char msg[32]; |
33096 | 429 wItem *item; |
32873 | 430 |
33106 | 431 if (!window_item("menu")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
432 return 1; |
32873 | 433 |
33058 | 434 if (in_window("main")) |
435 return 1; | |
436 if (in_window("sub")) | |
437 return 1; | |
438 if (in_window("playbar")) | |
439 return 1; | |
32873 | 440 |
33089 | 441 x = cutItemToInt(in, ',', 0); |
442 y = cutItemToInt(in, ',', 1); | |
443 w = cutItemToInt(in, ',', 2); | |
444 h = cutItemToInt(in, ',', 3); | |
33071 | 445 cutItem(in, msg, ',', 4); |
446 | |
447 message = appFindMessage(msg); | |
23077 | 448 |
33071 | 449 if (message == -1) { |
450 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
451 return 1; | |
452 } | |
32873 | 453 |
33098 | 454 item = next_item(); |
455 | |
456 if (!item) | |
457 return 1; | |
458 | |
33100 | 459 item->type = itMenu; |
33096 | 460 item->x = x; |
461 item->y = y; | |
462 item->width = w; | |
463 item->height = h; | |
464 item->message = message; | |
23077 | 465 |
33096 | 466 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h); |
33071 | 467 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
23077 | 468 |
33096 | 469 item->Bitmap.Image = NULL; |
33053 | 470 |
32873 | 471 return 0; |
23077 | 472 } |
473 | |
32873 | 474 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
33106 | 475 static int item_hpotmeter(char *in) |
32873 | 476 { |
33090 | 477 unsigned char pfname[256]; |
478 unsigned char phfname[256]; | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
479 unsigned char buf[512]; |
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
480 int pwidth, pheight, ph, d, x, y, w, h, message; |
32873 | 481 wItem *item; |
23077 | 482 |
33106 | 483 if (!window_item("h/v potmeter")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
484 return 1; |
23077 | 485 |
33058 | 486 if (in_window("sub")) |
487 return 1; | |
488 if (in_window("menu")) | |
489 return 1; | |
23077 | 490 |
32873 | 491 cutItem(in, pfname, ',', 0); |
32911 | 492 pwidth = cutItemToInt(in, ',', 1); |
493 pheight = cutItemToInt(in, ',', 2); | |
32873 | 494 cutItem(in, phfname, ',', 3); |
495 ph = cutItemToInt(in, ',', 4); | |
496 d = cutItemToInt(in, ',', 5); | |
497 x = cutItemToInt(in, ',', 6); | |
498 y = cutItemToInt(in, ',', 7); | |
33089 | 499 w = cutItemToInt(in, ',', 8); |
500 h = cutItemToInt(in, ',', 9); | |
501 cutItem(in, buf, ',', 10); | |
32873 | 502 |
33089 | 503 message = appFindMessage(buf); |
23077 | 504 |
33069 | 505 if (message == -1) { |
33089 | 506 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 507 return 1; |
508 } | |
509 | |
33089 | 510 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 511 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); |
512 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
33089 | 513 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 514 |
33098 | 515 item = next_item(); |
516 | |
517 if (!item) | |
518 return 1; | |
519 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
520 item->type = itHPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
521 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
522 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
523 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
524 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
525 item->pwidth = pwidth; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
526 item->pheight = pheight; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
527 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
528 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
529 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
530 item->pressed = btnReleased; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
531 |
32873 | 532 item->Bitmap.Image = NULL; |
23077 | 533 |
32873 | 534 if (strcmp(phfname, "NULL") != 0) { |
33089 | 535 av_strlcpy(buf, path, sizeof(buf)); |
536 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 537 |
33089 | 538 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 539 return 1; |
32951 | 540 |
541 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 542 } |
543 | |
544 item->Mask.Image = NULL; | |
23077 | 545 |
32873 | 546 if (strcmp(pfname, "NULL") != 0) { |
33089 | 547 av_strlcpy(buf, path, sizeof(buf)); |
548 av_strlcat(buf, pfname, sizeof(buf)); | |
32873 | 549 |
33089 | 550 if (skinBPRead(buf, &item->Mask) != 0) |
32873 | 551 return 1; |
32951 | 552 |
553 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); | |
32873 | 554 } |
555 | |
556 return 0; | |
23077 | 557 } |
558 | |
32873 | 559 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
33106 | 560 static int item_vpotmeter(char *in) |
23077 | 561 { |
33056 | 562 int r; |
32873 | 563 wItem *item; |
23077 | 564 |
33106 | 565 r = item_hpotmeter(in); |
33056 | 566 |
567 if (r == 0) { | |
33057 | 568 item = &currWinItems[*currWinItemIdx]; |
569 item->type = itVPotmeter; | |
33056 | 570 } |
33053 | 571 |
32873 | 572 return r; |
23077 | 573 } |
574 | |
32873 | 575 // potmeter=phases,numphases,default,x,y,width,height,message |
33106 | 576 static int item_potmeter(char *in) |
32873 | 577 { |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
578 unsigned char phfname[256]; |
33089 | 579 unsigned char buf[512]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
580 int ph, d, x, y, w, h, message; |
32873 | 581 wItem *item; |
23077 | 582 |
33106 | 583 if (!window_item("potmeter")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
584 return 1; |
23077 | 585 |
33058 | 586 if (in_window("sub")) |
587 return 1; | |
588 if (in_window("menu")) | |
589 return 1; | |
23077 | 590 |
32873 | 591 cutItem(in, phfname, ',', 0); |
592 ph = cutItemToInt(in, ',', 1); | |
593 d = cutItemToInt(in, ',', 2); | |
594 x = cutItemToInt(in, ',', 3); | |
595 y = cutItemToInt(in, ',', 4); | |
33089 | 596 w = cutItemToInt(in, ',', 5); |
597 h = cutItemToInt(in, ',', 6); | |
598 cutItem(in, buf, ',', 7); | |
32873 | 599 |
33089 | 600 message = appFindMessage(buf); |
23077 | 601 |
33069 | 602 if (message == -1) { |
33089 | 603 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 604 return 1; |
605 } | |
606 | |
33089 | 607 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 608 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); |
33089 | 609 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 610 |
33098 | 611 item = next_item(); |
612 | |
613 if (!item) | |
614 return 1; | |
615 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
616 item->type = itPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
617 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
618 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
619 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
620 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
621 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
622 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
623 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
624 |
32873 | 625 item->Bitmap.Image = NULL; |
23077 | 626 |
32873 | 627 if (strcmp(phfname, "NULL") != 0) { |
33089 | 628 av_strlcpy(buf, path, sizeof(buf)); |
629 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 630 |
33089 | 631 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 632 return 1; |
32951 | 633 |
634 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 635 } |
636 | |
637 return 0; | |
23077 | 638 } |
639 | |
32873 | 640 // font=fontfile |
33106 | 641 static int item_font(char *in) |
32873 | 642 { |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
643 char fnt[256]; |
23077 | 644 |
33106 | 645 if (!window_item("font")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
646 return 1; |
23077 | 647 |
33058 | 648 if (in_window("sub")) |
649 return 1; | |
650 if (in_window("menu")) | |
651 return 1; | |
23077 | 652 |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
653 cutItem(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility |
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
654 // reasons with a meanwhile depreciated second parameter. |
33099
0b17f6bed6fc
Don't needlessly store font information in the wItems array
ib
parents:
33098
diff
changeset
|
655 switch (fntRead(path, fnt)) { |
32873 | 656 case -1: |
33097 | 657 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 658 return 1; |
23077 | 659 |
32873 | 660 case -2: |
33022 | 661 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); |
32873 | 662 return 1; |
663 | |
664 case -3: | |
33022 | 665 skin_error(MSGTR_SKIN_FONT_FontFileNotFound); |
32873 | 666 return 1; |
667 | |
668 case -4: | |
33022 | 669 skin_error(MSGTR_SKIN_FONT_FontImageNotFound); |
32873 | 670 return 1; |
671 } | |
672 | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
673 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); |
32951 | 674 |
32873 | 675 return 0; |
23077 | 676 } |
677 | |
32873 | 678 // slabel=x,y,fontfile,"text" |
33106 | 679 static int item_slabel(char *in) |
23077 | 680 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
681 int x, y, id; |
33090 | 682 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
683 char txt[256]; |
32873 | 684 wItem *item; |
685 | |
33106 | 686 if (!window_item("slabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
687 return 1; |
23077 | 688 |
33058 | 689 if (in_window("sub")) |
690 return 1; | |
691 if (in_window("menu")) | |
692 return 1; | |
32873 | 693 |
694 x = cutItemToInt(in, ',', 0); | |
695 y = cutItemToInt(in, ',', 1); | |
33089 | 696 cutItem(in, fnt, ',', 2); |
697 cutItem(in, txt, ',', 3); | |
698 cutItem(txt, txt, '"', 1); | |
32951 | 699 |
33089 | 700 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt); |
32951 | 701 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
23077 | 702 |
33089 | 703 id = fntFindID(fnt); |
23077 | 704 |
32873 | 705 if (id < 0) { |
33097 | 706 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt); |
32873 | 707 return 1; |
708 } | |
23077 | 709 |
33089 | 710 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 711 |
33098 | 712 item = next_item(); |
713 | |
714 if (!item) | |
715 return 1; | |
716 | |
32873 | 717 item->type = itSLabel; |
718 item->x = x; | |
719 item->y = y; | |
720 item->width = -1; | |
721 item->height = -1; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
722 item->fontid = id; |
33089 | 723 item->label = strdup(txt); |
23077 | 724 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
725 if (!item->label) { |
33097 | 726 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 727 return 1; |
728 } | |
23077 | 729 |
32873 | 730 return 0; |
23077 | 731 } |
732 | |
32910 | 733 // dlabel=x,y,width,align,fontfile,"text" |
33106 | 734 static int item_dlabel(char *in) |
32873 | 735 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
736 int x, y, w, a, id; |
33090 | 737 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
738 char txt[256]; |
32873 | 739 wItem *item; |
23077 | 740 |
33106 | 741 if (!window_item("dlabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
742 return 1; |
23077 | 743 |
33058 | 744 if (in_window("sub")) |
745 return 1; | |
746 if (in_window("menu")) | |
747 return 1; | |
32873 | 748 |
33089 | 749 x = cutItemToInt(in, ',', 0); |
750 y = cutItemToInt(in, ',', 1); | |
751 w = cutItemToInt(in, ',', 2); | |
752 a = cutItemToInt(in, ',', 3); | |
753 cutItem(in, fnt, ',', 4); | |
754 cutItem(in, txt, ',', 5); | |
755 cutItem(txt, txt, '"', 1); | |
32951 | 756 |
33089 | 757 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); |
32951 | 758 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
33089 | 759 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); |
23077 | 760 |
33089 | 761 id = fntFindID(fnt); |
23077 | 762 |
32873 | 763 if (id < 0) { |
33097 | 764 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt); |
32873 | 765 return 1; |
766 } | |
23077 | 767 |
33089 | 768 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 769 |
33098 | 770 item = next_item(); |
771 | |
772 if (!item) | |
773 return 1; | |
774 | |
32873 | 775 item->type = itDLabel; |
776 item->x = x; | |
777 item->y = y; | |
33089 | 778 item->width = w; |
32873 | 779 item->height = -1; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
780 item->fontid = id; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
781 item->align = a; |
33089 | 782 item->label = strdup(txt); |
23077 | 783 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
784 if (!item->label) { |
33097 | 785 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 786 return 1; |
787 } | |
23077 | 788 |
32873 | 789 return 0; |
23077 | 790 } |
791 | |
32873 | 792 // decoration=enable|disable |
33106 | 793 static int item_decoration(char *in) |
23077 | 794 { |
33106 | 795 if (!window_item("decoration")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
796 return 1; |
32873 | 797 |
33058 | 798 if (in_window("sub")) |
799 return 1; | |
800 if (in_window("playbar")) | |
801 return 1; | |
802 if (in_window("menu")) | |
803 return 1; | |
32873 | 804 |
33086 | 805 strlower(in); |
32873 | 806 |
33086 | 807 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
808 skin_error(MSGTR_SKIN_UnknownParameter, in); | |
32873 | 809 return 1; |
810 } | |
23077 | 811 |
33087 | 812 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 813 |
33086 | 814 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in); |
32873 | 815 |
816 return 0; | |
23077 | 817 } |
818 | |
32878 | 819 static _item skinItem[] = { |
33106 | 820 { "background", item_background }, |
821 { "base", item_base }, | |
822 { "button", item_button }, | |
823 { "decoration", item_decoration }, | |
824 { "dlabel", item_dlabel }, | |
825 { "end", item_end }, | |
826 { "font", item_font }, | |
827 { "hpotmeter", item_hpotmeter }, | |
828 { "menu", item_menu }, | |
829 { "potmeter", item_potmeter }, | |
830 { "section", item_section }, | |
831 { "selected", item_selected }, | |
832 { "slabel", item_slabel }, | |
833 { "vpotmeter", item_vpotmeter }, | |
834 { "window", item_window } | |
32873 | 835 }; |
836 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
837 static char *setname(char *dir, char *sname) |
32873 | 838 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
839 static char skinfname[512]; |
32873 | 840 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
841 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
842 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
843 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
844 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
845 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
846 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 847 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
848 return skinfname; |
23077 | 849 } |
850 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
851 int skinRead(char *sname) |
23077 | 852 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
853 char *skinfname; |
32873 | 854 FILE *skinFile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
855 unsigned char line[256]; |
33075 | 856 unsigned char item[32]; |
32873 | 857 unsigned char param[256]; |
32944 | 858 unsigned int i; |
32873 | 859 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
860 skinfname = setname(skinDirInHome, sname); |
23077 | 861 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
862 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
863 skinfname = setname(skinMPlayerDir, sname); |
32873 | 864 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
865 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
866 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname); |
32873 | 867 return -1; |
868 } | |
23077 | 869 } |
32873 | 870 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
871 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 872 |
32932 | 873 appFreeStruct(); |
23077 | 874 |
33078 | 875 skin = NULL; |
876 currWinName[0] = 0; | |
33079 | 877 linenumber = 0; |
23077 | 878 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
879 while (fgets(line, sizeof(line), skinFile)) { |
32873 | 880 linenumber++; |
881 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
882 line[strcspn(line, "\n\r")] = 0; // remove any kind of newline, if any |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
883 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
884 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
885 decomment(line); |
32873 | 886 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
887 if (!*line) |
32873 | 888 continue; |
23077 | 889 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
890 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
891 cutItem(line, param, '=', 1); |
33075 | 892 strlower(item); |
32873 | 893 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
894 for (i = 0; i < FF_ARRAY_ELEMS(skinItem); i++) { |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
895 if (!strcmp(item, skinItem[i].name)) { |
32873 | 896 if (skinItem[i].func(param) != 0) |
897 return -2; | |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
898 else |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
899 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
900 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
901 } |
33077 | 902 |
903 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
904 skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item); | |
905 return -2; | |
906 } | |
32873 | 907 } |
908 | |
909 if (linenumber == 0) { | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
910 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname); |
32873 | 911 return -1; |
912 } | |
913 | |
914 return 0; | |
23077 | 915 } |