Mercurial > mplayer.hg
annotate Gui/skin/skin.c @ 6139:3898967fcc96
some more output cosmetics, especially for vivo and mov demuxers
author | arpi |
---|---|
date | Mon, 20 May 2002 03:51:58 +0000 |
parents | 436cf6ef67fd |
children | 8cfddba867b4 |
rev | line source |
---|---|
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
1 |
1693 | 2 #include <stdio.h> |
3 #include <stdlib.h> | |
4 #include <string.h> | |
5 | |
6 #include "cut.h" | |
7 #include "font.h" | |
8 #include "../app.h" | |
3586 | 9 |
1693 | 10 #include "../../config.h" |
3586 | 11 #include "../../mp_msg.h" |
1884 | 12 #include "../../help_mp.h" |
1693 | 13 |
14 listItems * skinAppMPlayer = &appMPlayer; | |
15 | |
16 int linenumber; | |
17 | |
18 unsigned char path[512],fn[512]; | |
19 | |
20 listItems * defList = NULL; | |
21 unsigned char winList[32] = ""; | |
22 | |
23 #include <stdarg.h> | |
24 | |
25 void ERRORMESSAGE( const char * format, ... ) | |
26 { | |
27 char p[512]; | |
28 va_list ap; | |
29 va_start( ap,format ); | |
30 vsnprintf( p,512,format,ap ); | |
31 va_end( ap ); | |
1884 | 32 // message( False,"[skin] error in skin config file on line %d: %s",linenumber,p ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
33 // message( False,MSGTR_SKIN_ERRORMESSAGE,linenumber,p ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
34 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_ERRORMESSAGE,linenumber,p ); |
1693 | 35 } |
36 | |
1884 | 37 #define CHECKDEFLIST( str ) \ |
38 { \ | |
39 if ( defList == NULL ) \ | |
40 { \ | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
41 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING1,linenumber,str ); \ |
1884 | 42 return 1; \ |
43 } \ | |
44 } | |
45 | |
46 #define CHECKWINLIST( str ) \ | |
47 { \ | |
48 if ( !strlen( winList ) ) \ | |
49 { \ | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
50 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING2,linenumber,str ); \ |
1884 | 51 return 1; \ |
52 } \ | |
53 } | |
1693 | 54 |
55 char * strlower( char * in ) | |
56 { | |
57 int i; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
58 for( i=0;i<(int)strlen( in );i++ ) in[i]=( in[i] >= 'A' ? ( in[i] <= 'Z' ? in[i]+='A' : in[i] ) : in[i] ); |
1693 | 59 return in; |
60 } | |
61 | |
62 int skinBPRead( char * fname, txSample * bf ) | |
63 { | |
64 int i=bpRead( fname,bf ); | |
65 switch ( i ) | |
66 { | |
1884 | 67 case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit,fname ); break; |
68 case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound,fname ); break; | |
69 case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError,fname ); break; | |
70 case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError,fname ); break; | |
71 case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError,fname ); break; | |
72 case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported,fname ); break; | |
73 case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType,fname ); break; | |
74 case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConvertError,fname ); break; | |
1693 | 75 } |
76 return i; | |
77 } | |
78 | |
79 int __section( char * in ) | |
80 { | |
81 strlower( in ); | |
82 defList=NULL; | |
83 if ( !strcmp( in,"movieplayer" ) ) defList=skinAppMPlayer; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
84 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] sectionname: %s\n",in ); |
1693 | 85 return 0; |
86 } | |
87 | |
88 int __end( char * in ) | |
89 { | |
90 if ( strlen( winList ) ) winList[0]=0; | |
91 else defList=NULL; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
92 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] end section\n" ); |
1693 | 93 return 0; |
94 } | |
95 | |
96 int __window( char * in ) | |
97 { | |
98 CHECKDEFLIST( "window" ); | |
99 | |
100 strlower( in ); | |
101 strcpy( winList,in ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
102 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window: %s\n",winList ); |
1693 | 103 return 0; |
104 } | |
105 | |
106 int __base( char * in ) | |
107 { | |
108 unsigned char fname[512]; | |
109 unsigned char tmp[512]; | |
110 int x,y; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
111 int sx=0,sy=0; |
1693 | 112 |
113 CHECKDEFLIST( "base" ); | |
114 CHECKWINLIST( "base" ); | |
115 | |
116 cutItem( in,fname,',',0 ); | |
1852 | 117 x=cutItemToInt( in,',',1 ); |
118 y=cutItemToInt( in,',',2 ); | |
3080 | 119 sx=cutItemToInt( in,',',3 ); |
120 sy=cutItemToInt( in,',',4 ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
121 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] base: %s x: %d y: %d ( %dx%d )\n",fname,x,y,sx,sy ); |
1693 | 122 if ( !strcmp( winList,"main" ) ) |
123 { | |
124 defList->main.x=x; | |
125 defList->main.y=y; | |
126 defList->main.type=itBase; | |
127 strcpy( tmp,path ); strcat( tmp,fname ); | |
128 if ( skinBPRead( tmp,&defList->main.Bitmap ) ) return 1; | |
129 defList->main.width=defList->main.Bitmap.Width; | |
130 defList->main.height=defList->main.Bitmap.Height; | |
131 #ifdef HAVE_XSHAPE | |
2717 | 132 Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
133 #if 0 |
2717 | 134 { |
135 if ( defList->main.Mask.Image != NULL ) | |
136 { | |
137 txSample d; | |
138 Convert1to32( &defList->main.Mask,&d ); | |
139 tgaWriteTexture( "debug.tga",&d ); | |
140 } | |
1693 | 141 } |
2781 | 142 #endif |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
143 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->main.Mask.Width,defList->main.Mask.Height ); |
1693 | 144 #else |
145 defList->main.Mask.Image=NULL; | |
146 #endif | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
147 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->main.width,defList->main.height ); |
1693 | 148 } |
149 if ( !strcmp( winList,"sub" ) ) | |
150 { | |
151 defList->sub.type=itBase; | |
152 strcpy( tmp,path ); strcat( tmp,fname ); | |
153 if ( skinBPRead( tmp,&defList->sub.Bitmap ) ) return 1; | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1884
diff
changeset
|
154 defList->sub.x=x; |
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1884
diff
changeset
|
155 defList->sub.y=y; |
1693 | 156 defList->sub.width=defList->sub.Bitmap.Width; |
157 defList->sub.height=defList->sub.Bitmap.Height; | |
3080 | 158 if ( sx && sy ) |
159 { | |
160 defList->sub.width=sx; | |
161 defList->sub.height=sy; | |
162 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
163 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] %d,%d %dx%d\n",defList->sub.x,defList->sub.y,defList->sub.width,defList->sub.height ); |
1693 | 164 } |
165 /* | |
166 if ( !strcmp( winList,"eq" ) ) | |
167 { | |
168 defList->eq.x=x; | |
169 defList->eq.y=y; | |
170 defList->eq.type=itBase; | |
171 strcpy( tmp,path ); strcat( tmp,fname ); | |
172 if ( skinBPRead( tmp,&defList->eq.Bitmap ) ) return 1; | |
173 defList->eq.width=defList->eq.Bitmap.Width; | |
174 defList->eq.height=defList->eq.Bitmap.Height; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
175 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->eq.width,defList->eq.height ); |
1693 | 176 } |
177 */ | |
178 if ( !strcmp( winList,"menu" ) ) | |
179 { | |
180 defList->menuBase.type=itBase; | |
181 strcpy( tmp,path ); strcat( tmp,fname ); | |
182 if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) ) return 1; | |
183 defList->menuBase.width=defList->menuBase.Bitmap.Width; | |
184 defList->menuBase.height=defList->menuBase.Bitmap.Height; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
185 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuBase.width,defList->menuBase.height ); |
1693 | 186 } |
187 return 0; | |
188 } | |
189 | |
190 int __background( char * in ) | |
191 { | |
192 CHECKDEFLIST( "background" ); | |
193 CHECKWINLIST( "background" ); | |
194 | |
195 if ( !strcmp( winList,"sub" ) ) | |
196 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
197 defList->subR=cutItemToInt( in,',',0 ); |
1852 | 198 defList->subG=cutItemToInt( in,',',1 ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
199 defList->subB=cutItemToInt( in,',',2 ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
200 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] subwindow background color is #%x%x%x.\n",defList->subR,defList->subG,defList->subB ); |
1693 | 201 } |
202 return 0; | |
203 } | |
204 | |
205 int __button( char * in ) | |
206 { | |
207 unsigned char fname[512]; | |
208 unsigned char tmp[512]; | |
209 int x,y,sx,sy; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
210 char msg[32]; |
1693 | 211 |
212 CHECKDEFLIST( "button" ); | |
213 CHECKWINLIST( "button" ); | |
214 | |
215 cutItem( in,fname,',',0 ); | |
1852 | 216 x=cutItemToInt( in,',',1 ); |
217 y=cutItemToInt( in,',',2 ); | |
218 sx=cutItemToInt( in,',',3 ); | |
219 sy=cutItemToInt( in,',',4 ); | |
1693 | 220 cutItem( in,msg,',',5 ); |
221 | |
222 defList->NumberOfItems++; | |
223 defList->Items[ defList->NumberOfItems ].type=itButton; | |
224 defList->Items[ defList->NumberOfItems ].x=x; | |
225 defList->Items[ defList->NumberOfItems ].y=y; | |
226 defList->Items[ defList->NumberOfItems ].width=sx; | |
227 defList->Items[ defList->NumberOfItems ].height=sy; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
228 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] button: fname: %s\n",fname ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
229 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); |
1693 | 230 |
231 if ( ( defList->Items[ defList->NumberOfItems ].msg=appFindMessage( msg ) ) == -1 ) | |
1884 | 232 { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,msg ); return 1; } |
1693 | 233 defList->Items[ defList->NumberOfItems ].pressed=btnReleased; |
234 if ( defList->Items[ defList->NumberOfItems ].msg == evPauseSwitchToPlay ) defList->Items[ defList->NumberOfItems ].pressed=btnDisabled; | |
235 defList->Items[ defList->NumberOfItems ].tmp=1; | |
236 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
237 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg ); |
1693 | 238 |
239 defList->Items[ defList->NumberOfItems ].Bitmap.Image=NULL; | |
240 if ( strcmp( fname,"NULL" ) ) | |
241 { | |
242 strcpy( tmp,path ); strcat( tmp,fname ); | |
243 if ( skinBPRead( tmp,&defList->Items[ defList->NumberOfItems ].Bitmap ) ) return 1; | |
244 } | |
245 return 0; | |
246 } | |
247 | |
248 int __selected( char * in ) | |
249 { | |
250 unsigned char fname[512]; | |
251 unsigned char tmp[512]; | |
252 | |
253 CHECKDEFLIST( "selected" ); | |
254 CHECKWINLIST( "selected" ); | |
255 | |
256 cutItem( in,fname,',',0 ); | |
257 defList->menuSelected.type=itBase; | |
258 strcpy( tmp,path ); strcat( tmp,fname ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
259 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname ); |
1693 | 260 if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1; |
261 defList->menuSelected.width=defList->menuSelected.Bitmap.Width; | |
262 defList->menuSelected.height=defList->menuSelected.Bitmap.Height; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
263 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height ); |
1693 | 264 return 0; |
265 } | |
266 | |
267 int __menu( char * in ) | |
268 { // menu = number,x,y,sx,sy,msg | |
269 int x,y,sx,sy,msg; | |
270 unsigned char tmp[64]; | |
271 | |
272 CHECKDEFLIST( "menu" ); | |
273 CHECKWINLIST( "menu" ); | |
274 | |
1852 | 275 x=cutItemToInt( in,',',0 ); |
276 y=cutItemToInt( in,',',1 ); | |
277 sx=cutItemToInt( in,',',2 ); | |
278 sy=cutItemToInt( in,',',3 ); | |
1693 | 279 cutItem( in,tmp,',',4 ); msg=appFindMessage( tmp ); |
280 | |
281 defList->NumberOfMenuItems++; | |
282 defList->MenuItems[ defList->NumberOfMenuItems ].x=x; | |
283 defList->MenuItems[ defList->NumberOfMenuItems ].y=y; | |
284 defList->MenuItems[ defList->NumberOfMenuItems ].width=sx; | |
285 defList->MenuItems[ defList->NumberOfMenuItems ].height=sy; | |
286 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
287 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
288 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); |
1693 | 289 |
290 if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 ) | |
1884 | 291 ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,tmp ); |
1693 | 292 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
293 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg ); |
1693 | 294 |
295 defList->MenuItems[ defList->NumberOfMenuItems ].Bitmap.Image=NULL; | |
296 return 0; | |
297 } | |
298 | |
299 int __hpotmeter( char * in ) | |
300 { // hpotmeter=buttonbitmaps,sx,sy,phasebitmaps,phases,default value,x,y,sx,sy,msg | |
301 int x,y,psx,psy,ph,sx,sy,msg,d; | |
302 unsigned char tmp[512]; | |
303 unsigned char pfname[512]; | |
304 unsigned char phfname[512]; | |
305 wItem * item; | |
306 | |
307 CHECKDEFLIST( "hpotmeter" ); | |
308 CHECKWINLIST( "hpotmeter" ); | |
309 | |
310 cutItem( in,pfname,',',0 ); | |
1852 | 311 psx=cutItemToInt( in,',',1 ); |
312 psy=cutItemToInt( in,',',2 ); | |
1693 | 313 cutItem( in,phfname,',',3 ); |
1852 | 314 ph=cutItemToInt( in,',',4 ); |
315 d=cutItemToInt( in,',',5 ); | |
316 x=cutItemToInt( in,',',6 ); | |
317 y=cutItemToInt( in,',',7 ); | |
318 sx=cutItemToInt( in,',',8 ); | |
319 sy=cutItemToInt( in,',',9 ); | |
1693 | 320 cutItem( in,tmp,',',10 ); msg=appFindMessage( tmp ); |
321 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
322 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] hpotmeter: pointer filename: '%s'\n",pfname ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
323 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pointer size is %dx%d\n",psx,psy ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
324 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phasebitmaps filename: '%s'\n",phfname ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
325 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
326 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
327 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg ); |
1693 | 328 |
329 defList->NumberOfItems++; | |
330 item=&defList->Items[ defList->NumberOfItems ]; | |
331 item->type=itHPotmeter; | |
332 item->x=x; item->y=y; item->width=sx; item->height=sy; | |
333 item->phases=ph; | |
334 item->psx=psx; item->psy=psy; | |
335 item->msg=msg; | |
336 item->value=(float)d; | |
337 item->pressed=btnReleased; | |
338 | |
339 item->Bitmap.Image=NULL; | |
340 if ( strcmp( phfname,"NULL" ) ) | |
341 { | |
342 strcpy( tmp,path ); strcat( tmp,phfname ); | |
343 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; | |
344 } | |
345 | |
346 item->Mask.Image=NULL; | |
347 if ( strcmp( pfname,"NULL" ) ) | |
348 { | |
349 strcpy( tmp,path ); strcat( tmp,pfname ); | |
350 if ( skinBPRead( tmp,&item->Mask ) ) return 1; | |
351 } | |
352 | |
353 return 0; | |
354 } | |
355 | |
356 int __potmeter( char * in ) | |
357 { // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg | |
358 int x,y,ph,sx,sy,msg,d; | |
359 unsigned char tmp[512]; | |
360 unsigned char phfname[512]; | |
361 wItem * item; | |
362 | |
363 CHECKDEFLIST( "potmeter" ); | |
364 CHECKWINLIST( "potmeter" ); | |
365 | |
366 cutItem( in,phfname,',',0 ); | |
1852 | 367 ph=cutItemToInt( in,',',1 ); |
368 d=cutItemToInt( in,',',2 ); | |
369 x=cutItemToInt( in,',',3 ); | |
370 y=cutItemToInt( in,',',4 ); | |
371 sx=cutItemToInt( in,',',5 ); | |
372 sy=cutItemToInt( in,',',6 ); | |
1693 | 373 cutItem( in,tmp,',',7 ); msg=appFindMessage( tmp ); |
374 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
375 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] potmeter: phases filename: '%s'\n",phfname ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
376 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
377 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phases: %d\n",ph ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
378 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
379 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg ); |
1693 | 380 |
381 defList->NumberOfItems++; | |
382 item=&defList->Items[ defList->NumberOfItems ]; | |
383 item->type=itPotmeter; | |
384 item->x=x; item->y=y; | |
385 item->width=sx; item->height=sy; | |
386 item->phases=ph; | |
387 item->msg=msg; | |
388 item->value=(float)d; | |
389 | |
390 item->Bitmap.Image=NULL; | |
391 if ( strcmp( phfname,"NULL" ) ) | |
392 { | |
393 strcpy( tmp,path ); strcat( tmp,phfname ); | |
394 if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; | |
395 } | |
396 return 0; | |
397 } | |
398 | |
399 int __font( char * in ) | |
400 { // font=fontname,fontid | |
401 char name[512]; | |
402 char id[512]; | |
403 wItem * item; | |
404 | |
405 CHECKDEFLIST( "font" ); | |
406 CHECKWINLIST( "font" ); | |
407 | |
408 cutItem( in,name,',',0 ); | |
409 cutItem( in,id,',',1 ); | |
410 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
411 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] font\n" ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
412 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] name: %s\n",name ); |
1693 | 413 |
414 defList->NumberOfItems++; | |
415 item=&defList->Items[ defList->NumberOfItems ]; | |
416 item->type=itFont; | |
417 item->fontid=fntAddNewFont( name ); | |
418 switch ( item->fontid ) | |
419 { | |
1884 | 420 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; |
421 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1; | |
1693 | 422 } |
423 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
424 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",id,item->fontid ); |
1693 | 425 |
426 switch ( fntRead( path,name,item->fontid ) ) | |
427 { | |
1884 | 428 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1; |
429 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1; | |
1693 | 430 } |
431 | |
432 return 0; | |
433 } | |
434 | |
435 int __slabel( char * in ) | |
436 { | |
437 char tmp[512]; | |
438 char sid[63]; | |
439 int x,y,id; | |
440 wItem * item; | |
441 | |
442 CHECKDEFLIST( "slabel" ); | |
443 CHECKWINLIST( "slabel" ); | |
444 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
445 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] slabel\n" ); |
1693 | 446 |
1852 | 447 x=cutItemToInt( in,',',0 ); |
448 y=cutItemToInt( in,',',1 ); | |
1693 | 449 cutItem( in,sid,',',2 ); id=fntFindID( sid ); |
1884 | 450 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } |
1693 | 451 cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 ); |
452 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
453 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d\n",x,y ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
454 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
455 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp ); |
1693 | 456 |
457 defList->NumberOfItems++; | |
458 item=&defList->Items[ defList->NumberOfItems ]; | |
459 item->type=itSLabel; | |
460 item->fontid=id; | |
461 item->x=x; item->y=y; | |
462 item->width=-1; item->height=-1; | |
1884 | 463 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } |
1693 | 464 strcpy( item->label,tmp ); |
465 | |
466 return 0; | |
467 } | |
468 | |
469 int __dlabel( char * in ) | |
470 { // dlabel=x,y,sx,align,fontid,string ... | |
471 char tmp[512]; | |
472 char sid[63]; | |
473 int x,y,sx,id,a; | |
474 wItem * item; | |
475 | |
476 CHECKDEFLIST( "dlabel" ); | |
477 CHECKWINLIST( "dlabel" ); | |
478 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
479 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] dlabel\n" ); |
1693 | 480 |
1852 | 481 x=cutItemToInt( in,',',0 ); |
482 y=cutItemToInt( in,',',1 ); | |
483 sx=cutItemToInt( in,',',2 ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
484 a=cutItemToInt( in,',',3 ); |
1693 | 485 cutItem( in,sid,',',4 ); id=fntFindID( sid ); |
1884 | 486 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } |
1693 | 487 cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 ); |
488 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
489 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
490 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
491 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp ); |
1693 | 492 |
493 defList->NumberOfItems++; | |
494 item=&defList->Items[ defList->NumberOfItems ]; | |
495 item->type=itDLabel; | |
496 item->fontid=id; item->align=a; | |
497 item->x=x; item->y=y; | |
498 item->width=sx; item->height=-1; | |
1884 | 499 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } |
1693 | 500 strcpy( item->label,tmp ); |
501 | |
502 return 0; | |
503 } | |
504 | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
505 int __decoration( char * in ) |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
506 { |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
507 char tmp[512]; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
508 |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
509 CHECKDEFLIST( "decoration" ); |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
510 CHECKWINLIST( "decoration" ); |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
511 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
512 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",in ); |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
513 cutItem( in,tmp,',',0 ); |
1884 | 514 if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; } |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
515 if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
516 else defList->mainDecoration=1; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
517 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
518 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") ); |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
519 return 0; |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
520 } |
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
521 |
1693 | 522 typedef struct |
523 { | |
524 char * name; | |
525 int (*func)( char * in ); | |
526 } _item; | |
527 | |
528 _item skinItem[] = | |
529 { | |
530 { "section", __section }, | |
531 { "end", __end }, | |
532 { "window", __window }, | |
533 { "base", __base }, | |
534 { "button", __button }, | |
535 { "selected", __selected }, | |
536 { "background", __background }, | |
537 { "hpotmeter", __hpotmeter }, | |
538 { "potmeter", __potmeter }, | |
539 { "font", __font }, | |
540 { "slabel", __slabel }, | |
541 { "dlabel", __dlabel }, | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1852
diff
changeset
|
542 { "decoration", __decoration }, |
1693 | 543 { "menu", __menu } |
544 }; | |
545 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
546 #define ITEMS (int)( sizeof( skinItem )/sizeof( _item ) ) |
1693 | 547 |
548 char * strdelspacesbeforecommand( char * in ) | |
549 { | |
550 int c = 0; | |
551 char * out; | |
552 if ( strlen( in ) == 0 ) return NULL; | |
553 while ( in[c] == ' ' ) c++; | |
554 if ( c != 0 ) | |
555 { | |
556 out=malloc( strlen( in ) - c + 1 ); | |
557 memcpy( out,&in[c],strlen( in ) - c + 1 ); | |
558 } | |
559 else out=in; | |
560 return out; | |
561 } | |
562 | |
563 char * strswap( char * in,char what,char whereof ) | |
564 { | |
565 int i; | |
566 if ( strlen( in ) == 0 ) return NULL; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
567 for ( i=0;i<(int)strlen( in );i++ ) |
1693 | 568 if ( in[i] == what ) in[i]=whereof; |
569 return in; | |
570 } | |
571 | |
572 char * strdelspaces( char * in ) | |
573 { | |
574 int c = 0,i = 0,id = 0; | |
575 if ( strlen( in ) == 0 ) return NULL; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
576 while ( c != (int)strlen( in ) ) |
1693 | 577 { |
578 if ( in[c] == '"' ) id=!id; | |
579 if ( ( in[c] == ' ' )&&( !id ) ) | |
580 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
581 for ( i=0;i<(int)strlen( in ) - c; i++ ) in[c+i]=in[c+i+1]; |
1693 | 582 continue; |
583 } | |
584 c++; | |
585 } | |
586 return in; | |
587 } | |
588 | |
589 FILE * skinFile; | |
590 | |
591 void setname( char * item1, char * item2 ) | |
592 { strcpy( fn,item1 ); strcat( fn,"/" ); strcat( fn,item2 ); strcpy( path,fn ); strcat( path,"/" ); strcat( fn,"/skin" ); } | |
593 | |
594 int skinRead( char * dname ) | |
595 { | |
596 unsigned char tmp[255]; | |
597 unsigned char * ptmp; | |
598 unsigned char command[32]; | |
599 unsigned char param[256]; | |
600 int c,i; | |
601 | |
602 setname( skinMPlayerDir,dname ); | |
603 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) | |
604 { | |
605 setname( skinDirInHome,dname ); | |
606 if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) | |
607 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
608 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[skin] file ( %s ) not found.\n",fn ); |
1693 | 609 return -1; |
610 } | |
611 } | |
612 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
613 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] file: %s\n",fn ); |
1693 | 614 |
5690 | 615 appInitStruct( skinAppMPlayer ); |
1693 | 616 |
617 linenumber=0; | |
618 while ( !feof( skinFile ) ) | |
619 { | |
620 fgets( tmp,255,skinFile ); linenumber++; | |
621 | |
622 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
623 c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
3586
diff
changeset
|
624 for ( c=0;c<(int)strlen( tmp );c++ ) |
1693 | 625 if ( tmp[c] == ';' ) |
626 { | |
627 tmp[c]=0; | |
628 break; | |
629 } | |
630 if ( strlen( tmp ) == 0 ) continue; | |
631 ptmp=strdelspacesbeforecommand( tmp ); | |
632 if ( strlen( ptmp ) == 0 ) continue; | |
633 ptmp=strswap( ptmp,'\t',' ' ); | |
634 ptmp=strdelspaces( ptmp ); | |
635 | |
636 cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 ); | |
637 strlower( command ); | |
638 for( i=0;i<ITEMS;i++ ) | |
639 if ( !strcmp( command,skinItem[i].name ) ) | |
640 if ( skinItem[i].func( param ) ) return -2; | |
641 } | |
642 return 0; | |
643 } | |
644 | |
645 void btnModify( int event,float state ) | |
646 { | |
647 int j; | |
648 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ ) | |
649 if ( appMPlayer.Items[j].msg == event ) | |
650 { | |
651 switch ( appMPlayer.Items[j].type ) | |
652 { | |
653 case itButton: | |
654 appMPlayer.Items[j].pressed=(int)state; | |
3479 | 655 appMPlayer.Items[j].tmp=(int)state; |
1693 | 656 break; |
657 case itPotmeter: | |
658 case itHPotmeter: | |
659 if ( state < 0.0f ) state=0.0f; | |
660 if ( state > 100.f ) state=100.0f; | |
661 appMPlayer.Items[j].value=state; | |
662 break; | |
663 } | |
664 } | |
665 } | |
666 | |
1729 | 667 float btnGetValue( int event ) |
1693 | 668 { |
669 int j; | |
670 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ ) | |
671 if ( appMPlayer.Items[j].msg == event ) return appMPlayer.Items[j].value; | |
672 return 0; | |
673 } |