Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 37051:1468239c0fe3
Remove pointless initialization.
The variables will be set unconditionally anyway.
author | ib |
---|---|
date | Thu, 10 Apr 2014 10:20:27 +0000 |
parents | 3555aa94b881 |
children | 84c93a60ead3 |
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 |
33968 | 19 /** |
20 * @file | |
21 * @brief Skin parser | |
22 */ | |
23 | |
23077 | 24 #include <stdio.h> |
25 #include <string.h> | |
26 | |
32873 | 27 #include "skin.h" |
23077 | 28 #include "font.h" |
36032 | 29 #include "gui/interface.h" |
35525 | 30 #include "gui/app/app.h" |
31 #include "gui/app/gui.h" | |
35529 | 32 #include "gui/dialog/dialog.h" |
37024 | 33 #include "gui/util/misc.h" |
33048 | 34 #include "gui/util/string.h" |
23077 | 35 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
36 #include "help_mp.h" |
36032 | 37 #include "mp_msg.h" |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23077
diff
changeset
|
38 #include "libavutil/avstring.h" |
32944 | 39 #include "libavutil/common.h" |
23077 | 40 |
32873 | 41 typedef struct { |
42 const char *name; | |
43 int (*func)(char *in); | |
44 } _item; | |
23077 | 45 |
33749 | 46 char *skinDirInHome; |
36043 | 47 char *skinDirInData; |
33749 | 48 |
32937 | 49 static guiItems *skin; |
23077 | 50 |
32873 | 51 static int linenumber; |
37028 | 52 static unsigned char currItem[32]; |
32873 | 53 static unsigned char path[512]; |
23077 | 54 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
55 static unsigned char currWinName[32]; |
35688 | 56 static guiItem *currWin; |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
57 static int *currWinItemIdx; |
35688 | 58 static guiItem *currWinItems; |
23077 | 59 |
33968 | 60 /** |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
61 * @brief Print a legacy information on an entry. |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
62 * |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
63 * @param old identifier (and deprecated entry) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
64 * @param data pointer to additional data necessary for checking and |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
65 * to print the information on @a old |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
66 */ |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
67 static void skin_legacy(const char *old, const char *data) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
68 { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
69 const char *p; |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
70 |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
71 if (strcmp(old, "fontid") == 0) { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
72 p = strchr(data, ','); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
73 |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
74 if (p) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
75 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, p, "font = fontfile"); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
76 } else if (strcmp(old, "$l") == 0) { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
77 p = strstr(old, data); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
78 |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
79 if (p && (p == data || p[-1] != '$')) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
80 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "$p"); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
81 } else if (strcmp(old, "evSetURL") == 0 && strcmp(data, old) == 0) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
82 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "evLoadURL"); |
36892 | 83 else if (strcmp(old, "sub") == 0 || strcmp(old, "potmeter") == 0) |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
84 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, data); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
85 } |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
86 |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
87 /** |
33968 | 88 * @brief Display a skin error message. |
89 * | |
90 * @param format format string | |
91 * @param ... arguments | |
92 */ | |
33022 | 93 static void skin_error(const char *format, ...) |
23077 | 94 { |
32873 | 95 char p[512]; |
96 va_list ap; | |
97 | |
98 va_start(ap, format); | |
99 vsnprintf(p, sizeof(p), format, ap); | |
100 va_end(ap); | |
101 | |
36694 | 102 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinErrorMessage, linenumber, p); |
23077 | 103 } |
104 | |
33968 | 105 /** |
106 * @brief Check whether a @a section definition has started. | |
107 * | |
108 * @param item name of the item to be put in a message in case of an error | |
109 * | |
35493 | 110 * @return #True (ok) or #False (error) |
33968 | 111 */ |
33106 | 112 static int section_item(char *item) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
113 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
114 if (!skin) { |
36694 | 115 skin_error(MSGTR_GUI_MSG_SkinErrorSection, item); |
35493 | 116 return False; |
32873 | 117 } |
118 | |
35493 | 119 return True; |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
120 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
121 |
33968 | 122 /** |
123 * @brief Check whether a @a window definition has started. | |
124 * | |
125 * @param item name of the item to be put in a message in case of an error | |
126 * | |
35493 | 127 * @return #True (ok) or #False (error) |
33968 | 128 */ |
33106 | 129 static int window_item(char *item) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
130 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
131 if (!currWinName[0]) { |
36694 | 132 skin_error(MSGTR_GUI_MSG_SkinErrorWindow, item); |
35493 | 133 return False; |
32873 | 134 } |
23077 | 135 |
35493 | 136 return True; |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
137 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
138 |
33968 | 139 /** |
140 * @brief Check whether a specific @a window definition has started. | |
141 * | |
142 * @param name name of the window to be checked | |
143 * | |
144 * @return 0 (ok) or 1 (error) | |
145 */ | |
33058 | 146 static int in_window(char *name) |
147 { | |
148 if (strcmp(currWinName, name) == 0) { | |
36694 | 149 skin_error(MSGTR_GUI_MSG_SkinErrorItem, name); |
33058 | 150 return 1; |
32873 | 151 } |
152 | |
33058 | 153 return 0; |
154 } | |
155 | |
33968 | 156 /** |
157 * @brief Get next free item in current @a window. | |
158 * | |
159 * @return pointer to next free item (ok) or NULL (error) | |
160 */ | |
35688 | 161 static guiItem *next_item(void) |
33098 | 162 { |
35688 | 163 guiItem *item = NULL; |
33098 | 164 |
165 if (*currWinItemIdx < MAX_ITEMS - 1) { | |
166 (*currWinItemIdx)++; | |
167 item = &currWinItems[*currWinItemIdx]; | |
168 } else | |
36694 | 169 skin_error(MSGTR_GUI_MSG_SkinTooManyItems); |
33098 | 170 |
171 return item; | |
172 } | |
173 | |
33968 | 174 /** |
175 * @brief Parse a @a section definition. | |
176 * | |
177 * Syntax: section=movieplayer | |
178 * | |
179 * @param in definition to be analyzed | |
180 * | |
181 * @return 0 (ok) or 1 (error) | |
182 */ | |
33106 | 183 static int item_section(char *in) |
23077 | 184 { |
33064 | 185 if (skin) { |
37028 | 186 skin_error(MSGTR_GUI_MSG_SkinErrorItem, currItem); |
33064 | 187 return 1; |
188 } | |
189 | |
33055 | 190 if (!strcmp(strlower(in), "movieplayer")) |
33555 | 191 skin = &guiApp; |
33067 | 192 else { |
36694 | 193 skin_error(MSGTR_GUI_MSG_SkinUnknownName, in); |
33067 | 194 return 1; |
195 } | |
32873 | 196 |
37028 | 197 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s\n", currItem, in); |
32873 | 198 |
199 return 0; | |
23077 | 200 } |
201 | |
33968 | 202 /** |
203 * @brief Parse an @a end definition. | |
204 * | |
205 * Syntax: end | |
206 * | |
207 * @param in definition to be analyzed | |
208 * | |
209 * @return 0 (ok) or 1 (error) | |
210 */ | |
33106 | 211 static int item_end(char *in) |
23077 | 212 { |
32951 | 213 char *space, *name; |
214 | |
33985 | 215 (void)in; |
216 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
217 if (currWinName[0]) { |
32951 | 218 space = " "; |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
219 name = currWinName; |
32951 | 220 } else { |
221 space = ""; | |
222 name = "section"; | |
223 } | |
224 | |
37028 | 225 if (!section_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
226 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
227 |
37028 | 228 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s%s (%s)\n", space, currItem, name); |
32951 | 229 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
230 if (currWinName[0]) { |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
231 currWinName[0] = 0; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
232 currWin = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
233 currWinItemIdx = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
234 currWinItems = NULL; |
32873 | 235 } else |
32937 | 236 skin = NULL; |
32873 | 237 |
238 return 0; | |
23077 | 239 } |
240 | |
33968 | 241 /** |
242 * @brief Parse a @a window definition. | |
243 * | |
34697 | 244 * Syntax: window=main|video|playbar|menu |
33968 | 245 * |
246 * @param in definition to be analyzed | |
247 * | |
248 * @return 0 (ok) or 1 (error) | |
249 */ | |
33106 | 250 static int item_window(char *in) |
23077 | 251 { |
37028 | 252 if (!section_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
253 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
254 |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
255 if (currWinName[0]) { |
37028 | 256 skin_error(MSGTR_GUI_MSG_SkinErrorItem, currItem); |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
257 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
258 } |
32873 | 259 |
33083 | 260 strlower(in); |
23077 | 261 |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
262 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
263 if (strcmp(in, "sub") == 0) { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
264 strcpy(in, "video"); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
265 skin_legacy("sub", in); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
266 } |
34697 | 267 |
33083 | 268 if (strcmp(in, "main") == 0) { |
33095 | 269 currWin = &skin->main; |
270 currWinItemIdx = &skin->IndexOfMainItems; | |
271 currWinItems = skin->mainItems; | |
34697 | 272 } else if (strcmp(in, "video") == 0) { |
273 currWin = &skin->video; | |
33083 | 274 currWinItemIdx = NULL; |
275 currWinItems = NULL; | |
276 } else if (strcmp(in, "playbar") == 0) { | |
33555 | 277 currWin = &skin->playbar; |
278 currWinItemIdx = &skin->IndexOfPlaybarItems; | |
279 currWinItems = skin->playbarItems; | |
33083 | 280 } else if (strcmp(in, "menu") == 0) { |
33095 | 281 currWin = &skin->menu; |
282 currWinItemIdx = &skin->IndexOfMenuItems; | |
283 currWinItems = skin->menuItems; | |
33066 | 284 } else { |
36694 | 285 skin_error(MSGTR_GUI_MSG_SkinUnknownName, in); |
33066 | 286 return 1; |
287 } | |
32873 | 288 |
33083 | 289 av_strlcpy(currWinName, in, sizeof(currWinName)); |
290 | |
37028 | 291 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s\n", currItem, currWinName); |
32873 | 292 |
293 return 0; | |
23077 | 294 } |
295 | |
33968 | 296 /** |
297 * @brief Parse a @a base definition. | |
298 * | |
299 * Syntax: base=image,x,y[,width,height] | |
300 * | |
301 * @param in definition to be analyzed | |
302 * | |
303 * @return 0 (ok) or 1 (error) | |
304 */ | |
33106 | 305 static int item_base(char *in) |
23077 | 306 { |
33090 | 307 unsigned char fname[256]; |
33089 | 308 unsigned char file[512]; |
37051 | 309 int x, y, w, h; |
34697 | 310 int is_video, is_bar, is_menu; |
32873 | 311 |
37028 | 312 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
313 return 1; |
23077 | 314 |
34697 | 315 is_video = (strcmp(currWinName, "video") == 0); |
34698 | 316 is_bar = (strcmp(currWinName, "playbar") == 0); |
317 is_menu = (strcmp(currWinName, "menu") == 0); | |
33104 | 318 |
36991 | 319 cutStr(in, fname, ',', 0); |
320 x = cutInt(in, ',', 1); | |
321 y = cutInt(in, ',', 2); | |
322 w = cutInt(in, ',', 3); | |
323 h = cutInt(in, ',', 4); | |
32873 | 324 |
33985 | 325 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s", fname); |
23077 | 326 |
33105 | 327 currWin->type = itBase; |
33104 | 328 |
33105 | 329 if (!is_menu) { |
330 currWin->x = x; | |
331 currWin->y = y; | |
32873 | 332 |
33985 | 333 mp_msg(MSGT_GPLAYER, MSGL_DBG2, " %d,%d", x, y); |
33105 | 334 } |
32951 | 335 |
33985 | 336 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "\n"); |
32873 | 337 |
35785 | 338 if (is_video && (strcmp(fname, "NULL") == 0)) { |
339 currWin->width = 0; | |
340 currWin->height = 0; | |
341 } else { | |
35786 | 342 av_strlcpy(file, path, sizeof(file)); |
343 av_strlcat(file, fname, sizeof(file)); | |
32873 | 344 |
35786 | 345 if (skinImageRead(file, &currWin->Bitmap) != 0) |
346 return 1; | |
32873 | 347 |
35786 | 348 currWin->width = currWin->Bitmap.Width; |
349 currWin->height = currWin->Bitmap.Height; | |
35785 | 350 } |
32873 | 351 |
34697 | 352 if (is_video) { |
33089 | 353 if (w && h) { |
33096 | 354 currWin->width = w; |
355 currWin->height = h; | |
32873 | 356 } |
33105 | 357 } |
32873 | 358 |
35785 | 359 if (currWin->width == 0 || currWin->height == 0) |
360 return 1; | |
361 | |
36975 | 362 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %dx%d\n", is_video && w && h ? "size" : " bitmap", currWin->width, currWin->height); |
32951 | 363 |
34697 | 364 if (!is_video) { |
33555 | 365 if (!bpRenderMask(&currWin->Bitmap, &currWin->Mask)) { |
36694 | 366 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
33114 | 367 return 1; |
368 } | |
36996 | 369 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %ux%u\n", currWin->Mask.Width, currWin->Mask.Height); |
33105 | 370 } |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
371 |
33105 | 372 if (is_bar) |
35493 | 373 skin->playbarIsPresent = True; |
33105 | 374 if (is_menu) |
35493 | 375 skin->menuIsPresent = True; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
376 |
32873 | 377 return 0; |
23077 | 378 } |
379 | |
33968 | 380 /** |
381 * @brief Parse a @a background definition. | |
382 * | |
383 * Syntax: background=R,G,B | |
384 * | |
385 * @param in definition to be analyzed | |
386 * | |
387 * @return 0 (ok) or 1 (error) | |
388 */ | |
33106 | 389 static int item_background(char *in) |
23077 | 390 { |
37028 | 391 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
392 return 1; |
23077 | 393 |
33058 | 394 if (in_window("main")) |
395 return 1; | |
33088 | 396 if (in_window("playbar")) |
397 return 1; | |
33058 | 398 if (in_window("menu")) |
399 return 1; | |
23077 | 400 |
36991 | 401 currWin->R = cutInt(in, ',', 0); |
402 currWin->G = cutInt(in, ',', 1); | |
403 currWin->B = cutInt(in, ',', 2); | |
23077 | 404 |
37028 | 405 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s color: #%02x%02x%02x\n", currItem, currWin->R, currWin->G, currWin->B); |
23077 | 406 |
32873 | 407 return 0; |
23077 | 408 } |
409 | |
33968 | 410 /** |
411 * @brief Parse a @a button definition. | |
412 * | |
413 * Syntax: button=image,x,y,width,height,message | |
414 * | |
415 * @param in definition to be analyzed | |
416 * | |
417 * @return 0 (ok) or 1 (error) | |
418 */ | |
33106 | 419 static int item_button(char *in) |
23077 | 420 { |
33090 | 421 unsigned char fname[256]; |
33089 | 422 unsigned char file[512]; |
423 int x, y, w, h, message; | |
32873 | 424 char msg[32]; |
35688 | 425 guiItem *item; |
32873 | 426 |
37028 | 427 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
428 return 1; |
32873 | 429 |
34697 | 430 if (in_window("video")) |
33058 | 431 return 1; |
432 if (in_window("menu")) | |
433 return 1; | |
23077 | 434 |
36991 | 435 cutStr(in, fname, ',', 0); |
436 x = cutInt(in, ',', 1); | |
437 y = cutInt(in, ',', 2); | |
438 w = cutInt(in, ',', 3); | |
439 h = cutInt(in, ',', 4); | |
440 cutStr(in, msg, ',', 5); | |
32873 | 441 |
33071 | 442 message = appFindMessage(msg); |
443 | |
444 if (message == -1) { | |
36694 | 445 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, msg); |
33071 | 446 return 1; |
447 } | |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
448 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
449 else |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
450 skin_legacy("evSetURL", msg); |
33071 | 451 |
37028 | 452 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s image: %s %d,%d\n", currItem, fname, x, y); |
33985 | 453 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
454 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", w, h); | |
33102
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
455 |
33098 | 456 item = next_item(); |
457 | |
458 if (!item) | |
459 return 1; | |
460 | |
461 item->type = itButton; | |
462 item->x = x; | |
463 item->y = y; | |
464 item->width = w; | |
465 item->height = h; | |
466 item->message = message; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
467 item->pressed = btnReleased; |
23077 | 468 |
33098 | 469 if (item->message == evPauseSwitchToPlay) |
470 item->pressed = btnDisabled; | |
23077 | 471 |
33098 | 472 item->Bitmap.Image = NULL; |
32873 | 473 |
474 if (strcmp(fname, "NULL") != 0) { | |
33089 | 475 av_strlcpy(file, path, sizeof(file)); |
476 av_strlcat(file, fname, sizeof(file)); | |
32873 | 477 |
33969 | 478 if (skinImageRead(file, &item->Bitmap) != 0) |
32873 | 479 return 1; |
32951 | 480 |
36996 | 481 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %ux%u)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 482 } |
483 | |
484 return 0; | |
23077 | 485 } |
486 | |
33968 | 487 /** |
488 * @brief Parse a @a selected definition. | |
489 * | |
490 * Syntax: selected=image | |
491 * | |
492 * @param in definition to be analyzed | |
493 * | |
494 * @return 0 (ok) or 1 (error) | |
495 */ | |
33106 | 496 static int item_selected(char *in) |
32873 | 497 { |
33089 | 498 unsigned char file[512]; |
37028 | 499 guiItem *item; |
32873 | 500 |
37028 | 501 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
502 return 1; |
32873 | 503 |
33058 | 504 if (in_window("main")) |
505 return 1; | |
34697 | 506 if (in_window("video")) |
33058 | 507 return 1; |
508 if (in_window("playbar")) | |
509 return 1; | |
32873 | 510 |
37028 | 511 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image %s: %s\n", currItem, in); |
33102
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
512 |
37028 | 513 item = &skin->menuSelected; |
514 item->type = itBase; | |
32873 | 515 |
33089 | 516 av_strlcpy(file, path, sizeof(file)); |
33091 | 517 av_strlcat(file, in, sizeof(file)); |
32873 | 518 |
37028 | 519 if (skinImageRead(file, &item->Bitmap) != 0) |
32873 | 520 return 1; |
521 | |
37028 | 522 item->width = item->Bitmap.Width; |
523 item->height = item->Bitmap.Height; | |
32873 | 524 |
37028 | 525 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", item->width, item->height); |
32873 | 526 |
527 return 0; | |
528 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
529 |
33968 | 530 /** |
531 * @brief Parse a @a menu definition. | |
532 * | |
533 * Syntax: menu=x,y,width,height,message | |
534 * | |
535 * @param in definition to be analyzed | |
536 * | |
537 * @return 0 (ok) or 1 (error) | |
538 */ | |
33106 | 539 static int item_menu(char *in) |
32873 | 540 { |
33089 | 541 int x, y, w, h, message; |
33071 | 542 char msg[32]; |
35688 | 543 guiItem *item; |
32873 | 544 |
37028 | 545 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
546 return 1; |
32873 | 547 |
33058 | 548 if (in_window("main")) |
549 return 1; | |
34697 | 550 if (in_window("video")) |
33058 | 551 return 1; |
552 if (in_window("playbar")) | |
553 return 1; | |
32873 | 554 |
36991 | 555 x = cutInt(in, ',', 0); |
556 y = cutInt(in, ',', 1); | |
557 w = cutInt(in, ',', 2); | |
558 h = cutInt(in, ',', 3); | |
559 cutStr(in, msg, ',', 4); | |
33071 | 560 |
561 message = appFindMessage(msg); | |
23077 | 562 |
33071 | 563 if (message == -1) { |
36694 | 564 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, msg); |
33071 | 565 return 1; |
566 } | |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
567 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
568 else |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
569 skin_legacy("evSetURL", msg); |
32873 | 570 |
33098 | 571 item = next_item(); |
572 | |
573 if (!item) | |
574 return 1; | |
575 | |
33100 | 576 item->type = itMenu; |
33096 | 577 item->x = x; |
578 item->y = y; | |
579 item->width = w; | |
580 item->height = h; | |
581 item->message = message; | |
23077 | 582 |
33985 | 583 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h); |
584 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); | |
23077 | 585 |
33096 | 586 item->Bitmap.Image = NULL; |
33053 | 587 |
32873 | 588 return 0; |
23077 | 589 } |
590 | |
33968 | 591 /** |
37027 | 592 * @brief Parse a hpotmeter or vpotmeter definition. |
33968 | 593 * |
37027 | 594 * Parameters: button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
33968 | 595 * |
37027 | 596 * @param item pointer to item to store the parameters in |
33968 | 597 * @param in definition to be analyzed |
598 * | |
599 * @return 0 (ok) or 1 (error) | |
600 */ | |
37027 | 601 static int parse_potmeter(guiItem *item, char *in) |
32873 | 602 { |
36999 | 603 unsigned char bfname[256]; |
33090 | 604 unsigned char phfname[256]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
605 unsigned char buf[512]; |
36999 | 606 int bwidth, bheight, num, d, x, y, w, h, message; |
23077 | 607 |
37028 | 608 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
609 return 1; |
23077 | 610 |
34697 | 611 if (in_window("video")) |
33058 | 612 return 1; |
613 if (in_window("menu")) | |
614 return 1; | |
23077 | 615 |
36999 | 616 cutStr(in, bfname, ',', 0); |
617 bwidth = cutInt(in, ',', 1); | |
618 bheight = cutInt(in, ',', 2); | |
36991 | 619 cutStr(in, phfname, ',', 3); |
36999 | 620 num = cutInt(in, ',', 4); |
37000 | 621 d = cutInt(in, ',', 5); |
622 x = cutInt(in, ',', 6); | |
623 y = cutInt(in, ',', 7); | |
624 w = cutInt(in, ',', 8); | |
625 h = cutInt(in, ',', 9); | |
36991 | 626 cutStr(in, buf, ',', 10); |
32873 | 627 |
33089 | 628 message = appFindMessage(buf); |
23077 | 629 |
33069 | 630 if (message == -1) { |
36694 | 631 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf); |
33069 | 632 return 1; |
633 } | |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
634 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
635 else |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
636 skin_legacy("evSetURL", buf); |
33069 | 637 |
37050 | 638 if (d < 0 || d > 100) { |
639 skin_error(MSGTR_GUI_MSG_SkinErrorDefault, d); | |
640 return 1; | |
641 } | |
642 | |
37028 | 643 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s image: %s %d,%d %dx%d\n", currItem, phfname, x, y, w, h); |
36999 | 644 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", bfname, bwidth, bheight); |
645 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", num, d); | |
33985 | 646 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 647 |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
648 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
649 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
650 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
651 item->height = h; |
37020 | 652 item->pbwidth = bwidth; |
653 item->pbheight = bheight; | |
36999 | 654 item->numphases = num; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
655 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
656 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
657 item->pressed = btnReleased; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
658 |
32873 | 659 item->Bitmap.Image = NULL; |
23077 | 660 |
32873 | 661 if (strcmp(phfname, "NULL") != 0) { |
37001 | 662 if (num == 0) { |
663 skin_error(MSGTR_GUI_MSG_SkinErrorNumphases); | |
664 return 1; | |
665 } | |
666 | |
33089 | 667 av_strlcpy(buf, path, sizeof(buf)); |
668 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 669 |
33969 | 670 if (skinImageRead(buf, &item->Bitmap) != 0) |
32873 | 671 return 1; |
32951 | 672 |
37028 | 673 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (%s bitmap: %ux%u)\n", currItem, item->Bitmap.Width, item->Bitmap.Height); |
32873 | 674 } |
675 | |
676 item->Mask.Image = NULL; | |
23077 | 677 |
36999 | 678 if (strcmp(bfname, "NULL") != 0) { |
33089 | 679 av_strlcpy(buf, path, sizeof(buf)); |
36999 | 680 av_strlcat(buf, bfname, sizeof(buf)); |
32873 | 681 |
33969 | 682 if (skinImageRead(buf, &item->Mask) != 0) |
32873 | 683 return 1; |
32951 | 684 |
36996 | 685 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %ux%u)\n", item->Mask.Width, item->Mask.Height); |
32873 | 686 } |
687 | |
688 return 0; | |
23077 | 689 } |
690 | |
33968 | 691 /** |
37027 | 692 * @brief Parse a @a hpotmeter definition. |
693 * | |
694 * Syntax: hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message | |
695 * | |
696 * @param in definition to be analyzed | |
697 * | |
698 * @return 0 (ok) or 1 (error) | |
699 */ | |
700 static int item_hpotmeter(char *in) | |
701 { | |
702 guiItem *item; | |
703 | |
704 item = next_item(); | |
705 | |
706 if (!item) | |
707 return 1; | |
708 | |
709 item->type = itHPotmeter; | |
710 | |
711 return parse_potmeter(item, in); | |
712 } | |
713 | |
714 /** | |
33968 | 715 * @brief Parse a @a vpotmeter definition. |
716 * | |
717 * Syntax: vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message | |
718 * | |
719 * @param in definition to be analyzed | |
720 * | |
721 * @return 0 (ok) or 1 (error) | |
722 */ | |
33106 | 723 static int item_vpotmeter(char *in) |
23077 | 724 { |
35688 | 725 guiItem *item; |
23077 | 726 |
37027 | 727 item = next_item(); |
33056 | 728 |
37027 | 729 if (!item) |
730 return 1; | |
33053 | 731 |
37027 | 732 item->type = itVPotmeter; |
733 | |
734 return parse_potmeter(item, in); | |
23077 | 735 } |
736 | |
33968 | 737 /** |
738 * @brief Parse a @a potmeter definition. | |
739 * | |
740 * Syntax: potmeter=phases,numphases,default,x,y,width,height,message | |
741 * | |
36920 | 742 * @note THIS ITEM IS DEPRECATED. |
743 * | |
33968 | 744 * @param in definition to be analyzed |
745 * | |
746 * @return 0 (ok) or 1 (error) | |
747 */ | |
33106 | 748 static int item_potmeter(char *in) |
32873 | 749 { |
36892 | 750 char param[256]; |
751 | |
752 // legacy | |
37028 | 753 skin_legacy(currItem, "hpotmeter"); |
36892 | 754 |
755 snprintf(param, sizeof(param), "NULL,0,0,%s", in); | |
756 | |
757 return item_hpotmeter(param); | |
36920 | 758 } |
759 | |
760 /** | |
761 * @brief Parse a @a pimage definition. | |
762 * | |
763 * Syntax: pimage=phases,numphases,default,x,y,width,height,message | |
764 * | |
765 * @param in definition to be analyzed | |
766 * | |
767 * @return 0 (ok) or 1 (error) | |
768 */ | |
769 static int item_pimage(char *in) | |
770 { | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
771 unsigned char phfname[256]; |
33089 | 772 unsigned char buf[512]; |
36999 | 773 int num, d, x, y, w, h, message; |
35688 | 774 guiItem *item; |
23077 | 775 |
37028 | 776 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
777 return 1; |
23077 | 778 |
34697 | 779 if (in_window("video")) |
33058 | 780 return 1; |
781 if (in_window("menu")) | |
782 return 1; | |
23077 | 783 |
36991 | 784 cutStr(in, phfname, ',', 0); |
36999 | 785 num = cutInt(in, ',', 1); |
37000 | 786 d = cutInt(in, ',', 2); |
787 x = cutInt(in, ',', 3); | |
788 y = cutInt(in, ',', 4); | |
789 w = cutInt(in, ',', 5); | |
790 h = cutInt(in, ',', 6); | |
36991 | 791 cutStr(in, buf, ',', 7); |
32873 | 792 |
33089 | 793 message = appFindMessage(buf); |
23077 | 794 |
33069 | 795 if (message == -1) { |
36694 | 796 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf); |
33069 | 797 return 1; |
798 } | |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
799 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
800 else |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
801 skin_legacy("evSetURL", buf); |
33069 | 802 |
37050 | 803 if (d < 0 || d > 100) { |
804 skin_error(MSGTR_GUI_MSG_SkinErrorDefault, d); | |
805 return 1; | |
806 } | |
807 | |
37028 | 808 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s image: %s %d,%d %dx%d\n", currItem, phfname, x, y, w, h); |
36999 | 809 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", num, d); |
33985 | 810 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 811 |
33098 | 812 item = next_item(); |
813 | |
814 if (!item) | |
815 return 1; | |
816 | |
36920 | 817 item->type = itPimage; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
818 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
819 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
820 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
821 item->height = h; |
36999 | 822 item->numphases = num; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
823 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
824 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
825 |
32873 | 826 item->Bitmap.Image = NULL; |
23077 | 827 |
32873 | 828 if (strcmp(phfname, "NULL") != 0) { |
37001 | 829 if (num == 0) { |
830 skin_error(MSGTR_GUI_MSG_SkinErrorNumphases); | |
831 return 1; | |
832 } | |
833 | |
33089 | 834 av_strlcpy(buf, path, sizeof(buf)); |
835 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 836 |
33969 | 837 if (skinImageRead(buf, &item->Bitmap) != 0) |
32873 | 838 return 1; |
32951 | 839 |
36996 | 840 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %ux%u)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 841 } |
842 | |
843 return 0; | |
23077 | 844 } |
845 | |
33968 | 846 /** |
847 * @brief Parse a @a font definition. | |
848 * | |
849 * Syntax: font=fontfile | |
850 * | |
851 * @param in definition to be analyzed | |
852 * | |
853 * @return 0 (ok) or 1 (error) | |
854 */ | |
33106 | 855 static int item_font(char *in) |
32873 | 856 { |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
857 char fnt[256]; |
23077 | 858 |
37028 | 859 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
860 return 1; |
23077 | 861 |
34697 | 862 if (in_window("video")) |
33058 | 863 return 1; |
864 if (in_window("menu")) | |
865 return 1; | |
23077 | 866 |
36991 | 867 cutStr(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility |
868 // reasons with a meanwhile deprecated second parameter. | |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
869 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
870 skin_legacy("fontid", in); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
871 |
33099
0b17f6bed6fc
Don't needlessly store font information in the wItems array
ib
parents:
33098
diff
changeset
|
872 switch (fntRead(path, fnt)) { |
32873 | 873 case -1: |
36694 | 874 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 875 return 1; |
23077 | 876 |
32873 | 877 case -2: |
36694 | 878 skin_error(MSGTR_GUI_MSG_SkinTooManyFonts); |
32873 | 879 return 1; |
880 | |
881 case -3: | |
36694 | 882 skin_error(MSGTR_GUI_MSG_SkinFontFileNotFound); |
32873 | 883 return 1; |
884 | |
885 case -4: | |
36694 | 886 skin_error(MSGTR_GUI_MSG_SkinFontImageNotFound); |
32873 | 887 return 1; |
888 } | |
889 | |
37028 | 890 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s (#%d)\n", currItem, fnt, fntFindID(fnt)); |
32951 | 891 |
32873 | 892 return 0; |
23077 | 893 } |
894 | |
33968 | 895 /** |
896 * @brief Parse a @a slabel definition. | |
897 * | |
898 * Syntax: slabel=x,y,fontfile,"text" | |
899 * | |
900 * @param in definition to be analyzed | |
901 * | |
902 * @return 0 (ok) or 1 (error) | |
903 */ | |
33106 | 904 static int item_slabel(char *in) |
23077 | 905 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
906 int x, y, id; |
33090 | 907 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
908 char txt[256]; |
35688 | 909 guiItem *item; |
32873 | 910 |
37028 | 911 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
912 return 1; |
23077 | 913 |
34697 | 914 if (in_window("video")) |
33058 | 915 return 1; |
916 if (in_window("menu")) | |
917 return 1; | |
32873 | 918 |
36991 | 919 x = cutInt(in, ',', 0); |
920 y = cutInt(in, ',', 1); | |
921 cutStr(in, fnt, ',', 2); | |
922 cutStr(in, txt, ',', 3); | |
923 cutStr(txt, txt, '"', 1); | |
32951 | 924 |
37028 | 925 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: \"%s\"\n", currItem, txt); |
33985 | 926 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
23077 | 927 |
33089 | 928 id = fntFindID(fnt); |
23077 | 929 |
32873 | 930 if (id < 0) { |
36694 | 931 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt); |
32873 | 932 return 1; |
933 } | |
23077 | 934 |
33985 | 935 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 936 |
33098 | 937 item = next_item(); |
938 | |
939 if (!item) | |
940 return 1; | |
941 | |
32873 | 942 item->type = itSLabel; |
943 item->x = x; | |
944 item->y = y; | |
945 item->width = -1; | |
946 item->height = -1; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
947 item->fontid = id; |
33089 | 948 item->label = strdup(txt); |
23077 | 949 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
950 if (!item->label) { |
36694 | 951 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 952 return 1; |
953 } | |
23077 | 954 |
32873 | 955 return 0; |
23077 | 956 } |
957 | |
33968 | 958 /** |
959 * @brief Parse a @a dlabel definition. | |
960 * | |
961 * Syntax: dlabel=x,y,width,align,fontfile,"text" | |
962 * | |
963 * @param in definition to be analyzed | |
964 * | |
965 * @return 0 (ok) or 1 (error) | |
966 */ | |
33106 | 967 static int item_dlabel(char *in) |
32873 | 968 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
969 int x, y, w, a, id; |
33090 | 970 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
971 char txt[256]; |
35688 | 972 guiItem *item; |
23077 | 973 |
37028 | 974 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
975 return 1; |
23077 | 976 |
34697 | 977 if (in_window("video")) |
33058 | 978 return 1; |
979 if (in_window("menu")) | |
980 return 1; | |
32873 | 981 |
36991 | 982 x = cutInt(in, ',', 0); |
983 y = cutInt(in, ',', 1); | |
984 w = cutInt(in, ',', 2); | |
985 a = cutInt(in, ',', 3); | |
986 cutStr(in, fnt, ',', 4); | |
987 cutStr(in, txt, ',', 5); | |
988 cutStr(txt, txt, '"', 1); | |
32951 | 989 |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
990 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
991 skin_legacy("$l", txt); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
992 |
37028 | 993 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: \"%s\"\n", currItem, txt); |
33985 | 994 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
995 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); | |
23077 | 996 |
33089 | 997 id = fntFindID(fnt); |
23077 | 998 |
32873 | 999 if (id < 0) { |
36694 | 1000 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt); |
32873 | 1001 return 1; |
1002 } | |
23077 | 1003 |
33985 | 1004 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 1005 |
33098 | 1006 item = next_item(); |
1007 | |
1008 if (!item) | |
1009 return 1; | |
1010 | |
32873 | 1011 item->type = itDLabel; |
1012 item->x = x; | |
1013 item->y = y; | |
33089 | 1014 item->width = w; |
32873 | 1015 item->height = -1; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
1016 item->fontid = id; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
1017 item->align = a; |
33089 | 1018 item->label = strdup(txt); |
23077 | 1019 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
1020 if (!item->label) { |
36694 | 1021 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 1022 return 1; |
1023 } | |
23077 | 1024 |
32873 | 1025 return 0; |
23077 | 1026 } |
1027 | |
33968 | 1028 /** |
1029 * @brief Parse a @a decoration definition. | |
1030 * | |
1031 * Syntax: decoration=enable|disable | |
1032 * | |
1033 * @param in definition to be analyzed | |
1034 * | |
1035 * @return 0 (ok) or 1 (error) | |
1036 */ | |
33106 | 1037 static int item_decoration(char *in) |
23077 | 1038 { |
37028 | 1039 if (!window_item(currItem)) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
1040 return 1; |
32873 | 1041 |
34697 | 1042 if (in_window("video")) |
33058 | 1043 return 1; |
1044 if (in_window("playbar")) | |
1045 return 1; | |
1046 if (in_window("menu")) | |
1047 return 1; | |
32873 | 1048 |
33086 | 1049 strlower(in); |
32873 | 1050 |
33086 | 1051 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
36694 | 1052 skin_error(MSGTR_GUI_MSG_SkinUnknownParameter, in); |
32873 | 1053 return 1; |
1054 } | |
23077 | 1055 |
33087 | 1056 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 1057 |
37028 | 1058 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s\n", currItem, in); |
32873 | 1059 |
1060 return 0; | |
23077 | 1061 } |
1062 | |
33968 | 1063 /** |
1064 * @brief Parsing functions responsible for skin item definitions. | |
1065 */ | |
32878 | 1066 static _item skinItem[] = { |
33106 | 1067 { "background", item_background }, |
1068 { "base", item_base }, | |
1069 { "button", item_button }, | |
1070 { "decoration", item_decoration }, | |
1071 { "dlabel", item_dlabel }, | |
1072 { "end", item_end }, | |
1073 { "font", item_font }, | |
1074 { "hpotmeter", item_hpotmeter }, | |
1075 { "menu", item_menu }, | |
36920 | 1076 { "pimage", item_pimage }, |
36892 | 1077 { "potmeter", item_potmeter }, // legacy |
33106 | 1078 { "section", item_section }, |
1079 { "selected", item_selected }, | |
1080 { "slabel", item_slabel }, | |
1081 { "vpotmeter", item_vpotmeter }, | |
1082 { "window", item_window } | |
32873 | 1083 }; |
1084 | |
33968 | 1085 /** |
35662 | 1086 * @brief Read a skin @a image file. |
1087 * | |
1088 * @param fname filename (with path) | |
1089 * @param img pointer suitable to store the image data | |
1090 * | |
1091 * @return return code of #bpRead() | |
1092 */ | |
1093 int skinImageRead(char *fname, guiImage *img) | |
1094 { | |
1095 int i = bpRead(fname, img); | |
1096 | |
1097 switch (i) { | |
1098 case -1: | |
36694 | 1099 skin_error(MSGTR_GUI_MSG_SkinErrorBitmap16Bit, fname); |
35662 | 1100 break; |
1101 | |
1102 case -2: | |
36694 | 1103 skin_error(MSGTR_GUI_MSG_SkinBitmapNotFound, fname); |
35662 | 1104 break; |
1105 | |
1106 case -5: | |
36694 | 1107 skin_error(MSGTR_GUI_MSG_SkinBitmapPngReadError, fname); |
35662 | 1108 break; |
1109 | |
1110 case -8: | |
36694 | 1111 skin_error(MSGTR_GUI_MSG_SkinBitmapConversionError, fname); |
35662 | 1112 break; |
1113 } | |
1114 | |
1115 return i; | |
1116 } | |
1117 | |
1118 /** | |
33968 | 1119 * @brief Build the skin file path for a skin name. |
1120 * | |
1121 * @param dir skins directory | |
1122 * @param sname name of the skin | |
1123 * | |
1124 * @return skin file path | |
1125 * | |
1126 * @note As a side effect, variable #path gets set to the skin path. | |
1127 */ | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1128 static char *setname(char *dir, char *sname) |
32873 | 1129 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1130 static char skinfname[512]; |
32873 | 1131 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1132 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1133 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1134 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1135 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1136 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1137 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 1138 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1139 return skinfname; |
23077 | 1140 } |
1141 | |
33968 | 1142 /** |
1143 * @brief Read and parse a skin. | |
1144 * | |
1145 * @param sname name of the skin | |
1146 * | |
1147 * @return 0 (ok), -1 (skin file not found or not readable) or -2 (parsing error) | |
1148 */ | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1149 int skinRead(char *sname) |
23077 | 1150 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1151 char *skinfname; |
34578 | 1152 FILE *skinfile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1153 unsigned char line[256]; |
32873 | 1154 unsigned char param[256]; |
32944 | 1155 unsigned int i; |
32873 | 1156 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1157 skinfname = setname(skinDirInHome, sname); |
23077 | 1158 |
34578 | 1159 if ((skinfile = fopen(skinfname, "rt")) == NULL) { |
36043 | 1160 skinfname = setname(skinDirInData, sname); |
32873 | 1161 |
34578 | 1162 if ((skinfile = fopen(skinfname, "rt")) == NULL) { |
36694 | 1163 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotFound, skinfname); |
32873 | 1164 return -1; |
1165 } | |
23077 | 1166 } |
32873 | 1167 |
33985 | 1168 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 1169 |
32932 | 1170 appFreeStruct(); |
23077 | 1171 |
33078 | 1172 skin = NULL; |
1173 currWinName[0] = 0; | |
33079 | 1174 linenumber = 0; |
23077 | 1175 |
34578 | 1176 while (fgetstr(line, sizeof(line), skinfile)) { |
32873 | 1177 linenumber++; |
1178 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1179 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1180 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1181 decomment(line); |
32873 | 1182 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1183 if (!*line) |
32873 | 1184 continue; |
23077 | 1185 |
37028 | 1186 cutStr(line, currItem, '=', 0); |
36991 | 1187 cutStr(line, param, '=', 1); |
37028 | 1188 strlower(currItem); |
32873 | 1189 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1190 for (i = 0; i < FF_ARRAY_ELEMS(skinItem); i++) { |
37028 | 1191 if (!strcmp(currItem, skinItem[i].name)) { |
35360 | 1192 if (skinItem[i].func(param) != 0) { |
1193 fclose(skinfile); | |
32873 | 1194 return -2; |
35360 | 1195 } else |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1196 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1197 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1198 } |
33077 | 1199 |
1200 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
37028 | 1201 skin_error(MSGTR_GUI_MSG_SkinUnknownItem, currItem); |
35360 | 1202 fclose(skinfile); |
33077 | 1203 return -2; |
1204 } | |
32873 | 1205 } |
1206 | |
35360 | 1207 fclose(skinfile); |
1208 | |
32873 | 1209 if (linenumber == 0) { |
36694 | 1210 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotReadable, skinfname); |
32873 | 1211 return -1; |
1212 } | |
1213 | |
1214 return 0; | |
23077 | 1215 } |