Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 33084:b8779b19730e
Cosmetic: Rename menuBase menu.
The new name corresponds better to the names of the other wItems and
statements using it are more intelligible.
author | ib |
---|---|
date | Thu, 31 Mar 2011 12:25:32 +0000 |
parents | 8c96263e0f09 |
children | 1b9f989855f3 |
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 |
33083 | 182 strlower(in); |
23077 | 183 |
33083 | 184 if (strcmp(in, "main") == 0) { |
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; |
33083 | 188 } else if (strcmp(in, "sub") == 0) { |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
189 currWin = &appMPlayer.sub; |
33083 | 190 currWinItemIdx = NULL; |
191 currWinItems = NULL; | |
192 } else if (strcmp(in, "playbar") == 0) { | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
193 currWin = &appMPlayer.bar; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
194 currWinItemIdx = &appMPlayer.IndexOfBarItems; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
195 currWinItems = appMPlayer.barItems; |
33083 | 196 } else if (strcmp(in, "menu") == 0) { |
33084 | 197 currWin = &appMPlayer.menu; |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
198 currWinItemIdx = &appMPlayer.IndexOfMenuItems; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
199 currWinItems = appMPlayer.menuItems; |
33066 | 200 } else { |
33065 | 201 skin_error(MSGTR_SKIN_UNKNOWN_NAME, in); |
33066 | 202 return 1; |
203 } | |
32873 | 204 |
33083 | 205 av_strlcpy(currWinName, in, sizeof(currWinName)); |
206 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
207 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] window: %s\n", currWinName); |
32873 | 208 |
209 return 0; | |
23077 | 210 } |
211 | |
32873 | 212 // base=image,x,y[,width,height] |
213 static int cmd_base(char *in) | |
23077 | 214 { |
32873 | 215 unsigned char fname[512]; |
216 unsigned char tmp[512]; | |
217 int x, y; | |
218 int sx = 0, sy = 0; | |
219 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
220 if (!window_cmd("base")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
221 return 1; |
23077 | 222 |
32873 | 223 cutItem(in, fname, ',', 0); |
224 x = cutItemToInt(in, ',', 1); | |
225 y = cutItemToInt(in, ',', 2); | |
226 sx = cutItemToInt(in, ',', 3); | |
227 sy = cutItemToInt(in, ',', 4); | |
228 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
229 if (!strcmp(currWinName, "main")) { |
32951 | 230 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); |
23077 | 231 |
32937 | 232 skin->main.x = x; |
233 skin->main.y = y; | |
234 skin->main.type = itBase; | |
32873 | 235 |
236 av_strlcpy(tmp, path, sizeof(tmp)); | |
237 av_strlcat(tmp, fname, sizeof(tmp)); | |
238 | |
32937 | 239 if (skinBPRead(tmp, &skin->main.Bitmap) != 0) |
32873 | 240 return 1; |
241 | |
32937 | 242 skin->main.width = skin->main.Bitmap.Width; |
243 skin->main.height = skin->main.Bitmap.Height; | |
32873 | 244 |
32951 | 245 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->main.width, skin->main.height); |
246 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
247 #ifdef CONFIG_XSHAPE |
32937 | 248 Convert32to1(&skin->main.Bitmap, &skin->main.Mask, 0x00ff00ff); |
32951 | 249 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", skin->main.Mask.Width, skin->main.Mask.Height); |
23077 | 250 #else |
32937 | 251 skin->main.Mask.Image = NULL; |
23077 | 252 #endif |
253 } | |
32873 | 254 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
255 if (!strcmp(currWinName, "sub")) { |
32958 | 256 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); |
257 | |
32937 | 258 skin->sub.type = itBase; |
32873 | 259 |
260 av_strlcpy(tmp, path, sizeof(tmp)); | |
261 av_strlcat(tmp, fname, sizeof(tmp)); | |
262 | |
32937 | 263 if (skinBPRead(tmp, &skin->sub.Bitmap) != 0) |
32873 | 264 return 1; |
265 | |
32937 | 266 skin->sub.x = x; |
267 skin->sub.y = y; | |
268 skin->sub.width = skin->sub.Bitmap.Width; | |
269 skin->sub.height = skin->sub.Bitmap.Height; | |
32873 | 270 |
271 if (sx && sy) { | |
32937 | 272 skin->sub.width = sx; |
273 skin->sub.height = sy; | |
32873 | 274 } |
275 | |
32951 | 276 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->sub.width, skin->sub.height); |
32873 | 277 } |
278 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
279 if (!strcmp(currWinName, "menu")) { |
32958 | 280 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s\n", fname); |
281 | |
32937 | 282 skin->menuIsPresent = 1; |
33084 | 283 skin->menu.type = itBase; |
32873 | 284 |
285 av_strlcpy(tmp, path, sizeof(tmp)); | |
286 av_strlcat(tmp, fname, sizeof(tmp)); | |
287 | |
33084 | 288 if (skinBPRead(tmp, &skin->menu.Bitmap) != 0) |
32873 | 289 return 1; |
290 | |
33084 | 291 skin->menu.width = skin->menu.Bitmap.Width; |
292 skin->menu.height = skin->menu.Bitmap.Height; | |
32873 | 293 |
33084 | 294 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->menu.width, skin->menu.height); |
32951 | 295 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
296 #ifdef CONFIG_XSHAPE |
33084 | 297 Convert32to1(&skin->menu.Bitmap, &skin->menu.Mask, 0x00ff00ff); |
298 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", skin->menu.Mask.Width, skin->menu.Mask.Height); | |
23077 | 299 #else |
33084 | 300 skin->menu.Mask.Image = NULL; |
23077 | 301 #endif |
32873 | 302 } |
303 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
304 if (!strcmp(currWinName, "playbar")) { |
32958 | 305 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); |
306 | |
32937 | 307 skin->barIsPresent = 1; |
308 skin->bar.x = x; | |
309 skin->bar.y = y; | |
310 skin->bar.type = itBase; | |
32873 | 311 |
312 av_strlcpy(tmp, path, sizeof(tmp)); | |
313 av_strlcat(tmp, fname, sizeof(tmp)); | |
314 | |
32937 | 315 if (skinBPRead(tmp, &skin->bar.Bitmap) != 0) |
32873 | 316 return 1; |
317 | |
32937 | 318 skin->bar.width = skin->bar.Bitmap.Width; |
319 skin->bar.height = skin->bar.Bitmap.Height; | |
32873 | 320 |
32951 | 321 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->bar.width, skin->bar.height); |
322 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
323 #ifdef CONFIG_XSHAPE |
32937 | 324 Convert32to1(&skin->bar.Bitmap, &skin->bar.Mask, 0x00ff00ff); |
32951 | 325 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", skin->bar.Mask.Width, skin->bar.Mask.Height); |
23077 | 326 #else |
32937 | 327 skin->bar.Mask.Image = NULL; |
23077 | 328 #endif |
32873 | 329 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
330 |
32873 | 331 return 0; |
23077 | 332 } |
333 | |
32873 | 334 // background=R,G,B |
335 static int cmd_background(char *in) | |
23077 | 336 { |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
337 if (!window_cmd("background")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
338 return 1; |
23077 | 339 |
33058 | 340 if (in_window("main")) |
341 return 1; | |
342 if (in_window("menu")) | |
343 return 1; | |
23077 | 344 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
345 currWin->R = cutItemToInt(in, ',', 0); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
346 currWin->G = cutItemToInt(in, ',', 1); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
347 currWin->B = cutItemToInt(in, ',', 2); |
23077 | 348 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
349 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B); |
23077 | 350 |
32873 | 351 return 0; |
23077 | 352 } |
353 | |
32873 | 354 // button=image,x,y,width,height,message |
355 static int cmd_button(char *in) | |
23077 | 356 { |
32873 | 357 unsigned char fname[512]; |
358 unsigned char tmp[512]; | |
33071 | 359 int x, y, sx, sy, message; |
32873 | 360 char msg[32]; |
361 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
362 if (!window_cmd("button")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
363 return 1; |
32873 | 364 |
33058 | 365 if (in_window("sub")) |
366 return 1; | |
367 if (in_window("menu")) | |
368 return 1; | |
23077 | 369 |
32873 | 370 cutItem(in, fname, ',', 0); |
371 x = cutItemToInt(in, ',', 1); | |
372 y = cutItemToInt(in, ',', 2); | |
373 sx = cutItemToInt(in, ',', 3); | |
374 sy = cutItemToInt(in, ',', 4); | |
375 cutItem(in, msg, ',', 5); | |
376 | |
33071 | 377 message = appFindMessage(msg); |
378 | |
379 if (message == -1) { | |
380 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
381 return 1; | |
382 } | |
383 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
384 (*currWinItemIdx)++; |
33072 | 385 currWinItems[*currWinItemIdx].type = itButton; |
386 currWinItems[*currWinItemIdx].x = x; | |
387 currWinItems[*currWinItemIdx].y = y; | |
388 currWinItems[*currWinItemIdx].width = sx; | |
389 currWinItems[*currWinItemIdx].height = sy; | |
33071 | 390 currWinItems[*currWinItemIdx].message = message; |
23077 | 391 |
32951 | 392 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y); |
33071 | 393 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
32951 | 394 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", sx, sy); |
395 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
396 currWinItems[*currWinItemIdx].pressed = btnReleased; |
32873 | 397 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
398 if (currWinItems[*currWinItemIdx].message == evPauseSwitchToPlay) |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
399 currWinItems[*currWinItemIdx].pressed = btnDisabled; |
23077 | 400 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
401 currWinItems[*currWinItemIdx].tmp = 1; |
32873 | 402 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
403 currWinItems[*currWinItemIdx].Bitmap.Image = NULL; |
32873 | 404 |
405 if (strcmp(fname, "NULL") != 0) { | |
406 av_strlcpy(tmp, path, sizeof(tmp)); | |
407 av_strlcat(tmp, fname, sizeof(tmp)); | |
408 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
409 if (skinBPRead(tmp, &currWinItems[*currWinItemIdx].Bitmap) != 0) |
32873 | 410 return 1; |
32951 | 411 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
412 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", currWinItems[*currWinItemIdx].Bitmap.Width, currWinItems[*currWinItemIdx].Bitmap.Height); |
32873 | 413 } |
414 | |
415 return 0; | |
23077 | 416 } |
417 | |
32873 | 418 // selected=image |
419 static int cmd_selected(char *in) | |
420 { | |
421 unsigned char fname[512]; | |
422 unsigned char tmp[512]; | |
423 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
424 if (!window_cmd("selected")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
425 return 1; |
32873 | 426 |
33058 | 427 if (in_window("main")) |
428 return 1; | |
429 if (in_window("sub")) | |
430 return 1; | |
431 if (in_window("playbar")) | |
432 return 1; | |
32873 | 433 |
434 cutItem(in, fname, ',', 0); | |
23077 | 435 |
32937 | 436 skin->menuSelected.type = itBase; |
32873 | 437 |
438 av_strlcpy(tmp, path, sizeof(tmp)); | |
439 av_strlcat(tmp, fname, sizeof(tmp)); | |
440 | |
32951 | 441 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image selected: %s\n", fname); |
23077 | 442 |
32937 | 443 if (skinBPRead(tmp, &skin->menuSelected.Bitmap) != 0) |
32873 | 444 return 1; |
445 | |
32937 | 446 skin->menuSelected.width = skin->menuSelected.Bitmap.Width; |
447 skin->menuSelected.height = skin->menuSelected.Bitmap.Height; | |
32873 | 448 |
32951 | 449 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->menuSelected.width, skin->menuSelected.height); |
32873 | 450 |
451 return 0; | |
452 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
453 |
32873 | 454 // menu=x,y,width,height,message |
455 static int cmd_menu(char *in) | |
456 { | |
32911 | 457 int x, y, sx, sy, message; |
33071 | 458 char msg[32]; |
32873 | 459 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
460 if (!window_cmd("menu")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
461 return 1; |
32873 | 462 |
33058 | 463 if (in_window("main")) |
464 return 1; | |
465 if (in_window("sub")) | |
466 return 1; | |
467 if (in_window("playbar")) | |
468 return 1; | |
32873 | 469 |
470 x = cutItemToInt(in, ',', 0); | |
471 y = cutItemToInt(in, ',', 1); | |
472 sx = cutItemToInt(in, ',', 2); | |
473 sy = cutItemToInt(in, ',', 3); | |
33071 | 474 cutItem(in, msg, ',', 4); |
475 | |
476 message = appFindMessage(msg); | |
23077 | 477 |
33071 | 478 if (message == -1) { |
479 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
480 return 1; | |
481 } | |
32873 | 482 |
32937 | 483 skin->IndexOfMenuItems++; |
33072 | 484 skin->menuItems[skin->IndexOfMenuItems].x = x; |
485 skin->menuItems[skin->IndexOfMenuItems].y = y; | |
486 skin->menuItems[skin->IndexOfMenuItems].width = sx; | |
487 skin->menuItems[skin->IndexOfMenuItems].height = sy; | |
33071 | 488 skin->menuItems[skin->IndexOfMenuItems].message = message; |
23077 | 489 |
32951 | 490 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", skin->IndexOfMenuItems, x, y, sx, sy); |
33071 | 491 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
23077 | 492 |
32937 | 493 skin->menuItems[skin->IndexOfMenuItems].Bitmap.Image = NULL; |
33053 | 494 |
32873 | 495 return 0; |
23077 | 496 } |
497 | |
32873 | 498 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
499 static int cmd_hpotmeter(char *in) | |
500 { | |
32911 | 501 int x, y, pwidth, pheight, ph, sx, sy, message, d; |
32873 | 502 unsigned char tmp[512]; |
503 unsigned char pfname[512]; | |
504 unsigned char phfname[512]; | |
505 wItem *item; | |
23077 | 506 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
507 if (!window_cmd("h/v potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
508 return 1; |
23077 | 509 |
33058 | 510 if (in_window("sub")) |
511 return 1; | |
512 if (in_window("menu")) | |
513 return 1; | |
23077 | 514 |
32873 | 515 cutItem(in, pfname, ',', 0); |
32911 | 516 pwidth = cutItemToInt(in, ',', 1); |
517 pheight = cutItemToInt(in, ',', 2); | |
32873 | 518 cutItem(in, phfname, ',', 3); |
519 ph = cutItemToInt(in, ',', 4); | |
520 d = cutItemToInt(in, ',', 5); | |
521 x = cutItemToInt(in, ',', 6); | |
522 y = cutItemToInt(in, ',', 7); | |
523 sx = cutItemToInt(in, ',', 8); | |
524 sy = cutItemToInt(in, ',', 9); | |
525 cutItem(in, tmp, ',', 10); | |
526 | |
32911 | 527 message = appFindMessage(tmp); |
23077 | 528 |
33069 | 529 if (message == -1) { |
530 skin_error(MSGTR_SKIN_UnknownMessage, tmp); | |
531 return 1; | |
532 } | |
533 | |
32951 | 534 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy); |
535 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); | |
536 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
537 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message); | |
23077 | 538 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
539 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
540 item = &currWinItems[*currWinItemIdx]; |
32873 | 541 item->type = itHPotmeter; |
542 item->x = x; | |
543 item->y = y; | |
544 item->width = sx; | |
545 item->height = sy; | |
32911 | 546 item->numphases = ph; |
547 item->pwidth = pwidth; | |
548 item->pheight = pheight; | |
549 item->message = message; | |
32873 | 550 item->value = (float)d; |
551 item->pressed = btnReleased; | |
552 item->Bitmap.Image = NULL; | |
23077 | 553 |
32873 | 554 if (strcmp(phfname, "NULL") != 0) { |
555 av_strlcpy(tmp, path, sizeof(tmp)); | |
556 av_strlcat(tmp, phfname, sizeof(tmp)); | |
557 | |
558 if (skinBPRead(tmp, &item->Bitmap) != 0) | |
559 return 1; | |
32951 | 560 |
561 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 562 } |
563 | |
564 item->Mask.Image = NULL; | |
23077 | 565 |
32873 | 566 if (strcmp(pfname, "NULL") != 0) { |
567 av_strlcpy(tmp, path, sizeof(tmp)); | |
568 av_strlcat(tmp, pfname, sizeof(tmp)); | |
569 | |
570 if (skinBPRead(tmp, &item->Mask) != 0) | |
571 return 1; | |
32951 | 572 |
573 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); | |
32873 | 574 } |
575 | |
576 return 0; | |
23077 | 577 } |
578 | |
32873 | 579 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
580 static int cmd_vpotmeter(char *in) | |
23077 | 581 { |
33056 | 582 int r; |
32873 | 583 wItem *item; |
23077 | 584 |
33056 | 585 r = cmd_hpotmeter(in); |
586 | |
587 if (r == 0) { | |
33057 | 588 item = &currWinItems[*currWinItemIdx]; |
589 item->type = itVPotmeter; | |
33056 | 590 } |
33053 | 591 |
32873 | 592 return r; |
23077 | 593 } |
594 | |
32873 | 595 // potmeter=phases,numphases,default,x,y,width,height,message |
596 static int cmd_potmeter(char *in) | |
597 { | |
32911 | 598 int x, y, ph, sx, sy, message, d; |
32873 | 599 unsigned char tmp[512]; |
600 unsigned char phfname[512]; | |
601 wItem *item; | |
23077 | 602 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
603 if (!window_cmd("potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
604 return 1; |
23077 | 605 |
33058 | 606 if (in_window("sub")) |
607 return 1; | |
608 if (in_window("menu")) | |
609 return 1; | |
23077 | 610 |
32873 | 611 cutItem(in, phfname, ',', 0); |
612 ph = cutItemToInt(in, ',', 1); | |
613 d = cutItemToInt(in, ',', 2); | |
614 x = cutItemToInt(in, ',', 3); | |
615 y = cutItemToInt(in, ',', 4); | |
616 sx = cutItemToInt(in, ',', 5); | |
617 sy = cutItemToInt(in, ',', 6); | |
618 cutItem(in, tmp, ',', 7); | |
619 | |
32911 | 620 message = appFindMessage(tmp); |
23077 | 621 |
33069 | 622 if (message == -1) { |
623 skin_error(MSGTR_SKIN_UnknownMessage, tmp); | |
624 return 1; | |
625 } | |
626 | |
32951 | 627 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, sx, sy); |
628 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
629 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", tmp, message); | |
23077 | 630 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
631 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
632 item = &currWinItems[*currWinItemIdx]; |
32873 | 633 item->type = itPotmeter; |
634 item->x = x; | |
635 item->y = y; | |
636 item->width = sx; | |
637 item->height = sy; | |
32911 | 638 item->numphases = ph; |
639 item->message = message; | |
32873 | 640 item->value = (float)d; |
641 item->Bitmap.Image = NULL; | |
23077 | 642 |
32873 | 643 if (strcmp(phfname, "NULL") != 0) { |
644 av_strlcpy(tmp, path, sizeof(tmp)); | |
645 av_strlcat(tmp, phfname, sizeof(tmp)); | |
646 | |
647 if (skinBPRead(tmp, &item->Bitmap) != 0) | |
648 return 1; | |
32951 | 649 |
650 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 651 } |
652 | |
653 return 0; | |
23077 | 654 } |
655 | |
32873 | 656 // font=fontfile |
657 static int cmd_font(char *in) | |
658 { | |
659 char name[512]; | |
660 wItem *item; | |
23077 | 661 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
662 if (!window_cmd("font")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
663 return 1; |
23077 | 664 |
33058 | 665 if (in_window("sub")) |
666 return 1; | |
667 if (in_window("menu")) | |
668 return 1; | |
23077 | 669 |
32873 | 670 cutItem(in, name, ',', 0); |
671 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
672 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
673 item = &currWinItems[*currWinItemIdx]; |
32873 | 674 item->type = itFont; |
675 item->fontid = fntRead(path, name); | |
23077 | 676 |
32873 | 677 switch (item->fontid) { |
678 case -1: | |
33022 | 679 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 680 return 1; |
23077 | 681 |
32873 | 682 case -2: |
33022 | 683 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); |
32873 | 684 return 1; |
685 | |
686 case -3: | |
33022 | 687 skin_error(MSGTR_SKIN_FONT_FontFileNotFound); |
32873 | 688 return 1; |
689 | |
690 case -4: | |
33022 | 691 skin_error(MSGTR_SKIN_FONT_FontImageNotFound); |
32873 | 692 return 1; |
693 } | |
694 | |
32951 | 695 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", name, fntFindID(name)); |
696 | |
32873 | 697 return 0; |
23077 | 698 } |
699 | |
32873 | 700 // slabel=x,y,fontfile,"text" |
701 static int cmd_slabel(char *in) | |
23077 | 702 { |
32873 | 703 char tmp[512]; |
704 char sid[64]; | |
705 int x, y, id; | |
706 wItem *item; | |
707 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
708 if (!window_cmd("slabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
709 return 1; |
23077 | 710 |
33058 | 711 if (in_window("sub")) |
712 return 1; | |
713 if (in_window("menu")) | |
714 return 1; | |
32873 | 715 |
716 x = cutItemToInt(in, ',', 0); | |
717 y = cutItemToInt(in, ',', 1); | |
718 cutItem(in, sid, ',', 2); | |
32951 | 719 cutItem(in, tmp, ',', 3); |
720 cutItem(tmp, tmp, '"', 1); | |
721 | |
722 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", tmp); | |
723 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
23077 | 724 |
32873 | 725 id = fntFindID(sid); |
23077 | 726 |
32873 | 727 if (id < 0) { |
33022 | 728 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, sid); |
32873 | 729 return 1; |
730 } | |
23077 | 731 |
32951 | 732 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id); |
23077 | 733 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
734 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
735 item = &currWinItems[*currWinItemIdx]; |
32873 | 736 item->type = itSLabel; |
737 item->fontid = id; | |
738 item->x = x; | |
739 item->y = y; | |
740 item->width = -1; | |
741 item->height = -1; | |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
742 item->label = strdup(tmp); |
23077 | 743 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
744 if (!item->label) { |
33022 | 745 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 746 return 1; |
747 } | |
23077 | 748 |
32873 | 749 return 0; |
23077 | 750 } |
751 | |
32910 | 752 // dlabel=x,y,width,align,fontfile,"text" |
32873 | 753 static int cmd_dlabel(char *in) |
754 { | |
755 char tmp[512]; | |
756 char sid[64]; | |
757 int x, y, sx, id, a; | |
758 wItem *item; | |
23077 | 759 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
760 if (!window_cmd("dlabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
761 return 1; |
23077 | 762 |
33058 | 763 if (in_window("sub")) |
764 return 1; | |
765 if (in_window("menu")) | |
766 return 1; | |
32873 | 767 |
768 x = cutItemToInt(in, ',', 0); | |
769 y = cutItemToInt(in, ',', 1); | |
770 sx = cutItemToInt(in, ',', 2); | |
771 a = cutItemToInt(in, ',', 3); | |
772 cutItem(in, sid, ',', 4); | |
32951 | 773 cutItem(in, tmp, ',', 5); |
774 cutItem(tmp, tmp, '"', 1); | |
775 | |
776 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", tmp); | |
777 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
778 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", sx, a); | |
23077 | 779 |
32873 | 780 id = fntFindID(sid); |
23077 | 781 |
32873 | 782 if (id < 0) { |
33022 | 783 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, sid); |
32873 | 784 return 1; |
785 } | |
23077 | 786 |
32951 | 787 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", sid, id); |
23077 | 788 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
789 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
790 item = &currWinItems[*currWinItemIdx]; |
32873 | 791 item->type = itDLabel; |
792 item->fontid = id; | |
793 item->align = a; | |
794 item->x = x; | |
795 item->y = y; | |
796 item->width = sx; | |
797 item->height = -1; | |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
798 item->label = strdup(tmp); |
23077 | 799 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
800 if (!item->label) { |
33022 | 801 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 802 return 1; |
803 } | |
23077 | 804 |
32873 | 805 return 0; |
23077 | 806 } |
807 | |
32873 | 808 // decoration=enable|disable |
809 static int cmd_decoration(char *in) | |
23077 | 810 { |
32873 | 811 char tmp[512]; |
812 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
813 if (!window_cmd("decoration")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
814 return 1; |
32873 | 815 |
33058 | 816 if (in_window("sub")) |
817 return 1; | |
818 if (in_window("playbar")) | |
819 return 1; | |
820 if (in_window("menu")) | |
821 return 1; | |
32873 | 822 |
33055 | 823 cutItem(strlower(in), tmp, ',', 0); |
32873 | 824 |
825 if (strcmp(tmp, "enable") != 0 && strcmp(tmp, "disable") != 0) { | |
33022 | 826 skin_error(MSGTR_SKIN_UnknownParameter, tmp); |
32873 | 827 return 1; |
828 } | |
23077 | 829 |
32873 | 830 if (strcmp(tmp, "enable") != 0) |
32937 | 831 skin->mainDecoration = 0; |
32873 | 832 else |
32937 | 833 skin->mainDecoration = 1; |
23077 | 834 |
32951 | 835 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", tmp); |
32873 | 836 |
837 return 0; | |
23077 | 838 } |
839 | |
32878 | 840 static _item skinItem[] = { |
32873 | 841 { "section", cmd_section }, |
842 { "end", cmd_end }, | |
843 { "window", cmd_window }, | |
844 { "base", cmd_base }, | |
845 { "button", cmd_button }, | |
846 { "selected", cmd_selected }, | |
847 { "background", cmd_background }, | |
848 { "vpotmeter", cmd_vpotmeter }, | |
849 { "hpotmeter", cmd_hpotmeter }, | |
850 { "potmeter", cmd_potmeter }, | |
851 { "font", cmd_font }, | |
852 { "slabel", cmd_slabel }, | |
853 { "dlabel", cmd_dlabel }, | |
854 { "decoration", cmd_decoration }, | |
855 { "menu", cmd_menu } | |
856 }; | |
857 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
858 static char *setname(char *dir, char *sname) |
32873 | 859 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
860 static char skinfname[512]; |
32873 | 861 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
862 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
863 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
864 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
865 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
866 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
867 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 868 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
869 return skinfname; |
23077 | 870 } |
871 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
872 int skinRead(char *sname) |
23077 | 873 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
874 char *skinfname; |
32873 | 875 FILE *skinFile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
876 unsigned char line[256]; |
33075 | 877 unsigned char item[32]; |
32873 | 878 unsigned char param[256]; |
32944 | 879 unsigned int i; |
32873 | 880 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
881 skinfname = setname(skinDirInHome, sname); |
23077 | 882 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
883 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
884 skinfname = setname(skinMPlayerDir, sname); |
32873 | 885 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
886 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
887 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname); |
32873 | 888 return -1; |
889 } | |
23077 | 890 } |
32873 | 891 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
892 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 893 |
32932 | 894 appFreeStruct(); |
23077 | 895 |
33078 | 896 skin = NULL; |
897 currWinName[0] = 0; | |
33079 | 898 linenumber = 0; |
23077 | 899 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
900 while (fgets(line, sizeof(line), skinFile)) { |
32873 | 901 linenumber++; |
902 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
903 line[strcspn(line, "\n\r")] = 0; // remove any kind of newline, if any |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
904 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
905 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
906 decomment(line); |
32873 | 907 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
908 if (!*line) |
32873 | 909 continue; |
23077 | 910 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
911 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
912 cutItem(line, param, '=', 1); |
33075 | 913 strlower(item); |
32873 | 914 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
915 for (i = 0; i < FF_ARRAY_ELEMS(skinItem); i++) { |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
916 if (!strcmp(item, skinItem[i].name)) { |
32873 | 917 if (skinItem[i].func(param) != 0) |
918 return -2; | |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
919 else |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
920 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
921 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
922 } |
33077 | 923 |
924 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
925 skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item); | |
926 return -2; | |
927 } | |
32873 | 928 } |
929 | |
930 if (linenumber == 0) { | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
931 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname); |
32873 | 932 return -1; |
933 } | |
934 | |
935 return 0; | |
23077 | 936 } |