Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 33095:772af04413f3
Avoid using appMPlayer.
Use skin pointer instead.
author | ib |
---|---|
date | Fri, 01 Apr 2011 13:30:17 +0000 |
parents | 2faf1c3ded5d |
children | ca1a01b56c90 |
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) { |
33095 | 185 currWin = &skin->main; |
186 currWinItemIdx = &skin->IndexOfMainItems; | |
187 currWinItems = skin->mainItems; | |
33083 | 188 } else if (strcmp(in, "sub") == 0) { |
33095 | 189 currWin = &skin->sub; |
33083 | 190 currWinItemIdx = NULL; |
191 currWinItems = NULL; | |
192 } else if (strcmp(in, "playbar") == 0) { | |
33095 | 193 currWin = &skin->bar; |
194 currWinItemIdx = &skin->IndexOfBarItems; | |
195 currWinItems = skin->barItems; | |
33083 | 196 } else if (strcmp(in, "menu") == 0) { |
33095 | 197 currWin = &skin->menu; |
198 currWinItemIdx = &skin->IndexOfMenuItems; | |
199 currWinItems = skin->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 { |
33090 | 215 unsigned char fname[256]; |
33089 | 216 unsigned char file[512]; |
32873 | 217 int x, y; |
33089 | 218 int w = 0, h = 0; |
32873 | 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); |
33089 | 224 x = cutItemToInt(in, ',', 1); |
225 y = cutItemToInt(in, ',', 2); | |
226 w = cutItemToInt(in, ',', 3); | |
227 h = cutItemToInt(in, ',', 4); | |
32873 | 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 |
33089 | 236 av_strlcpy(file, path, sizeof(file)); |
237 av_strlcat(file, fname, sizeof(file)); | |
32873 | 238 |
33089 | 239 if (skinBPRead(file, &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 |
33089 | 260 av_strlcpy(file, path, sizeof(file)); |
261 av_strlcat(file, fname, sizeof(file)); | |
32873 | 262 |
33089 | 263 if (skinBPRead(file, &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 |
33089 | 271 if (w && h) { |
272 skin->sub.width = w; | |
273 skin->sub.height = h; | |
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 |
33089 | 285 av_strlcpy(file, path, sizeof(file)); |
286 av_strlcat(file, fname, sizeof(file)); | |
32873 | 287 |
33089 | 288 if (skinBPRead(file, &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 |
33089 | 312 av_strlcpy(file, path, sizeof(file)); |
313 av_strlcat(file, fname, sizeof(file)); | |
32873 | 314 |
33089 | 315 if (skinBPRead(file, &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; | |
33088 | 342 if (in_window("playbar")) |
343 return 1; | |
33058 | 344 if (in_window("menu")) |
345 return 1; | |
23077 | 346 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
347 currWin->R = cutItemToInt(in, ',', 0); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
348 currWin->G = cutItemToInt(in, ',', 1); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
349 currWin->B = cutItemToInt(in, ',', 2); |
23077 | 350 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
351 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B); |
23077 | 352 |
32873 | 353 return 0; |
23077 | 354 } |
355 | |
32873 | 356 // button=image,x,y,width,height,message |
357 static int cmd_button(char *in) | |
23077 | 358 { |
33090 | 359 unsigned char fname[256]; |
33089 | 360 unsigned char file[512]; |
361 int x, y, w, h, message; | |
32873 | 362 char msg[32]; |
363 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
364 if (!window_cmd("button")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
365 return 1; |
32873 | 366 |
33058 | 367 if (in_window("sub")) |
368 return 1; | |
369 if (in_window("menu")) | |
370 return 1; | |
23077 | 371 |
32873 | 372 cutItem(in, fname, ',', 0); |
33089 | 373 x = cutItemToInt(in, ',', 1); |
374 y = cutItemToInt(in, ',', 2); | |
375 w = cutItemToInt(in, ',', 3); | |
376 h = cutItemToInt(in, ',', 4); | |
32873 | 377 cutItem(in, msg, ',', 5); |
378 | |
33071 | 379 message = appFindMessage(msg); |
380 | |
381 if (message == -1) { | |
382 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
383 return 1; | |
384 } | |
385 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
386 (*currWinItemIdx)++; |
33072 | 387 currWinItems[*currWinItemIdx].type = itButton; |
388 currWinItems[*currWinItemIdx].x = x; | |
389 currWinItems[*currWinItemIdx].y = y; | |
33089 | 390 currWinItems[*currWinItemIdx].width = w; |
391 currWinItems[*currWinItemIdx].height = h; | |
33071 | 392 currWinItems[*currWinItemIdx].message = message; |
23077 | 393 |
32951 | 394 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y); |
33071 | 395 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
33089 | 396 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", w, h); |
32951 | 397 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
398 currWinItems[*currWinItemIdx].pressed = btnReleased; |
32873 | 399 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
400 if (currWinItems[*currWinItemIdx].message == evPauseSwitchToPlay) |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
401 currWinItems[*currWinItemIdx].pressed = btnDisabled; |
23077 | 402 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
403 currWinItems[*currWinItemIdx].tmp = 1; |
32873 | 404 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
405 currWinItems[*currWinItemIdx].Bitmap.Image = NULL; |
32873 | 406 |
407 if (strcmp(fname, "NULL") != 0) { | |
33089 | 408 av_strlcpy(file, path, sizeof(file)); |
409 av_strlcat(file, fname, sizeof(file)); | |
32873 | 410 |
33089 | 411 if (skinBPRead(file, &currWinItems[*currWinItemIdx].Bitmap) != 0) |
32873 | 412 return 1; |
32951 | 413 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
414 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", currWinItems[*currWinItemIdx].Bitmap.Width, currWinItems[*currWinItemIdx].Bitmap.Height); |
32873 | 415 } |
416 | |
417 return 0; | |
23077 | 418 } |
419 | |
32873 | 420 // selected=image |
421 static int cmd_selected(char *in) | |
422 { | |
33089 | 423 unsigned char file[512]; |
32873 | 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 |
32937 | 435 skin->menuSelected.type = itBase; |
32873 | 436 |
33089 | 437 av_strlcpy(file, path, sizeof(file)); |
33091 | 438 av_strlcat(file, in, sizeof(file)); |
32873 | 439 |
33091 | 440 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image selected: %s\n", in); |
23077 | 441 |
33089 | 442 if (skinBPRead(file, &skin->menuSelected.Bitmap) != 0) |
32873 | 443 return 1; |
444 | |
32937 | 445 skin->menuSelected.width = skin->menuSelected.Bitmap.Width; |
446 skin->menuSelected.height = skin->menuSelected.Bitmap.Height; | |
32873 | 447 |
32951 | 448 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", skin->menuSelected.width, skin->menuSelected.height); |
32873 | 449 |
450 return 0; | |
451 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
452 |
32873 | 453 // menu=x,y,width,height,message |
454 static int cmd_menu(char *in) | |
455 { | |
33089 | 456 int x, y, w, h, message; |
33071 | 457 char msg[32]; |
32873 | 458 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
459 if (!window_cmd("menu")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
460 return 1; |
32873 | 461 |
33058 | 462 if (in_window("main")) |
463 return 1; | |
464 if (in_window("sub")) | |
465 return 1; | |
466 if (in_window("playbar")) | |
467 return 1; | |
32873 | 468 |
33089 | 469 x = cutItemToInt(in, ',', 0); |
470 y = cutItemToInt(in, ',', 1); | |
471 w = cutItemToInt(in, ',', 2); | |
472 h = cutItemToInt(in, ',', 3); | |
33071 | 473 cutItem(in, msg, ',', 4); |
474 | |
475 message = appFindMessage(msg); | |
23077 | 476 |
33071 | 477 if (message == -1) { |
478 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
479 return 1; | |
480 } | |
32873 | 481 |
32937 | 482 skin->IndexOfMenuItems++; |
33072 | 483 skin->menuItems[skin->IndexOfMenuItems].x = x; |
484 skin->menuItems[skin->IndexOfMenuItems].y = y; | |
33089 | 485 skin->menuItems[skin->IndexOfMenuItems].width = w; |
486 skin->menuItems[skin->IndexOfMenuItems].height = h; | |
33071 | 487 skin->menuItems[skin->IndexOfMenuItems].message = message; |
23077 | 488 |
33089 | 489 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", skin->IndexOfMenuItems, x, y, w, h); |
33071 | 490 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, 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 { | |
33090 | 500 unsigned char pfname[256]; |
501 unsigned char phfname[256]; | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
502 unsigned char buf[512]; |
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
503 int pwidth, pheight, ph, d, x, y, w, h, message; |
32873 | 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); | |
33089 | 522 w = cutItemToInt(in, ',', 8); |
523 h = cutItemToInt(in, ',', 9); | |
524 cutItem(in, buf, ',', 10); | |
32873 | 525 |
33089 | 526 message = appFindMessage(buf); |
23077 | 527 |
33069 | 528 if (message == -1) { |
33089 | 529 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 530 return 1; |
531 } | |
532 | |
33089 | 533 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 534 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); |
535 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
33089 | 536 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 537 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
538 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
539 item = &currWinItems[*currWinItemIdx]; |
32873 | 540 item->type = itHPotmeter; |
541 item->x = x; | |
542 item->y = y; | |
33089 | 543 item->width = w; |
544 item->height = h; | |
32911 | 545 item->numphases = ph; |
546 item->pwidth = pwidth; | |
547 item->pheight = pheight; | |
548 item->message = message; | |
32873 | 549 item->value = (float)d; |
550 item->pressed = btnReleased; | |
551 item->Bitmap.Image = NULL; | |
23077 | 552 |
32873 | 553 if (strcmp(phfname, "NULL") != 0) { |
33089 | 554 av_strlcpy(buf, path, sizeof(buf)); |
555 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 556 |
33089 | 557 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 558 return 1; |
32951 | 559 |
560 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 561 } |
562 | |
563 item->Mask.Image = NULL; | |
23077 | 564 |
32873 | 565 if (strcmp(pfname, "NULL") != 0) { |
33089 | 566 av_strlcpy(buf, path, sizeof(buf)); |
567 av_strlcat(buf, pfname, sizeof(buf)); | |
32873 | 568 |
33089 | 569 if (skinBPRead(buf, &item->Mask) != 0) |
32873 | 570 return 1; |
32951 | 571 |
572 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); | |
32873 | 573 } |
574 | |
575 return 0; | |
23077 | 576 } |
577 | |
32873 | 578 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
579 static int cmd_vpotmeter(char *in) | |
23077 | 580 { |
33056 | 581 int r; |
32873 | 582 wItem *item; |
23077 | 583 |
33056 | 584 r = cmd_hpotmeter(in); |
585 | |
586 if (r == 0) { | |
33057 | 587 item = &currWinItems[*currWinItemIdx]; |
588 item->type = itVPotmeter; | |
33056 | 589 } |
33053 | 590 |
32873 | 591 return r; |
23077 | 592 } |
593 | |
32873 | 594 // potmeter=phases,numphases,default,x,y,width,height,message |
595 static int cmd_potmeter(char *in) | |
596 { | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
597 unsigned char phfname[256]; |
33089 | 598 unsigned char buf[512]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
599 int ph, d, x, y, w, h, message; |
32873 | 600 wItem *item; |
23077 | 601 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
602 if (!window_cmd("potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
603 return 1; |
23077 | 604 |
33058 | 605 if (in_window("sub")) |
606 return 1; | |
607 if (in_window("menu")) | |
608 return 1; | |
23077 | 609 |
32873 | 610 cutItem(in, phfname, ',', 0); |
611 ph = cutItemToInt(in, ',', 1); | |
612 d = cutItemToInt(in, ',', 2); | |
613 x = cutItemToInt(in, ',', 3); | |
614 y = cutItemToInt(in, ',', 4); | |
33089 | 615 w = cutItemToInt(in, ',', 5); |
616 h = cutItemToInt(in, ',', 6); | |
617 cutItem(in, buf, ',', 7); | |
32873 | 618 |
33089 | 619 message = appFindMessage(buf); |
23077 | 620 |
33069 | 621 if (message == -1) { |
33089 | 622 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 623 return 1; |
624 } | |
625 | |
33089 | 626 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 627 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); |
33089 | 628 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 629 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
630 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
631 item = &currWinItems[*currWinItemIdx]; |
32873 | 632 item->type = itPotmeter; |
633 item->x = x; | |
634 item->y = y; | |
33089 | 635 item->width = w; |
636 item->height = h; | |
32911 | 637 item->numphases = ph; |
638 item->message = message; | |
32873 | 639 item->value = (float)d; |
640 item->Bitmap.Image = NULL; | |
23077 | 641 |
32873 | 642 if (strcmp(phfname, "NULL") != 0) { |
33089 | 643 av_strlcpy(buf, path, sizeof(buf)); |
644 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 645 |
33089 | 646 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 647 return 1; |
32951 | 648 |
649 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 650 } |
651 | |
652 return 0; | |
23077 | 653 } |
654 | |
32873 | 655 // font=fontfile |
656 static int cmd_font(char *in) | |
657 { | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
658 char fnt[256]; |
32873 | 659 wItem *item; |
23077 | 660 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
661 if (!window_cmd("font")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
662 return 1; |
23077 | 663 |
33058 | 664 if (in_window("sub")) |
665 return 1; | |
666 if (in_window("menu")) | |
667 return 1; | |
23077 | 668 |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
669 cutItem(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility |
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
670 // reasons with a meanwhile depreciated second parameter. |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
671 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
672 item = &currWinItems[*currWinItemIdx]; |
32873 | 673 item->type = itFont; |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
674 item->fontid = fntRead(path, fnt); |
23077 | 675 |
32873 | 676 switch (item->fontid) { |
677 case -1: | |
33022 | 678 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 679 return 1; |
23077 | 680 |
32873 | 681 case -2: |
33022 | 682 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); |
32873 | 683 return 1; |
684 | |
685 case -3: | |
33022 | 686 skin_error(MSGTR_SKIN_FONT_FontFileNotFound); |
32873 | 687 return 1; |
688 | |
689 case -4: | |
33022 | 690 skin_error(MSGTR_SKIN_FONT_FontImageNotFound); |
32873 | 691 return 1; |
692 } | |
693 | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
694 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); |
32951 | 695 |
32873 | 696 return 0; |
23077 | 697 } |
698 | |
32873 | 699 // slabel=x,y,fontfile,"text" |
700 static int cmd_slabel(char *in) | |
23077 | 701 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
702 int x, y, id; |
33090 | 703 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
704 char txt[256]; |
32873 | 705 wItem *item; |
706 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
707 if (!window_cmd("slabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
708 return 1; |
23077 | 709 |
33058 | 710 if (in_window("sub")) |
711 return 1; | |
712 if (in_window("menu")) | |
713 return 1; | |
32873 | 714 |
715 x = cutItemToInt(in, ',', 0); | |
716 y = cutItemToInt(in, ',', 1); | |
33089 | 717 cutItem(in, fnt, ',', 2); |
718 cutItem(in, txt, ',', 3); | |
719 cutItem(txt, txt, '"', 1); | |
32951 | 720 |
33089 | 721 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt); |
32951 | 722 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
23077 | 723 |
33089 | 724 id = fntFindID(fnt); |
23077 | 725 |
32873 | 726 if (id < 0) { |
33089 | 727 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, fnt); |
32873 | 728 return 1; |
729 } | |
23077 | 730 |
33089 | 731 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 732 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
733 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
734 item = &currWinItems[*currWinItemIdx]; |
32873 | 735 item->type = itSLabel; |
736 item->fontid = id; | |
737 item->x = x; | |
738 item->y = y; | |
739 item->width = -1; | |
740 item->height = -1; | |
33089 | 741 item->label = strdup(txt); |
23077 | 742 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
743 if (!item->label) { |
33022 | 744 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 745 return 1; |
746 } | |
23077 | 747 |
32873 | 748 return 0; |
23077 | 749 } |
750 | |
32910 | 751 // dlabel=x,y,width,align,fontfile,"text" |
32873 | 752 static int cmd_dlabel(char *in) |
753 { | |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
754 int x, y, w, a, id; |
33090 | 755 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
756 char txt[256]; |
32873 | 757 wItem *item; |
23077 | 758 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
759 if (!window_cmd("dlabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
760 return 1; |
23077 | 761 |
33058 | 762 if (in_window("sub")) |
763 return 1; | |
764 if (in_window("menu")) | |
765 return 1; | |
32873 | 766 |
33089 | 767 x = cutItemToInt(in, ',', 0); |
768 y = cutItemToInt(in, ',', 1); | |
769 w = cutItemToInt(in, ',', 2); | |
770 a = cutItemToInt(in, ',', 3); | |
771 cutItem(in, fnt, ',', 4); | |
772 cutItem(in, txt, ',', 5); | |
773 cutItem(txt, txt, '"', 1); | |
32951 | 774 |
33089 | 775 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); |
32951 | 776 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
33089 | 777 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); |
23077 | 778 |
33089 | 779 id = fntFindID(fnt); |
23077 | 780 |
32873 | 781 if (id < 0) { |
33089 | 782 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, fnt); |
32873 | 783 return 1; |
784 } | |
23077 | 785 |
33089 | 786 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 787 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
788 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
789 item = &currWinItems[*currWinItemIdx]; |
32873 | 790 item->type = itDLabel; |
791 item->fontid = id; | |
792 item->align = a; | |
793 item->x = x; | |
794 item->y = y; | |
33089 | 795 item->width = w; |
32873 | 796 item->height = -1; |
33089 | 797 item->label = strdup(txt); |
23077 | 798 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
799 if (!item->label) { |
33022 | 800 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 801 return 1; |
802 } | |
23077 | 803 |
32873 | 804 return 0; |
23077 | 805 } |
806 | |
32873 | 807 // decoration=enable|disable |
808 static int cmd_decoration(char *in) | |
23077 | 809 { |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
810 if (!window_cmd("decoration")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
811 return 1; |
32873 | 812 |
33058 | 813 if (in_window("sub")) |
814 return 1; | |
815 if (in_window("playbar")) | |
816 return 1; | |
817 if (in_window("menu")) | |
818 return 1; | |
32873 | 819 |
33086 | 820 strlower(in); |
32873 | 821 |
33086 | 822 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
823 skin_error(MSGTR_SKIN_UnknownParameter, in); | |
32873 | 824 return 1; |
825 } | |
23077 | 826 |
33087 | 827 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 828 |
33086 | 829 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in); |
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 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
852 static char *setname(char *dir, char *sname) |
32873 | 853 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
854 static char skinfname[512]; |
32873 | 855 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
856 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
857 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
858 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
859 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
860 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
861 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 862 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
863 return skinfname; |
23077 | 864 } |
865 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
866 int skinRead(char *sname) |
23077 | 867 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
868 char *skinfname; |
32873 | 869 FILE *skinFile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
870 unsigned char line[256]; |
33075 | 871 unsigned char item[32]; |
32873 | 872 unsigned char param[256]; |
32944 | 873 unsigned int i; |
32873 | 874 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
875 skinfname = setname(skinDirInHome, sname); |
23077 | 876 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
877 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
878 skinfname = setname(skinMPlayerDir, sname); |
32873 | 879 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
880 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
881 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname); |
32873 | 882 return -1; |
883 } | |
23077 | 884 } |
32873 | 885 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
886 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 887 |
32932 | 888 appFreeStruct(); |
23077 | 889 |
33078 | 890 skin = NULL; |
891 currWinName[0] = 0; | |
33079 | 892 linenumber = 0; |
23077 | 893 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
894 while (fgets(line, sizeof(line), skinFile)) { |
32873 | 895 linenumber++; |
896 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
897 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
|
898 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
899 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
900 decomment(line); |
32873 | 901 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
902 if (!*line) |
32873 | 903 continue; |
23077 | 904 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
905 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
906 cutItem(line, param, '=', 1); |
33075 | 907 strlower(item); |
32873 | 908 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
909 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
|
910 if (!strcmp(item, skinItem[i].name)) { |
32873 | 911 if (skinItem[i].func(param) != 0) |
912 return -2; | |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
913 else |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
914 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
915 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
916 } |
33077 | 917 |
918 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
919 skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item); | |
920 return -2; | |
921 } | |
32873 | 922 } |
923 | |
924 if (linenumber == 0) { | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
925 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname); |
32873 | 926 return -1; |
927 } | |
928 | |
929 return 0; | |
23077 | 930 } |