annotate Gui/win32/skinload.c @ 19493:aa58338824f8

Remove backup files from the win32 subdir as well.
author diego
date Tue, 22 Aug 2006 23:04:48 +0000
parents d450ec82ae57
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1 /*
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
2 MPlayer Gui for win32
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
6
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
10 (at your option) any later version.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
11
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
15 GNU General Public License for more details.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
16
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
18 along with this program; if not, write to the Free Software
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
20 */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
21
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
22 #include <stdlib.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
23 #include <inttypes.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
24 #include <windows.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
25 #include <png.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
26
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
27 #include <mp_msg.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
28 #include <cpudetect.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
29 #include <libswscale/rgb2rgb.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
30 #include <libswscale/swscale.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
31
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
32 #include "gui.h"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
33
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
34 #define MAX_LINESIZE 256
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
35
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
36 typedef struct
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
37 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
38 int msg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
39 char *name;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
40 } evName;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
41
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
42 static const evName evNames[] =
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
43 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
44 { evNone, "evNone" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
45 { evPlay, "evPlay" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
46 { evDropFile, "evDropFile" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
47 { evStop, "evStop" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
48 { evPause, "evPause" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
49 { evPrev, "evPrev" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
50 { evNext, "evNext" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
51 { evLoad, "evLoad" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
52 { evEqualizer, "evEqualizer" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
53 { evEqualizer, "evEqualeaser" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
54 { evPlayList, "evPlaylist" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
55 { evExit, "evExit" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
56 { evIconify, "evIconify" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
57 { evIncBalance, "evIncBalance" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
58 { evDecBalance, "evDecBalance" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
59 { evFullScreen, "evFullScreen" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
60 { evFName, "evFName" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
61 { evMovieTime, "evMovieTime" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
62 { evAbout, "evAbout" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
63 { evLoadPlay, "evLoadPlay" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
64 { evPreferences, "evPreferences" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
65 { evSkinBrowser, "evSkinBrowser" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
66 { evBackward10sec, "evBackward10sec" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
67 { evForward10sec, "evForward10sec" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
68 { evBackward1min, "evBackward1min" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
69 { evForward1min, "evForward1min" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
70 { evBackward10min, "evBackward10min" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
71 { evForward10min, "evForward10min" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
72 { evIncVolume, "evIncVolume" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
73 { evDecVolume, "evDecVolume" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
74 { evMute, "evMute" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
75 { evIncAudioBufDelay, "evIncAudioBufDelay" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
76 { evDecAudioBufDelay, "evDecAudioBufDelay" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
77 { evPlaySwitchToPause, "evPlaySwitchToPause" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
78 { evPauseSwitchToPlay, "evPauseSwitchToPlay" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
79 { evNormalSize, "evNormalSize" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
80 { evDoubleSize, "evDoubleSize" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
81 { evSetMoviePosition, "evSetMoviePosition" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
82 { evSetVolume, "evSetVolume" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
83 { evSetBalance, "evSetBalance" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
84 { evHelp, "evHelp" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
85 { evLoadSubtitle, "evLoadSubtitle" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
86 { evPlayDVD, "evPlayDVD" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
87 { evPlayVCD, "evPlayVCD" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
88 { evSetURL, "evSetURL" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
89 { evLoadAudioFile, "evLoadAudioFile" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
90 { evDropSubtitle, "evDropSubtitle" },
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
91 { evSetAspect, "evSetAspect" }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
92 };
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
93
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
94 static const int evBoxs = sizeof(evNames) / sizeof(evName);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
95
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
96 static char *geteventname(int event)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
97 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
98 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
99 for(i=0; i<evBoxs; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
100 if(evNames[i].msg == event)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
101 return evNames[i].name;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
102 return NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
103 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
104
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
105 static inline int get_sws_cpuflags(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
106 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
107 return (gCpuCaps.hasMMX ? SWS_CPU_CAPS_MMX : 0) |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
108 (gCpuCaps.hasMMX2 ? SWS_CPU_CAPS_MMX2 : 0) |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
109 (gCpuCaps.has3DNow ? SWS_CPU_CAPS_3DNOW : 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
110 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
111
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
112 /* reads a complete image as is into image buffer */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
113 static image *pngRead(skin_t *skin, unsigned char *fname)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
114 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
115 unsigned char header[8];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
116 png_structp png;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
117 png_infop info;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
118 png_infop endinfo;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
119 png_bytep *row_p;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
120 int color, h;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
121 png_uint_32 i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
122 int BPP;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
123 char *img;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
124 unsigned int imgsize;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
125 image *bf;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
126 char *filename;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
127 FILE *fp;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
128
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
129 if(!stricmp(fname, "NULL")) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
130
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
131 /* find filename in order file file.png */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
132 if(!(fp = fopen(fname, "rb")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
133 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
134 filename = calloc(1, strlen(skin->skindir) + strlen(fname) + 6);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
135 sprintf(filename, "%s\\%s.png", skin->skindir, fname);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
136 if(!(fp = fopen(filename, "rb")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
137 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
138 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[png] cannot find image %s\n", filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
139 free(filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
140 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
141 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
142 free(filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
143 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
144
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
145 for (i=0; i < skin->imagecount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
146 if(!strcmp(fname, skin->images[i]->name))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
147 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
148 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
149 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[png] skinfile %s already exists\n", fname);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
150 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
151 return skin->images[i];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
152 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
153 (skin->imagecount)++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
154 skin->images = realloc(skin->images, sizeof(image *) * skin->imagecount);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
155 bf = skin->images[(skin->imagecount) - 1] = calloc(1, sizeof(image));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
156 bf->name = strdup(fname);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
157 fread(header,1,8,fp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
158 if (!png_check_sig(header, 8)) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
159 png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
160 info = png_create_info_struct(png);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
161 endinfo = png_create_info_struct(png);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
162
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
163 png_init_io(png, fp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
164 png_set_sig_bytes(png, 8);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
165 png_read_info(png, info);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
166 png_get_IHDR(png, info, (png_uint_32*) &bf->width, (png_uint_32*) &bf->height, &BPP, &color, NULL, NULL, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
167
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
168 if(color & PNG_COLOR_MASK_ALPHA)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
169 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
170 if(color & PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY_ALPHA ) BPP *= 2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
171 else BPP *= 4;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
172 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
173 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
174 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
175 if(color & PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY ) BPP *= 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
176 else BPP *= 3;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
177 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
178 row_p = (png_bytep *) malloc (sizeof(png_bytep) * bf->height);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
179 img = (png_bytep) calloc(png_get_rowbytes(png, info), bf->height);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
180 for (h=0; h < bf->height; h++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
181 row_p[h] = &img[png_get_rowbytes(png, info) * h];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
182 png_read_image(png, row_p);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
183 free(row_p);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
184
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
185 png_read_end(png, endinfo);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
186 png_destroy_read_struct(&png, &info, &endinfo);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
187 fclose(fp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
188 imgsize=bf->width * bf->height * (BPP / 8);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
189
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
190 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
191 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[png] loaded image %s\n", fname);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
192 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[png] size: %dx%d bits: %d\n", bf->width, bf->height, BPP);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
193 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[png] imagesize: %u\n", imgsize);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
194 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
195
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
196 bf->size = bf->width * bf->height * skin->desktopbpp / 8;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
197 bf->data = malloc(bf->size);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
198 if(skin->desktopbpp == 16 && BPP == 24) rgb24tobgr15(img, bf->data, imgsize);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
199 else if(skin->desktopbpp == 16 && BPP == 32) rgb32tobgr15(img, bf->data, imgsize);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
200 else if(skin->desktopbpp == 24 && BPP == 24) rgb24tobgr24(img, bf->data, imgsize);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
201 else if(skin->desktopbpp == 24 && BPP == 32) rgb32tobgr24(img, bf->data, imgsize);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
202 else if(skin->desktopbpp == 32 && BPP == 24) rgb24tobgr32(img, bf->data, imgsize);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
203 else if(skin->desktopbpp == 32 && BPP == 32) rgb32tobgr32(img, bf->data, imgsize);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
204 free(img);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
205 return bf;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
206 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
207
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
208 /* frees all skin images */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
209 static void freeimages(skin_t *skin)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
210 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
211 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
212 for (i=0; i<skin->imagecount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
213 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
214 if(skin->images && skin->images[i])
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
215 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
216 if(skin->images[i]->data) free(skin->images[i]->data);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
217 if(skin->images[i]->name) free(skin->images[i]->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
218 free(skin->images[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
219 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
220 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
221 free(skin->images);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
222 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
223
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
224 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
225 void dumpwidgets(skin_t *skin)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
226 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
227 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
228 for (i=0; i<skin->widgetcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
229 mp_msg(MSGT_GPLAYER, MSGL_V, "widget %p id %i\n", skin->widgets[i], skin->widgets[i]->id);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
230 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
231 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
232
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
233 static int counttonextchar(const char *s1, char c)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
234 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
235 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
236 for (i=0; i<strlen(s1); i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
237 if(s1[i] == c) return i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
238 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
239 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
240
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
241 static char *findnextstring(char *temp, const char *desc, int *base)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
242 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
243 int len = counttonextchar(*base + desc, ',');
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
244 memset(temp, 0, strlen(desc) + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
245 if(!len) len = strlen(desc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
246 memcpy(temp, *base + desc, len);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
247 *base += (len+1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
248 return temp;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
249 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
250
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
251 static void freeskin(skin_t *skin)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
252 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
253 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
254 if(skin->skindir)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
255 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
256 free(skin->skindir);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
257 skin->skindir = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
258 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
259
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
260 for (i=1; i<=skin->lastusedid; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
261 skin->removewidget(skin, i);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
262
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
263 if(skin->widgets)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
264 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
265 free(skin->widgets);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
266 skin->widgets = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
267 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
268
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
269 freeimages(skin);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
270 for(i=0; i<skin->windowcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
271 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
272 if(skin->windows[i]->name)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
273 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
274 free(skin->windows[i]->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
275 skin->windows[i]->name = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
276 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
277 free(skin->windows[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
278 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
279
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
280 free(skin->windows);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
281 skin->windows = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
282
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
283 for (i=0; i<skin->fontcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
284 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
285 unsigned int x;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
286 if(skin->fonts[i]->name)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
287 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
288 free(skin->fonts[i]->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
289 skin->fonts[i]->name = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
290 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
291
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
292 if(skin->fonts[i]->id)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
293 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
294 free(skin->fonts[i]->id);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
295 skin->fonts[i]->id = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
296 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
297
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
298 for (x=0; x<skin->fonts[i]->charcount; x++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
299 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
300 free(skin->fonts[i]->chars[x]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
301 skin->fonts[i]->chars[x] = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
302 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
303
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
304 if(skin->fonts[i]->chars)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
305 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
306 free(skin->fonts[i]->chars);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
307 skin->fonts[i]->chars = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
308 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
309
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
310 free(skin->fonts[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
311 skin->fonts[i] = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
312 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
313 free(skin->fonts);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
314 skin->fonts = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
315 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
316 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN FREE] skin freed\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
317 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
318 free(skin);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
319 skin = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
320 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
321
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
322 static void removewidget(skin_t *skin, int id)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
323 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
324 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
325 unsigned int pos=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
326 widget **temp = calloc(skin->widgetcount - 1, sizeof(widget *));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
327
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
328 for (i=0; i<skin->widgetcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
329 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
330 if(skin->widgets[i]->id == id)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
331 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
332 if(skin->widgets[i]->label)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
333 free(skin->widgets[i]->label);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
334 free(skin->widgets[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
335 skin->widgets[i] = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
336 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
337 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
338 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
339 temp[pos] = skin->widgets[i];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
340 pos++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
341 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
342 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
343 if (pos != i)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
344 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
345 (skin->widgetcount)--;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
346 free(skin->widgets);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
347 skin->widgets = temp;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
348 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
349 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "removed widget %i\n", id);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
350 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
351 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
352 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
353 free(temp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
354 mp_msg(MSGT_GPLAYER, MSGL_ERR, "widget %i not found\n", id);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
355 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
356
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
357 static void addwidget(skin_t *skin, window *win, const char *desc)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
358 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
359 widget *mywidget;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
360 char *temp = calloc(1, strlen(desc) + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
361 (skin->widgetcount)++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
362 (skin->lastusedid)++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
363 skin->widgets = realloc(skin->widgets, sizeof(widget *) * skin->widgetcount);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
364 mywidget = skin->widgets[(skin->widgetcount) - 1] = calloc(1, sizeof(widget));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
365 mywidget->id = skin->lastusedid;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
366 mywidget->window = win->type;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
367 /* parse and fill widget specific info */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
368 if(!strncmp(desc, "base", 4))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
369 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
370 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
371 mywidget->type = tyBase;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
372 mywidget->bitmap[0] = pngRead(skin, findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
373 mywidget->wx = mywidget->x = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
374 mywidget->wy = mywidget->y = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
375 mywidget->wwidth = mywidget->width = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
376 mywidget->wheight = mywidget->height = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
377 win->base = mywidget;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
378 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
379 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] [BASE] %s %i %i %i %i\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
380 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
381 mywidget->x, mywidget->y, mywidget->width, mywidget->height);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
382 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
383 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
384 else if(!strncmp(desc, "button", 6))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
385 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
386 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
387 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
388 mywidget->type = tyButton;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
389 mywidget->bitmap[0] = pngRead(skin, findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
390 mywidget->wx = mywidget->x = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
391 mywidget->wy = mywidget->y = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
392 mywidget->wwidth = mywidget->width = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
393 mywidget->wheight = mywidget->height = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
394 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
395
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
396 /* Assign corresponding event to the widget */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
397 mywidget->msg = evNone;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
398 for (i=0; i<evBoxs; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
399 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
400 if(!strcmp(temp, evNames[i].name))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
401 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
402 mywidget->msg = evNames[i].msg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
403 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
404 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
405 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
406
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
407 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
408 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] [BUTTON] %s %i %i %i %i msg %i\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
409 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
410 mywidget->x, mywidget->y, mywidget->width, mywidget->height, mywidget->msg);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
411 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
412 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
413 else if(!strncmp(desc, "hpotmeter", 9) || !strncmp(desc, "vpotmeter", 9))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
414 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
415 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
416 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
417 /* hpotmeter = button, bwidth, bheight, phases, numphases, default, X, Y, width, height, message */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
418 if(!strncmp(desc, "hpotmeter", 9)) mywidget->type = tyHpotmeter;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
419 else mywidget->type = tyVpotmeter;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
420 mywidget->bitmap[0] = pngRead(skin, findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
421 mywidget->width = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
422 mywidget->height = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
423 mywidget->bitmap[1] = pngRead(skin, findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
424 mywidget->phases = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
425 mywidget->value = atof(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
426 mywidget->x = mywidget->wx = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
427 mywidget->y = mywidget->wy = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
428 mywidget->wwidth = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
429 mywidget->wheight = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
430 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
431 mywidget->msg = evNone;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
432 for (i=0; i<evBoxs; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
433 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
434 if(!strcmp(temp, evNames[i].name))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
435 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
436 mywidget->msg = evNames[i].msg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
437 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
438 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
439 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
440 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
441 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] %s %s %i %i %s %i %f %i %i %i %i msg %i\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
442 (mywidget->type == tyHpotmeter) ? "[HPOTMETER]" : "[VPOTMETER]",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
443 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
444 mywidget->width, mywidget->height,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
445 (mywidget->bitmap[1]) ? mywidget->bitmap[1]->name : NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
446 mywidget->phases, mywidget->value,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
447 mywidget->wx, mywidget->wy, mywidget->wwidth, mywidget->wwidth,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
448 mywidget->msg);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
449 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
450 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
451 else if(!strncmp(desc, "potmeter", 8))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
452 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
453 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
454 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
455 /* potmeter = phases, numphases, default, X, Y, width, height, message */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
456 mywidget->type = tyPotmeter;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
457 mywidget->bitmap[0] = pngRead(skin, findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
458 mywidget->phases = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
459 mywidget->value = atof(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
460 mywidget->wx = mywidget->x = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
461 mywidget->wy = mywidget->y = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
462 mywidget->wwidth = mywidget->width = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
463 mywidget->wheight = mywidget->height = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
464 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
465 mywidget->msg = evNone;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
466 for (i=0; i<evBoxs; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
467 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
468 if(!strcmp(temp, evNames[i].name))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
469 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
470 mywidget->msg=evNames[i].msg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
471 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
472 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
473 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
474 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
475 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] [POTMETER] %s %i %i %i %f %i %i msg %i\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
476 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
477 mywidget->width, mywidget->height,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
478 mywidget->phases, mywidget->value,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
479 mywidget->x, mywidget->y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
480 mywidget->msg);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
481 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
482 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
483 else if(!strncmp(desc, "menu", 4))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
484 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
485 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
486 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
487 mywidget->type = tyMenu;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
488 mywidget->wx=atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
489 mywidget->x=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
490 mywidget->wy=mywidget->y=atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
491 mywidget->wwidth=mywidget->width=atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
492 mywidget->wheight=mywidget->height=atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
493 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
494 mywidget->msg = evNone;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
495 for (i=0; i<evBoxs; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
496 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
497 if(!strcmp(temp, evNames[i].name))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
498 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
499 mywidget->msg = evNames[i].msg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
500 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
501 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
502 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
503 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
504 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] [MENU] %i %i %i %i msg %i\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
505 mywidget->x, mywidget->y, mywidget->width, mywidget->height, mywidget->msg);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
506 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
507 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
508 else if(!strncmp(desc, "selected", 8))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
509 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
510 win->base->bitmap[1] = pngRead(skin, (char *) desc + 9);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
511 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
512 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] [BASE] added image %s\n", win->base->bitmap[1]->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
513 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
514 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
515 else if(!strncmp(desc, "slabel",6))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
516 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
517 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
518 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
519 mywidget->type = tySlabel;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
520 mywidget->wx = mywidget->x = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
521 mywidget->wy = mywidget->y = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
522 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
523 mywidget->font = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
524 for (i=0; i<skin->fontcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
525 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
526 if(!strcmp(temp, skin->fonts[i]->name))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
527 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
528 mywidget->font = skin->fonts[i];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
529 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
530 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
531 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
532 mywidget->label = strdup(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
533 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
534 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] [SLABEL] %i %i %s %s\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
535 mywidget->x, mywidget->y, mywidget->font->name, mywidget->label);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
536 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
537 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
538 else if(!strncmp(desc, "dlabel", 6))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
539 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
540 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
541 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
542 mywidget->type = tyDlabel;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
543 mywidget->wx = mywidget->x = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
544 mywidget->wy = mywidget->y = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
545 mywidget->length = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
546 mywidget->align = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
547 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
548 mywidget->font = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
549 for (i=0; i<skin->fontcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
550 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
551 if(!strcmp(temp, skin->fonts[i]->name))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
552 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
553 mywidget->font=skin->fonts[i];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
554 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
555 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
556 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
557 mywidget->label=strdup(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
558 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
559 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [ITEM] [DLABEL] %i %i %i %i %s \"%s\"\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
560 mywidget->x, mywidget->y, mywidget->length, mywidget->align, mywidget->font->name, mywidget->label);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
561 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
562 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
563 free(temp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
564 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
565
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
566 static void loadfonts(skin_t* skin)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
567 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
568 unsigned int x;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
569 for (x=0; x<skin->fontcount; x++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
570 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
571 FILE *fp;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
572 int linenumber=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
573 char *filename;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
574 char *tmp = calloc(1, MAX_LINESIZE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
575 char *desc = calloc(1, MAX_LINESIZE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
576 filename = calloc(1, strlen(skin->skindir) + strlen(skin->fonts[x]->name) + 6);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
577 sprintf(filename, "%s\\%s.fnt", skin->skindir, skin->fonts[x]->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
578 if(!(fp = fopen(filename,"rb")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
579 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
580 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[FONT LOAD] Font not found \"%s\"\n", skin->fonts[x]->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
581 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
582 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
583 while(!feof(fp))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
584 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
585 int pos = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
586 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
587 fgets(tmp, MAX_LINESIZE, fp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
588 linenumber++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
589 memset(desc, 0, MAX_LINESIZE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
590 for (i=0; i<strlen(tmp); i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
591 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
592 /* remove spaces and linebreaks */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
593 if((tmp[i] == ' ') || (tmp[i] == '\n') || (tmp[i] == '\r')) continue;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
594 /* remove comments */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
595 if((tmp[i] == ';') && ((i < 1) || (tmp[i-1] != '\"')))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
596 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
597 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
598 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[FONT LOAD] Comment: %s", tmp + i + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
599 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
600 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
601 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
602 desc[pos] = tmp[i];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
603 pos++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
604 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
605 if(!strlen(desc)) continue;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
606 /* now we have "readable" output -> parse it */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
607 if(!strncmp(desc, "image", 5))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
608 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
609 skin->fonts[x]->image = pngRead(skin, desc + 6);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
610 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
611 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[FONT] [IMAGE] \"%s\"\n", desc + 6);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
612 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
613 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
614 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
615 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
616 int base = 4;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
617 if(*desc != '"') break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
618 if(*(desc + 1) == 0) break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
619 (skin->fonts[x]->charcount)++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
620 skin->fonts[x]->chars = realloc(skin->fonts[x]->chars, sizeof(char_t *) *skin->fonts[x]->charcount);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
621 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]=calloc(1, sizeof(char_t));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
622 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->c = ((*(desc + 1) == '"') && (*(desc + 2) != '"')) ? ' ': *(desc + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
623 if((*(desc + 1) == '"') && (*(desc + 2) != '"')) base = 3;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
624 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->x = atoi(findnextstring(tmp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
625 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->y = atoi(findnextstring(tmp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
626 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->width = atoi(findnextstring(tmp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
627 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->height = atoi(findnextstring(tmp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
628 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
629 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[FONT] [CHAR] %c %i %i %i %i\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
630 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->c,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
631 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
632 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
633 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->width,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
634 skin->fonts[x]->chars[skin->fonts[x]->charcount - 1]->height);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
635 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
636 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
637 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
638 free(desc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
639 free(filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
640 free(tmp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
641 fclose(fp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
642 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
643 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
644
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
645 skin_t* loadskin(char* skindir, int desktopbpp)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
646 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
647 FILE *fp;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
648 int reachedendofwindow = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
649 int linenumber = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
650 skin_t *skin = calloc(1, sizeof(skin_t));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
651 char *filename;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
652 char *tmp = calloc(1, MAX_LINESIZE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
653 char *desc = calloc(1, MAX_LINESIZE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
654 window* mywindow = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
655
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
656 /* init swscaler */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
657 sws_rgb2rgb_init(get_sws_cpuflags());
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
658 /* setup funcs */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
659 skin->freeskin = freeskin;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
660 skin->pngRead = pngRead;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
661 skin->addwidget = addwidget;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
662 skin->removewidget = removewidget;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
663 skin->geteventname = geteventname;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
664 skin->desktopbpp = desktopbpp;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
665 skin->skindir = strdup(skindir);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
666
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
667 filename = calloc(1, strlen(skin->skindir) + strlen("skin") + 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
668 sprintf(filename, "%s\\skin", skin->skindir);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
669 if(!(fp = fopen(filename, "rb")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
670 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
671 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[SKIN LOAD] Skin \"%s\" not found\n", skindir);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
672 skin->freeskin(skin);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
673 return NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
674 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
675
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
676 while(!feof(fp))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
677 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
678 int pos = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
679 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
680 int insidequote = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
681 fgets(tmp, MAX_LINESIZE, fp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
682 linenumber++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
683 memset(desc, 0, MAX_LINESIZE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
684 for (i=0; i<strlen(tmp); i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
685 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
686 if((tmp[i] == '"') && !insidequote) { insidequote=1; continue; }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
687 else if((tmp[i] == '"') && insidequote) { insidequote=0 ; continue; }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
688 /* remove spaces and linebreaks */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
689 if((!insidequote && (tmp[i] == ' ')) || (tmp[i] == '\n') || (tmp[i] == '\r')) continue;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
690 /* remove comments */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
691 else if(tmp[i] == ';')
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
692 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
693 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
694 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN LOAD] Comment: %s", tmp + i + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
695 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
696 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
697 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
698 desc[pos] = tmp[i];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
699 pos++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
700 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
701
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
702 if(!strlen(desc)) continue;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
703 /* now we have "readable" output -> parse it */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
704 /* parse window specific info */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
705 if(!strncmp(desc, "section", 7))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
706 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
707 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
708 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [SECTION] \"%s\"\n", desc + 8);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
709 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
710 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
711 else if(!strncmp(desc, "window", 6))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
712 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
713 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
714 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [WINDOW] \"%s\"\n", desc + 7);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
715 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
716 reachedendofwindow = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
717 (skin->windowcount)++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
718 skin->windows = realloc(skin->windows, sizeof(window *) * skin->windowcount);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
719 mywindow = skin->windows[(skin->windowcount) - 1] = calloc(1, sizeof(window));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
720 mywindow->name = strdup(desc + 7);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
721 if(!strncmp(desc + 7, "main", 4)) mywindow->type = wiMain;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
722 else if(!strncmp(desc+7, "sub", 3))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
723 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
724 mywindow->type = wiSub;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
725 mywindow->decoration = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
726 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
727 else if(!strncmp(desc + 7, "menu", 4)) mywindow->type = wiMenu;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
728 else if(!strncmp(desc + 7, "playbar", 7)) mywindow->type = wiPlaybar;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
729 else mp_msg(MSGT_GPLAYER, MSGL_V, "[SKIN] warning found unknown windowtype");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
730 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
731 else if(!strncmp(desc, "decoration", 10) && !strncmp(desc + 11, "enable", 6))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
732 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
733 mywindow->decoration = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
734 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
735 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [DECORATION] enabled decoration for window \"%s\"\n", mywindow->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
736 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
737 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
738 else if(!strncmp(desc, "background", 10))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
739 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
740 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
741 char temp[MAX_LINESIZE];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
742 mywindow->backgroundcolor[0] = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
743 mywindow->backgroundcolor[1] = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
744 mywindow->backgroundcolor[2] = atoi(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
745 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
746 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [BACKGROUND] window \"%s\" has backgroundcolor (%i,%i,%i)\n", mywindow->name,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
747 mywindow->backgroundcolor[0],
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
748 mywindow->backgroundcolor[1],
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
749 mywindow->backgroundcolor[2]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
750 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
751 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
752 else if(!strncmp(desc, "end", 3))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
753 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
754 if(reachedendofwindow)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
755 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
756 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
757 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [END] of section\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
758 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
759 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
760 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
761 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
762 reachedendofwindow = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
763 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
764 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [END] of window \"%s\"\n", mywindow->name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
765 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
766 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
767 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
768 else if(!strncmp(desc, "font", 4))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
769 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
770 unsigned int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
771 int id = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
772 char temp[MAX_LINESIZE];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
773 int base = counttonextchar(desc, '=')+1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
774 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
775 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
776 for (i=0; i<skin->fontcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
777 if(!strcmp(skin->fonts[i]->id, temp))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
778 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
779 id = i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
780 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
781 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
782 if(!id)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
783 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
784 int base = counttonextchar(desc, '=') + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
785 findnextstring(temp, desc, &base);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
786 id = skin->fontcount;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
787 (skin->fontcount)++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
788 skin->fonts = realloc(skin->fonts, sizeof(font_t *) * skin->fontcount);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
789 skin->fonts[id]=calloc(1, sizeof(font_t));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
790 skin->fonts[id]->name = strdup(temp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
791 skin->fonts[id]->id = strdup(findnextstring(temp, desc, &base));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
792 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
793 #ifdef DEBUG
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
794 mp_msg(MSGT_GPLAYER, MSGL_DBG4, "[SKIN] [FONT] id \"%s\" name \"%s\"\n", skin->fonts[id]->name, skin->fonts[id]->id);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
795 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
796 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
797 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
798 skin->addwidget(skin, mywindow, desc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
799 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
800
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
801 free(desc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
802 free(filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
803 free(tmp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
804 fclose(fp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
805 loadfonts(skin);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
806 mp_msg(MSGT_GPLAYER, MSGL_V, "[SKIN LOAD] loaded skin \"%s\"\n", skin->skindir);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
807 /* dumpwidgets(skin); */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
808 return skin;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
809 }