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