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