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