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