Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 33069:4b7d4905862c
Rename error message and add missing checks.
MSGTR_SKIN_BITMAP_UnknownMessage has nothing to do with bitmaps.
The return codes have been changed (resp. added) to indicate the error.
author | ib |
---|---|
date | Wed, 30 Mar 2011 12:07:54 +0000 |
parents | 2d0058f30a6b |
children | f4895241bdd5 |
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) { |
33069 | 383 skin_error(MSGTR_SKIN_UnknownMessage, msg); |
384 return 1; | |
32873 | 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 |
33069 | 480 if ((skin->menuItems[skin->IndexOfMenuItems].message = message) == -1) { |
481 skin_error(MSGTR_SKIN_UnknownMessage, tmp); | |
482 return 1; | |
483 } | |
23077 | 484 |
32951 | 485 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, skin->menuItems[skin->IndexOfMenuItems].message); |
23077 | 486 |
32937 | 487 skin->menuItems[skin->IndexOfMenuItems].Bitmap.Image = NULL; |
33053 | 488 |
32873 | 489 return 0; |
23077 | 490 } |
491 | |
32873 | 492 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
493 static int cmd_hpotmeter(char *in) | |
494 { | |
32911 | 495 int x, y, pwidth, pheight, ph, sx, sy, message, d; |
32873 | 496 unsigned char tmp[512]; |
497 unsigned char pfname[512]; | |
498 unsigned char phfname[512]; | |
499 wItem *item; | |
23077 | 500 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
501 if (!window_cmd("h/v potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
502 return 1; |
23077 | 503 |
33058 | 504 if (in_window("sub")) |
505 return 1; | |
506 if (in_window("menu")) | |
507 return 1; | |
23077 | 508 |
32873 | 509 cutItem(in, pfname, ',', 0); |
32911 | 510 pwidth = cutItemToInt(in, ',', 1); |
511 pheight = cutItemToInt(in, ',', 2); | |
32873 | 512 cutItem(in, phfname, ',', 3); |
513 ph = cutItemToInt(in, ',', 4); | |
514 d = cutItemToInt(in, ',', 5); | |
515 x = cutItemToInt(in, ',', 6); | |
516 y = cutItemToInt(in, ',', 7); | |
517 sx = cutItemToInt(in, ',', 8); | |
518 sy = cutItemToInt(in, ',', 9); | |
519 cutItem(in, tmp, ',', 10); | |
520 | |
32911 | 521 message = appFindMessage(tmp); |
23077 | 522 |
33069 | 523 if (message == -1) { |
524 skin_error(MSGTR_SKIN_UnknownMessage, tmp); | |
525 return 1; | |
526 } | |
527 | |
32951 | 528 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy); |
529 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); | |
530 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
531 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message); | |
23077 | 532 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
533 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
534 item = &currWinItems[*currWinItemIdx]; |
32873 | 535 item->type = itHPotmeter; |
536 item->x = x; | |
537 item->y = y; | |
538 item->width = sx; | |
539 item->height = sy; | |
32911 | 540 item->numphases = ph; |
541 item->pwidth = pwidth; | |
542 item->pheight = pheight; | |
543 item->message = message; | |
32873 | 544 item->value = (float)d; |
545 item->pressed = btnReleased; | |
546 item->Bitmap.Image = NULL; | |
23077 | 547 |
32873 | 548 if (strcmp(phfname, "NULL") != 0) { |
549 av_strlcpy(tmp, path, sizeof(tmp)); | |
550 av_strlcat(tmp, phfname, sizeof(tmp)); | |
551 | |
552 if (skinBPRead(tmp, &item->Bitmap) != 0) | |
553 return 1; | |
32951 | 554 |
555 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 556 } |
557 | |
558 item->Mask.Image = NULL; | |
23077 | 559 |
32873 | 560 if (strcmp(pfname, "NULL") != 0) { |
561 av_strlcpy(tmp, path, sizeof(tmp)); | |
562 av_strlcat(tmp, pfname, sizeof(tmp)); | |
563 | |
564 if (skinBPRead(tmp, &item->Mask) != 0) | |
565 return 1; | |
32951 | 566 |
567 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); | |
32873 | 568 } |
569 | |
570 return 0; | |
23077 | 571 } |
572 | |
32873 | 573 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
574 static int cmd_vpotmeter(char *in) | |
23077 | 575 { |
33056 | 576 int r; |
32873 | 577 wItem *item; |
23077 | 578 |
33056 | 579 r = cmd_hpotmeter(in); |
580 | |
581 if (r == 0) { | |
33057 | 582 item = &currWinItems[*currWinItemIdx]; |
583 item->type = itVPotmeter; | |
33056 | 584 } |
33053 | 585 |
32873 | 586 return r; |
23077 | 587 } |
588 | |
32873 | 589 // potmeter=phases,numphases,default,x,y,width,height,message |
590 static int cmd_potmeter(char *in) | |
591 { | |
32911 | 592 int x, y, ph, sx, sy, message, d; |
32873 | 593 unsigned char tmp[512]; |
594 unsigned char phfname[512]; | |
595 wItem *item; | |
23077 | 596 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
597 if (!window_cmd("potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
598 return 1; |
23077 | 599 |
33058 | 600 if (in_window("sub")) |
601 return 1; | |
602 if (in_window("menu")) | |
603 return 1; | |
23077 | 604 |
32873 | 605 cutItem(in, phfname, ',', 0); |
606 ph = cutItemToInt(in, ',', 1); | |
607 d = cutItemToInt(in, ',', 2); | |
608 x = cutItemToInt(in, ',', 3); | |
609 y = cutItemToInt(in, ',', 4); | |
610 sx = cutItemToInt(in, ',', 5); | |
611 sy = cutItemToInt(in, ',', 6); | |
612 cutItem(in, tmp, ',', 7); | |
613 | |
32911 | 614 message = appFindMessage(tmp); |
23077 | 615 |
33069 | 616 if (message == -1) { |
617 skin_error(MSGTR_SKIN_UnknownMessage, tmp); | |
618 return 1; | |
619 } | |
620 | |
32951 | 621 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy); |
622 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
623 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message); | |
23077 | 624 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
625 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
626 item = &currWinItems[*currWinItemIdx]; |
32873 | 627 item->type = itPotmeter; |
628 item->x = x; | |
629 item->y = y; | |
630 item->width = sx; | |
631 item->height = sy; | |
32911 | 632 item->numphases = ph; |
633 item->message = message; | |
32873 | 634 item->value = (float)d; |
635 item->Bitmap.Image = NULL; | |
23077 | 636 |
32873 | 637 if (strcmp(phfname, "NULL") != 0) { |
638 av_strlcpy(tmp, path, sizeof(tmp)); | |
639 av_strlcat(tmp, phfname, sizeof(tmp)); | |
640 | |
641 if (skinBPRead(tmp, &item->Bitmap) != 0) | |
642 return 1; | |
32951 | 643 |
644 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 645 } |
646 | |
647 return 0; | |
23077 | 648 } |
649 | |
32873 | 650 // font=fontfile |
651 static int cmd_font(char *in) | |
652 { | |
653 char name[512]; | |
654 wItem *item; | |
23077 | 655 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
656 if (!window_cmd("font")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
657 return 1; |
23077 | 658 |
33058 | 659 if (in_window("sub")) |
660 return 1; | |
661 if (in_window("menu")) | |
662 return 1; | |
23077 | 663 |
32873 | 664 cutItem(in, name, ',', 0); |
665 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
666 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
667 item = &currWinItems[*currWinItemIdx]; |
32873 | 668 item->type = itFont; |
669 item->fontid = fntRead(path, name); | |
23077 | 670 |
32873 | 671 switch (item->fontid) { |
672 case -1: | |
33022 | 673 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 674 return 1; |
23077 | 675 |
32873 | 676 case -2: |
33022 | 677 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); |
32873 | 678 return 1; |
679 | |
680 case -3: | |
33022 | 681 skin_error(MSGTR_SKIN_FONT_FontFileNotFound); |
32873 | 682 return 1; |
683 | |
684 case -4: | |
33022 | 685 skin_error(MSGTR_SKIN_FONT_FontImageNotFound); |
32873 | 686 return 1; |
687 } | |
688 | |
32951 | 689 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", name, fntFindID(name)); |
690 | |
32873 | 691 return 0; |
23077 | 692 } |
693 | |
32873 | 694 // slabel=x,y,fontfile,"text" |
695 static int cmd_slabel(char *in) | |
23077 | 696 { |
32873 | 697 char tmp[512]; |
698 char sid[64]; | |
699 int x, y, id; | |
700 wItem *item; | |
701 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
702 if (!window_cmd("slabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
703 return 1; |
23077 | 704 |
33058 | 705 if (in_window("sub")) |
706 return 1; | |
707 if (in_window("menu")) | |
708 return 1; | |
32873 | 709 |
710 x = cutItemToInt(in, ',', 0); | |
711 y = cutItemToInt(in, ',', 1); | |
712 cutItem(in, sid, ',', 2); | |
32951 | 713 cutItem(in, tmp, ',', 3); |
714 cutItem(tmp, tmp, '"', 1); | |
715 | |
716 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", tmp); | |
717 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
23077 | 718 |
32873 | 719 id = fntFindID(sid); |
23077 | 720 |
32873 | 721 if (id < 0) { |
33022 | 722 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, sid); |
32873 | 723 return 1; |
724 } | |
23077 | 725 |
32951 | 726 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id); |
23077 | 727 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
728 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
729 item = &currWinItems[*currWinItemIdx]; |
32873 | 730 item->type = itSLabel; |
731 item->fontid = id; | |
732 item->x = x; | |
733 item->y = y; | |
734 item->width = -1; | |
735 item->height = -1; | |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
736 item->label = strdup(tmp); |
23077 | 737 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
738 if (!item->label) { |
33022 | 739 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 740 return 1; |
741 } | |
23077 | 742 |
32873 | 743 return 0; |
23077 | 744 } |
745 | |
32910 | 746 // dlabel=x,y,width,align,fontfile,"text" |
32873 | 747 static int cmd_dlabel(char *in) |
748 { | |
749 char tmp[512]; | |
750 char sid[64]; | |
751 int x, y, sx, id, a; | |
752 wItem *item; | |
23077 | 753 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
754 if (!window_cmd("dlabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
755 return 1; |
23077 | 756 |
33058 | 757 if (in_window("sub")) |
758 return 1; | |
759 if (in_window("menu")) | |
760 return 1; | |
32873 | 761 |
762 x = cutItemToInt(in, ',', 0); | |
763 y = cutItemToInt(in, ',', 1); | |
764 sx = cutItemToInt(in, ',', 2); | |
765 a = cutItemToInt(in, ',', 3); | |
766 cutItem(in, sid, ',', 4); | |
32951 | 767 cutItem(in, tmp, ',', 5); |
768 cutItem(tmp, tmp, '"', 1); | |
769 | |
770 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", tmp); | |
771 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
772 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", sx, a); | |
23077 | 773 |
32873 | 774 id = fntFindID(sid); |
23077 | 775 |
32873 | 776 if (id < 0) { |
33022 | 777 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, sid); |
32873 | 778 return 1; |
779 } | |
23077 | 780 |
32951 | 781 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id); |
23077 | 782 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
783 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
784 item = &currWinItems[*currWinItemIdx]; |
32873 | 785 item->type = itDLabel; |
786 item->fontid = id; | |
787 item->align = a; | |
788 item->x = x; | |
789 item->y = y; | |
790 item->width = sx; | |
791 item->height = -1; | |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
792 item->label = strdup(tmp); |
23077 | 793 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
794 if (!item->label) { |
33022 | 795 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 796 return 1; |
797 } | |
23077 | 798 |
32873 | 799 return 0; |
23077 | 800 } |
801 | |
32873 | 802 // decoration=enable|disable |
803 static int cmd_decoration(char *in) | |
23077 | 804 { |
32873 | 805 char tmp[512]; |
806 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
807 if (!window_cmd("decoration")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
808 return 1; |
32873 | 809 |
33058 | 810 if (in_window("sub")) |
811 return 1; | |
812 if (in_window("playbar")) | |
813 return 1; | |
814 if (in_window("menu")) | |
815 return 1; | |
32873 | 816 |
33055 | 817 cutItem(strlower(in), tmp, ',', 0); |
32873 | 818 |
819 if (strcmp(tmp, "enable") != 0 && strcmp(tmp, "disable") != 0) { | |
33022 | 820 skin_error(MSGTR_SKIN_UnknownParameter, tmp); |
32873 | 821 return 1; |
822 } | |
23077 | 823 |
32873 | 824 if (strcmp(tmp, "enable") != 0) |
32937 | 825 skin->mainDecoration = 0; |
32873 | 826 else |
32937 | 827 skin->mainDecoration = 1; |
23077 | 828 |
32951 | 829 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", tmp); |
32873 | 830 |
831 return 0; | |
23077 | 832 } |
833 | |
32878 | 834 static _item skinItem[] = { |
32873 | 835 { "section", cmd_section }, |
836 { "end", cmd_end }, | |
837 { "window", cmd_window }, | |
838 { "base", cmd_base }, | |
839 { "button", cmd_button }, | |
840 { "selected", cmd_selected }, | |
841 { "background", cmd_background }, | |
842 { "vpotmeter", cmd_vpotmeter }, | |
843 { "hpotmeter", cmd_hpotmeter }, | |
844 { "potmeter", cmd_potmeter }, | |
845 { "font", cmd_font }, | |
846 { "slabel", cmd_slabel }, | |
847 { "dlabel", cmd_dlabel }, | |
848 { "decoration", cmd_decoration }, | |
849 { "menu", cmd_menu } | |
850 }; | |
851 | |
852 static char *setname(char *item1, char *item2) | |
853 { | |
854 static char fn[512]; | |
855 | |
856 av_strlcpy(fn, item1, sizeof(fn)); | |
857 av_strlcat(fn, "/", sizeof(fn)); | |
858 av_strlcat(fn, item2, sizeof(fn)); | |
859 av_strlcpy(path, fn, sizeof(path)); | |
860 av_strlcat(path, "/", sizeof(path)); | |
861 av_strlcat(fn, "/skin", sizeof(fn)); | |
862 | |
863 return fn; | |
23077 | 864 } |
865 | |
32873 | 866 int skinRead(char *dname) |
23077 | 867 { |
32873 | 868 char *fn; |
869 FILE *skinFile; | |
870 unsigned char tmp[256]; | |
871 unsigned char *ptmp; | |
872 unsigned char command[32]; | |
873 unsigned char param[256]; | |
32944 | 874 unsigned int i; |
32873 | 875 |
876 fn = setname(skinDirInHome, dname); | |
23077 | 877 |
32873 | 878 if ((skinFile = fopen(fn, "rt")) == NULL) { |
879 fn = setname(skinMPlayerDir, dname); | |
880 | |
881 if ((skinFile = fopen(fn, "rt")) == NULL) { | |
32877 | 882 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, fn); |
32873 | 883 return -1; |
884 } | |
23077 | 885 } |
32873 | 886 |
32951 | 887 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", fn); |
23077 | 888 |
32932 | 889 appFreeStruct(); |
23077 | 890 |
32873 | 891 linenumber = 0; |
23077 | 892 |
32873 | 893 while (fgets(tmp, sizeof(tmp), skinFile)) { |
894 linenumber++; | |
895 | |
896 tmp[strcspn(tmp, "\n\r")] = 0; // remove any kind of newline, if any | |
897 strswap(tmp, '\t', ' '); | |
898 trim(tmp); | |
899 ptmp = strchr(tmp, ';'); | |
900 | |
901 if (ptmp) | |
902 *ptmp = 0; | |
903 | |
904 if (!*tmp) | |
905 continue; | |
23077 | 906 |
32873 | 907 cutItem(tmp, command, '=', 0); |
908 cutItem(tmp, param, '=', 1); | |
909 strlower(command); | |
910 | |
32944 | 911 for (i = 0; i < FF_ARRAY_ELEMS(skinItem); i++) |
32873 | 912 if (!strcmp(command, skinItem[i].name)) |
913 if (skinItem[i].func(param) != 0) | |
914 return -2; | |
915 } | |
916 | |
917 if (linenumber == 0) { | |
32877 | 918 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, fn); |
32873 | 919 return -1; |
920 } | |
921 | |
922 return 0; | |
23077 | 923 } |