📄 skin.c
字号:
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 ); (*currSubItem)++; item=&currSubItems[ *currSubItem ]; 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" ) ) { av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, phfname, sizeof( tmp )); if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; } item->Mask.Image=NULL; if ( strcmp( pfname,"NULL" ) ) { av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, pfname, sizeof( tmp )); if ( skinBPRead( tmp,&item->Mask ) ) return 1; } return 0;}int cmd_vpotmeter( char * in ){ int r = cmd_hpotmeter( in ); wItem * item; item=&currSubItems[ *currSubItem ]; item->type=itVPotmeter; return r;}int cmd_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" ); CHECK( "sub" ); CHECK( "menu" ); cutItem( in,phfname,',',0 ); ph=cutItemToInt( in,',',1 ); d=cutItemToInt( in,',',2 ); x=cutItemToInt( in,',',3 ); y=cutItemToInt( in,',',4 ); sx=cutItemToInt( in,',',5 ); sy=cutItemToInt( in,',',6 ); cutItem( in,tmp,',',7 ); msg=appFindMessage( tmp ); 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 ); (*currSubItem)++; item=&currSubItems[ *currSubItem ]; 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" ) ) { av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, phfname, sizeof( tmp )); if ( skinBPRead( tmp,&item->Bitmap ) ) return 1; } return 0;}int cmd_font( char * in ){ // font=fontname,fontid char name[512]; char id[512]; wItem * item; CHECKDEFLIST( "font" ); CHECKWINLIST( "font" ); CHECK( "sub" ); CHECK( "menu" ); cutItem( in,name,',',0 ); cutItem( in,id,',',1 ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] font\n" ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] name: %s\n",name ); (*currSubItem)++; item=&currSubItems[ *currSubItem ]; item->type=itFont; item->fontid=fntRead( path,name ); switch ( item->fontid ) { case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1; case -3: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1; case -4: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1; } return 0;}int cmd_slabel( char * in ){ char tmp[512]; char sid[63]; int x,y,id; wItem * item; CHECKDEFLIST( "slabel" ); CHECKWINLIST( "slabel" ); CHECK( "sub" ); CHECK( "menu" ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] slabel\n" ); x=cutItemToInt( in,',',0 ); y=cutItemToInt( in,',',1 ); cutItem( in,sid,',',2 ); id=fntFindID( sid ); if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 ); 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 ); (*currSubItem)++; item=&currSubItems[ *currSubItem ]; item->type=itSLabel; item->fontid=id; item->x=x; item->y=y; item->width=-1; item->height=-1; if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } strcpy( item->label,tmp ); return 0;}int cmd_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" ); CHECK( "sub" ); CHECK( "menu" ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] dlabel\n" ); x=cutItemToInt( in,',',0 ); y=cutItemToInt( in,',',1 ); sx=cutItemToInt( in,',',2 ); a=cutItemToInt( in,',',3 ); cutItem( in,sid,',',4 ); id=fntFindID( sid ); if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 ); 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 ); (*currSubItem)++; item=&currSubItems[ *currSubItem ]; item->type=itDLabel; item->fontid=id; item->align=a; item->x=x; item->y=y; item->width=sx; item->height=-1; if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } strcpy( item->label,tmp ); return 0;}int cmd_decoration( char * in ){ char tmp[512]; CHECKDEFLIST( "decoration" ); CHECKWINLIST( "decoration" ); CHECK( "sub" ); CHECK( "menu" ); CHECK( "playbar" ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",in ); strlower( in ); cutItem( in,tmp,',',0 ); if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; } if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0; else defList->mainDecoration=1; mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") ); return 0;}typedef struct{ const char * name; int (*func)( char * in );} _item;_item skinItem[] = { { "section", cmd_section }, { "end", cmd_end }, { "window", cmd_window }, { "base", cmd_base }, { "button", cmd_button }, { "selected", cmd_selected }, { "background", cmd_background }, { "vpotmeter", cmd_vpotmeter }, { "hpotmeter", cmd_hpotmeter }, { "potmeter", cmd_potmeter }, { "font", cmd_font }, { "slabel", cmd_slabel }, { "dlabel", cmd_dlabel }, { "decoration", cmd_decoration }, { "menu", cmd_menu } };#define ITEMS (int)( sizeof( skinItem )/sizeof( _item ) )char * trimleft( 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; for ( i=0;i<(int)strlen( in );i++ ) if ( in[i] == what ) in[i]=whereof; return in;}char * trim( char * in ){ int c = 0,i = 0,id = 0; if ( strlen( in ) == 0 ) return NULL; while ( c != (int)strlen( in ) ) { if ( in[c] == '"' ) id=!id; if ( ( in[c] == ' ' )&&( !id ) ) { for ( i=0;i<(int)strlen( in ) - c; i++ ) in[c+i]=in[c+i+1]; continue; } c++; } return in;}FILE * skinFile;void setname( char * item1, char * item2 ){ av_strlcpy(fn, item1, sizeof( fn )); av_strlcat(fn, "/", sizeof( fn )); av_strlcat(fn, item2, sizeof( fn )); av_strlcpy(path, fn, sizeof( path )); av_strlcat(path, "/", sizeof( path )); av_strlcat(fn, "/skin", sizeof( fn ));}int skinRead( char * dname ){ unsigned char tmp[255]; unsigned char * ptmp; unsigned char command[32]; unsigned char param[256]; int c,i; setname( skinDirInHome,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinMPlayerDir,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinDirInHome_obsolete,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinMPlayerDir_obsolete,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinMPlayerDir,dname ); mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_SkinFileNotFound,fn ); return -1; } } } } mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] file: %s\n",fn ); appInitStruct( skinAppMPlayer ); linenumber=0; while (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; for ( c=0;c<(int)strlen( tmp );c++ ) if ( tmp[c] == ';' ) { tmp[c]=0; break; } if ( strlen( tmp ) == 0 ) continue; ptmp=trimleft( tmp ); if ( strlen( ptmp ) == 0 ) continue; ptmp=strswap( ptmp,'\t',' ' ); ptmp=trim( 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; } if (linenumber == 0) { mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SkinFileNotReadable, fn); return -1; } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -