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