Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 36965:5fb43d5efdca
configure: add CONFIG_CABAC
fix ffmpeg linking
author | michael |
---|---|
date | Tue, 25 Mar 2014 00:15:02 +0000 |
parents | 40ad45360c8a |
children | 91f11a849d4d |
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"); |
36892 | 82 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
|
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 * | |
36920 | 716 * @note THIS ITEM IS DEPRECATED. |
717 * | |
33968 | 718 * @param in definition to be analyzed |
719 * | |
720 * @return 0 (ok) or 1 (error) | |
721 */ | |
33106 | 722 static int item_potmeter(char *in) |
32873 | 723 { |
36892 | 724 char param[256]; |
725 | |
726 // legacy | |
727 skin_legacy("potmeter", "hpotmeter"); | |
728 | |
729 snprintf(param, sizeof(param), "NULL,0,0,%s", in); | |
730 | |
731 return item_hpotmeter(param); | |
36920 | 732 } |
733 | |
734 /** | |
735 * @brief Parse a @a pimage definition. | |
736 * | |
737 * Syntax: pimage=phases,numphases,default,x,y,width,height,message | |
738 * | |
739 * @param in definition to be analyzed | |
740 * | |
741 * @return 0 (ok) or 1 (error) | |
742 */ | |
743 static int item_pimage(char *in) | |
744 { | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
745 unsigned char phfname[256]; |
33089 | 746 unsigned char buf[512]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
747 int ph, d, x, y, w, h, message; |
35688 | 748 guiItem *item; |
23077 | 749 |
36920 | 750 if (!window_item("pimage")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
751 return 1; |
23077 | 752 |
34697 | 753 if (in_window("video")) |
33058 | 754 return 1; |
755 if (in_window("menu")) | |
756 return 1; | |
23077 | 757 |
32873 | 758 cutItem(in, phfname, ',', 0); |
759 ph = cutItemToInt(in, ',', 1); | |
760 d = cutItemToInt(in, ',', 2); | |
761 x = cutItemToInt(in, ',', 3); | |
762 y = cutItemToInt(in, ',', 4); | |
33089 | 763 w = cutItemToInt(in, ',', 5); |
764 h = cutItemToInt(in, ',', 6); | |
765 cutItem(in, buf, ',', 7); | |
32873 | 766 |
33089 | 767 message = appFindMessage(buf); |
23077 | 768 |
33069 | 769 if (message == -1) { |
36694 | 770 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf); |
33069 | 771 return 1; |
772 } | |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
773 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
774 else |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
775 skin_legacy("evSetURL", buf); |
33069 | 776 |
36920 | 777 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pimage image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
33985 | 778 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); |
779 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); | |
23077 | 780 |
33098 | 781 item = next_item(); |
782 | |
783 if (!item) | |
784 return 1; | |
785 | |
36920 | 786 item->type = itPimage; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
787 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
788 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
789 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
790 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
791 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
792 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
793 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
794 |
32873 | 795 item->Bitmap.Image = NULL; |
23077 | 796 |
32873 | 797 if (strcmp(phfname, "NULL") != 0) { |
33089 | 798 av_strlcpy(buf, path, sizeof(buf)); |
799 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 800 |
33969 | 801 if (skinImageRead(buf, &item->Bitmap) != 0) |
32873 | 802 return 1; |
32951 | 803 |
33985 | 804 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 805 } |
806 | |
807 return 0; | |
23077 | 808 } |
809 | |
33968 | 810 /** |
811 * @brief Parse a @a font definition. | |
812 * | |
813 * Syntax: font=fontfile | |
814 * | |
815 * @param in definition to be analyzed | |
816 * | |
817 * @return 0 (ok) or 1 (error) | |
818 */ | |
33106 | 819 static int item_font(char *in) |
32873 | 820 { |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
821 char fnt[256]; |
23077 | 822 |
33106 | 823 if (!window_item("font")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
824 return 1; |
23077 | 825 |
34697 | 826 if (in_window("video")) |
33058 | 827 return 1; |
828 if (in_window("menu")) | |
829 return 1; | |
23077 | 830 |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
831 cutItem(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility |
36876 | 832 // reasons with a meanwhile deprecated second parameter. |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
833 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
834 skin_legacy("fontid", in); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
835 |
33099
0b17f6bed6fc
Don't needlessly store font information in the wItems array
ib
parents:
33098
diff
changeset
|
836 switch (fntRead(path, fnt)) { |
32873 | 837 case -1: |
36694 | 838 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 839 return 1; |
23077 | 840 |
32873 | 841 case -2: |
36694 | 842 skin_error(MSGTR_GUI_MSG_SkinTooManyFonts); |
32873 | 843 return 1; |
844 | |
845 case -3: | |
36694 | 846 skin_error(MSGTR_GUI_MSG_SkinFontFileNotFound); |
32873 | 847 return 1; |
848 | |
849 case -4: | |
36694 | 850 skin_error(MSGTR_GUI_MSG_SkinFontImageNotFound); |
32873 | 851 return 1; |
852 } | |
853 | |
33985 | 854 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); |
32951 | 855 |
32873 | 856 return 0; |
23077 | 857 } |
858 | |
33968 | 859 /** |
860 * @brief Parse a @a slabel definition. | |
861 * | |
862 * Syntax: slabel=x,y,fontfile,"text" | |
863 * | |
864 * @param in definition to be analyzed | |
865 * | |
866 * @return 0 (ok) or 1 (error) | |
867 */ | |
33106 | 868 static int item_slabel(char *in) |
23077 | 869 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
870 int x, y, id; |
33090 | 871 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
872 char txt[256]; |
35688 | 873 guiItem *item; |
32873 | 874 |
33106 | 875 if (!window_item("slabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
876 return 1; |
23077 | 877 |
34697 | 878 if (in_window("video")) |
33058 | 879 return 1; |
880 if (in_window("menu")) | |
881 return 1; | |
32873 | 882 |
883 x = cutItemToInt(in, ',', 0); | |
884 y = cutItemToInt(in, ',', 1); | |
33089 | 885 cutItem(in, fnt, ',', 2); |
886 cutItem(in, txt, ',', 3); | |
887 cutItem(txt, txt, '"', 1); | |
32951 | 888 |
33985 | 889 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt); |
890 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
23077 | 891 |
33089 | 892 id = fntFindID(fnt); |
23077 | 893 |
32873 | 894 if (id < 0) { |
36694 | 895 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt); |
32873 | 896 return 1; |
897 } | |
23077 | 898 |
33985 | 899 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 900 |
33098 | 901 item = next_item(); |
902 | |
903 if (!item) | |
904 return 1; | |
905 | |
32873 | 906 item->type = itSLabel; |
907 item->x = x; | |
908 item->y = y; | |
909 item->width = -1; | |
910 item->height = -1; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
911 item->fontid = id; |
33089 | 912 item->label = strdup(txt); |
23077 | 913 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
914 if (!item->label) { |
36694 | 915 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 916 return 1; |
917 } | |
23077 | 918 |
32873 | 919 return 0; |
23077 | 920 } |
921 | |
33968 | 922 /** |
923 * @brief Parse a @a dlabel definition. | |
924 * | |
925 * Syntax: dlabel=x,y,width,align,fontfile,"text" | |
926 * | |
927 * @param in definition to be analyzed | |
928 * | |
929 * @return 0 (ok) or 1 (error) | |
930 */ | |
33106 | 931 static int item_dlabel(char *in) |
32873 | 932 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
933 int x, y, w, a, id; |
33090 | 934 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
935 char txt[256]; |
35688 | 936 guiItem *item; |
23077 | 937 |
33106 | 938 if (!window_item("dlabel")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
939 return 1; |
23077 | 940 |
34697 | 941 if (in_window("video")) |
33058 | 942 return 1; |
943 if (in_window("menu")) | |
944 return 1; | |
32873 | 945 |
33089 | 946 x = cutItemToInt(in, ',', 0); |
947 y = cutItemToInt(in, ',', 1); | |
948 w = cutItemToInt(in, ',', 2); | |
949 a = cutItemToInt(in, ',', 3); | |
950 cutItem(in, fnt, ',', 4); | |
951 cutItem(in, txt, ',', 5); | |
952 cutItem(txt, txt, '"', 1); | |
32951 | 953 |
36891
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
954 // legacy |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
955 skin_legacy("$l", txt); |
c5ee0fc2ec75
Print an information on deprecated skin config file entries.
ib
parents:
36876
diff
changeset
|
956 |
33985 | 957 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); |
958 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); | |
959 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); | |
23077 | 960 |
33089 | 961 id = fntFindID(fnt); |
23077 | 962 |
32873 | 963 if (id < 0) { |
36694 | 964 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt); |
32873 | 965 return 1; |
966 } | |
23077 | 967 |
33985 | 968 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 969 |
33098 | 970 item = next_item(); |
971 | |
972 if (!item) | |
973 return 1; | |
974 | |
32873 | 975 item->type = itDLabel; |
976 item->x = x; | |
977 item->y = y; | |
33089 | 978 item->width = w; |
32873 | 979 item->height = -1; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
980 item->fontid = id; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
981 item->align = a; |
33089 | 982 item->label = strdup(txt); |
23077 | 983 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
984 if (!item->label) { |
36694 | 985 skin_error(MSGTR_GUI_MSG_SkinMemoryError); |
32873 | 986 return 1; |
987 } | |
23077 | 988 |
32873 | 989 return 0; |
23077 | 990 } |
991 | |
33968 | 992 /** |
993 * @brief Parse a @a decoration definition. | |
994 * | |
995 * Syntax: decoration=enable|disable | |
996 * | |
997 * @param in definition to be analyzed | |
998 * | |
999 * @return 0 (ok) or 1 (error) | |
1000 */ | |
33106 | 1001 static int item_decoration(char *in) |
23077 | 1002 { |
33106 | 1003 if (!window_item("decoration")) |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
1004 return 1; |
32873 | 1005 |
34697 | 1006 if (in_window("video")) |
33058 | 1007 return 1; |
1008 if (in_window("playbar")) | |
1009 return 1; | |
1010 if (in_window("menu")) | |
1011 return 1; | |
32873 | 1012 |
33086 | 1013 strlower(in); |
32873 | 1014 |
33086 | 1015 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
36694 | 1016 skin_error(MSGTR_GUI_MSG_SkinUnknownParameter, in); |
32873 | 1017 return 1; |
1018 } | |
23077 | 1019 |
33087 | 1020 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 1021 |
33985 | 1022 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in); |
32873 | 1023 |
1024 return 0; | |
23077 | 1025 } |
1026 | |
33968 | 1027 /** |
1028 * @brief Parsing functions responsible for skin item definitions. | |
1029 */ | |
32878 | 1030 static _item skinItem[] = { |
33106 | 1031 { "background", item_background }, |
1032 { "base", item_base }, | |
1033 { "button", item_button }, | |
1034 { "decoration", item_decoration }, | |
1035 { "dlabel", item_dlabel }, | |
1036 { "end", item_end }, | |
1037 { "font", item_font }, | |
1038 { "hpotmeter", item_hpotmeter }, | |
1039 { "menu", item_menu }, | |
36920 | 1040 { "pimage", item_pimage }, |
36892 | 1041 { "potmeter", item_potmeter }, // legacy |
33106 | 1042 { "section", item_section }, |
1043 { "selected", item_selected }, | |
1044 { "slabel", item_slabel }, | |
1045 { "vpotmeter", item_vpotmeter }, | |
1046 { "window", item_window } | |
32873 | 1047 }; |
1048 | |
33968 | 1049 /** |
35662 | 1050 * @brief Read a skin @a image file. |
1051 * | |
1052 * @param fname filename (with path) | |
1053 * @param img pointer suitable to store the image data | |
1054 * | |
1055 * @return return code of #bpRead() | |
1056 */ | |
1057 int skinImageRead(char *fname, guiImage *img) | |
1058 { | |
1059 int i = bpRead(fname, img); | |
1060 | |
1061 switch (i) { | |
1062 case -1: | |
36694 | 1063 skin_error(MSGTR_GUI_MSG_SkinErrorBitmap16Bit, fname); |
35662 | 1064 break; |
1065 | |
1066 case -2: | |
36694 | 1067 skin_error(MSGTR_GUI_MSG_SkinBitmapNotFound, fname); |
35662 | 1068 break; |
1069 | |
1070 case -5: | |
36694 | 1071 skin_error(MSGTR_GUI_MSG_SkinBitmapPngReadError, fname); |
35662 | 1072 break; |
1073 | |
1074 case -8: | |
36694 | 1075 skin_error(MSGTR_GUI_MSG_SkinBitmapConversionError, fname); |
35662 | 1076 break; |
1077 } | |
1078 | |
1079 return i; | |
1080 } | |
1081 | |
1082 /** | |
33968 | 1083 * @brief Build the skin file path for a skin name. |
1084 * | |
1085 * @param dir skins directory | |
1086 * @param sname name of the skin | |
1087 * | |
1088 * @return skin file path | |
1089 * | |
1090 * @note As a side effect, variable #path gets set to the skin path. | |
1091 */ | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1092 static char *setname(char *dir, char *sname) |
32873 | 1093 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1094 static char skinfname[512]; |
32873 | 1095 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1096 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1097 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1098 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1099 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1100 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1101 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 1102 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1103 return skinfname; |
23077 | 1104 } |
1105 | |
33968 | 1106 /** |
1107 * @brief Read and parse a skin. | |
1108 * | |
1109 * @param sname name of the skin | |
1110 * | |
1111 * @return 0 (ok), -1 (skin file not found or not readable) or -2 (parsing error) | |
1112 */ | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1113 int skinRead(char *sname) |
23077 | 1114 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1115 char *skinfname; |
34578 | 1116 FILE *skinfile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1117 unsigned char line[256]; |
33075 | 1118 unsigned char item[32]; |
32873 | 1119 unsigned char param[256]; |
32944 | 1120 unsigned int i; |
32873 | 1121 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1122 skinfname = setname(skinDirInHome, sname); |
23077 | 1123 |
34578 | 1124 if ((skinfile = fopen(skinfname, "rt")) == NULL) { |
36043 | 1125 skinfname = setname(skinDirInData, sname); |
32873 | 1126 |
34578 | 1127 if ((skinfile = fopen(skinfname, "rt")) == NULL) { |
36694 | 1128 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotFound, skinfname); |
32873 | 1129 return -1; |
1130 } | |
23077 | 1131 } |
32873 | 1132 |
33985 | 1133 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 1134 |
32932 | 1135 appFreeStruct(); |
23077 | 1136 |
33078 | 1137 skin = NULL; |
1138 currWinName[0] = 0; | |
33079 | 1139 linenumber = 0; |
23077 | 1140 |
34578 | 1141 while (fgetstr(line, sizeof(line), skinfile)) { |
32873 | 1142 linenumber++; |
1143 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1144 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1145 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1146 decomment(line); |
32873 | 1147 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1148 if (!*line) |
32873 | 1149 continue; |
23077 | 1150 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1151 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
1152 cutItem(line, param, '=', 1); |
33075 | 1153 strlower(item); |
32873 | 1154 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1155 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
|
1156 if (!strcmp(item, skinItem[i].name)) { |
35360 | 1157 if (skinItem[i].func(param) != 0) { |
1158 fclose(skinfile); | |
32873 | 1159 return -2; |
35360 | 1160 } else |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1161 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1162 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
1163 } |
33077 | 1164 |
1165 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
36694 | 1166 skin_error(MSGTR_GUI_MSG_SkinUnknownItem, item); |
35360 | 1167 fclose(skinfile); |
33077 | 1168 return -2; |
1169 } | |
32873 | 1170 } |
1171 | |
35360 | 1172 fclose(skinfile); |
1173 | |
32873 | 1174 if (linenumber == 0) { |
36694 | 1175 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotReadable, skinfname); |
32873 | 1176 return -1; |
1177 } | |
1178 | |
1179 return 0; | |
23077 | 1180 } |