Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 33115:c2da7b725fd8
Use appropriate data type uint32_t for 32 bpp bitmap data.
Don't use int. Besides, rename variable holding transparent color.
author | ib |
---|---|
date | Mon, 04 Apr 2011 13:02:56 +0000 |
parents | 5ad451a5ebec |
children | 5f3171d4d7a4 |
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 |
33114 | 280 if (!Convert32to1(&currWin->Bitmap, &currWin->Mask, 0x00ff00ff)) { |
281 skin_error(MSGTR_SKIN_NotEnoughMemory); | |
282 return 1; | |
283 } | |
33096 | 284 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); |
23077 | 285 #else |
33096 | 286 currWin->Mask.Image = NULL; |
23077 | 287 #endif |
33105 | 288 } |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
289 |
33105 | 290 if (is_bar) |
291 skin->barIsPresent = 1; | |
292 if (is_menu) | |
293 skin->menuIsPresent = 1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
294 |
32873 | 295 return 0; |
23077 | 296 } |
297 | |
32873 | 298 // background=R,G,B |
33106 | 299 static int item_background(char *in) |
23077 | 300 { |
33106 | 301 if (!window_item("background")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
302 return 1; |
23077 | 303 |
33058 | 304 if (in_window("main")) |
305 return 1; | |
33088 | 306 if (in_window("playbar")) |
307 return 1; | |
33058 | 308 if (in_window("menu")) |
309 return 1; | |
23077 | 310 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
311 currWin->R = cutItemToInt(in, ',', 0); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
312 currWin->G = cutItemToInt(in, ',', 1); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
313 currWin->B = cutItemToInt(in, ',', 2); |
23077 | 314 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
315 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B); |
23077 | 316 |
32873 | 317 return 0; |
23077 | 318 } |
319 | |
32873 | 320 // button=image,x,y,width,height,message |
33106 | 321 static int item_button(char *in) |
23077 | 322 { |
33090 | 323 unsigned char fname[256]; |
33089 | 324 unsigned char file[512]; |
325 int x, y, w, h, message; | |
32873 | 326 char msg[32]; |
33098 | 327 wItem *item; |
32873 | 328 |
33106 | 329 if (!window_item("button")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
330 return 1; |
32873 | 331 |
33058 | 332 if (in_window("sub")) |
333 return 1; | |
334 if (in_window("menu")) | |
335 return 1; | |
23077 | 336 |
32873 | 337 cutItem(in, fname, ',', 0); |
33089 | 338 x = cutItemToInt(in, ',', 1); |
339 y = cutItemToInt(in, ',', 2); | |
340 w = cutItemToInt(in, ',', 3); | |
341 h = cutItemToInt(in, ',', 4); | |
32873 | 342 cutItem(in, msg, ',', 5); |
343 | |
33071 | 344 message = appFindMessage(msg); |
345 | |
346 if (message == -1) { | |
347 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
348 return 1; | |
349 } | |
350 | |
33102
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
351 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
|
352 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
|
353 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
|
354 |
33098 | 355 item = next_item(); |
356 | |
357 if (!item) | |
358 return 1; | |
359 | |
360 item->type = itButton; | |
361 item->x = x; | |
362 item->y = y; | |
363 item->width = w; | |
364 item->height = h; | |
365 item->message = message; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
366 item->pressed = btnReleased; |
23077 | 367 |
33098 | 368 if (item->message == evPauseSwitchToPlay) |
369 item->pressed = btnDisabled; | |
23077 | 370 |
33098 | 371 item->Bitmap.Image = NULL; |
32873 | 372 |
373 if (strcmp(fname, "NULL") != 0) { | |
33089 | 374 av_strlcpy(file, path, sizeof(file)); |
375 av_strlcat(file, fname, sizeof(file)); | |
32873 | 376 |
33098 | 377 if (skinBPRead(file, &item->Bitmap) != 0) |
32873 | 378 return 1; |
32951 | 379 |
33098 | 380 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 381 } |
382 | |
383 return 0; | |
23077 | 384 } |
385 | |
32873 | 386 // selected=image |
33106 | 387 static int item_selected(char *in) |
32873 | 388 { |
33089 | 389 unsigned char file[512]; |
33096 | 390 wItem *currItem; |
32873 | 391 |
33106 | 392 if (!window_item("selected")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
393 return 1; |
32873 | 394 |
33058 | 395 if (in_window("main")) |
396 return 1; | |
397 if (in_window("sub")) | |
398 return 1; | |
399 if (in_window("playbar")) | |
400 return 1; | |
32873 | 401 |
33102
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
402 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
|
403 |
33096 | 404 currItem = &skin->menuSelected; |
405 currItem->type = itBase; | |
32873 | 406 |
33089 | 407 av_strlcpy(file, path, sizeof(file)); |
33091 | 408 av_strlcat(file, in, sizeof(file)); |
32873 | 409 |
33096 | 410 if (skinBPRead(file, &currItem->Bitmap) != 0) |
32873 | 411 return 1; |
412 | |
33096 | 413 currItem->width = currItem->Bitmap.Width; |
414 currItem->height = currItem->Bitmap.Height; | |
32873 | 415 |
33096 | 416 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currItem->width, currItem->height); |
32873 | 417 |
418 return 0; | |
419 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
420 |
32873 | 421 // menu=x,y,width,height,message |
33106 | 422 static int item_menu(char *in) |
32873 | 423 { |
33089 | 424 int x, y, w, h, message; |
33071 | 425 char msg[32]; |
33096 | 426 wItem *item; |
32873 | 427 |
33106 | 428 if (!window_item("menu")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
429 return 1; |
32873 | 430 |
33058 | 431 if (in_window("main")) |
432 return 1; | |
433 if (in_window("sub")) | |
434 return 1; | |
435 if (in_window("playbar")) | |
436 return 1; | |
32873 | 437 |
33089 | 438 x = cutItemToInt(in, ',', 0); |
439 y = cutItemToInt(in, ',', 1); | |
440 w = cutItemToInt(in, ',', 2); | |
441 h = cutItemToInt(in, ',', 3); | |
33071 | 442 cutItem(in, msg, ',', 4); |
443 | |
444 message = appFindMessage(msg); | |
23077 | 445 |
33071 | 446 if (message == -1) { |
447 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
448 return 1; | |
449 } | |
32873 | 450 |
33098 | 451 item = next_item(); |
452 | |
453 if (!item) | |
454 return 1; | |
455 | |
33100 | 456 item->type = itMenu; |
33096 | 457 item->x = x; |
458 item->y = y; | |
459 item->width = w; | |
460 item->height = h; | |
461 item->message = message; | |
23077 | 462 |
33096 | 463 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h); |
33071 | 464 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
23077 | 465 |
33096 | 466 item->Bitmap.Image = NULL; |
33053 | 467 |
32873 | 468 return 0; |
23077 | 469 } |
470 | |
32873 | 471 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
33106 | 472 static int item_hpotmeter(char *in) |
32873 | 473 { |
33090 | 474 unsigned char pfname[256]; |
475 unsigned char phfname[256]; | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
476 unsigned char buf[512]; |
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
477 int pwidth, pheight, ph, d, x, y, w, h, message; |
32873 | 478 wItem *item; |
23077 | 479 |
33106 | 480 if (!window_item("h/v potmeter")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
481 return 1; |
23077 | 482 |
33058 | 483 if (in_window("sub")) |
484 return 1; | |
485 if (in_window("menu")) | |
486 return 1; | |
23077 | 487 |
32873 | 488 cutItem(in, pfname, ',', 0); |
32911 | 489 pwidth = cutItemToInt(in, ',', 1); |
490 pheight = cutItemToInt(in, ',', 2); | |
32873 | 491 cutItem(in, phfname, ',', 3); |
492 ph = cutItemToInt(in, ',', 4); | |
493 d = cutItemToInt(in, ',', 5); | |
494 x = cutItemToInt(in, ',', 6); | |
495 y = cutItemToInt(in, ',', 7); | |
33089 | 496 w = cutItemToInt(in, ',', 8); |
497 h = cutItemToInt(in, ',', 9); | |
498 cutItem(in, buf, ',', 10); | |
32873 | 499 |
33089 | 500 message = appFindMessage(buf); |
23077 | 501 |
33069 | 502 if (message == -1) { |
33089 | 503 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 504 return 1; |
505 } | |
506 | |
33089 | 507 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 508 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); |
509 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
33089 | 510 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 511 |
33098 | 512 item = next_item(); |
513 | |
514 if (!item) | |
515 return 1; | |
516 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
517 item->type = itHPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
518 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
519 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
520 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
521 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
522 item->pwidth = pwidth; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
523 item->pheight = pheight; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
524 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
525 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
526 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
527 item->pressed = btnReleased; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
528 |
32873 | 529 item->Bitmap.Image = NULL; |
23077 | 530 |
32873 | 531 if (strcmp(phfname, "NULL") != 0) { |
33089 | 532 av_strlcpy(buf, path, sizeof(buf)); |
533 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 534 |
33089 | 535 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 536 return 1; |
32951 | 537 |
538 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 539 } |
540 | |
541 item->Mask.Image = NULL; | |
23077 | 542 |
32873 | 543 if (strcmp(pfname, "NULL") != 0) { |
33089 | 544 av_strlcpy(buf, path, sizeof(buf)); |
545 av_strlcat(buf, pfname, sizeof(buf)); | |
32873 | 546 |
33089 | 547 if (skinBPRead(buf, &item->Mask) != 0) |
32873 | 548 return 1; |
32951 | 549 |
550 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); | |
32873 | 551 } |
552 | |
553 return 0; | |
23077 | 554 } |
555 | |
32873 | 556 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
33106 | 557 static int item_vpotmeter(char *in) |
23077 | 558 { |
33056 | 559 int r; |
32873 | 560 wItem *item; |
23077 | 561 |
33106 | 562 r = item_hpotmeter(in); |
33056 | 563 |
564 if (r == 0) { | |
33057 | 565 item = &currWinItems[*currWinItemIdx]; |
566 item->type = itVPotmeter; | |
33056 | 567 } |
33053 | 568 |
32873 | 569 return r; |
23077 | 570 } |
571 | |
32873 | 572 // potmeter=phases,numphases,default,x,y,width,height,message |
33106 | 573 static int item_potmeter(char *in) |
32873 | 574 { |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
575 unsigned char phfname[256]; |
33089 | 576 unsigned char buf[512]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
577 int ph, d, x, y, w, h, message; |
32873 | 578 wItem *item; |
23077 | 579 |
33106 | 580 if (!window_item("potmeter")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
581 return 1; |
23077 | 582 |
33058 | 583 if (in_window("sub")) |
584 return 1; | |
585 if (in_window("menu")) | |
586 return 1; | |
23077 | 587 |
32873 | 588 cutItem(in, phfname, ',', 0); |
589 ph = cutItemToInt(in, ',', 1); | |
590 d = cutItemToInt(in, ',', 2); | |
591 x = cutItemToInt(in, ',', 3); | |
592 y = cutItemToInt(in, ',', 4); | |
33089 | 593 w = cutItemToInt(in, ',', 5); |
594 h = cutItemToInt(in, ',', 6); | |
595 cutItem(in, buf, ',', 7); | |
32873 | 596 |
33089 | 597 message = appFindMessage(buf); |
23077 | 598 |
33069 | 599 if (message == -1) { |
33089 | 600 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 601 return 1; |
602 } | |
603 | |
33089 | 604 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 605 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); |
33089 | 606 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 607 |
33098 | 608 item = next_item(); |
609 | |
610 if (!item) | |
611 return 1; | |
612 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
613 item->type = itPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
614 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
615 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
616 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
617 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
618 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
619 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
620 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
621 |
32873 | 622 item->Bitmap.Image = NULL; |
23077 | 623 |
32873 | 624 if (strcmp(phfname, "NULL") != 0) { |
33089 | 625 av_strlcpy(buf, path, sizeof(buf)); |
626 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 627 |
33089 | 628 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 629 return 1; |
32951 | 630 |
631 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 632 } |
633 | |
634 return 0; | |
23077 | 635 } |
636 | |
32873 | 637 // font=fontfile |
33106 | 638 static int item_font(char *in) |
32873 | 639 { |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
640 char fnt[256]; |
23077 | 641 |
33106 | 642 if (!window_item("font")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
643 return 1; |
23077 | 644 |
33058 | 645 if (in_window("sub")) |
646 return 1; | |
647 if (in_window("menu")) | |
648 return 1; | |
23077 | 649 |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
650 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
|
651 // reasons with a meanwhile depreciated second parameter. |
33099
0b17f6bed6fc
Don't needlessly store font information in the wItems array
ib
parents:
33098
diff
changeset
|
652 switch (fntRead(path, fnt)) { |
32873 | 653 case -1: |
33097 | 654 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 655 return 1; |
23077 | 656 |
32873 | 657 case -2: |
33022 | 658 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); |
32873 | 659 return 1; |
660 | |
661 case -3: | |
33022 | 662 skin_error(MSGTR_SKIN_FONT_FontFileNotFound); |
32873 | 663 return 1; |
664 | |
665 case -4: | |
33022 | 666 skin_error(MSGTR_SKIN_FONT_FontImageNotFound); |
32873 | 667 return 1; |
668 } | |
669 | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
670 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); |
32951 | 671 |
32873 | 672 return 0; |
23077 | 673 } |
674 | |
32873 | 675 // slabel=x,y,fontfile,"text" |
33106 | 676 static int item_slabel(char *in) |
23077 | 677 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
678 int x, y, id; |
33090 | 679 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
680 char txt[256]; |
32873 | 681 wItem *item; |
682 | |
33106 | 683 if (!window_item("slabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
684 return 1; |
23077 | 685 |
33058 | 686 if (in_window("sub")) |
687 return 1; | |
688 if (in_window("menu")) | |
689 return 1; | |
32873 | 690 |
691 x = cutItemToInt(in, ',', 0); | |
692 y = cutItemToInt(in, ',', 1); | |
33089 | 693 cutItem(in, fnt, ',', 2); |
694 cutItem(in, txt, ',', 3); | |
695 cutItem(txt, txt, '"', 1); | |
32951 | 696 |
33089 | 697 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt); |
32951 | 698 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
23077 | 699 |
33089 | 700 id = fntFindID(fnt); |
23077 | 701 |
32873 | 702 if (id < 0) { |
33097 | 703 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt); |
32873 | 704 return 1; |
705 } | |
23077 | 706 |
33089 | 707 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 708 |
33098 | 709 item = next_item(); |
710 | |
711 if (!item) | |
712 return 1; | |
713 | |
32873 | 714 item->type = itSLabel; |
715 item->x = x; | |
716 item->y = y; | |
717 item->width = -1; | |
718 item->height = -1; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
719 item->fontid = id; |
33089 | 720 item->label = strdup(txt); |
23077 | 721 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
722 if (!item->label) { |
33097 | 723 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 724 return 1; |
725 } | |
23077 | 726 |
32873 | 727 return 0; |
23077 | 728 } |
729 | |
32910 | 730 // dlabel=x,y,width,align,fontfile,"text" |
33106 | 731 static int item_dlabel(char *in) |
32873 | 732 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
733 int x, y, w, a, id; |
33090 | 734 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
735 char txt[256]; |
32873 | 736 wItem *item; |
23077 | 737 |
33106 | 738 if (!window_item("dlabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
739 return 1; |
23077 | 740 |
33058 | 741 if (in_window("sub")) |
742 return 1; | |
743 if (in_window("menu")) | |
744 return 1; | |
32873 | 745 |
33089 | 746 x = cutItemToInt(in, ',', 0); |
747 y = cutItemToInt(in, ',', 1); | |
748 w = cutItemToInt(in, ',', 2); | |
749 a = cutItemToInt(in, ',', 3); | |
750 cutItem(in, fnt, ',', 4); | |
751 cutItem(in, txt, ',', 5); | |
752 cutItem(txt, txt, '"', 1); | |
32951 | 753 |
33089 | 754 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); |
32951 | 755 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
33089 | 756 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); |
23077 | 757 |
33089 | 758 id = fntFindID(fnt); |
23077 | 759 |
32873 | 760 if (id < 0) { |
33097 | 761 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt); |
32873 | 762 return 1; |
763 } | |
23077 | 764 |
33089 | 765 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 766 |
33098 | 767 item = next_item(); |
768 | |
769 if (!item) | |
770 return 1; | |
771 | |
32873 | 772 item->type = itDLabel; |
773 item->x = x; | |
774 item->y = y; | |
33089 | 775 item->width = w; |
32873 | 776 item->height = -1; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
777 item->fontid = id; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
778 item->align = a; |
33089 | 779 item->label = strdup(txt); |
23077 | 780 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
781 if (!item->label) { |
33097 | 782 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 783 return 1; |
784 } | |
23077 | 785 |
32873 | 786 return 0; |
23077 | 787 } |
788 | |
32873 | 789 // decoration=enable|disable |
33106 | 790 static int item_decoration(char *in) |
23077 | 791 { |
33106 | 792 if (!window_item("decoration")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
793 return 1; |
32873 | 794 |
33058 | 795 if (in_window("sub")) |
796 return 1; | |
797 if (in_window("playbar")) | |
798 return 1; | |
799 if (in_window("menu")) | |
800 return 1; | |
32873 | 801 |
33086 | 802 strlower(in); |
32873 | 803 |
33086 | 804 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
805 skin_error(MSGTR_SKIN_UnknownParameter, in); | |
32873 | 806 return 1; |
807 } | |
23077 | 808 |
33087 | 809 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 810 |
33086 | 811 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in); |
32873 | 812 |
813 return 0; | |
23077 | 814 } |
815 | |
32878 | 816 static _item skinItem[] = { |
33106 | 817 { "background", item_background }, |
818 { "base", item_base }, | |
819 { "button", item_button }, | |
820 { "decoration", item_decoration }, | |
821 { "dlabel", item_dlabel }, | |
822 { "end", item_end }, | |
823 { "font", item_font }, | |
824 { "hpotmeter", item_hpotmeter }, | |
825 { "menu", item_menu }, | |
826 { "potmeter", item_potmeter }, | |
827 { "section", item_section }, | |
828 { "selected", item_selected }, | |
829 { "slabel", item_slabel }, | |
830 { "vpotmeter", item_vpotmeter }, | |
831 { "window", item_window } | |
32873 | 832 }; |
833 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
834 static char *setname(char *dir, char *sname) |
32873 | 835 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
836 static char skinfname[512]; |
32873 | 837 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
838 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
839 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
840 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
841 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
842 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
843 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 844 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
845 return skinfname; |
23077 | 846 } |
847 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
848 int skinRead(char *sname) |
23077 | 849 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
850 char *skinfname; |
32873 | 851 FILE *skinFile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
852 unsigned char line[256]; |
33075 | 853 unsigned char item[32]; |
32873 | 854 unsigned char param[256]; |
32944 | 855 unsigned int i; |
32873 | 856 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
857 skinfname = setname(skinDirInHome, sname); |
23077 | 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 skinfname = setname(skinMPlayerDir, sname); |
32873 | 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 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname); |
32873 | 864 return -1; |
865 } | |
23077 | 866 } |
32873 | 867 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
868 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 869 |
32932 | 870 appFreeStruct(); |
23077 | 871 |
33078 | 872 skin = NULL; |
873 currWinName[0] = 0; | |
33079 | 874 linenumber = 0; |
23077 | 875 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
876 while (fgets(line, sizeof(line), skinFile)) { |
32873 | 877 linenumber++; |
878 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
879 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
|
880 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
881 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
882 decomment(line); |
32873 | 883 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
884 if (!*line) |
32873 | 885 continue; |
23077 | 886 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
887 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
888 cutItem(line, param, '=', 1); |
33075 | 889 strlower(item); |
32873 | 890 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
891 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
|
892 if (!strcmp(item, skinItem[i].name)) { |
32873 | 893 if (skinItem[i].func(param) != 0) |
894 return -2; | |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
895 else |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
896 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
897 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
898 } |
33077 | 899 |
900 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
901 skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item); | |
902 return -2; | |
903 } | |
32873 | 904 } |
905 | |
906 if (linenumber == 0) { | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
907 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname); |
32873 | 908 return -1; |
909 } | |
910 | |
911 return 0; | |
23077 | 912 } |