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