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