Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 36891:c5ee0fc2ec75
Print an information on deprecated skin config file entries.
There are several skin config file entries which oughtn't be used
any more, although they are still being supported.
Inform the user about these without being too annoying.
author | ib |
---|---|
date | Mon, 10 Mar 2014 17:15:24 +0000 |
parents | 27b48ba4fe15 |
children | f50427ad9ff6 |
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" |
33046 | 33 #include "gui/util/cut.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; |
52 static unsigned char path[512]; | |
23077 | 53 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
54 static unsigned char currWinName[32]; |
35688 | 55 static guiItem *currWin; |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
56 static int *currWinItemIdx; |
35688 | 57 static guiItem *currWinItems; |
23077 | 58 |
33968 | 59 /** |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
60 * @brief Print a legacy information on an entry. |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
61 * |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
62 * @param old identifier (and deprecated entry) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
63 * @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
|
64 * to print the information on @a old |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
65 */ |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
66 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
|
67 { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
68 const char *p; |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
69 |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
70 if (strcmp(old, "fontid") == 0) { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
71 p = strchr(data, ','); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
72 |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
73 if (p) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
74 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
|
75 } else if (strcmp(old, "$l") == 0) { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
76 p = strstr(old, data); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
77 |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
78 if (p && (p == data || p[-1] != '$')) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
79 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
|
80 } 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
|
81 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "evLoadURL"); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
82 else if (strcmp(old, "sub") == 0) |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
83 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
|
84 } |
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 /** |
33968 | 87 * @brief Display a skin error message. |
88 * | |
89 * @param format format string | |
90 * @param ... arguments | |
91 */ | |
33022 | 92 static void skin_error(const char *format, ...) |
23077 | 93 { |
32873 | 94 char p[512]; |
95 va_list ap; | |
96 | |
97 va_start(ap, format); | |
98 vsnprintf(p, sizeof(p), format, ap); | |
99 va_end(ap); | |
100 | |
36694 | 101 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinErrorMessage, linenumber, p); |
23077 | 102 } |
103 | |
33968 | 104 /** |
105 * @brief Check whether a @a section definition has started. | |
106 * | |
107 * @param item name of the item to be put in a message in case of an error | |
108 * | |
35493 | 109 * @return #True (ok) or #False (error) |
33968 | 110 */ |
33106 | 111 static int section_item(char *item) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
112 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
113 if (!skin) { |
36694 | 114 skin_error(MSGTR_GUI_MSG_SkinErrorSection, item); |
35493 | 115 return False; |
32873 | 116 } |
117 | |
35493 | 118 return True; |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
119 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
120 |
33968 | 121 /** |
122 * @brief Check whether a @a window definition has started. | |
123 * | |
124 * @param item name of the item to be put in a message in case of an error | |
125 * | |
35493 | 126 * @return #True (ok) or #False (error) |
33968 | 127 */ |
33106 | 128 static int window_item(char *item) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
129 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
130 if (!currWinName[0]) { |
36694 | 131 skin_error(MSGTR_GUI_MSG_SkinErrorWindow, item); |
35493 | 132 return False; |
32873 | 133 } |
23077 | 134 |
35493 | 135 return True; |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
136 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
137 |
33968 | 138 /** |
139 * @brief Check whether a specific @a window definition has started. | |
140 * | |
141 * @param name name of the window to be checked | |
142 * | |
143 * @return 0 (ok) or 1 (error) | |
144 */ | |
33058 | 145 static int in_window(char *name) |
146 { | |
147 if (strcmp(currWinName, name) == 0) { | |
36694 | 148 skin_error(MSGTR_GUI_MSG_SkinErrorItem, name); |
33058 | 149 return 1; |
32873 | 150 } |
151 | |
33058 | 152 return 0; |
153 } | |
154 | |
33968 | 155 /** |
156 * @brief Get next free item in current @a window. | |
157 * | |
158 * @return pointer to next free item (ok) or NULL (error) | |
159 */ | |
35688 | 160 static guiItem *next_item(void) |
33098 | 161 { |
35688 | 162 guiItem *item = NULL; |
33098 | 163 |
164 if (*currWinItemIdx < MAX_ITEMS - 1) { | |
165 (*currWinItemIdx)++; | |
166 item = &currWinItems[*currWinItemIdx]; | |
167 } else | |
36694 | 168 skin_error(MSGTR_GUI_MSG_SkinTooManyItems); |
33098 | 169 |
170 return item; | |
171 } | |
172 | |
33968 | 173 /** |
174 * @brief Parse a @a section definition. | |
175 * | |
176 * Syntax: section=movieplayer | |
177 * | |
178 * @param in definition to be analyzed | |
179 * | |
180 * @return 0 (ok) or 1 (error) | |
181 */ | |
33106 | 182 static int item_section(char *in) |
23077 | 183 { |
33064 | 184 if (skin) { |
36694 | 185 skin_error(MSGTR_GUI_MSG_SkinErrorItem, "section"); |
33064 | 186 return 1; |
187 } | |
188 | |
33055 | 189 if (!strcmp(strlower(in), "movieplayer")) |
33555 | 190 skin = &guiApp; |
33067 | 191 else { |
36694 | 192 skin_error(MSGTR_GUI_MSG_SkinUnknownName, in); |
33067 | 193 return 1; |
194 } | |
32873 | 195 |
33985 | 196 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] section: %s\n", in); |
32873 | 197 |
198 return 0; | |
23077 | 199 } |
200 | |
33968 | 201 /** |
202 * @brief Parse an @a end definition. | |
203 * | |
204 * Syntax: end | |
205 * | |
206 * @param in definition to be analyzed | |
207 * | |
208 * @return 0 (ok) or 1 (error) | |
209 */ | |
33106 | 210 static int item_end(char *in) |
23077 | 211 { |
32951 | 212 char *space, *name; |
213 | |
33985 | 214 (void)in; |
215 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
216 if (currWinName[0]) { |
32951 | 217 space = " "; |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
218 name = currWinName; |
32951 | 219 } else { |
220 space = ""; | |
221 name = "section"; | |
222 } | |
223 | |
33106 | 224 if (!section_item("end")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
225 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
226 |
33985 | 227 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %send (%s)\n", space, name); |
32951 | 228 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
229 if (currWinName[0]) { |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
230 currWinName[0] = 0; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
231 currWin = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
232 currWinItemIdx = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
233 currWinItems = NULL; |
32873 | 234 } else |
32937 | 235 skin = NULL; |
32873 | 236 |
237 return 0; | |
23077 | 238 } |
239 | |
33968 | 240 /** |
241 * @brief Parse a @a window definition. | |
242 * | |
34697 | 243 * Syntax: window=main|video|playbar|menu |
33968 | 244 * |
245 * @param in definition to be analyzed | |
246 * | |
247 * @return 0 (ok) or 1 (error) | |
248 */ | |
33106 | 249 static int item_window(char *in) |
23077 | 250 { |
33106 | 251 if (!section_item("window")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
252 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
253 |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
254 if (currWinName[0]) { |
36694 | 255 skin_error(MSGTR_GUI_MSG_SkinErrorItem, "window"); |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
256 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
257 } |
32873 | 258 |
33083 | 259 strlower(in); |
23077 | 260 |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
261 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
262 if (strcmp(in, "sub") == 0) { |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
263 strcpy(in, "video"); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
264 skin_legacy("sub", in); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
265 } |
34697 | 266 |
33083 | 267 if (strcmp(in, "main") == 0) { |
33095 | 268 currWin = &skin->main; |
269 currWinItemIdx = &skin->IndexOfMainItems; | |
270 currWinItems = skin->mainItems; | |
34697 | 271 } else if (strcmp(in, "video") == 0) { |
272 currWin = &skin->video; | |
33083 | 273 currWinItemIdx = NULL; |
274 currWinItems = NULL; | |
275 } else if (strcmp(in, "playbar") == 0) { | |
33555 | 276 currWin = &skin->playbar; |
277 currWinItemIdx = &skin->IndexOfPlaybarItems; | |
278 currWinItems = skin->playbarItems; | |
33083 | 279 } else if (strcmp(in, "menu") == 0) { |
33095 | 280 currWin = &skin->menu; |
281 currWinItemIdx = &skin->IndexOfMenuItems; | |
282 currWinItems = skin->menuItems; | |
33066 | 283 } else { |
36694 | 284 skin_error(MSGTR_GUI_MSG_SkinUnknownName, in); |
33066 | 285 return 1; |
286 } | |
32873 | 287 |
33083 | 288 av_strlcpy(currWinName, in, sizeof(currWinName)); |
289 | |
33985 | 290 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] window: %s\n", currWinName); |
32873 | 291 |
292 return 0; | |
23077 | 293 } |
294 | |
33968 | 295 /** |
296 * @brief Parse a @a base definition. | |
297 * | |
298 * Syntax: base=image,x,y[,width,height] | |
299 * | |
300 * @param in definition to be analyzed | |
301 * | |
302 * @return 0 (ok) or 1 (error) | |
303 */ | |
33106 | 304 static int item_base(char *in) |
23077 | 305 { |
33090 | 306 unsigned char fname[256]; |
33089 | 307 unsigned char file[512]; |
32873 | 308 int x, y; |
33089 | 309 int w = 0, h = 0; |
34697 | 310 int is_video, is_bar, is_menu; |
32873 | 311 |
33106 | 312 if (!window_item("base")) |
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 |
32873 | 319 cutItem(in, fname, ',', 0); |
33089 | 320 x = cutItemToInt(in, ',', 1); |
321 y = cutItemToInt(in, ',', 2); | |
322 w = cutItemToInt(in, ',', 3); | |
323 h = cutItemToInt(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 | |
35784 | 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 } | |
33985 | 369 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\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 { |
33106 | 391 if (!window_item("background")) |
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 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
401 currWin->R = cutItemToInt(in, ',', 0); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
402 currWin->G = cutItemToInt(in, ',', 1); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
403 currWin->B = cutItemToInt(in, ',', 2); |
23077 | 404 |
33985 | 405 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", 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 |
33106 | 427 if (!window_item("button")) |
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 |
32873 | 435 cutItem(in, fname, ',', 0); |
33089 | 436 x = cutItemToInt(in, ',', 1); |
437 y = cutItemToInt(in, ',', 2); | |
438 w = cutItemToInt(in, ',', 3); | |
439 h = cutItemToInt(in, ',', 4); | |
32873 | 440 cutItem(in, msg, ',', 5); |
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 |
33985 | 452 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y); |
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 |
33985 | 481 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\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]; |
35688 | 499 guiItem *currItem; |
32873 | 500 |
33106 | 501 if (!window_item("selected")) |
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 |
33985 | 511 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image selected: %s\n", in); |
33102
de688a61e439
Move debug messages so that they will be processed earlier.
ib
parents:
33101
diff
changeset
|
512 |
33096 | 513 currItem = &skin->menuSelected; |
514 currItem->type = itBase; | |
32873 | 515 |
33089 | 516 av_strlcpy(file, path, sizeof(file)); |
33091 | 517 av_strlcat(file, in, sizeof(file)); |
32873 | 518 |
33969 | 519 if (skinImageRead(file, &currItem->Bitmap) != 0) |
32873 | 520 return 1; |
521 | |
33096 | 522 currItem->width = currItem->Bitmap.Width; |
523 currItem->height = currItem->Bitmap.Height; | |
32873 | 524 |
33985 | 525 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currItem->width, currItem->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 |
33106 | 545 if (!window_item("menu")) |
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 |
33089 | 555 x = cutItemToInt(in, ',', 0); |
556 y = cutItemToInt(in, ',', 1); | |
557 w = cutItemToInt(in, ',', 2); | |
558 h = cutItemToInt(in, ',', 3); | |
33071 | 559 cutItem(in, msg, ',', 4); |
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 /** |
592 * @brief Parse a @a hpotmeter definition. | |
593 * | |
594 * Syntax: hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message | |
595 * | |
596 * @param in definition to be analyzed | |
597 * | |
598 * @return 0 (ok) or 1 (error) | |
599 */ | |
33106 | 600 static int item_hpotmeter(char *in) |
32873 | 601 { |
33090 | 602 unsigned char pfname[256]; |
603 unsigned char phfname[256]; | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
604 unsigned char buf[512]; |
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
605 int pwidth, pheight, ph, d, x, y, w, h, message; |
35688 | 606 guiItem *item; |
23077 | 607 |
33106 | 608 if (!window_item("h/v potmeter")) |
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 |
32873 | 616 cutItem(in, pfname, ',', 0); |
32911 | 617 pwidth = cutItemToInt(in, ',', 1); |
618 pheight = cutItemToInt(in, ',', 2); | |
32873 | 619 cutItem(in, phfname, ',', 3); |
620 ph = cutItemToInt(in, ',', 4); | |
621 d = cutItemToInt(in, ',', 5); | |
622 x = cutItemToInt(in, ',', 6); | |
623 y = cutItemToInt(in, ',', 7); | |
33089 | 624 w = cutItemToInt(in, ',', 8); |
625 h = cutItemToInt(in, ',', 9); | |
626 cutItem(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 |
33985 | 638 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
639 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); | |
640 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
641 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); | |
23077 | 642 |
33098 | 643 item = next_item(); |
644 | |
645 if (!item) | |
646 return 1; | |
647 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
648 item->type = itHPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
649 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
650 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
651 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
652 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
653 item->pwidth = pwidth; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
654 item->pheight = pheight; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
655 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
656 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
657 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
658 item->pressed = btnReleased; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
659 |
32873 | 660 item->Bitmap.Image = NULL; |
23077 | 661 |
32873 | 662 if (strcmp(phfname, "NULL") != 0) { |
33089 | 663 av_strlcpy(buf, path, sizeof(buf)); |
664 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 665 |
33969 | 666 if (skinImageRead(buf, &item->Bitmap) != 0) |
32873 | 667 return 1; |
32951 | 668 |
33985 | 669 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 670 } |
671 | |
672 item->Mask.Image = NULL; | |
23077 | 673 |
32873 | 674 if (strcmp(pfname, "NULL") != 0) { |
33089 | 675 av_strlcpy(buf, path, sizeof(buf)); |
676 av_strlcat(buf, pfname, sizeof(buf)); | |
32873 | 677 |
33969 | 678 if (skinImageRead(buf, &item->Mask) != 0) |
32873 | 679 return 1; |
32951 | 680 |
33985 | 681 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); |
32873 | 682 } |
683 | |
684 return 0; | |
23077 | 685 } |
686 | |
33968 | 687 /** |
688 * @brief Parse a @a vpotmeter definition. | |
689 * | |
690 * Syntax: vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message | |
691 * | |
692 * @param in definition to be analyzed | |
693 * | |
694 * @return 0 (ok) or 1 (error) | |
695 */ | |
33106 | 696 static int item_vpotmeter(char *in) |
23077 | 697 { |
33056 | 698 int r; |
35688 | 699 guiItem *item; |
23077 | 700 |
33106 | 701 r = item_hpotmeter(in); |
33056 | 702 |
703 if (r == 0) { | |
33057 | 704 item = &currWinItems[*currWinItemIdx]; |
705 item->type = itVPotmeter; | |
33056 | 706 } |
33053 | 707 |
32873 | 708 return r; |
23077 | 709 } |
710 | |
33968 | 711 /** |
712 * @brief Parse a @a potmeter definition. | |
713 * | |
714 * Syntax: potmeter=phases,numphases,default,x,y,width,height,message | |
715 * | |
716 * @param in definition to be analyzed | |
717 * | |
718 * @return 0 (ok) or 1 (error) | |
719 */ | |
33106 | 720 static int item_potmeter(char *in) |
32873 | 721 { |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
722 unsigned char phfname[256]; |
33089 | 723 unsigned char buf[512]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
724 int ph, d, x, y, w, h, message; |
35688 | 725 guiItem *item; |
23077 | 726 |
33106 | 727 if (!window_item("potmeter")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
728 return 1; |
23077 | 729 |
34697 | 730 if (in_window("video")) |
33058 | 731 return 1; |
732 if (in_window("menu")) | |
733 return 1; | |
23077 | 734 |
32873 | 735 cutItem(in, phfname, ',', 0); |
736 ph = cutItemToInt(in, ',', 1); | |
737 d = cutItemToInt(in, ',', 2); | |
738 x = cutItemToInt(in, ',', 3); | |
739 y = cutItemToInt(in, ',', 4); | |
33089 | 740 w = cutItemToInt(in, ',', 5); |
741 h = cutItemToInt(in, ',', 6); | |
742 cutItem(in, buf, ',', 7); | |
32873 | 743 |
33089 | 744 message = appFindMessage(buf); |
23077 | 745 |
33069 | 746 if (message == -1) { |
36694 | 747 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf); |
33069 | 748 return 1; |
749 } | |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
750 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
751 else |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
752 skin_legacy("evSetURL", buf); |
33069 | 753 |
33985 | 754 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
755 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
756 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); | |
23077 | 757 |
33098 | 758 item = next_item(); |
759 | |
760 if (!item) | |
761 return 1; | |
762 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
763 item->type = itPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
764 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
765 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
766 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
767 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
768 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
769 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
770 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
771 |
32873 | 772 item->Bitmap.Image = NULL; |
23077 | 773 |
32873 | 774 if (strcmp(phfname, "NULL") != 0) { |
33089 | 775 av_strlcpy(buf, path, sizeof(buf)); |
776 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 777 |
33969 | 778 if (skinImageRead(buf, &item->Bitmap) != 0) |
32873 | 779 return 1; |
32951 | 780 |
33985 | 781 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 782 } |
783 | |
784 return 0; | |
23077 | 785 } |
786 | |
33968 | 787 /** |
788 * @brief Parse a @a font definition. | |
789 * | |
790 * Syntax: font=fontfile | |
791 * | |
792 * @param in definition to be analyzed | |
793 * | |
794 * @return 0 (ok) or 1 (error) | |
795 */ | |
33106 | 796 static int item_font(char *in) |
32873 | 797 { |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
798 char fnt[256]; |
23077 | 799 |
33106 | 800 if (!window_item("font")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
801 return 1; |
23077 | 802 |
34697 | 803 if (in_window("video")) |
33058 | 804 return 1; |
805 if (in_window("menu")) | |
806 return 1; | |
23077 | 807 |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
808 cutItem(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility |
36876 | 809 // reasons with a meanwhile deprecated second parameter. |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
810 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
811 skin_legacy("fontid", in); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
812 |
33099
0b17f6bed6fc
Don't needlessly store font information in the wItems array
ib
parents:
33098
diff
changeset
|
813 switch (fntRead(path, fnt)) { |
32873 | 814 case -1: |
36694 | 815 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 816 return 1; |
23077 | 817 |
32873 | 818 case -2: |
36694 | 819 skin_error(MSGTR_GUI_MSG_SkinTooManyFonts); |
32873 | 820 return 1; |
821 | |
822 case -3: | |
36694 | 823 skin_error(MSGTR_GUI_MSG_SkinFontFileNotFound); |
32873 | 824 return 1; |
825 | |
826 case -4: | |
36694 | 827 skin_error(MSGTR_GUI_MSG_SkinFontImageNotFound); |
32873 | 828 return 1; |
829 } | |
830 | |
33985 | 831 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); |
32951 | 832 |
32873 | 833 return 0; |
23077 | 834 } |
835 | |
33968 | 836 /** |
837 * @brief Parse a @a slabel definition. | |
838 * | |
839 * Syntax: slabel=x,y,fontfile,"text" | |
840 * | |
841 * @param in definition to be analyzed | |
842 * | |
843 * @return 0 (ok) or 1 (error) | |
844 */ | |
33106 | 845 static int item_slabel(char *in) |
23077 | 846 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
847 int x, y, id; |
33090 | 848 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
849 char txt[256]; |
35688 | 850 guiItem *item; |
32873 | 851 |
33106 | 852 if (!window_item("slabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
853 return 1; |
23077 | 854 |
34697 | 855 if (in_window("video")) |
33058 | 856 return 1; |
857 if (in_window("menu")) | |
858 return 1; | |
32873 | 859 |
860 x = cutItemToInt(in, ',', 0); | |
861 y = cutItemToInt(in, ',', 1); | |
33089 | 862 cutItem(in, fnt, ',', 2); |
863 cutItem(in, txt, ',', 3); | |
864 cutItem(txt, txt, '"', 1); | |
32951 | 865 |
33985 | 866 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt); |
867 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
23077 | 868 |
33089 | 869 id = fntFindID(fnt); |
23077 | 870 |
32873 | 871 if (id < 0) { |
36694 | 872 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt); |
32873 | 873 return 1; |
874 } | |
23077 | 875 |
33985 | 876 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 877 |
33098 | 878 item = next_item(); |
879 | |
880 if (!item) | |
881 return 1; | |
882 | |
32873 | 883 item->type = itSLabel; |
884 item->x = x; | |
885 item->y = y; | |
886 item->width = -1; | |
887 item->height = -1; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
888 item->fontid = id; |
33089 | 889 item->label = strdup(txt); |
23077 | 890 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
891 if (!item->label) { |
36694 | 892 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 893 return 1; |
894 } | |
23077 | 895 |
32873 | 896 return 0; |
23077 | 897 } |
898 | |
33968 | 899 /** |
900 * @brief Parse a @a dlabel definition. | |
901 * | |
902 * Syntax: dlabel=x,y,width,align,fontfile,"text" | |
903 * | |
904 * @param in definition to be analyzed | |
905 * | |
906 * @return 0 (ok) or 1 (error) | |
907 */ | |
33106 | 908 static int item_dlabel(char *in) |
32873 | 909 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
910 int x, y, w, a, id; |
33090 | 911 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
912 char txt[256]; |
35688 | 913 guiItem *item; |
23077 | 914 |
33106 | 915 if (!window_item("dlabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
916 return 1; |
23077 | 917 |
34697 | 918 if (in_window("video")) |
33058 | 919 return 1; |
920 if (in_window("menu")) | |
921 return 1; | |
32873 | 922 |
33089 | 923 x = cutItemToInt(in, ',', 0); |
924 y = cutItemToInt(in, ',', 1); | |
925 w = cutItemToInt(in, ',', 2); | |
926 a = cutItemToInt(in, ',', 3); | |
927 cutItem(in, fnt, ',', 4); | |
928 cutItem(in, txt, ',', 5); | |
929 cutItem(txt, txt, '"', 1); | |
32951 | 930 |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
931 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
932 skin_legacy("$l", txt); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
933 |
33985 | 934 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); |
935 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
936 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); | |
23077 | 937 |
33089 | 938 id = fntFindID(fnt); |
23077 | 939 |
32873 | 940 if (id < 0) { |
36694 | 941 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt); |
32873 | 942 return 1; |
943 } | |
23077 | 944 |
33985 | 945 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 946 |
33098 | 947 item = next_item(); |
948 | |
949 if (!item) | |
950 return 1; | |
951 | |
32873 | 952 item->type = itDLabel; |
953 item->x = x; | |
954 item->y = y; | |
33089 | 955 item->width = w; |
32873 | 956 item->height = -1; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
957 item->fontid = id; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
958 item->align = a; |
33089 | 959 item->label = strdup(txt); |
23077 | 960 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
961 if (!item->label) { |
36694 | 962 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 963 return 1; |
964 } | |
23077 | 965 |
32873 | 966 return 0; |
23077 | 967 } |
968 | |
33968 | 969 /** |
970 * @brief Parse a @a decoration definition. | |
971 * | |
972 * Syntax: decoration=enable|disable | |
973 * | |
974 * @param in definition to be analyzed | |
975 * | |
976 * @return 0 (ok) or 1 (error) | |
977 */ | |
33106 | 978 static int item_decoration(char *in) |
23077 | 979 { |
33106 | 980 if (!window_item("decoration")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
981 return 1; |
32873 | 982 |
34697 | 983 if (in_window("video")) |
33058 | 984 return 1; |
985 if (in_window("playbar")) | |
986 return 1; | |
987 if (in_window("menu")) | |
988 return 1; | |
32873 | 989 |
33086 | 990 strlower(in); |
32873 | 991 |
33086 | 992 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
36694 | 993 skin_error(MSGTR_GUI_MSG_SkinUnknownParameter, in); |
32873 | 994 return 1; |
995 } | |
23077 | 996 |
33087 | 997 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 998 |
33985 | 999 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in); |
32873 | 1000 |
1001 return 0; | |
23077 | 1002 } |
1003 | |
33968 | 1004 /** |
1005 * @brief Parsing functions responsible for skin item definitions. | |
1006 */ | |
32878 | 1007 static _item skinItem[] = { |
33106 | 1008 { "background", item_background }, |
1009 { "base", item_base }, | |
1010 { "button", item_button }, | |
1011 { "decoration", item_decoration }, | |
1012 { "dlabel", item_dlabel }, | |
1013 { "end", item_end }, | |
1014 { "font", item_font }, | |
1015 { "hpotmeter", item_hpotmeter }, | |
1016 { "menu", item_menu }, | |
1017 { "potmeter", item_potmeter }, | |
1018 { "section", item_section }, | |
1019 { "selected", item_selected }, | |
1020 { "slabel", item_slabel }, | |
1021 { "vpotmeter", item_vpotmeter }, | |
1022 { "window", item_window } | |
32873 | 1023 }; |
1024 | |
33968 | 1025 /** |
35662 | 1026 * @brief Read a skin @a image file. |
1027 * | |
1028 * @param fname filename (with path) | |
1029 * @param img pointer suitable to store the image data | |
1030 * | |
1031 * @return return code of #bpRead() | |
1032 */ | |
1033 int skinImageRead(char *fname, guiImage *img) | |
1034 { | |
1035 int i = bpRead(fname, img); | |
1036 | |
1037 switch (i) { | |
1038 case -1: | |
36694 | 1039 skin_error(MSGTR_GUI_MSG_SkinErrorBitmap16Bit, fname); |
35662 | 1040 break; |
1041 | |
1042 case -2: | |
36694 | 1043 skin_error(MSGTR_GUI_MSG_SkinBitmapNotFound, fname); |
35662 | 1044 break; |
1045 | |
1046 case -5: | |
36694 | 1047 skin_error(MSGTR_GUI_MSG_SkinBitmapPngReadError, fname); |
35662 | 1048 break; |
1049 | |
1050 case -8: | |
36694 | 1051 skin_error(MSGTR_GUI_MSG_SkinBitmapConversionError, fname); |
35662 | 1052 break; |
1053 } | |
1054 | |
1055 return i; | |
1056 } | |
1057 | |
1058 /** | |
33968 | 1059 * @brief Build the skin file path for a skin name. |
1060 * | |
1061 * @param dir skins directory | |
1062 * @param sname name of the skin | |
1063 * | |
1064 * @return skin file path | |
1065 * | |
1066 * @note As a side effect, variable #path gets set to the skin path. | |
1067 */ | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1068 static char *setname(char *dir, char *sname) |
32873 | 1069 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1070 static char skinfname[512]; |
32873 | 1071 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1072 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1073 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1074 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1075 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1076 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1077 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 1078 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1079 return skinfname; |
23077 | 1080 } |
1081 | |
33968 | 1082 /** |
1083 * @brief Read and parse a skin. | |
1084 * | |
1085 * @param sname name of the skin | |
1086 * | |
1087 * @return 0 (ok), -1 (skin file not found or not readable) or -2 (parsing error) | |
1088 */ | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1089 int skinRead(char *sname) |
23077 | 1090 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1091 char *skinfname; |
34578 | 1092 FILE *skinfile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1093 unsigned char line[256]; |
33075 | 1094 unsigned char item[32]; |
32873 | 1095 unsigned char param[256]; |
32944 | 1096 unsigned int i; |
32873 | 1097 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1098 skinfname = setname(skinDirInHome, sname); |
23077 | 1099 |
34578 | 1100 if ((skinfile = fopen(skinfname, "rt")) == NULL) { |
36043 | 1101 skinfname = setname(skinDirInData, sname); |
32873 | 1102 |
34578 | 1103 if ((skinfile = fopen(skinfname, "rt")) == NULL) { |
36694 | 1104 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotFound, skinfname); |
32873 | 1105 return -1; |
1106 } | |
23077 | 1107 } |
32873 | 1108 |
33985 | 1109 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 1110 |
32932 | 1111 appFreeStruct(); |
23077 | 1112 |
33078 | 1113 skin = NULL; |
1114 currWinName[0] = 0; | |
33079 | 1115 linenumber = 0; |
23077 | 1116 |
34578 | 1117 while (fgetstr(line, sizeof(line), skinfile)) { |
32873 | 1118 linenumber++; |
1119 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1120 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1121 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1122 decomment(line); |
32873 | 1123 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1124 if (!*line) |
32873 | 1125 continue; |
23077 | 1126 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1127 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1128 cutItem(line, param, '=', 1); |
33075 | 1129 strlower(item); |
32873 | 1130 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1131 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
|
1132 if (!strcmp(item, skinItem[i].name)) { |
35360 | 1133 if (skinItem[i].func(param) != 0) { |
1134 fclose(skinfile); | |
32873 | 1135 return -2; |
35360 | 1136 } else |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1137 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1138 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1139 } |
33077 | 1140 |
1141 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
36694 | 1142 skin_error(MSGTR_GUI_MSG_SkinUnknownItem, item); |
35360 | 1143 fclose(skinfile); |
33077 | 1144 return -2; |
1145 } | |
32873 | 1146 } |
1147 | |
35360 | 1148 fclose(skinfile); |
1149 | |
32873 | 1150 if (linenumber == 0) { |
36694 | 1151 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotReadable, skinfname); |
32873 | 1152 return -1; |
1153 } | |
1154 | |
1155 return 0; | |
23077 | 1156 } |