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