Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 33096:ca1a01b56c90
Avoid using skin pointer.
During the further processing of the skin use currWin pointer instead.
author | ib |
---|---|
date | Fri, 01 Apr 2011 13:59:50 +0000 |
parents | 772af04413f3 |
children | 533c658a18da |
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 |
33096 | 232 currWin->x = x; |
233 currWin->y = y; | |
234 currWin->type = itBase; | |
32873 | 235 |
33089 | 236 av_strlcpy(file, path, sizeof(file)); |
237 av_strlcat(file, fname, sizeof(file)); | |
32873 | 238 |
33096 | 239 if (skinBPRead(file, &currWin->Bitmap) != 0) |
32873 | 240 return 1; |
241 | |
33096 | 242 currWin->width = currWin->Bitmap.Width; |
243 currWin->height = currWin->Bitmap.Height; | |
32873 | 244 |
33096 | 245 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
32951 | 246 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
247 #ifdef CONFIG_XSHAPE |
33096 | 248 Convert32to1(&currWin->Bitmap, &currWin->Mask, 0x00ff00ff); |
249 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); | |
23077 | 250 #else |
33096 | 251 currWin->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 | |
33096 | 258 currWin->type = itBase; |
32873 | 259 |
33089 | 260 av_strlcpy(file, path, sizeof(file)); |
261 av_strlcat(file, fname, sizeof(file)); | |
32873 | 262 |
33096 | 263 if (skinBPRead(file, &currWin->Bitmap) != 0) |
32873 | 264 return 1; |
265 | |
33096 | 266 currWin->x = x; |
267 currWin->y = y; | |
268 currWin->width = currWin->Bitmap.Width; | |
269 currWin->height = currWin->Bitmap.Height; | |
32873 | 270 |
33089 | 271 if (w && h) { |
33096 | 272 currWin->width = w; |
273 currWin->height = h; | |
32873 | 274 } |
275 | |
33096 | 276 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->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; |
33096 | 283 currWin->type = itBase; |
32873 | 284 |
33089 | 285 av_strlcpy(file, path, sizeof(file)); |
286 av_strlcat(file, fname, sizeof(file)); | |
32873 | 287 |
33096 | 288 if (skinBPRead(file, &currWin->Bitmap) != 0) |
32873 | 289 return 1; |
290 | |
33096 | 291 currWin->width = currWin->Bitmap.Width; |
292 currWin->height = currWin->Bitmap.Height; | |
32873 | 293 |
33096 | 294 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
32951 | 295 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
296 #ifdef CONFIG_XSHAPE |
33096 | 297 Convert32to1(&currWin->Bitmap, &currWin->Mask, 0x00ff00ff); |
298 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); | |
23077 | 299 #else |
33096 | 300 currWin->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; |
33096 | 308 currWin->x = x; |
309 currWin->y = y; | |
310 currWin->type = itBase; | |
32873 | 311 |
33089 | 312 av_strlcpy(file, path, sizeof(file)); |
313 av_strlcat(file, fname, sizeof(file)); | |
32873 | 314 |
33096 | 315 if (skinBPRead(file, &currWin->Bitmap) != 0) |
32873 | 316 return 1; |
317 | |
33096 | 318 currWin->width = currWin->Bitmap.Width; |
319 currWin->height = currWin->Bitmap.Height; | |
32873 | 320 |
33096 | 321 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
32951 | 322 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
323 #ifdef CONFIG_XSHAPE |
33096 | 324 Convert32to1(&currWin->Bitmap, &currWin->Mask, 0x00ff00ff); |
325 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); | |
23077 | 326 #else |
33096 | 327 currWin->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]; |
33096 | 424 wItem *currItem; |
32873 | 425 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
426 if (!window_cmd("selected")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
427 return 1; |
32873 | 428 |
33058 | 429 if (in_window("main")) |
430 return 1; | |
431 if (in_window("sub")) | |
432 return 1; | |
433 if (in_window("playbar")) | |
434 return 1; | |
32873 | 435 |
33096 | 436 currItem = &skin->menuSelected; |
437 currItem->type = itBase; | |
32873 | 438 |
33089 | 439 av_strlcpy(file, path, sizeof(file)); |
33091 | 440 av_strlcat(file, in, sizeof(file)); |
32873 | 441 |
33091 | 442 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image selected: %s\n", in); |
23077 | 443 |
33096 | 444 if (skinBPRead(file, &currItem->Bitmap) != 0) |
32873 | 445 return 1; |
446 | |
33096 | 447 currItem->width = currItem->Bitmap.Width; |
448 currItem->height = currItem->Bitmap.Height; | |
32873 | 449 |
33096 | 450 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currItem->width, currItem->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 { | |
33089 | 458 int x, y, w, h, message; |
33071 | 459 char msg[32]; |
33096 | 460 wItem *item; |
32873 | 461 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
462 if (!window_cmd("menu")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
463 return 1; |
32873 | 464 |
33058 | 465 if (in_window("main")) |
466 return 1; | |
467 if (in_window("sub")) | |
468 return 1; | |
469 if (in_window("playbar")) | |
470 return 1; | |
32873 | 471 |
33089 | 472 x = cutItemToInt(in, ',', 0); |
473 y = cutItemToInt(in, ',', 1); | |
474 w = cutItemToInt(in, ',', 2); | |
475 h = cutItemToInt(in, ',', 3); | |
33071 | 476 cutItem(in, msg, ',', 4); |
477 | |
478 message = appFindMessage(msg); | |
23077 | 479 |
33071 | 480 if (message == -1) { |
481 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
482 return 1; | |
483 } | |
32873 | 484 |
33096 | 485 (*currWinItemIdx)++; |
486 item = &currWinItems[*currWinItemIdx]; | |
487 item->x = x; | |
488 item->y = y; | |
489 item->width = w; | |
490 item->height = h; | |
491 item->message = message; | |
23077 | 492 |
33096 | 493 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h); |
33071 | 494 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
23077 | 495 |
33096 | 496 item->Bitmap.Image = NULL; |
33053 | 497 |
32873 | 498 return 0; |
23077 | 499 } |
500 | |
32873 | 501 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
502 static int cmd_hpotmeter(char *in) | |
503 { | |
33090 | 504 unsigned char pfname[256]; |
505 unsigned char phfname[256]; | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
506 unsigned char buf[512]; |
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
507 int pwidth, pheight, ph, d, x, y, w, h, message; |
32873 | 508 wItem *item; |
23077 | 509 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
510 if (!window_cmd("h/v potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
511 return 1; |
23077 | 512 |
33058 | 513 if (in_window("sub")) |
514 return 1; | |
515 if (in_window("menu")) | |
516 return 1; | |
23077 | 517 |
32873 | 518 cutItem(in, pfname, ',', 0); |
32911 | 519 pwidth = cutItemToInt(in, ',', 1); |
520 pheight = cutItemToInt(in, ',', 2); | |
32873 | 521 cutItem(in, phfname, ',', 3); |
522 ph = cutItemToInt(in, ',', 4); | |
523 d = cutItemToInt(in, ',', 5); | |
524 x = cutItemToInt(in, ',', 6); | |
525 y = cutItemToInt(in, ',', 7); | |
33089 | 526 w = cutItemToInt(in, ',', 8); |
527 h = cutItemToInt(in, ',', 9); | |
528 cutItem(in, buf, ',', 10); | |
32873 | 529 |
33089 | 530 message = appFindMessage(buf); |
23077 | 531 |
33069 | 532 if (message == -1) { |
33089 | 533 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 534 return 1; |
535 } | |
536 | |
33089 | 537 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 538 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); |
539 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
33089 | 540 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 541 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
542 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
543 item = &currWinItems[*currWinItemIdx]; |
32873 | 544 item->type = itHPotmeter; |
545 item->x = x; | |
546 item->y = y; | |
33089 | 547 item->width = w; |
548 item->height = h; | |
32911 | 549 item->numphases = ph; |
550 item->pwidth = pwidth; | |
551 item->pheight = pheight; | |
552 item->message = message; | |
32873 | 553 item->value = (float)d; |
554 item->pressed = btnReleased; | |
555 item->Bitmap.Image = NULL; | |
23077 | 556 |
32873 | 557 if (strcmp(phfname, "NULL") != 0) { |
33089 | 558 av_strlcpy(buf, path, sizeof(buf)); |
559 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 560 |
33089 | 561 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 562 return 1; |
32951 | 563 |
564 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 565 } |
566 | |
567 item->Mask.Image = NULL; | |
23077 | 568 |
32873 | 569 if (strcmp(pfname, "NULL") != 0) { |
33089 | 570 av_strlcpy(buf, path, sizeof(buf)); |
571 av_strlcat(buf, pfname, sizeof(buf)); | |
32873 | 572 |
33089 | 573 if (skinBPRead(buf, &item->Mask) != 0) |
32873 | 574 return 1; |
32951 | 575 |
576 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); | |
32873 | 577 } |
578 | |
579 return 0; | |
23077 | 580 } |
581 | |
32873 | 582 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
583 static int cmd_vpotmeter(char *in) | |
23077 | 584 { |
33056 | 585 int r; |
32873 | 586 wItem *item; |
23077 | 587 |
33056 | 588 r = cmd_hpotmeter(in); |
589 | |
590 if (r == 0) { | |
33057 | 591 item = &currWinItems[*currWinItemIdx]; |
592 item->type = itVPotmeter; | |
33056 | 593 } |
33053 | 594 |
32873 | 595 return r; |
23077 | 596 } |
597 | |
32873 | 598 // potmeter=phases,numphases,default,x,y,width,height,message |
599 static int cmd_potmeter(char *in) | |
600 { | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
601 unsigned char phfname[256]; |
33089 | 602 unsigned char buf[512]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
603 int ph, d, x, y, w, h, message; |
32873 | 604 wItem *item; |
23077 | 605 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
606 if (!window_cmd("potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
607 return 1; |
23077 | 608 |
33058 | 609 if (in_window("sub")) |
610 return 1; | |
611 if (in_window("menu")) | |
612 return 1; | |
23077 | 613 |
32873 | 614 cutItem(in, phfname, ',', 0); |
615 ph = cutItemToInt(in, ',', 1); | |
616 d = cutItemToInt(in, ',', 2); | |
617 x = cutItemToInt(in, ',', 3); | |
618 y = cutItemToInt(in, ',', 4); | |
33089 | 619 w = cutItemToInt(in, ',', 5); |
620 h = cutItemToInt(in, ',', 6); | |
621 cutItem(in, buf, ',', 7); | |
32873 | 622 |
33089 | 623 message = appFindMessage(buf); |
23077 | 624 |
33069 | 625 if (message == -1) { |
33089 | 626 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 627 return 1; |
628 } | |
629 | |
33089 | 630 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 631 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); |
33089 | 632 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 633 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
634 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
635 item = &currWinItems[*currWinItemIdx]; |
32873 | 636 item->type = itPotmeter; |
637 item->x = x; | |
638 item->y = y; | |
33089 | 639 item->width = w; |
640 item->height = h; | |
32911 | 641 item->numphases = ph; |
642 item->message = message; | |
32873 | 643 item->value = (float)d; |
644 item->Bitmap.Image = NULL; | |
23077 | 645 |
32873 | 646 if (strcmp(phfname, "NULL") != 0) { |
33089 | 647 av_strlcpy(buf, path, sizeof(buf)); |
648 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 649 |
33089 | 650 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 651 return 1; |
32951 | 652 |
653 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 654 } |
655 | |
656 return 0; | |
23077 | 657 } |
658 | |
32873 | 659 // font=fontfile |
660 static int cmd_font(char *in) | |
661 { | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
662 char fnt[256]; |
32873 | 663 wItem *item; |
23077 | 664 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
665 if (!window_cmd("font")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
666 return 1; |
23077 | 667 |
33058 | 668 if (in_window("sub")) |
669 return 1; | |
670 if (in_window("menu")) | |
671 return 1; | |
23077 | 672 |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
673 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
|
674 // reasons with a meanwhile depreciated second parameter. |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
675 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
676 item = &currWinItems[*currWinItemIdx]; |
32873 | 677 item->type = itFont; |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
678 item->fontid = fntRead(path, fnt); |
23077 | 679 |
32873 | 680 switch (item->fontid) { |
681 case -1: | |
33022 | 682 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 683 return 1; |
23077 | 684 |
32873 | 685 case -2: |
33022 | 686 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); |
32873 | 687 return 1; |
688 | |
689 case -3: | |
33022 | 690 skin_error(MSGTR_SKIN_FONT_FontFileNotFound); |
32873 | 691 return 1; |
692 | |
693 case -4: | |
33022 | 694 skin_error(MSGTR_SKIN_FONT_FontImageNotFound); |
32873 | 695 return 1; |
696 } | |
697 | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
698 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); |
32951 | 699 |
32873 | 700 return 0; |
23077 | 701 } |
702 | |
32873 | 703 // slabel=x,y,fontfile,"text" |
704 static int cmd_slabel(char *in) | |
23077 | 705 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
706 int x, y, id; |
33090 | 707 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
708 char txt[256]; |
32873 | 709 wItem *item; |
710 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
711 if (!window_cmd("slabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
712 return 1; |
23077 | 713 |
33058 | 714 if (in_window("sub")) |
715 return 1; | |
716 if (in_window("menu")) | |
717 return 1; | |
32873 | 718 |
719 x = cutItemToInt(in, ',', 0); | |
720 y = cutItemToInt(in, ',', 1); | |
33089 | 721 cutItem(in, fnt, ',', 2); |
722 cutItem(in, txt, ',', 3); | |
723 cutItem(txt, txt, '"', 1); | |
32951 | 724 |
33089 | 725 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt); |
32951 | 726 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
23077 | 727 |
33089 | 728 id = fntFindID(fnt); |
23077 | 729 |
32873 | 730 if (id < 0) { |
33089 | 731 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, fnt); |
32873 | 732 return 1; |
733 } | |
23077 | 734 |
33089 | 735 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 736 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
737 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
738 item = &currWinItems[*currWinItemIdx]; |
32873 | 739 item->type = itSLabel; |
740 item->fontid = id; | |
741 item->x = x; | |
742 item->y = y; | |
743 item->width = -1; | |
744 item->height = -1; | |
33089 | 745 item->label = strdup(txt); |
23077 | 746 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
747 if (!item->label) { |
33022 | 748 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 749 return 1; |
750 } | |
23077 | 751 |
32873 | 752 return 0; |
23077 | 753 } |
754 | |
32910 | 755 // dlabel=x,y,width,align,fontfile,"text" |
32873 | 756 static int cmd_dlabel(char *in) |
757 { | |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
758 int x, y, w, a, id; |
33090 | 759 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
760 char txt[256]; |
32873 | 761 wItem *item; |
23077 | 762 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
763 if (!window_cmd("dlabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
764 return 1; |
23077 | 765 |
33058 | 766 if (in_window("sub")) |
767 return 1; | |
768 if (in_window("menu")) | |
769 return 1; | |
32873 | 770 |
33089 | 771 x = cutItemToInt(in, ',', 0); |
772 y = cutItemToInt(in, ',', 1); | |
773 w = cutItemToInt(in, ',', 2); | |
774 a = cutItemToInt(in, ',', 3); | |
775 cutItem(in, fnt, ',', 4); | |
776 cutItem(in, txt, ',', 5); | |
777 cutItem(txt, txt, '"', 1); | |
32951 | 778 |
33089 | 779 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); |
32951 | 780 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
33089 | 781 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); |
23077 | 782 |
33089 | 783 id = fntFindID(fnt); |
23077 | 784 |
32873 | 785 if (id < 0) { |
33089 | 786 skin_error(MSGTR_SKIN_FONT_NonExistentFontID, fnt); |
32873 | 787 return 1; |
788 } | |
23077 | 789 |
33089 | 790 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 791 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
792 (*currWinItemIdx)++; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
793 item = &currWinItems[*currWinItemIdx]; |
32873 | 794 item->type = itDLabel; |
795 item->fontid = id; | |
796 item->align = a; | |
797 item->x = x; | |
798 item->y = y; | |
33089 | 799 item->width = w; |
32873 | 800 item->height = -1; |
33089 | 801 item->label = strdup(txt); |
23077 | 802 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
803 if (!item->label) { |
33022 | 804 skin_error(MSGTR_SKIN_FONT_NotEnoughtMemory); |
32873 | 805 return 1; |
806 } | |
23077 | 807 |
32873 | 808 return 0; |
23077 | 809 } |
810 | |
32873 | 811 // decoration=enable|disable |
812 static int cmd_decoration(char *in) | |
23077 | 813 { |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
814 if (!window_cmd("decoration")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
815 return 1; |
32873 | 816 |
33058 | 817 if (in_window("sub")) |
818 return 1; | |
819 if (in_window("playbar")) | |
820 return 1; | |
821 if (in_window("menu")) | |
822 return 1; | |
32873 | 823 |
33086 | 824 strlower(in); |
32873 | 825 |
33086 | 826 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
827 skin_error(MSGTR_SKIN_UnknownParameter, in); | |
32873 | 828 return 1; |
829 } | |
23077 | 830 |
33087 | 831 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 832 |
33086 | 833 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in); |
32873 | 834 |
835 return 0; | |
23077 | 836 } |
837 | |
32878 | 838 static _item skinItem[] = { |
32873 | 839 { "section", cmd_section }, |
840 { "end", cmd_end }, | |
841 { "window", cmd_window }, | |
842 { "base", cmd_base }, | |
843 { "button", cmd_button }, | |
844 { "selected", cmd_selected }, | |
845 { "background", cmd_background }, | |
846 { "vpotmeter", cmd_vpotmeter }, | |
847 { "hpotmeter", cmd_hpotmeter }, | |
848 { "potmeter", cmd_potmeter }, | |
849 { "font", cmd_font }, | |
850 { "slabel", cmd_slabel }, | |
851 { "dlabel", cmd_dlabel }, | |
852 { "decoration", cmd_decoration }, | |
853 { "menu", cmd_menu } | |
854 }; | |
855 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
856 static char *setname(char *dir, char *sname) |
32873 | 857 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
858 static char skinfname[512]; |
32873 | 859 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
860 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
861 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
862 av_strlcat(skinfname, sname, 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_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
865 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 866 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
867 return skinfname; |
23077 | 868 } |
869 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
870 int skinRead(char *sname) |
23077 | 871 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
872 char *skinfname; |
32873 | 873 FILE *skinFile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
874 unsigned char line[256]; |
33075 | 875 unsigned char item[32]; |
32873 | 876 unsigned char param[256]; |
32944 | 877 unsigned int i; |
32873 | 878 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
879 skinfname = setname(skinDirInHome, sname); |
23077 | 880 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
881 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
882 skinfname = setname(skinMPlayerDir, sname); |
32873 | 883 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
884 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
885 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname); |
32873 | 886 return -1; |
887 } | |
23077 | 888 } |
32873 | 889 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
890 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 891 |
32932 | 892 appFreeStruct(); |
23077 | 893 |
33078 | 894 skin = NULL; |
895 currWinName[0] = 0; | |
33079 | 896 linenumber = 0; |
23077 | 897 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
898 while (fgets(line, sizeof(line), skinFile)) { |
32873 | 899 linenumber++; |
900 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
901 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
|
902 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
903 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
904 decomment(line); |
32873 | 905 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
906 if (!*line) |
32873 | 907 continue; |
23077 | 908 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
909 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
910 cutItem(line, param, '=', 1); |
33075 | 911 strlower(item); |
32873 | 912 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
913 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
|
914 if (!strcmp(item, skinItem[i].name)) { |
32873 | 915 if (skinItem[i].func(param) != 0) |
916 return -2; | |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
917 else |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
918 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
919 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
920 } |
33077 | 921 |
922 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
923 skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item); | |
924 return -2; | |
925 } | |
32873 | 926 } |
927 | |
928 if (linenumber == 0) { | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
929 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname); |
32873 | 930 return -1; |
931 } | |
932 | |
933 return 0; | |
23077 | 934 } |