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