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