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