Mercurial > mplayer.hg
annotate gui/skin/skin.c @ 33101:930338bde973
Order member assignments according to their definition in the structure.
author | ib |
---|---|
date | Sat, 02 Apr 2011 20:24:19 +0000 |
parents | 35efac3ece2c |
children | de688a61e439 |
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 |
19 #include <stdio.h> | |
20 #include <string.h> | |
21 | |
32873 | 22 #include "skin.h" |
23077 | 23 #include "font.h" |
32893 | 24 #include "gui/app.h" |
33023 | 25 #include "gui/interface.h" |
32873 | 26 #include "gui/mplayer/widgets.h" |
33046 | 27 #include "gui/util/cut.h" |
33048 | 28 #include "gui/util/string.h" |
23077 | 29 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
30 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
31 #include "help_mp.h" |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23077
diff
changeset
|
32 #include "libavutil/avstring.h" |
32944 | 33 #include "libavutil/common.h" |
32873 | 34 #include "mp_msg.h" |
23077 | 35 |
32873 | 36 typedef struct { |
37 const char *name; | |
38 int (*func)(char *in); | |
39 } _item; | |
23077 | 40 |
32937 | 41 static guiItems *skin; |
23077 | 42 |
32873 | 43 static int linenumber; |
44 static unsigned char path[512]; | |
23077 | 45 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
46 static unsigned char currWinName[32]; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
47 static wItem *currWin; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
48 static int *currWinItemIdx; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
49 static wItem *currWinItems; |
23077 | 50 |
33022 | 51 static void skin_error(const char *format, ...) |
23077 | 52 { |
32873 | 53 char p[512]; |
54 va_list ap; | |
55 | |
56 va_start(ap, format); | |
57 vsnprintf(p, sizeof(p), format, ap); | |
58 va_end(ap); | |
59 | |
33023 | 60 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_ERRORMESSAGE, linenumber, p); |
23077 | 61 } |
62 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
63 static int section_cmd(char *cmd) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
64 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
65 if (!skin) { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
66 skin_error(MSGTR_SKIN_ERROR_SECTION, cmd); |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
67 return 0; |
32873 | 68 } |
69 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
70 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
71 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
72 |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
73 static int window_cmd(char *cmd) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
74 { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
75 if (!currWinName[0]) { |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
76 skin_error(MSGTR_SKIN_ERROR_WINDOW, cmd); |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
77 return 0; |
32873 | 78 } |
23077 | 79 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
80 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
81 } |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
82 |
33058 | 83 static int in_window(char *name) |
84 { | |
85 if (strcmp(currWinName, name) == 0) { | |
33062 | 86 skin_error(MSGTR_SKIN_ERROR_ITEM, name); |
33058 | 87 return 1; |
32873 | 88 } |
89 | |
33058 | 90 return 0; |
91 } | |
92 | |
32873 | 93 int skinBPRead(char *fname, txSample *bf) |
94 { | |
95 int i = bpRead(fname, bf); | |
96 | |
97 switch (i) { | |
98 case -1: | |
33022 | 99 skin_error(MSGTR_SKIN_BITMAP_16bit, fname); |
32873 | 100 break; |
101 | |
102 case -2: | |
33022 | 103 skin_error(MSGTR_SKIN_BITMAP_FileNotFound, fname); |
32873 | 104 break; |
105 | |
106 case -5: | |
33022 | 107 skin_error(MSGTR_SKIN_BITMAP_PNGReadError, fname); |
32873 | 108 break; |
109 | |
110 case -8: | |
33022 | 111 skin_error(MSGTR_SKIN_BITMAP_ConversionError, fname); |
32873 | 112 break; |
113 } | |
114 | |
115 return i; | |
23077 | 116 } |
117 | |
33098 | 118 static wItem *next_item(void) |
119 { | |
120 wItem *item = NULL; | |
121 | |
122 if (*currWinItemIdx < MAX_ITEMS - 1) { | |
123 (*currWinItemIdx)++; | |
124 item = &currWinItems[*currWinItemIdx]; | |
125 } else | |
126 skin_error(MSGTR_SKIN_TooManyItemsDeclared); | |
127 | |
128 return item; | |
129 } | |
130 | |
32873 | 131 // section=movieplayer |
132 static int cmd_section(char *in) | |
23077 | 133 { |
33064 | 134 if (skin) { |
135 skin_error(MSGTR_SKIN_ERROR_ITEM, "section"); | |
136 return 1; | |
137 } | |
138 | |
33055 | 139 if (!strcmp(strlower(in), "movieplayer")) |
32937 | 140 skin = &appMPlayer; |
33067 | 141 else { |
142 skin_error(MSGTR_SKIN_UNKNOWN_NAME, in); | |
143 return 1; | |
144 } | |
32873 | 145 |
32951 | 146 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] section: %s\n", in); |
32873 | 147 |
148 return 0; | |
23077 | 149 } |
150 | |
32873 | 151 // end |
152 static int cmd_end(char *in) | |
23077 | 153 { |
32958 | 154 #ifdef MP_DEBUG |
32951 | 155 char *space, *name; |
156 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
157 if (currWinName[0]) { |
32951 | 158 space = " "; |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
159 name = currWinName; |
32951 | 160 } else { |
161 space = ""; | |
162 name = "section"; | |
163 } | |
32958 | 164 #endif |
165 | |
166 (void)in; | |
32951 | 167 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
168 if (!section_cmd("end")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
169 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
170 |
32951 | 171 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %send (%s)\n", space, name); |
172 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
173 if (currWinName[0]) { |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
174 currWinName[0] = 0; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
175 currWin = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
176 currWinItemIdx = NULL; |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
177 currWinItems = NULL; |
32873 | 178 } else |
32937 | 179 skin = NULL; |
32873 | 180 |
181 return 0; | |
23077 | 182 } |
183 | |
32873 | 184 // window=main|sub|playbar|menu |
185 static int cmd_window(char *in) | |
23077 | 186 { |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
187 if (!section_cmd("window")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
188 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
189 |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
190 if (currWinName[0]) { |
33062 | 191 skin_error(MSGTR_SKIN_ERROR_ITEM, "window"); |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
192 return 1; |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
193 } |
32873 | 194 |
33083 | 195 strlower(in); |
23077 | 196 |
33083 | 197 if (strcmp(in, "main") == 0) { |
33095 | 198 currWin = &skin->main; |
199 currWinItemIdx = &skin->IndexOfMainItems; | |
200 currWinItems = skin->mainItems; | |
33083 | 201 } else if (strcmp(in, "sub") == 0) { |
33095 | 202 currWin = &skin->sub; |
33083 | 203 currWinItemIdx = NULL; |
204 currWinItems = NULL; | |
205 } else if (strcmp(in, "playbar") == 0) { | |
33095 | 206 currWin = &skin->bar; |
207 currWinItemIdx = &skin->IndexOfBarItems; | |
208 currWinItems = skin->barItems; | |
33083 | 209 } else if (strcmp(in, "menu") == 0) { |
33095 | 210 currWin = &skin->menu; |
211 currWinItemIdx = &skin->IndexOfMenuItems; | |
212 currWinItems = skin->menuItems; | |
33066 | 213 } else { |
33065 | 214 skin_error(MSGTR_SKIN_UNKNOWN_NAME, in); |
33066 | 215 return 1; |
216 } | |
32873 | 217 |
33083 | 218 av_strlcpy(currWinName, in, sizeof(currWinName)); |
219 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
220 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] window: %s\n", currWinName); |
32873 | 221 |
222 return 0; | |
23077 | 223 } |
224 | |
32873 | 225 // base=image,x,y[,width,height] |
226 static int cmd_base(char *in) | |
23077 | 227 { |
33090 | 228 unsigned char fname[256]; |
33089 | 229 unsigned char file[512]; |
32873 | 230 int x, y; |
33089 | 231 int w = 0, h = 0; |
32873 | 232 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
233 if (!window_cmd("base")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
234 return 1; |
23077 | 235 |
32873 | 236 cutItem(in, fname, ',', 0); |
33089 | 237 x = cutItemToInt(in, ',', 1); |
238 y = cutItemToInt(in, ',', 2); | |
239 w = cutItemToInt(in, ',', 3); | |
240 h = cutItemToInt(in, ',', 4); | |
32873 | 241 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
242 if (!strcmp(currWinName, "main")) { |
32951 | 243 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); |
23077 | 244 |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
245 currWin->type = itBase; |
33096 | 246 currWin->x = x; |
247 currWin->y = y; | |
32873 | 248 |
33089 | 249 av_strlcpy(file, path, sizeof(file)); |
250 av_strlcat(file, fname, sizeof(file)); | |
32873 | 251 |
33096 | 252 if (skinBPRead(file, &currWin->Bitmap) != 0) |
32873 | 253 return 1; |
254 | |
33096 | 255 currWin->width = currWin->Bitmap.Width; |
256 currWin->height = currWin->Bitmap.Height; | |
32873 | 257 |
33096 | 258 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
32951 | 259 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
260 #ifdef CONFIG_XSHAPE |
33096 | 261 Convert32to1(&currWin->Bitmap, &currWin->Mask, 0x00ff00ff); |
262 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); | |
23077 | 263 #else |
33096 | 264 currWin->Mask.Image = NULL; |
23077 | 265 #endif |
266 } | |
32873 | 267 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
268 if (!strcmp(currWinName, "sub")) { |
32958 | 269 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); |
270 | |
33096 | 271 currWin->type = itBase; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
272 currWin->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
273 currWin->y = y; |
32873 | 274 |
33089 | 275 av_strlcpy(file, path, sizeof(file)); |
276 av_strlcat(file, fname, sizeof(file)); | |
32873 | 277 |
33096 | 278 if (skinBPRead(file, &currWin->Bitmap) != 0) |
32873 | 279 return 1; |
280 | |
33096 | 281 currWin->width = currWin->Bitmap.Width; |
282 currWin->height = currWin->Bitmap.Height; | |
32873 | 283 |
33089 | 284 if (w && h) { |
33096 | 285 currWin->width = w; |
286 currWin->height = h; | |
32873 | 287 } |
288 | |
33096 | 289 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
32873 | 290 } |
291 | |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
292 if (!strcmp(currWinName, "menu")) { |
32958 | 293 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s\n", fname); |
294 | |
33096 | 295 currWin->type = itBase; |
32873 | 296 |
33089 | 297 av_strlcpy(file, path, sizeof(file)); |
298 av_strlcat(file, fname, sizeof(file)); | |
32873 | 299 |
33096 | 300 if (skinBPRead(file, &currWin->Bitmap) != 0) |
32873 | 301 return 1; |
302 | |
33096 | 303 currWin->width = currWin->Bitmap.Width; |
304 currWin->height = currWin->Bitmap.Height; | |
32873 | 305 |
33096 | 306 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
32951 | 307 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
308 #ifdef CONFIG_XSHAPE |
33096 | 309 Convert32to1(&currWin->Bitmap, &currWin->Mask, 0x00ff00ff); |
310 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); | |
23077 | 311 #else |
33096 | 312 currWin->Mask.Image = NULL; |
23077 | 313 #endif |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
314 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
315 skin->menuIsPresent = 1; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
316 } |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
317 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
318 if (!strcmp(currWinName, "playbar")) { |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
319 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s %d,%d\n", fname, x, y); |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
320 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
321 currWin->type = itBase; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
322 currWin->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
323 currWin->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
324 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
325 av_strlcpy(file, path, sizeof(file)); |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
326 av_strlcat(file, fname, sizeof(file)); |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
327 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
328 if (skinBPRead(file, &currWin->Bitmap) != 0) |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
329 return 1; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
330 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
331 currWin->width = currWin->Bitmap.Width; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
332 currWin->height = currWin->Bitmap.Height; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
333 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
334 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height); |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
335 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
336 #ifdef CONFIG_XSHAPE |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
337 Convert32to1(&currWin->Bitmap, &currWin->Mask, 0x00ff00ff); |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
338 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height); |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
339 #else |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
340 currWin->Mask.Image = NULL; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
341 #endif |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
342 |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
343 skin->barIsPresent = 1; |
32873 | 344 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
345 |
32873 | 346 return 0; |
23077 | 347 } |
348 | |
32873 | 349 // background=R,G,B |
350 static int cmd_background(char *in) | |
23077 | 351 { |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
352 if (!window_cmd("background")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
353 return 1; |
23077 | 354 |
33058 | 355 if (in_window("main")) |
356 return 1; | |
33088 | 357 if (in_window("playbar")) |
358 return 1; | |
33058 | 359 if (in_window("menu")) |
360 return 1; | |
23077 | 361 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
362 currWin->R = cutItemToInt(in, ',', 0); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
363 currWin->G = cutItemToInt(in, ',', 1); |
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
364 currWin->B = cutItemToInt(in, ',', 2); |
23077 | 365 |
32980
2bfd000bb789
Cosmetic: Rename pointers handling current window and items.
ib
parents:
32979
diff
changeset
|
366 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B); |
23077 | 367 |
32873 | 368 return 0; |
23077 | 369 } |
370 | |
32873 | 371 // button=image,x,y,width,height,message |
372 static int cmd_button(char *in) | |
23077 | 373 { |
33090 | 374 unsigned char fname[256]; |
33089 | 375 unsigned char file[512]; |
376 int x, y, w, h, message; | |
32873 | 377 char msg[32]; |
33098 | 378 wItem *item; |
32873 | 379 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
380 if (!window_cmd("button")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
381 return 1; |
32873 | 382 |
33058 | 383 if (in_window("sub")) |
384 return 1; | |
385 if (in_window("menu")) | |
386 return 1; | |
23077 | 387 |
32873 | 388 cutItem(in, fname, ',', 0); |
33089 | 389 x = cutItemToInt(in, ',', 1); |
390 y = cutItemToInt(in, ',', 2); | |
391 w = cutItemToInt(in, ',', 3); | |
392 h = cutItemToInt(in, ',', 4); | |
32873 | 393 cutItem(in, msg, ',', 5); |
394 | |
33071 | 395 message = appFindMessage(msg); |
396 | |
397 if (message == -1) { | |
398 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
399 return 1; | |
400 } | |
401 | |
33098 | 402 item = next_item(); |
403 | |
404 if (!item) | |
405 return 1; | |
406 | |
407 item->type = itButton; | |
408 item->x = x; | |
409 item->y = y; | |
410 item->width = w; | |
411 item->height = h; | |
412 item->message = message; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
413 item->pressed = btnReleased; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
414 item->tmp = 1; |
23077 | 415 |
32951 | 416 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y); |
33071 | 417 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
33089 | 418 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", w, h); |
32951 | 419 |
33098 | 420 if (item->message == evPauseSwitchToPlay) |
421 item->pressed = btnDisabled; | |
23077 | 422 |
33098 | 423 item->Bitmap.Image = NULL; |
32873 | 424 |
425 if (strcmp(fname, "NULL") != 0) { | |
33089 | 426 av_strlcpy(file, path, sizeof(file)); |
427 av_strlcat(file, fname, sizeof(file)); | |
32873 | 428 |
33098 | 429 if (skinBPRead(file, &item->Bitmap) != 0) |
32873 | 430 return 1; |
32951 | 431 |
33098 | 432 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); |
32873 | 433 } |
434 | |
435 return 0; | |
23077 | 436 } |
437 | |
32873 | 438 // selected=image |
439 static int cmd_selected(char *in) | |
440 { | |
33089 | 441 unsigned char file[512]; |
33096 | 442 wItem *currItem; |
32873 | 443 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
444 if (!window_cmd("selected")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
445 return 1; |
32873 | 446 |
33058 | 447 if (in_window("main")) |
448 return 1; | |
449 if (in_window("sub")) | |
450 return 1; | |
451 if (in_window("playbar")) | |
452 return 1; | |
32873 | 453 |
33096 | 454 currItem = &skin->menuSelected; |
455 currItem->type = itBase; | |
32873 | 456 |
33089 | 457 av_strlcpy(file, path, sizeof(file)); |
33091 | 458 av_strlcat(file, in, sizeof(file)); |
32873 | 459 |
33091 | 460 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image selected: %s\n", in); |
23077 | 461 |
33096 | 462 if (skinBPRead(file, &currItem->Bitmap) != 0) |
32873 | 463 return 1; |
464 | |
33096 | 465 currItem->width = currItem->Bitmap.Width; |
466 currItem->height = currItem->Bitmap.Height; | |
32873 | 467 |
33096 | 468 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currItem->width, currItem->height); |
32873 | 469 |
470 return 0; | |
471 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
472 |
32873 | 473 // menu=x,y,width,height,message |
474 static int cmd_menu(char *in) | |
475 { | |
33089 | 476 int x, y, w, h, message; |
33071 | 477 char msg[32]; |
33096 | 478 wItem *item; |
32873 | 479 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
480 if (!window_cmd("menu")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
481 return 1; |
32873 | 482 |
33058 | 483 if (in_window("main")) |
484 return 1; | |
485 if (in_window("sub")) | |
486 return 1; | |
487 if (in_window("playbar")) | |
488 return 1; | |
32873 | 489 |
33089 | 490 x = cutItemToInt(in, ',', 0); |
491 y = cutItemToInt(in, ',', 1); | |
492 w = cutItemToInt(in, ',', 2); | |
493 h = cutItemToInt(in, ',', 3); | |
33071 | 494 cutItem(in, msg, ',', 4); |
495 | |
496 message = appFindMessage(msg); | |
23077 | 497 |
33071 | 498 if (message == -1) { |
499 skin_error(MSGTR_SKIN_UnknownMessage, msg); | |
500 return 1; | |
501 } | |
32873 | 502 |
33098 | 503 item = next_item(); |
504 | |
505 if (!item) | |
506 return 1; | |
507 | |
33100 | 508 item->type = itMenu; |
33096 | 509 item->x = x; |
510 item->y = y; | |
511 item->width = w; | |
512 item->height = h; | |
513 item->message = message; | |
23077 | 514 |
33096 | 515 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h); |
33071 | 516 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message); |
23077 | 517 |
33096 | 518 item->Bitmap.Image = NULL; |
33053 | 519 |
32873 | 520 return 0; |
23077 | 521 } |
522 | |
32873 | 523 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
524 static int cmd_hpotmeter(char *in) | |
525 { | |
33090 | 526 unsigned char pfname[256]; |
527 unsigned char phfname[256]; | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
528 unsigned char buf[512]; |
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
529 int pwidth, pheight, ph, d, x, y, w, h, message; |
32873 | 530 wItem *item; |
23077 | 531 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
532 if (!window_cmd("h/v potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
533 return 1; |
23077 | 534 |
33058 | 535 if (in_window("sub")) |
536 return 1; | |
537 if (in_window("menu")) | |
538 return 1; | |
23077 | 539 |
32873 | 540 cutItem(in, pfname, ',', 0); |
32911 | 541 pwidth = cutItemToInt(in, ',', 1); |
542 pheight = cutItemToInt(in, ',', 2); | |
32873 | 543 cutItem(in, phfname, ',', 3); |
544 ph = cutItemToInt(in, ',', 4); | |
545 d = cutItemToInt(in, ',', 5); | |
546 x = cutItemToInt(in, ',', 6); | |
547 y = cutItemToInt(in, ',', 7); | |
33089 | 548 w = cutItemToInt(in, ',', 8); |
549 h = cutItemToInt(in, ',', 9); | |
550 cutItem(in, buf, ',', 10); | |
32873 | 551 |
33089 | 552 message = appFindMessage(buf); |
23077 | 553 |
33069 | 554 if (message == -1) { |
33089 | 555 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 556 return 1; |
557 } | |
558 | |
33089 | 559 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 560 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight); |
561 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); | |
33089 | 562 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 563 |
33098 | 564 item = next_item(); |
565 | |
566 if (!item) | |
567 return 1; | |
568 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
569 item->type = itHPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
570 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
571 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
572 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
573 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
574 item->pwidth = pwidth; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
575 item->pheight = pheight; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
576 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
577 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
578 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
579 item->pressed = btnReleased; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
580 |
32873 | 581 item->Bitmap.Image = NULL; |
23077 | 582 |
32873 | 583 if (strcmp(phfname, "NULL") != 0) { |
33089 | 584 av_strlcpy(buf, path, sizeof(buf)); |
585 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 586 |
33089 | 587 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 588 return 1; |
32951 | 589 |
590 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 591 } |
592 | |
593 item->Mask.Image = NULL; | |
23077 | 594 |
32873 | 595 if (strcmp(pfname, "NULL") != 0) { |
33089 | 596 av_strlcpy(buf, path, sizeof(buf)); |
597 av_strlcat(buf, pfname, sizeof(buf)); | |
32873 | 598 |
33089 | 599 if (skinBPRead(buf, &item->Mask) != 0) |
32873 | 600 return 1; |
32951 | 601 |
602 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height); | |
32873 | 603 } |
604 | |
605 return 0; | |
23077 | 606 } |
607 | |
32873 | 608 // vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message |
609 static int cmd_vpotmeter(char *in) | |
23077 | 610 { |
33056 | 611 int r; |
32873 | 612 wItem *item; |
23077 | 613 |
33056 | 614 r = cmd_hpotmeter(in); |
615 | |
616 if (r == 0) { | |
33057 | 617 item = &currWinItems[*currWinItemIdx]; |
618 item->type = itVPotmeter; | |
33056 | 619 } |
33053 | 620 |
32873 | 621 return r; |
23077 | 622 } |
623 | |
32873 | 624 // potmeter=phases,numphases,default,x,y,width,height,message |
625 static int cmd_potmeter(char *in) | |
626 { | |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
627 unsigned char phfname[256]; |
33089 | 628 unsigned char buf[512]; |
33093
3de646fca03b
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33092
diff
changeset
|
629 int ph, d, x, y, w, h, message; |
32873 | 630 wItem *item; |
23077 | 631 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
632 if (!window_cmd("potmeter")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
633 return 1; |
23077 | 634 |
33058 | 635 if (in_window("sub")) |
636 return 1; | |
637 if (in_window("menu")) | |
638 return 1; | |
23077 | 639 |
32873 | 640 cutItem(in, phfname, ',', 0); |
641 ph = cutItemToInt(in, ',', 1); | |
642 d = cutItemToInt(in, ',', 2); | |
643 x = cutItemToInt(in, ',', 3); | |
644 y = cutItemToInt(in, ',', 4); | |
33089 | 645 w = cutItemToInt(in, ',', 5); |
646 h = cutItemToInt(in, ',', 6); | |
647 cutItem(in, buf, ',', 7); | |
32873 | 648 |
33089 | 649 message = appFindMessage(buf); |
23077 | 650 |
33069 | 651 if (message == -1) { |
33089 | 652 skin_error(MSGTR_SKIN_UnknownMessage, buf); |
33069 | 653 return 1; |
654 } | |
655 | |
33089 | 656 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h); |
32951 | 657 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d); |
33089 | 658 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message); |
23077 | 659 |
33098 | 660 item = next_item(); |
661 | |
662 if (!item) | |
663 return 1; | |
664 | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
665 item->type = itPotmeter; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
666 item->x = x; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
667 item->y = y; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
668 item->width = w; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
669 item->height = h; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
670 item->numphases = ph; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
671 item->value = (float)d; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
672 item->message = message; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
673 |
32873 | 674 item->Bitmap.Image = NULL; |
23077 | 675 |
32873 | 676 if (strcmp(phfname, "NULL") != 0) { |
33089 | 677 av_strlcpy(buf, path, sizeof(buf)); |
678 av_strlcat(buf, phfname, sizeof(buf)); | |
32873 | 679 |
33089 | 680 if (skinBPRead(buf, &item->Bitmap) != 0) |
32873 | 681 return 1; |
32951 | 682 |
683 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height); | |
32873 | 684 } |
685 | |
686 return 0; | |
23077 | 687 } |
688 | |
32873 | 689 // font=fontfile |
690 static int cmd_font(char *in) | |
691 { | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
692 char fnt[256]; |
23077 | 693 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
694 if (!window_cmd("font")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
695 return 1; |
23077 | 696 |
33058 | 697 if (in_window("sub")) |
698 return 1; | |
699 if (in_window("menu")) | |
700 return 1; | |
23077 | 701 |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
702 cutItem(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility |
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
703 // reasons with a meanwhile depreciated second parameter. |
33099
0b17f6bed6fc
Don't needlessly store font information in the wItems array
ib
parents:
33098
diff
changeset
|
704 switch (fntRead(path, fnt)) { |
32873 | 705 case -1: |
33097 | 706 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 707 return 1; |
23077 | 708 |
32873 | 709 case -2: |
33022 | 710 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); |
32873 | 711 return 1; |
712 | |
713 case -3: | |
33022 | 714 skin_error(MSGTR_SKIN_FONT_FontFileNotFound); |
32873 | 715 return 1; |
716 | |
717 case -4: | |
33022 | 718 skin_error(MSGTR_SKIN_FONT_FontImageNotFound); |
32873 | 719 return 1; |
720 } | |
721 | |
33092
83052a4ac698
Use more appropriate name for variable and reduce it to reasonable size.
ib
parents:
33091
diff
changeset
|
722 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); |
32951 | 723 |
32873 | 724 return 0; |
23077 | 725 } |
726 | |
32873 | 727 // slabel=x,y,fontfile,"text" |
728 static int cmd_slabel(char *in) | |
23077 | 729 { |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
730 int x, y, id; |
33090 | 731 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
732 char txt[256]; |
32873 | 733 wItem *item; |
734 | |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
735 if (!window_cmd("slabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
736 return 1; |
23077 | 737 |
33058 | 738 if (in_window("sub")) |
739 return 1; | |
740 if (in_window("menu")) | |
741 return 1; | |
32873 | 742 |
743 x = cutItemToInt(in, ',', 0); | |
744 y = cutItemToInt(in, ',', 1); | |
33089 | 745 cutItem(in, fnt, ',', 2); |
746 cutItem(in, txt, ',', 3); | |
747 cutItem(txt, txt, '"', 1); | |
32951 | 748 |
33089 | 749 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt); |
32951 | 750 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
23077 | 751 |
33089 | 752 id = fntFindID(fnt); |
23077 | 753 |
32873 | 754 if (id < 0) { |
33097 | 755 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt); |
32873 | 756 return 1; |
757 } | |
23077 | 758 |
33089 | 759 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 760 |
33098 | 761 item = next_item(); |
762 | |
763 if (!item) | |
764 return 1; | |
765 | |
32873 | 766 item->type = itSLabel; |
767 item->x = x; | |
768 item->y = y; | |
769 item->width = -1; | |
770 item->height = -1; | |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
771 item->fontid = id; |
33089 | 772 item->label = strdup(txt); |
23077 | 773 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
774 if (!item->label) { |
33097 | 775 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 776 return 1; |
777 } | |
23077 | 778 |
32873 | 779 return 0; |
23077 | 780 } |
781 | |
32910 | 782 // dlabel=x,y,width,align,fontfile,"text" |
32873 | 783 static int cmd_dlabel(char *in) |
784 { | |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
785 int x, y, w, a, id; |
33090 | 786 char fnt[256]; |
33094
2faf1c3ded5d
Cosmetic: Rearrange variable declarations to match parameters.
ib
parents:
33093
diff
changeset
|
787 char txt[256]; |
32873 | 788 wItem *item; |
23077 | 789 |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
790 if (!window_cmd("dlabel")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
791 return 1; |
23077 | 792 |
33058 | 793 if (in_window("sub")) |
794 return 1; | |
795 if (in_window("menu")) | |
796 return 1; | |
32873 | 797 |
33089 | 798 x = cutItemToInt(in, ',', 0); |
799 y = cutItemToInt(in, ',', 1); | |
800 w = cutItemToInt(in, ',', 2); | |
801 a = cutItemToInt(in, ',', 3); | |
802 cutItem(in, fnt, ',', 4); | |
803 cutItem(in, txt, ',', 5); | |
804 cutItem(txt, txt, '"', 1); | |
32951 | 805 |
33089 | 806 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); |
32951 | 807 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); |
33089 | 808 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); |
23077 | 809 |
33089 | 810 id = fntFindID(fnt); |
23077 | 811 |
32873 | 812 if (id < 0) { |
33097 | 813 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt); |
32873 | 814 return 1; |
815 } | |
23077 | 816 |
33089 | 817 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); |
23077 | 818 |
33098 | 819 item = next_item(); |
820 | |
821 if (!item) | |
822 return 1; | |
823 | |
32873 | 824 item->type = itDLabel; |
825 item->x = x; | |
826 item->y = y; | |
33089 | 827 item->width = w; |
32873 | 828 item->height = -1; |
33101
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
829 item->fontid = id; |
930338bde973
Order member assignments according to their definition in the structure.
ib
parents:
33100
diff
changeset
|
830 item->align = a; |
33089 | 831 item->label = strdup(txt); |
23077 | 832 |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32958
diff
changeset
|
833 if (!item->label) { |
33097 | 834 skin_error(MSGTR_SKIN_NotEnoughMemory); |
32873 | 835 return 1; |
836 } | |
23077 | 837 |
32873 | 838 return 0; |
23077 | 839 } |
840 | |
32873 | 841 // decoration=enable|disable |
842 static int cmd_decoration(char *in) | |
23077 | 843 { |
33054
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
844 if (!window_cmd("decoration")) |
ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
ib
parents:
33053
diff
changeset
|
845 return 1; |
32873 | 846 |
33058 | 847 if (in_window("sub")) |
848 return 1; | |
849 if (in_window("playbar")) | |
850 return 1; | |
851 if (in_window("menu")) | |
852 return 1; | |
32873 | 853 |
33086 | 854 strlower(in); |
32873 | 855 |
33086 | 856 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) { |
857 skin_error(MSGTR_SKIN_UnknownParameter, in); | |
32873 | 858 return 1; |
859 } | |
23077 | 860 |
33087 | 861 skin->mainDecoration = (strcmp(in, "enable") == 0); |
23077 | 862 |
33086 | 863 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in); |
32873 | 864 |
865 return 0; | |
23077 | 866 } |
867 | |
32878 | 868 static _item skinItem[] = { |
32873 | 869 { "section", cmd_section }, |
870 { "end", cmd_end }, | |
871 { "window", cmd_window }, | |
872 { "base", cmd_base }, | |
873 { "button", cmd_button }, | |
874 { "selected", cmd_selected }, | |
875 { "background", cmd_background }, | |
876 { "vpotmeter", cmd_vpotmeter }, | |
877 { "hpotmeter", cmd_hpotmeter }, | |
878 { "potmeter", cmd_potmeter }, | |
879 { "font", cmd_font }, | |
880 { "slabel", cmd_slabel }, | |
881 { "dlabel", cmd_dlabel }, | |
882 { "decoration", cmd_decoration }, | |
883 { "menu", cmd_menu } | |
884 }; | |
885 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
886 static char *setname(char *dir, char *sname) |
32873 | 887 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
888 static char skinfname[512]; |
32873 | 889 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
890 av_strlcpy(skinfname, dir, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
891 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
892 av_strlcat(skinfname, sname, sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
893 av_strlcat(skinfname, "/", sizeof(skinfname)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
894 av_strlcpy(path, skinfname, sizeof(path)); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
895 av_strlcat(skinfname, "skin", sizeof(skinfname)); |
32873 | 896 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
897 return skinfname; |
23077 | 898 } |
899 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
900 int skinRead(char *sname) |
23077 | 901 { |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
902 char *skinfname; |
32873 | 903 FILE *skinFile; |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
904 unsigned char line[256]; |
33075 | 905 unsigned char item[32]; |
32873 | 906 unsigned char param[256]; |
32944 | 907 unsigned int i; |
32873 | 908 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
909 skinfname = setname(skinDirInHome, sname); |
23077 | 910 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
911 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
912 skinfname = setname(skinMPlayerDir, sname); |
32873 | 913 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
914 if ((skinFile = fopen(skinfname, "rt")) == NULL) { |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
915 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname); |
32873 | 916 return -1; |
917 } | |
23077 | 918 } |
32873 | 919 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
920 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); |
23077 | 921 |
32932 | 922 appFreeStruct(); |
23077 | 923 |
33078 | 924 skin = NULL; |
925 currWinName[0] = 0; | |
33079 | 926 linenumber = 0; |
23077 | 927 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
928 while (fgets(line, sizeof(line), skinFile)) { |
32873 | 929 linenumber++; |
930 | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
931 line[strcspn(line, "\n\r")] = 0; // remove any kind of newline, if any |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
932 strswap(line, '\t', ' '); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
933 trim(line); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
934 decomment(line); |
32873 | 935 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
936 if (!*line) |
32873 | 937 continue; |
23077 | 938 |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
939 cutItem(line, item, '=', 0); |
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
940 cutItem(line, param, '=', 1); |
33075 | 941 strlower(item); |
32873 | 942 |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
943 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
|
944 if (!strcmp(item, skinItem[i].name)) { |
32873 | 945 if (skinItem[i].func(param) != 0) |
946 return -2; | |
33076
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
947 else |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
948 break; |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
949 } |
27999e9c1b3f
Leave loop after item function has been found and called.
ib
parents:
33075
diff
changeset
|
950 } |
33077 | 951 |
952 if (i == FF_ARRAY_ELEMS(skinItem)) { | |
953 skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item); | |
954 return -2; | |
955 } | |
32873 | 956 } |
957 | |
958 if (linenumber == 0) { | |
33081
d217fdc83e63
(Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents:
33079
diff
changeset
|
959 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname); |
32873 | 960 return -1; |
961 } | |
962 | |
963 return 0; | |
23077 | 964 } |