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