Mercurial > mplayer.hg
comparison Gui/skin/skin.c @ 1884:d21f8afc7680
add to multi lang support
author | pontscho |
---|---|
date | Wed, 12 Sep 2001 15:08:53 +0000 |
parents | 32b1bb50a0e8 |
children | 0653e90b3118 |
comparison
equal
deleted
inserted
replaced
1883:5170fea62800 | 1884:d21f8afc7680 |
---|---|
5 | 5 |
6 #include "cut.h" | 6 #include "cut.h" |
7 #include "error.h" | 7 #include "error.h" |
8 #include "font.h" | 8 #include "font.h" |
9 #include "../app.h" | 9 #include "../app.h" |
10 #include "../language.h" | |
11 #include "../../config.h" | 10 #include "../../config.h" |
11 #include "../../help_mp.h" | |
12 | 12 |
13 listItems * skinAppMPlayer = &appMPlayer; | 13 listItems * skinAppMPlayer = &appMPlayer; |
14 | 14 |
15 int linenumber; | 15 int linenumber; |
16 | 16 |
26 char p[512]; | 26 char p[512]; |
27 va_list ap; | 27 va_list ap; |
28 va_start( ap,format ); | 28 va_start( ap,format ); |
29 vsnprintf( p,512,format,ap ); | 29 vsnprintf( p,512,format,ap ); |
30 va_end( ap ); | 30 va_end( ap ); |
31 message( False,"[skin] error in skin config file on line %d: %s",linenumber,p ); | 31 // message( False,"[skin] error in skin config file on line %d: %s",linenumber,p ); |
32 } | 32 message( False,MSGTR_SKIN_ERRORMESSAGE,linenumber,p ); |
33 | 33 } |
34 #define CHECKDEFLIST( str ) { \ | 34 |
35 if ( defList == NULL ) \ | 35 #define CHECKDEFLIST( str ) \ |
36 { \ | 36 { \ |
37 message( False,"[skin] warning in skin config file on line %d: widget found but before \"section\" not found ("str")",linenumber ); \ | 37 if ( defList == NULL ) \ |
38 return 1; \ | 38 { \ |
39 } \ | 39 message( False,MSGTR_SKIN_WARNING1,linenumber,str ); \ |
40 } | 40 return 1; \ |
41 #define CHECKWINLIST( str ) { \ | 41 } \ |
42 if ( !strlen( winList ) ) \ | 42 } |
43 { \ | 43 |
44 message( False,"[skin] warning in skin config file on line %d: widget found but before \"subsection\" not found ("str")",linenumber ); \ | 44 #define CHECKWINLIST( str ) \ |
45 return 1; \ | 45 { \ |
46 } \ | 46 if ( !strlen( winList ) ) \ |
47 } | 47 { \ |
48 message( False,MSGTR_SKIN_WARNING2,linenumber,str ); \ | |
49 return 1; \ | |
50 } \ | |
51 } | |
48 | 52 |
49 char * strlower( char * in ) | 53 char * strlower( char * in ) |
50 { | 54 { |
51 int i; | 55 int i; |
52 for( i=0;i<strlen( in );i++ ) in[i]=( in[i] >= 'A' ? ( in[i] <= 'Z' ? in[i]+='A' : in[i] ) : in[i] ); | 56 for( i=0;i<strlen( in );i++ ) in[i]=( in[i] >= 'A' ? ( in[i] <= 'Z' ? in[i]+='A' : in[i] ) : in[i] ); |
56 int skinBPRead( char * fname, txSample * bf ) | 60 int skinBPRead( char * fname, txSample * bf ) |
57 { | 61 { |
58 int i=bpRead( fname,bf ); | 62 int i=bpRead( fname,bf ); |
59 switch ( i ) | 63 switch ( i ) |
60 { | 64 { |
61 case -1: ERRORMESSAGE( "16 bits or less depth bitmap not supported ( %s ).\n",fname ); break; | 65 case -1: ERRORMESSAGE( MSGTR_SKIN_BITMAP_16bit,fname ); break; |
62 case -2: ERRORMESSAGE( "file not found ( %s )\n",fname ); break; | 66 case -2: ERRORMESSAGE( MSGTR_SKIN_BITMAP_FileNotFound,fname ); break; |
63 case -3: ERRORMESSAGE( "bmp read error ( %s )\n",fname ); break; | 67 case -3: ERRORMESSAGE( MSGTR_SKIN_BITMAP_BMPReadError,fname ); break; |
64 case -4: ERRORMESSAGE( "tga read error ( %s )\n",fname ); break; | 68 case -4: ERRORMESSAGE( MSGTR_SKIN_BITMAP_TGAReadError,fname ); break; |
65 case -5: ERRORMESSAGE( "png read error ( %s )\n",fname ); break; | 69 case -5: ERRORMESSAGE( MSGTR_SKIN_BITMAP_PNGReadError,fname ); break; |
66 case -6: ERRORMESSAGE( "RLE packed tga not supported ( %s )\n",fname ); break; | 70 case -6: ERRORMESSAGE( MSGTR_SKIN_BITMAP_RLENotSupported,fname ); break; |
67 case -7: ERRORMESSAGE( "unknown file type ( %s )\n",fname ); break; | 71 case -7: ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownFileType,fname ); break; |
68 case -8: ERRORMESSAGE( "24 bit to 32 bit convert error ( %s )\n",fname ); break; | 72 case -8: ERRORMESSAGE( MSGTR_SKIN_BITMAP_ConvertError,fname ); break; |
69 } | 73 } |
70 return i; | 74 return i; |
71 } | 75 } |
72 | 76 |
73 int __section( char * in ) | 77 int __section( char * in ) |
131 defList->main.Mask.Width=defList->main.Bitmap.Width; | 135 defList->main.Mask.Width=defList->main.Bitmap.Width; |
132 defList->main.Mask.Height=defList->main.Bitmap.Height; | 136 defList->main.Mask.Height=defList->main.Bitmap.Height; |
133 defList->main.Mask.BPP=1; | 137 defList->main.Mask.BPP=1; |
134 defList->main.Mask.ImageSize=defList->main.Mask.Width * defList->main.Mask.Height / 8; | 138 defList->main.Mask.ImageSize=defList->main.Mask.Width * defList->main.Mask.Height / 8; |
135 defList->main.Mask.Image=(char *)calloc( 1,defList->main.Mask.ImageSize ); | 139 defList->main.Mask.Image=(char *)calloc( 1,defList->main.Mask.ImageSize ); |
136 if ( defList->main.Mask.Image == NULL ) message( True,langNEMFMM ); | 140 if ( defList->main.Mask.Image == NULL ) message( True,MSGTR_NEMFMM ); |
137 { | 141 { |
138 int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; | 142 int i,b,c=0; unsigned long * buf = NULL; unsigned char tmp = 0; int nothaveshape = 1; |
139 buf=(unsigned long *)defList->main.Bitmap.Image; | 143 buf=(unsigned long *)defList->main.Bitmap.Image; |
140 for ( b=0,i=0;i < defList->main.Mask.Width * defList->main.Mask.Height;i++ ) | 144 for ( b=0,i=0;i < defList->main.Mask.Width * defList->main.Mask.Height;i++ ) |
141 { | 145 { |
242 dbprintf( 3,"\n[skin] button: fname: %s\n",fname ); | 246 dbprintf( 3,"\n[skin] button: fname: %s\n",fname ); |
243 dbprintf( 3,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); | 247 dbprintf( 3,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); |
244 #endif | 248 #endif |
245 | 249 |
246 if ( ( defList->Items[ defList->NumberOfItems ].msg=appFindMessage( msg ) ) == -1 ) | 250 if ( ( defList->Items[ defList->NumberOfItems ].msg=appFindMessage( msg ) ) == -1 ) |
247 { ERRORMESSAGE( "unknown message: %s\n",msg ); return 1; } | 251 { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,msg ); return 1; } |
248 defList->Items[ defList->NumberOfItems ].pressed=btnReleased; | 252 defList->Items[ defList->NumberOfItems ].pressed=btnReleased; |
249 if ( defList->Items[ defList->NumberOfItems ].msg == evPauseSwitchToPlay ) defList->Items[ defList->NumberOfItems ].pressed=btnDisabled; | 253 if ( defList->Items[ defList->NumberOfItems ].msg == evPauseSwitchToPlay ) defList->Items[ defList->NumberOfItems ].pressed=btnDisabled; |
250 defList->Items[ defList->NumberOfItems ].tmp=1; | 254 defList->Items[ defList->NumberOfItems ].tmp=1; |
251 | 255 |
252 #ifdef DEBUG | 256 #ifdef DEBUG |
310 dbprintf( 3,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems ); | 314 dbprintf( 3,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems ); |
311 dbprintf( 3,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); | 315 dbprintf( 3,"[skin] x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy ); |
312 #endif | 316 #endif |
313 | 317 |
314 if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 ) | 318 if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 ) |
315 ERRORMESSAGE( "unknown message: %s\n",tmp ); | 319 ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,tmp ); |
316 | 320 |
317 #ifdef DEBUG | 321 #ifdef DEBUG |
318 dbprintf( 3,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg ); | 322 dbprintf( 3,"[skin] message: %d\n",defList->Items[ defList->NumberOfItems ].msg ); |
319 #endif | 323 #endif |
320 | 324 |
447 item=&defList->Items[ defList->NumberOfItems ]; | 451 item=&defList->Items[ defList->NumberOfItems ]; |
448 item->type=itFont; | 452 item->type=itFont; |
449 item->fontid=fntAddNewFont( name ); | 453 item->fontid=fntAddNewFont( name ); |
450 switch ( item->fontid ) | 454 switch ( item->fontid ) |
451 { | 455 { |
452 case -1: ERRORMESSAGE( "not enought memory\n" ); return 1; | 456 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; |
453 case -2: ERRORMESSAGE( "too many fonts\n" ); return 1; | 457 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1; |
454 } | 458 } |
455 | 459 |
456 #ifdef DEBUG | 460 #ifdef DEBUG |
457 dbprintf( 3, "[skin] id: %s ( %d )\n",id,item->fontid ); | 461 dbprintf( 3, "[skin] id: %s ( %d )\n",id,item->fontid ); |
458 #endif | 462 #endif |
459 | 463 |
460 switch ( fntRead( path,name,item->fontid ) ) | 464 switch ( fntRead( path,name,item->fontid ) ) |
461 { | 465 { |
462 case -1: ERRORMESSAGE( "font file not found\n" ); return 1; | 466 case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1; |
463 case -2: ERRORMESSAGE( "font image not found\n" ); return 1; | 467 case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1; |
464 } | 468 } |
465 | 469 |
466 return 0; | 470 return 0; |
467 } | 471 } |
468 | 472 |
481 #endif | 485 #endif |
482 | 486 |
483 x=cutItemToInt( in,',',0 ); | 487 x=cutItemToInt( in,',',0 ); |
484 y=cutItemToInt( in,',',1 ); | 488 y=cutItemToInt( in,',',1 ); |
485 cutItem( in,sid,',',2 ); id=fntFindID( sid ); | 489 cutItem( in,sid,',',2 ); id=fntFindID( sid ); |
486 if ( id < 0 ) { ERRORMESSAGE( "nonexistent font id. ( %s )\n",sid ); return 1; } | 490 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } |
487 cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 ); | 491 cutItem( in,tmp,',',3 ); cutItem( tmp,tmp,'"',1 ); |
488 | 492 |
489 #ifdef DEBUG | 493 #ifdef DEBUG |
490 dbprintf( 3, "[skin] pos: %d,%d\n",x,y ); | 494 dbprintf( 3, "[skin] pos: %d,%d\n",x,y ); |
491 dbprintf( 3, "[skin] id: %s ( %d )\n",sid,id ); | 495 dbprintf( 3, "[skin] id: %s ( %d )\n",sid,id ); |
496 item=&defList->Items[ defList->NumberOfItems ]; | 500 item=&defList->Items[ defList->NumberOfItems ]; |
497 item->type=itSLabel; | 501 item->type=itSLabel; |
498 item->fontid=id; | 502 item->fontid=id; |
499 item->x=x; item->y=y; | 503 item->x=x; item->y=y; |
500 item->width=-1; item->height=-1; | 504 item->width=-1; item->height=-1; |
501 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( "not enought memory.\n" ); return 1; } | 505 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } |
502 strcpy( item->label,tmp ); | 506 strcpy( item->label,tmp ); |
503 | 507 |
504 return 0; | 508 return 0; |
505 } | 509 } |
506 | 510 |
521 x=cutItemToInt( in,',',0 ); | 525 x=cutItemToInt( in,',',0 ); |
522 y=cutItemToInt( in,',',1 ); | 526 y=cutItemToInt( in,',',1 ); |
523 sx=cutItemToInt( in,',',2 ); | 527 sx=cutItemToInt( in,',',2 ); |
524 a=cutItemToInt( in,',',3 ); | 528 a=cutItemToInt( in,',',3 ); |
525 cutItem( in,sid,',',4 ); id=fntFindID( sid ); | 529 cutItem( in,sid,',',4 ); id=fntFindID( sid ); |
526 if ( id < 0 ) { ERRORMESSAGE( "nonexistent font id. ( %s )\n",sid ); return 1; } | 530 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } |
527 cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 ); | 531 cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 ); |
528 | 532 |
529 #ifdef DEBUG | 533 #ifdef DEBUG |
530 dbprintf( 3,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a ); | 534 dbprintf( 3,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a ); |
531 dbprintf( 3,"[skin] id: %s ( %d )\n",sid,id ); | 535 dbprintf( 3,"[skin] id: %s ( %d )\n",sid,id ); |
536 item=&defList->Items[ defList->NumberOfItems ]; | 540 item=&defList->Items[ defList->NumberOfItems ]; |
537 item->type=itDLabel; | 541 item->type=itDLabel; |
538 item->fontid=id; item->align=a; | 542 item->fontid=id; item->align=a; |
539 item->x=x; item->y=y; | 543 item->x=x; item->y=y; |
540 item->width=sx; item->height=-1; | 544 item->width=sx; item->height=-1; |
541 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( "not enought memory.\n" ); return 1; } | 545 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } |
542 strcpy( item->label,tmp ); | 546 strcpy( item->label,tmp ); |
543 | 547 |
544 return 0; | 548 return 0; |
545 } | 549 } |
546 | 550 |
553 | 557 |
554 #ifdef DEBUG | 558 #ifdef DEBUG |
555 dbprintf( 0,"\n[skin] window decoration is %s\n",in ); | 559 dbprintf( 0,"\n[skin] window decoration is %s\n",in ); |
556 #endif | 560 #endif |
557 cutItem( in,tmp,',',0 ); | 561 cutItem( in,tmp,',',0 ); |
558 if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( "unknown parameter.\n" ); return 1; } | 562 if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; } |
559 if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0; | 563 if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0; |
560 else defList->mainDecoration=1; | 564 else defList->mainDecoration=1; |
561 | 565 |
562 #ifdef DEBUG | 566 #ifdef DEBUG |
563 dbprintf( 3,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") ); | 567 dbprintf( 3,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") ); |