2002-02-23 15:12:55 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "cut.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "../app.h"
|
2001-12-18 20:01:10 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
#include "../../config.h"
|
2001-12-18 20:01:10 +00:00
|
|
|
#include "../../mp_msg.h"
|
2001-09-12 15:08:53 +00:00
|
|
|
#include "../../help_mp.h"
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
listItems * skinAppMPlayer = &appMPlayer;
|
|
|
|
|
|
|
|
int linenumber;
|
|
|
|
|
|
|
|
unsigned char path[512],fn[512];
|
|
|
|
|
|
|
|
listItems * defList = NULL;
|
|
|
|
unsigned char winList[32] = "";
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
void ERRORMESSAGE( const char * format, ... )
|
|
|
|
{
|
|
|
|
char p[512];
|
|
|
|
va_list ap;
|
|
|
|
va_start( ap,format );
|
|
|
|
vsnprintf( p,512,format,ap );
|
|
|
|
va_end( ap );
|
2001-09-12 15:08:53 +00:00
|
|
|
// message( False,"[skin] error in skin config file on line %d: %s",linenumber,p );
|
2002-02-23 15:12:55 +00:00
|
|
|
// message( False,MSGTR_SKIN_ERRORMESSAGE,linenumber,p );
|
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_ERRORMESSAGE,linenumber,p );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
2001-09-12 15:08:53 +00:00
|
|
|
#define CHECKDEFLIST( str ) \
|
|
|
|
{ \
|
|
|
|
if ( defList == NULL ) \
|
|
|
|
{ \
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING1,linenumber,str ); \
|
2001-09-12 15:08:53 +00:00
|
|
|
return 1; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECKWINLIST( str ) \
|
|
|
|
{ \
|
|
|
|
if ( !strlen( winList ) ) \
|
|
|
|
{ \
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_WARNING2,linenumber,str ); \
|
2001-09-12 15:08:53 +00:00
|
|
|
return 1; \
|
|
|
|
} \
|
|
|
|
}
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
char * strlower( char * in )
|
|
|
|
{
|
|
|
|
int i;
|
2002-02-23 15:12:55 +00:00
|
|
|
for( i=0;i<(int)strlen( in );i++ ) in[i]=( in[i] >= 'A' ? ( in[i] <= 'Z' ? in[i]+='A' : in[i] ) : in[i] );
|
2001-08-25 21:04:29 +00:00
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
int skinBPRead( char * fname, txSample * bf )
|
|
|
|
{
|
|
|
|
int i=bpRead( fname,bf );
|
|
|
|
switch ( i )
|
|
|
|
{
|
2001-09-12 15:08:53 +00:00
|
|
|
case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit,fname ); break;
|
|
|
|
case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound,fname ); break;
|
|
|
|
case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError,fname ); break;
|
|
|
|
case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError,fname ); break;
|
|
|
|
case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError,fname ); break;
|
|
|
|
case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported,fname ); break;
|
|
|
|
case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType,fname ); break;
|
|
|
|
case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConvertError,fname ); break;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __section( char * in )
|
|
|
|
{
|
|
|
|
strlower( in );
|
|
|
|
defList=NULL;
|
|
|
|
if ( !strcmp( in,"movieplayer" ) ) defList=skinAppMPlayer;
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] sectionname: %s\n",in );
|
2001-08-25 21:04:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __end( char * in )
|
|
|
|
{
|
|
|
|
if ( strlen( winList ) ) winList[0]=0;
|
|
|
|
else defList=NULL;
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] end section\n" );
|
2001-08-25 21:04:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __window( char * in )
|
|
|
|
{
|
|
|
|
CHECKDEFLIST( "window" );
|
|
|
|
|
|
|
|
strlower( in );
|
|
|
|
strcpy( winList,in );
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window: %s\n",winList );
|
2001-08-25 21:04:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __base( char * in )
|
|
|
|
{
|
|
|
|
unsigned char fname[512];
|
|
|
|
unsigned char tmp[512];
|
|
|
|
int x,y;
|
2002-02-23 15:12:55 +00:00
|
|
|
int sx=0,sy=0;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
CHECKDEFLIST( "base" );
|
|
|
|
CHECKWINLIST( "base" );
|
|
|
|
|
|
|
|
cutItem( in,fname,',',0 );
|
2001-09-04 15:21:00 +00:00
|
|
|
x=cutItemToInt( in,',',1 );
|
|
|
|
y=cutItemToInt( in,',',2 );
|
2001-11-23 01:41:45 +00:00
|
|
|
sx=cutItemToInt( in,',',3 );
|
|
|
|
sy=cutItemToInt( in,',',4 );
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] base: %s x: %d y: %d ( %dx%d )\n",fname,x,y,sx,sy );
|
2001-08-25 21:04:29 +00:00
|
|
|
if ( !strcmp( winList,"main" ) )
|
|
|
|
{
|
|
|
|
defList->main.x=x;
|
|
|
|
defList->main.y=y;
|
|
|
|
defList->main.type=itBase;
|
|
|
|
strcpy( tmp,path ); strcat( tmp,fname );
|
|
|
|
if ( skinBPRead( tmp,&defList->main.Bitmap ) ) return 1;
|
|
|
|
defList->main.width=defList->main.Bitmap.Width;
|
|
|
|
defList->main.height=defList->main.Bitmap.Height;
|
|
|
|
#ifdef HAVE_XSHAPE
|
2001-11-05 17:00:42 +00:00
|
|
|
Convert32to1( &defList->main.Bitmap,&defList->main.Mask,0x00ff00ff );
|
2002-02-23 15:12:55 +00:00
|
|
|
#if 0
|
2001-11-05 17:00:42 +00:00
|
|
|
{
|
|
|
|
if ( defList->main.Mask.Image != NULL )
|
|
|
|
{
|
|
|
|
txSample d;
|
|
|
|
Convert1to32( &defList->main.Mask,&d );
|
|
|
|
tgaWriteTexture( "debug.tga",&d );
|
|
|
|
}
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
2001-11-09 12:58:43 +00:00
|
|
|
#endif
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] mask: %dx%d\n",defList->main.Mask.Width,defList->main.Mask.Height );
|
2001-08-25 21:04:29 +00:00
|
|
|
#else
|
|
|
|
defList->main.Mask.Image=NULL;
|
|
|
|
#endif
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->main.width,defList->main.height );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
if ( !strcmp( winList,"sub" ) )
|
|
|
|
{
|
|
|
|
defList->sub.type=itBase;
|
|
|
|
strcpy( tmp,path ); strcat( tmp,fname );
|
|
|
|
if ( skinBPRead( tmp,&defList->sub.Bitmap ) ) return 1;
|
2001-10-01 09:30:46 +00:00
|
|
|
defList->sub.x=x;
|
|
|
|
defList->sub.y=y;
|
2001-08-25 21:04:29 +00:00
|
|
|
defList->sub.width=defList->sub.Bitmap.Width;
|
|
|
|
defList->sub.height=defList->sub.Bitmap.Height;
|
2001-11-23 01:41:45 +00:00
|
|
|
if ( sx && sy )
|
|
|
|
{
|
|
|
|
defList->sub.width=sx;
|
|
|
|
defList->sub.height=sy;
|
|
|
|
}
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] %d,%d %dx%d\n",defList->sub.x,defList->sub.y,defList->sub.width,defList->sub.height );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
if ( !strcmp( winList,"eq" ) )
|
|
|
|
{
|
|
|
|
defList->eq.x=x;
|
|
|
|
defList->eq.y=y;
|
|
|
|
defList->eq.type=itBase;
|
|
|
|
strcpy( tmp,path ); strcat( tmp,fname );
|
|
|
|
if ( skinBPRead( tmp,&defList->eq.Bitmap ) ) return 1;
|
|
|
|
defList->eq.width=defList->eq.Bitmap.Width;
|
|
|
|
defList->eq.height=defList->eq.Bitmap.Height;
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->eq.width,defList->eq.height );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
if ( !strcmp( winList,"menu" ) )
|
|
|
|
{
|
|
|
|
defList->menuBase.type=itBase;
|
|
|
|
strcpy( tmp,path ); strcat( tmp,fname );
|
|
|
|
if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) ) return 1;
|
|
|
|
defList->menuBase.width=defList->menuBase.Bitmap.Width;
|
|
|
|
defList->menuBase.height=defList->menuBase.Bitmap.Height;
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuBase.width,defList->menuBase.height );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __background( char * in )
|
|
|
|
{
|
|
|
|
CHECKDEFLIST( "background" );
|
|
|
|
CHECKWINLIST( "background" );
|
|
|
|
|
|
|
|
if ( !strcmp( winList,"sub" ) )
|
|
|
|
{
|
2002-02-23 15:12:55 +00:00
|
|
|
defList->subR=cutItemToInt( in,',',0 );
|
2001-09-04 15:21:00 +00:00
|
|
|
defList->subG=cutItemToInt( in,',',1 );
|
2002-02-23 15:12:55 +00:00
|
|
|
defList->subB=cutItemToInt( in,',',2 );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] subwindow background color is #%x%x%x.\n",defList->subR,defList->subG,defList->subB );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __button( char * in )
|
|
|
|
{
|
|
|
|
unsigned char fname[512];
|
|
|
|
unsigned char tmp[512];
|
|
|
|
int x,y,sx,sy;
|
2002-02-23 15:12:55 +00:00
|
|
|
char msg[32];
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
CHECKDEFLIST( "button" );
|
|
|
|
CHECKWINLIST( "button" );
|
|
|
|
|
|
|
|
cutItem( in,fname,',',0 );
|
2001-09-04 15:21:00 +00:00
|
|
|
x=cutItemToInt( in,',',1 );
|
|
|
|
y=cutItemToInt( in,',',2 );
|
|
|
|
sx=cutItemToInt( in,',',3 );
|
|
|
|
sy=cutItemToInt( in,',',4 );
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,msg,',',5 );
|
|
|
|
|
|
|
|
defList->NumberOfItems++;
|
|
|
|
defList->Items[ defList->NumberOfItems ].type=itButton;
|
|
|
|
defList->Items[ defList->NumberOfItems ].x=x;
|
|
|
|
defList->Items[ defList->NumberOfItems ].y=y;
|
|
|
|
defList->Items[ defList->NumberOfItems ].width=sx;
|
|
|
|
defList->Items[ defList->NumberOfItems ].height=sy;
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] button: fname: %s\n",fname );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
if ( ( defList->Items[ defList->NumberOfItems ].msg=appFindMessage( msg ) ) == -1 )
|
2001-09-12 15:08:53 +00:00
|
|
|
{ ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,msg ); return 1; }
|
2001-08-25 21:04:29 +00:00
|
|
|
defList->Items[ defList->NumberOfItems ].pressed=btnReleased;
|
|
|
|
if ( defList->Items[ defList->NumberOfItems ].msg == evPauseSwitchToPlay ) defList->Items[ defList->NumberOfItems ].pressed=btnDisabled;
|
|
|
|
defList->Items[ defList->NumberOfItems ].tmp=1;
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
defList->Items[ defList->NumberOfItems ].Bitmap.Image=NULL;
|
|
|
|
if ( strcmp( fname,"NULL" ) )
|
|
|
|
{
|
|
|
|
strcpy( tmp,path ); strcat( tmp,fname );
|
|
|
|
if ( skinBPRead( tmp,&defList->Items[ defList->NumberOfItems ].Bitmap ) ) return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __selected( char * in )
|
|
|
|
{
|
|
|
|
unsigned char fname[512];
|
|
|
|
unsigned char tmp[512];
|
|
|
|
|
|
|
|
CHECKDEFLIST( "selected" );
|
|
|
|
CHECKWINLIST( "selected" );
|
|
|
|
|
|
|
|
cutItem( in,fname,',',0 );
|
|
|
|
defList->menuSelected.type=itBase;
|
|
|
|
strcpy( tmp,path ); strcat( tmp,fname );
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname );
|
2001-08-25 21:04:29 +00:00
|
|
|
if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1;
|
|
|
|
defList->menuSelected.width=defList->menuSelected.Bitmap.Width;
|
|
|
|
defList->menuSelected.height=defList->menuSelected.Bitmap.Height;
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height );
|
2001-08-25 21:04:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __menu( char * in )
|
|
|
|
{ // menu = number,x,y,sx,sy,msg
|
|
|
|
int x,y,sx,sy,msg;
|
|
|
|
unsigned char tmp[64];
|
|
|
|
|
|
|
|
CHECKDEFLIST( "menu" );
|
|
|
|
CHECKWINLIST( "menu" );
|
|
|
|
|
2001-09-04 15:21:00 +00:00
|
|
|
x=cutItemToInt( in,',',0 );
|
|
|
|
y=cutItemToInt( in,',',1 );
|
|
|
|
sx=cutItemToInt( in,',',2 );
|
|
|
|
sy=cutItemToInt( in,',',3 );
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,tmp,',',4 ); msg=appFindMessage( tmp );
|
|
|
|
|
|
|
|
defList->NumberOfMenuItems++;
|
|
|
|
defList->MenuItems[ defList->NumberOfMenuItems ].x=x;
|
|
|
|
defList->MenuItems[ defList->NumberOfMenuItems ].y=y;
|
|
|
|
defList->MenuItems[ defList->NumberOfMenuItems ].width=sx;
|
|
|
|
defList->MenuItems[ defList->NumberOfMenuItems ].height=sy;
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 )
|
2001-09-12 15:08:53 +00:00
|
|
|
ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,tmp );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
defList->MenuItems[ defList->NumberOfMenuItems ].Bitmap.Image=NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __hpotmeter( char * in )
|
|
|
|
{ // hpotmeter=buttonbitmaps,sx,sy,phasebitmaps,phases,default value,x,y,sx,sy,msg
|
|
|
|
int x,y,psx,psy,ph,sx,sy,msg,d;
|
|
|
|
unsigned char tmp[512];
|
|
|
|
unsigned char pfname[512];
|
|
|
|
unsigned char phfname[512];
|
|
|
|
wItem * item;
|
|
|
|
|
|
|
|
CHECKDEFLIST( "hpotmeter" );
|
|
|
|
CHECKWINLIST( "hpotmeter" );
|
|
|
|
|
|
|
|
cutItem( in,pfname,',',0 );
|
2001-09-04 15:21:00 +00:00
|
|
|
psx=cutItemToInt( in,',',1 );
|
|
|
|
psy=cutItemToInt( in,',',2 );
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,phfname,',',3 );
|
2001-09-04 15:21:00 +00:00
|
|
|
ph=cutItemToInt( in,',',4 );
|
|
|
|
d=cutItemToInt( in,',',5 );
|
|
|
|
x=cutItemToInt( in,',',6 );
|
|
|
|
y=cutItemToInt( in,',',7 );
|
|
|
|
sx=cutItemToInt( in,',',8 );
|
|
|
|
sy=cutItemToInt( in,',',9 );
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,tmp,',',10 ); msg=appFindMessage( tmp );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] hpotmeter: pointer filename: '%s'\n",pfname );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pointer size is %dx%d\n",psx,psy );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phasebitmaps filename: '%s'\n",phfname );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
defList->NumberOfItems++;
|
|
|
|
item=&defList->Items[ defList->NumberOfItems ];
|
|
|
|
item->type=itHPotmeter;
|
|
|
|
item->x=x; item->y=y; item->width=sx; item->height=sy;
|
|
|
|
item->phases=ph;
|
|
|
|
item->psx=psx; item->psy=psy;
|
|
|
|
item->msg=msg;
|
|
|
|
item->value=(float)d;
|
|
|
|
item->pressed=btnReleased;
|
|
|
|
|
|
|
|
item->Bitmap.Image=NULL;
|
|
|
|
if ( strcmp( phfname,"NULL" ) )
|
|
|
|
{
|
|
|
|
strcpy( tmp,path ); strcat( tmp,phfname );
|
|
|
|
if ( skinBPRead( tmp,&item->Bitmap ) ) return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->Mask.Image=NULL;
|
|
|
|
if ( strcmp( pfname,"NULL" ) )
|
|
|
|
{
|
|
|
|
strcpy( tmp,path ); strcat( tmp,pfname );
|
|
|
|
if ( skinBPRead( tmp,&item->Mask ) ) return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __potmeter( char * in )
|
|
|
|
{ // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg
|
|
|
|
int x,y,ph,sx,sy,msg,d;
|
|
|
|
unsigned char tmp[512];
|
|
|
|
unsigned char phfname[512];
|
|
|
|
wItem * item;
|
|
|
|
|
|
|
|
CHECKDEFLIST( "potmeter" );
|
|
|
|
CHECKWINLIST( "potmeter" );
|
|
|
|
|
|
|
|
cutItem( in,phfname,',',0 );
|
2001-09-04 15:21:00 +00:00
|
|
|
ph=cutItemToInt( in,',',1 );
|
|
|
|
d=cutItemToInt( in,',',2 );
|
|
|
|
x=cutItemToInt( in,',',3 );
|
|
|
|
y=cutItemToInt( in,',',4 );
|
|
|
|
sx=cutItemToInt( in,',',5 );
|
|
|
|
sy=cutItemToInt( in,',',6 );
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,tmp,',',7 ); msg=appFindMessage( tmp );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] potmeter: phases filename: '%s'\n",phfname );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] position: %d,%d %dx%d\n",x,y,sx,sy );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] phases: %d\n",ph );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] default value: %d\n",d );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] message: %d\n",msg );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
defList->NumberOfItems++;
|
|
|
|
item=&defList->Items[ defList->NumberOfItems ];
|
|
|
|
item->type=itPotmeter;
|
|
|
|
item->x=x; item->y=y;
|
|
|
|
item->width=sx; item->height=sy;
|
|
|
|
item->phases=ph;
|
|
|
|
item->msg=msg;
|
|
|
|
item->value=(float)d;
|
|
|
|
|
|
|
|
item->Bitmap.Image=NULL;
|
|
|
|
if ( strcmp( phfname,"NULL" ) )
|
|
|
|
{
|
|
|
|
strcpy( tmp,path ); strcat( tmp,phfname );
|
|
|
|
if ( skinBPRead( tmp,&item->Bitmap ) ) return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __font( char * in )
|
|
|
|
{ // font=fontname,fontid
|
|
|
|
char name[512];
|
|
|
|
char id[512];
|
|
|
|
wItem * item;
|
|
|
|
|
|
|
|
CHECKDEFLIST( "font" );
|
|
|
|
CHECKWINLIST( "font" );
|
|
|
|
|
|
|
|
cutItem( in,name,',',0 );
|
|
|
|
cutItem( in,id,',',1 );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] font\n" );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] name: %s\n",name );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
defList->NumberOfItems++;
|
|
|
|
item=&defList->Items[ defList->NumberOfItems ];
|
|
|
|
item->type=itFont;
|
|
|
|
item->fontid=fntAddNewFont( name );
|
|
|
|
switch ( item->fontid )
|
|
|
|
{
|
2001-09-12 15:08:53 +00:00
|
|
|
case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1;
|
|
|
|
case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",id,item->fontid );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
switch ( fntRead( path,name,item->fontid ) )
|
|
|
|
{
|
2001-09-12 15:08:53 +00:00
|
|
|
case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1;
|
|
|
|
case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __slabel( char * in )
|
|
|
|
{
|
|
|
|
char tmp[512];
|
|
|
|
char sid[63];
|
|
|
|
int x,y,id;
|
|
|
|
wItem * item;
|
|
|
|
|
|
|
|
CHECKDEFLIST( "slabel" );
|
|
|
|
CHECKWINLIST( "slabel" );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] slabel\n" );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2001-09-04 15:21:00 +00:00
|
|
|
x=cutItemToInt( in,',',0 );
|
|
|
|
y=cutItemToInt( in,',',1 );
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,sid,',',2 ); id=fntFindID( sid );
|
2001-09-12 15:08:53 +00:00
|
|
|
if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; }
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d\n",x,y );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
defList->NumberOfItems++;
|
|
|
|
item=&defList->Items[ defList->NumberOfItems ];
|
|
|
|
item->type=itSLabel;
|
|
|
|
item->fontid=id;
|
|
|
|
item->x=x; item->y=y;
|
|
|
|
item->width=-1; item->height=-1;
|
2001-09-12 15:08:53 +00:00
|
|
|
if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; }
|
2001-08-25 21:04:29 +00:00
|
|
|
strcpy( item->label,tmp );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __dlabel( char * in )
|
|
|
|
{ // dlabel=x,y,sx,align,fontid,string ...
|
|
|
|
char tmp[512];
|
|
|
|
char sid[63];
|
|
|
|
int x,y,sx,id,a;
|
|
|
|
wItem * item;
|
|
|
|
|
|
|
|
CHECKDEFLIST( "dlabel" );
|
|
|
|
CHECKWINLIST( "dlabel" );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] dlabel\n" );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2001-09-04 15:21:00 +00:00
|
|
|
x=cutItemToInt( in,',',0 );
|
|
|
|
y=cutItemToInt( in,',',1 );
|
|
|
|
sx=cutItemToInt( in,',',2 );
|
2002-02-23 15:12:55 +00:00
|
|
|
a=cutItemToInt( in,',',3 );
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,sid,',',4 ); id=fntFindID( sid );
|
2001-09-12 15:08:53 +00:00
|
|
|
if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; }
|
2001-08-25 21:04:29 +00:00
|
|
|
cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id );
|
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
defList->NumberOfItems++;
|
|
|
|
item=&defList->Items[ defList->NumberOfItems ];
|
|
|
|
item->type=itDLabel;
|
|
|
|
item->fontid=id; item->align=a;
|
|
|
|
item->x=x; item->y=y;
|
|
|
|
item->width=sx; item->height=-1;
|
2001-09-12 15:08:53 +00:00
|
|
|
if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; }
|
2001-08-25 21:04:29 +00:00
|
|
|
strcpy( item->label,tmp );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-09-07 21:04:14 +00:00
|
|
|
int __decoration( char * in )
|
|
|
|
{
|
|
|
|
char tmp[512];
|
|
|
|
|
|
|
|
CHECKDEFLIST( "decoration" );
|
|
|
|
CHECKWINLIST( "decoration" );
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",in );
|
2001-09-07 21:04:14 +00:00
|
|
|
cutItem( in,tmp,',',0 );
|
2001-09-12 15:08:53 +00:00
|
|
|
if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; }
|
2001-09-07 21:04:14 +00:00
|
|
|
if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0;
|
|
|
|
else defList->mainDecoration=1;
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") );
|
2001-09-07 21:04:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char * name;
|
|
|
|
int (*func)( char * in );
|
|
|
|
} _item;
|
|
|
|
|
|
|
|
_item skinItem[] =
|
|
|
|
{
|
|
|
|
{ "section", __section },
|
|
|
|
{ "end", __end },
|
|
|
|
{ "window", __window },
|
|
|
|
{ "base", __base },
|
|
|
|
{ "button", __button },
|
|
|
|
{ "selected", __selected },
|
|
|
|
{ "background", __background },
|
|
|
|
{ "hpotmeter", __hpotmeter },
|
|
|
|
{ "potmeter", __potmeter },
|
|
|
|
{ "font", __font },
|
|
|
|
{ "slabel", __slabel },
|
|
|
|
{ "dlabel", __dlabel },
|
2001-09-07 21:04:14 +00:00
|
|
|
{ "decoration", __decoration },
|
2001-08-25 21:04:29 +00:00
|
|
|
{ "menu", __menu }
|
|
|
|
};
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
#define ITEMS (int)( sizeof( skinItem )/sizeof( _item ) )
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
char * strdelspacesbeforecommand( char * in )
|
|
|
|
{
|
|
|
|
int c = 0;
|
|
|
|
char * out;
|
|
|
|
if ( strlen( in ) == 0 ) return NULL;
|
|
|
|
while ( in[c] == ' ' ) c++;
|
|
|
|
if ( c != 0 )
|
|
|
|
{
|
|
|
|
out=malloc( strlen( in ) - c + 1 );
|
|
|
|
memcpy( out,&in[c],strlen( in ) - c + 1 );
|
|
|
|
}
|
|
|
|
else out=in;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
char * strswap( char * in,char what,char whereof )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if ( strlen( in ) == 0 ) return NULL;
|
2002-02-23 15:12:55 +00:00
|
|
|
for ( i=0;i<(int)strlen( in );i++ )
|
2001-08-25 21:04:29 +00:00
|
|
|
if ( in[i] == what ) in[i]=whereof;
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
char * strdelspaces( char * in )
|
|
|
|
{
|
|
|
|
int c = 0,i = 0,id = 0;
|
|
|
|
if ( strlen( in ) == 0 ) return NULL;
|
2002-02-23 15:12:55 +00:00
|
|
|
while ( c != (int)strlen( in ) )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
|
|
|
if ( in[c] == '"' ) id=!id;
|
|
|
|
if ( ( in[c] == ' ' )&&( !id ) )
|
|
|
|
{
|
2002-02-23 15:12:55 +00:00
|
|
|
for ( i=0;i<(int)strlen( in ) - c; i++ ) in[c+i]=in[c+i+1];
|
2001-08-25 21:04:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE * skinFile;
|
|
|
|
|
|
|
|
void setname( char * item1, char * item2 )
|
|
|
|
{ strcpy( fn,item1 ); strcat( fn,"/" ); strcat( fn,item2 ); strcpy( path,fn ); strcat( path,"/" ); strcat( fn,"/skin" ); }
|
|
|
|
|
|
|
|
int skinRead( char * dname )
|
|
|
|
{
|
|
|
|
unsigned char tmp[255];
|
|
|
|
unsigned char * ptmp;
|
|
|
|
unsigned char command[32];
|
|
|
|
unsigned char param[256];
|
|
|
|
int c,i;
|
|
|
|
|
|
|
|
setname( skinMPlayerDir,dname );
|
|
|
|
if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )
|
|
|
|
{
|
|
|
|
setname( skinDirInHome,dname );
|
|
|
|
if ( ( skinFile = fopen( fn,"rt" ) ) == NULL )
|
|
|
|
{
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[skin] file ( %s ) not found.\n",fn );
|
2001-08-25 21:04:29 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] file: %s\n",fn );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
appInitStruct( &appMPlayer );
|
|
|
|
|
|
|
|
linenumber=0;
|
|
|
|
while ( !feof( skinFile ) )
|
|
|
|
{
|
|
|
|
fgets( tmp,255,skinFile ); linenumber++;
|
|
|
|
|
|
|
|
c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
|
|
|
|
c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
|
2002-02-23 15:12:55 +00:00
|
|
|
for ( c=0;c<(int)strlen( tmp );c++ )
|
2001-08-25 21:04:29 +00:00
|
|
|
if ( tmp[c] == ';' )
|
|
|
|
{
|
|
|
|
tmp[c]=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( strlen( tmp ) == 0 ) continue;
|
|
|
|
ptmp=strdelspacesbeforecommand( tmp );
|
|
|
|
if ( strlen( ptmp ) == 0 ) continue;
|
|
|
|
ptmp=strswap( ptmp,'\t',' ' );
|
|
|
|
ptmp=strdelspaces( ptmp );
|
|
|
|
|
|
|
|
cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );
|
|
|
|
strlower( command );
|
|
|
|
for( i=0;i<ITEMS;i++ )
|
|
|
|
if ( !strcmp( command,skinItem[i].name ) )
|
|
|
|
if ( skinItem[i].func( param ) ) return -2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void btnModify( int event,float state )
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ )
|
|
|
|
if ( appMPlayer.Items[j].msg == event )
|
|
|
|
{
|
2001-08-28 15:55:02 +00:00
|
|
|
if ( appMPlayer.Items[j].used ) continue;
|
2001-08-25 21:04:29 +00:00
|
|
|
switch ( appMPlayer.Items[j].type )
|
|
|
|
{
|
|
|
|
case itButton:
|
|
|
|
appMPlayer.Items[j].pressed=(int)state;
|
2001-12-13 00:25:08 +00:00
|
|
|
appMPlayer.Items[j].tmp=(int)state;
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
|
|
|
case itPotmeter:
|
|
|
|
case itHPotmeter:
|
|
|
|
if ( state < 0.0f ) state=0.0f;
|
|
|
|
if ( state > 100.f ) state=100.0f;
|
|
|
|
appMPlayer.Items[j].value=state;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-28 15:55:02 +00:00
|
|
|
float btnGetValue( int event )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ )
|
|
|
|
if ( appMPlayer.Items[j].msg == event ) return appMPlayer.Items[j].value;
|
|
|
|
return 0;
|
|
|
|
}
|