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