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