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