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