mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-12-26 08:31:55 +01:00
Gui interface zx spectrum style, submenu for 48k mode 2 & 3
This commit is contained in:
parent
174bfed1c3
commit
64f2b1d511
3
Makefile
3
Makefile
@ -134,7 +134,8 @@ dist: $(BUILD)
|
||||
cp images/symbol_shift_small.png $@/fbzx-wii/fbzx
|
||||
cp images/caps_shift_small.png $@/fbzx-wii/fbzx
|
||||
cp images/ZXSpectrum48k.png $@/fbzx-wii/fbzx
|
||||
cp images/FreeMono.ttf $@/fbzx-wii/fbzx
|
||||
cp images/ZX_Spectrum.ttf $@/fbzx-wii/fbzx
|
||||
cp images/ZX_Spectrum_narrow.ttf $@/fbzx-wii/fbzx
|
||||
cp fbzx.net $@/fbzx-wii
|
||||
cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/apps/fbzx-wii/doc
|
||||
touch $@/fbzx-wii/tapes/dummy
|
||||
|
@ -144,7 +144,8 @@ dist: $(BUILD)
|
||||
cp images/symbol_shift_small.png $@/fbzx-wii/fbzx
|
||||
cp images/caps_shift_small.png $@/fbzx-wii/fbzx
|
||||
cp images/ZXSpectrum48k.png $@/fbzx-wii/fbzx
|
||||
cp images/FreeMono.ttf $@/fbzx-wii/fbzx
|
||||
cp images/ZX_Spectrum.ttf $@/fbzx-wii/fbzx
|
||||
cp images/ZX_Spectrum_narrow.ttf $@/fbzx-wii/fbzx
|
||||
cp fbzx.net $@/fbzx-wii
|
||||
cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/fbzx-wii/doc
|
||||
touch $@/fbzx-wii/tapes/dummy
|
||||
|
BIN
images/ZX_Spectrum.ttf
Normal file
BIN
images/ZX_Spectrum.ttf
Normal file
Binary file not shown.
BIN
images/ZX_Spectrum_narrow.ttf
Normal file
BIN
images/ZX_Spectrum_narrow.ttf
Normal file
Binary file not shown.
199
src/gui_sdl.c
199
src/gui_sdl.c
@ -59,32 +59,36 @@ void clean_screen();
|
||||
|
||||
static const char *main_menu_messages[] = {
|
||||
/*00*/ "Tape",
|
||||
/*01*/ "^|Insert|Load|Play|Stop|Rewind|Create|Del|Browse",
|
||||
/*01*/ "^|Ins|Load|Play|Stop|Rew|Make|Del|Brows",
|
||||
/*02*/ "Snapshot",
|
||||
/*03*/ "^|Load|Save|Delete",
|
||||
/*04*/ "Wiimote configuration",
|
||||
/*05*/ "^|Wiimote1|Wiimote2",
|
||||
/*06*/ "Tape settings",
|
||||
/*07*/ "Emulation settings",
|
||||
/*08*/ "Screen settings",
|
||||
/*09*/ "Audio settings",
|
||||
/*10*/ "Config files",
|
||||
/*11*/ "Microdrive",
|
||||
/*12*/ "Tools",
|
||||
/*13*/ "Reset",
|
||||
/*14*/ "Quit",
|
||||
/*04*/ "#1----------------------------------------",
|
||||
/*05*/ "Wiimote configuration",
|
||||
/*06*/ "^|Wiimote1|Wiimote2",
|
||||
/*07*/ "Tape settings",
|
||||
/*08*/ "Emulation settings",
|
||||
/*09*/ "Screen settings",
|
||||
/*10*/ "Audio settings",
|
||||
/*11*/ "Config files",
|
||||
/*12*/ "Microdrive",
|
||||
/*13*/ "Tools",
|
||||
/*14*/ "Reset",
|
||||
/*15*/ "Quit",
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *emulation_messages[] = {
|
||||
/*00*/ "Emulated machine",
|
||||
/*01*/ "^|48k_2|48K_3|128k|+2|+2A/+3|128K_Sp|NTSC",
|
||||
/*02*/ " ",
|
||||
/*03*/ "Frame rate",
|
||||
/*04*/ "^|100%|50%|33%|25%|20%",
|
||||
/*05*/ " ",
|
||||
/*06*/ "Precision",
|
||||
/*07*/ "^|on|off",
|
||||
/*01*/ "^|48K|128K|+2|+2A/+3|128K_SP|48K_NTSC",
|
||||
/*02*/ " ",
|
||||
/*03*/ "48K model",
|
||||
/*04*/ "^|issue2|issue3",
|
||||
/*05*/ " ",
|
||||
/*06*/ "Frame rate",
|
||||
/*07*/ "^|100%|50%|33%|25%|20%",
|
||||
/*08*/ " ",
|
||||
/*09*/ "Precision",
|
||||
/*10*/ "^|on|off",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -125,7 +129,7 @@ static const char *screen_messages[] = {
|
||||
/*03*/ "TV mode",
|
||||
/*04*/ "^|Color|B&W|Green",
|
||||
/*05*/ " ",
|
||||
/*06*/ "Buffer resolution",
|
||||
/*06*/ "Screen resolution",
|
||||
/*07*/ "^|640X480|320X240",
|
||||
/*08* " ",
|
||||
*09* "576p video mode",
|
||||
@ -135,7 +139,7 @@ static const char *screen_messages[] = {
|
||||
|
||||
static const char *input_messages[] = {
|
||||
/*00*/ "Joystick type",
|
||||
/*01*/ "^|Cursor|Kempston|Sinclair1|Sinclair2|QAOP",
|
||||
/*01*/ "^|Cursor|Kempston|Sincl1|Sincl2|QAOP",
|
||||
/*02*/ "Bind key to Wiimote",
|
||||
/*03*/ "^|A|B|1|2|-|+",
|
||||
/*04*/ "Bind key to Nunchuk",
|
||||
@ -153,7 +157,7 @@ static const char *input_messages[] = {
|
||||
|
||||
static const char *microdrive_messages[] = {
|
||||
/*00*/ "Microdrive",
|
||||
/*01*/ "^|Insert|Create|Delete",
|
||||
/*01*/ "^|Insert|Make|Delete",
|
||||
/*02*/ " ",
|
||||
/*03*/ "Interface I",
|
||||
/*04*/ "^|on|off",
|
||||
@ -182,18 +186,18 @@ static const char *tools_messages[] = {
|
||||
};
|
||||
|
||||
static const char *help_messages[] = {
|
||||
/*00*/ "#2HOME enters the menu system, where arrow keys",
|
||||
/*01*/ "#2and nunchuck are used to navigate up and down.",
|
||||
/*02*/ "#2You can bind keyboard keys to the wiimote",
|
||||
/*03*/ "#2buttons in the 'Wiimote' menu and",
|
||||
/*04*/ "#2change emulation options in the Settings menu.",
|
||||
/*00*/ "#2HOME enters the menu system where pad",
|
||||
/*01*/ "#2and nunchuck are used to navigate.",
|
||||
/*02*/ "#2You can bind keyboard keys to the ",
|
||||
/*03*/ "#2wiimote buttons and change the",
|
||||
/*04*/ "#2emulation options.",
|
||||
/*05*/ "#2 ",
|
||||
/*06*/ "#2The easiest way to play a game is to load",
|
||||
/*07*/ "#2a snapshot (.z80 and .sna files).",
|
||||
/*08*/ "#2You can also insert a tape file (.tap and .tzx)",
|
||||
/*09*/ "#2and then load the file in the tape menu.",
|
||||
/*06*/ "#2The easiest way to play a game is to ",
|
||||
/*07*/ "#2load a snapshot (.z80 and .sna files).",
|
||||
/*08*/ "#2You can also insert a tape file",
|
||||
/*09*/ "#2and load it in the tape menu.",
|
||||
/*10*/ "#2 ",
|
||||
/*11*/ "#2More information is available on the wiki:",
|
||||
/*11*/ "#2More information is available in",
|
||||
/*12*/ "#2 http://wiibrew.org/wiki/FBZX_Wii",
|
||||
/*13*/ "#2 ",
|
||||
/*14*/ "OK",
|
||||
@ -351,7 +355,7 @@ static void delete_tape()
|
||||
|
||||
if ((ext_matches(filename, ".tap")|ext_matches(filename, ".TAP")|ext_matches(filename, ".tzx")|
|
||||
ext_matches(filename, ".TZX"))
|
||||
&& (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))) unlink(filename);
|
||||
&& (msgYesNo("Delete the file?", 0, -1, -1))) unlink(filename);
|
||||
|
||||
free((void *)filename);
|
||||
}
|
||||
@ -529,53 +533,45 @@ static int manage_tape(int which)
|
||||
static unsigned int get_machine_model(void)
|
||||
{
|
||||
if (ordenador.videosystem == 0)
|
||||
return (ordenador.mode128k + (ordenador.issue==3));
|
||||
else return (6);
|
||||
return (ordenador.mode128k);
|
||||
else return (5);
|
||||
}
|
||||
|
||||
static void set_machine_model(int which)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
case 0: //48k issue2
|
||||
ordenador.issue=2;
|
||||
case 0: //48k
|
||||
ordenador.mode128k=0;
|
||||
ordenador.ay_emul=0;
|
||||
ordenador.videosystem =0;
|
||||
break;
|
||||
case 1: //48k issue3
|
||||
ordenador.issue=3;
|
||||
ordenador.mode128k=0;
|
||||
ordenador.ay_emul=0;
|
||||
ordenador.videosystem =0;
|
||||
break;
|
||||
case 2: //128k
|
||||
case 1: //128k
|
||||
ordenador.issue=3;
|
||||
ordenador.mode128k=1;
|
||||
ordenador.ay_emul=1;
|
||||
ordenador.videosystem =0;
|
||||
break;
|
||||
case 3: //Amstrad +2
|
||||
case 2: //Amstrad +2
|
||||
ordenador.issue=3;
|
||||
ordenador.mode128k=2;
|
||||
ordenador.ay_emul=1;
|
||||
ordenador.videosystem =0;
|
||||
break;
|
||||
case 4: //Amstrad +2A/+3
|
||||
case 3: //Amstrad +2A/+3
|
||||
ordenador.issue=3;
|
||||
ordenador.mode128k=3;
|
||||
ordenador.ay_emul=1;
|
||||
ordenador.mdr_active=0;
|
||||
ordenador.videosystem =0;
|
||||
break;
|
||||
case 5: //128K Spanish
|
||||
case 4: //128K Spanish
|
||||
ordenador.issue=3;
|
||||
ordenador.mode128k=4;
|
||||
ordenador.ay_emul=1;
|
||||
ordenador.videosystem =0;
|
||||
break;
|
||||
case 6: //48k ntsc
|
||||
ordenador.issue=3;
|
||||
case 5: //48k ntsc
|
||||
ordenador.mode128k=0;
|
||||
ordenador.ay_emul=0;
|
||||
ordenador.videosystem =1;
|
||||
@ -585,19 +581,20 @@ static void set_machine_model(int which)
|
||||
|
||||
static int emulation_settings(void)
|
||||
{
|
||||
unsigned int submenus[3],submenus_old[3];
|
||||
unsigned int submenus[4],submenus_old[4];
|
||||
int opt, i, retorno;
|
||||
unsigned char old_mode, old_videosystem;
|
||||
|
||||
retorno=-1; //exit to the previous menue
|
||||
retorno=-1; //exit to the previous menu
|
||||
|
||||
memset(submenus, 0, sizeof(submenus));
|
||||
|
||||
submenus[0] = get_machine_model();
|
||||
submenus[1] = jump_frames;
|
||||
submenus[2] = !ordenador.precision;
|
||||
submenus[1] = ordenador.issue-2;
|
||||
submenus[2] = jump_frames;
|
||||
submenus[3] = !ordenador.precision;
|
||||
|
||||
for (i=0; i<3; i++) submenus_old[i] = submenus[i];
|
||||
for (i=0; i<4; i++) submenus_old[i] = submenus[i];
|
||||
old_mode=ordenador.mode128k;
|
||||
old_videosystem = ordenador.videosystem;
|
||||
|
||||
@ -605,17 +602,19 @@ static int emulation_settings(void)
|
||||
emulation_messages, submenus);
|
||||
if (opt < 0)
|
||||
return retorno;
|
||||
|
||||
curr_frames=0;
|
||||
|
||||
if (submenus[0]!=submenus_old[0]) set_machine_model(submenus[0]);
|
||||
if ((old_mode!=ordenador.mode128k)||(old_videosystem!=ordenador.videosystem)) {ResetComputer(); retorno=-2;}
|
||||
|
||||
curr_frames=0;
|
||||
if (ordenador.mode128k==0) ordenador.issue= submenus[1]+2; else ordenador.issue = 3;
|
||||
|
||||
jump_frames = submenus[1];
|
||||
jump_frames = submenus[2];
|
||||
|
||||
if (submenus[2] != submenus_old[2])
|
||||
if (submenus[3] != submenus_old[3])
|
||||
{
|
||||
ordenador.precision = !submenus[2];
|
||||
ordenador.precision = !submenus[3];
|
||||
ordenador.precision_old=ordenador.precision;
|
||||
if (ordenador.turbo_state!=1) //Tape is not loading with auto mode
|
||||
if (ordenador.precision)
|
||||
@ -942,7 +941,7 @@ static void delete_mdr()
|
||||
return;
|
||||
|
||||
if ((ext_matches(filename, ".mdr")|ext_matches(filename, ".MDR"))
|
||||
&& (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))) unlink(filename);
|
||||
&& (msgYesNo("Delete the file?", 0,-1, -1))) unlink(filename);
|
||||
|
||||
free((void *)filename);
|
||||
}
|
||||
@ -1074,7 +1073,7 @@ static void delete_scr()
|
||||
return;
|
||||
|
||||
if ((ext_matches(filename, ".scr")|ext_matches(filename, ".SCR"))
|
||||
&& (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))) unlink(filename);
|
||||
&& (msgYesNo("Delete the file?", 0, -1, -1))) unlink(filename);
|
||||
|
||||
free((void *)filename);
|
||||
}
|
||||
@ -1171,7 +1170,7 @@ static int save_scr(int i)
|
||||
if(fichero!=NULL)
|
||||
{
|
||||
fclose(fichero);
|
||||
if (!msgYesNo("Overwrite the exiting file?", 0, FULL_DISPLAY_X /2-160/RATIO, FULL_DISPLAY_Y /2-48/RATIO))
|
||||
if (!msgYesNo("Overwrite the exiting file?", 0, -1, -1))
|
||||
return 0; // file already exists
|
||||
}
|
||||
|
||||
@ -1382,16 +1381,21 @@ int parse_poke (const char *filename)
|
||||
FILE* fpoke;
|
||||
unsigned char title[128], flag, newfile, restore, old_mport1;
|
||||
int bank, address, value, original_value, ritorno,y,k, trainer, poke;
|
||||
SDL_Rect src, banner;
|
||||
SDL_Rect src, banner, src_ext;
|
||||
|
||||
src.x=0;
|
||||
src.y=30/RATIO;
|
||||
src.w=FULL_DISPLAY_X;
|
||||
src.h=FULL_DISPLAY_Y-60/RATIO;
|
||||
src.x=2/RATIO;
|
||||
src.y=28/RATIO;
|
||||
src.w=FULL_DISPLAY_X-4/RATIO;
|
||||
src.h=FULL_DISPLAY_Y-56/RATIO;
|
||||
|
||||
src_ext.x=0;
|
||||
src_ext.y=26/RATIO;
|
||||
src_ext.w=FULL_DISPLAY_X;
|
||||
src_ext.h=FULL_DISPLAY_Y-52/RATIO;
|
||||
|
||||
banner.x=0;
|
||||
banner.x=2/RATIO;
|
||||
banner.y=30/RATIO;
|
||||
banner.w=FULL_DISPLAY_X;
|
||||
banner.w=FULL_DISPLAY_X-4/RATIO;
|
||||
banner.h=20/RATIO;
|
||||
|
||||
y=60/RATIO;
|
||||
@ -1410,9 +1414,10 @@ int parse_poke (const char *filename)
|
||||
|
||||
clean_screen();
|
||||
|
||||
SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));
|
||||
SDL_FillRect(screen, &src_ext, SDL_MapRGB(screen->format, 220, 220, 0));
|
||||
SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0, 0, 0));
|
||||
|
||||
print_font(screen, 0x0, 0x0, 0x0,0, 30/RATIO, "Press 1 to deselect, 2 to select", 16);
|
||||
print_font(screen, 255, 255, 255,4/RATIO, 30/RATIO, "Press 1 to deselect, 2 to select", 16);
|
||||
|
||||
ritorno=0;
|
||||
do
|
||||
@ -1427,11 +1432,15 @@ int parse_poke (const char *filename)
|
||||
|
||||
if (strlen(title)>1) title[strlen(title)-2]='\0'; //cancel new line and line feed
|
||||
|
||||
if (y>420/RATIO) {SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));y=40/RATIO;}
|
||||
if (y>420/RATIO) {SDL_FillRect(screen, &src, SDL_MapRGB(screen->format, 0, 0, 0));y=40/RATIO;}
|
||||
|
||||
if (newfile) print_font(screen, 0x80, 0x80, 0x80,0, y, title+1, 16);
|
||||
else {if (old_poke[trainer][0]==0) print_font(screen, 0xd0, 0, 0,0, y, title+1, 16); //In row 0 information on trainer selection
|
||||
else print_font(screen, 0, 0xd0, 0,0, y, title+1, 16);}
|
||||
banner.y=y-2/RATIO;
|
||||
|
||||
SDL_FillRect(screen, &banner, SDL_MapRGB(screen->format, 0, 200, 200));
|
||||
|
||||
if (newfile) print_font(screen, 0, 0, 0,4/RATIO, y, title+1, 16);
|
||||
else {if (old_poke[trainer][0]==0) print_font(screen, 220, 0, 0,4/RATIO, y, title+1, 16); //In row 0 information on trainer selection
|
||||
else print_font(screen, 0, 250, 0,4/RATIO, y, title+1, 16);}
|
||||
|
||||
SDL_Flip(screen);
|
||||
k=0;
|
||||
@ -1439,19 +1448,17 @@ int parse_poke (const char *filename)
|
||||
while (!((k & KEY_ESCAPE)||(k & KEY_SELECT)))
|
||||
{k = menu_wait_key_press();}
|
||||
|
||||
banner.y=y;
|
||||
|
||||
SDL_FillRect(screen, &banner, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));
|
||||
SDL_FillRect(screen, &banner, SDL_MapRGB(screen->format, 0, 0, 0));
|
||||
|
||||
if (k & KEY_SELECT)
|
||||
{
|
||||
print_font(screen, 0, 0x40, 0,0, y, title+1, 16);
|
||||
print_font(screen, 0, 220, 0,4/RATIO, y, title+1, 16);
|
||||
old_poke[trainer][0]=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((!newfile)&&(old_poke[trainer][0]==1)) restore=1;
|
||||
print_font(screen, 0x80, 0, 0,0, y, title+1, 16);
|
||||
print_font(screen, 220, 0, 0,4/RATIO, y, title+1, 16);
|
||||
old_poke[trainer][0]=0;
|
||||
}
|
||||
|
||||
@ -1707,7 +1714,7 @@ static int save_load_snapshot(int which)
|
||||
}
|
||||
}
|
||||
else // Delete snashot file
|
||||
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) unlink(filename);
|
||||
if (msgYesNo("Delete the file?", 0, -1, -1)) unlink(filename);
|
||||
}
|
||||
free((void*)filename);
|
||||
} break;
|
||||
@ -1722,7 +1729,7 @@ static int save_load_snapshot(int which)
|
||||
retorno2=-1;
|
||||
break;
|
||||
case -1:
|
||||
if (msgYesNo("Overwrite the exiting file?", 0, FULL_DISPLAY_X /2-160/RATIO, FULL_DISPLAY_Y /2-48/RATIO))
|
||||
if (msgYesNo("Overwrite the exiting file?", 0, -1, -1))
|
||||
{
|
||||
save_z80(db,1); //force overwrite
|
||||
msgInfo("Snapshot saved",3000,NULL);
|
||||
@ -1769,7 +1776,7 @@ static int save_load_game_configurations(int which)
|
||||
if (!load_config(&ordenador,(char *)filename)) {msgInfo("Game confs loaded",3000,NULL);retorno2=-1;}
|
||||
}
|
||||
else // Delete config file
|
||||
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) unlink(filename);
|
||||
if (msgYesNo("Delete the file?", 0, -1, -1)) unlink(filename);
|
||||
}
|
||||
free((void*)filename);
|
||||
} break;
|
||||
@ -1800,7 +1807,7 @@ static int save_load_game_configurations(int which)
|
||||
retorno2=-1;
|
||||
break;
|
||||
case -1:
|
||||
if (msgYesNo("Overwrite the exiting file?", 0, FULL_DISPLAY_X /2-160/RATIO, FULL_DISPLAY_Y /2-48/RATIO))
|
||||
if (msgYesNo("Overwrite the exiting file?", 0, -1, -1))
|
||||
{
|
||||
save_config_game(&ordenador,db,1); //force overwrite
|
||||
msgInfo("Game confs saved",3000,NULL);
|
||||
@ -1840,7 +1847,7 @@ static void save_load_general_configurations(int which)
|
||||
fconfig = fopen(config_path,"rb");
|
||||
if (fconfig==NULL)
|
||||
{
|
||||
msgInfo("Can not access the file",3000,NULL);
|
||||
msgInfo("Can't access the file",3000,NULL);
|
||||
return;
|
||||
}
|
||||
else fclose(fconfig);
|
||||
@ -1855,7 +1862,7 @@ static void save_load_general_configurations(int which)
|
||||
break;
|
||||
}
|
||||
else // Delete config file
|
||||
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) unlink(config_path);
|
||||
if (msgYesNo("Delete the file?", 0, -1, -1)) unlink(config_path);
|
||||
|
||||
} break;
|
||||
case 1: // Save configuration file
|
||||
@ -1935,36 +1942,36 @@ void main_menu()
|
||||
case 2:
|
||||
retorno = save_load_snapshot(submenus[1]);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
input_options(submenus[2]);
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
tape_settings();
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
if (emulation_settings()==-2) retorno=-1;
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
screen_settings();
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
audio_settings();
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
manage_configurations();
|
||||
break;
|
||||
case 11:
|
||||
case 12:
|
||||
microdrive();
|
||||
break;
|
||||
case 12:
|
||||
case 13:
|
||||
if (tools()==-2) retorno=-1;
|
||||
break;
|
||||
case 13:
|
||||
case 14:
|
||||
ResetComputer ();
|
||||
retorno=-1;
|
||||
break;
|
||||
case 14:
|
||||
if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))
|
||||
case 15:
|
||||
if (msgYesNo("Are you sure to quit?", 0, -1, -1))
|
||||
{salir = 0;retorno=-1;}
|
||||
break;
|
||||
default:
|
||||
|
270
src/menu_sdl.c
270
src/menu_sdl.c
@ -88,35 +88,37 @@ static SDL_Surface *real_screen;
|
||||
#define IS_MARKER(p_msg) ( (p_msg)[0] == '@' )
|
||||
|
||||
static int is_inited = 0;
|
||||
static TTF_Font *menu_font16, *menu_font20, *menu_font8, *menu_font10;
|
||||
static TTF_Font *menu_font_alt_large, *menu_font_large, *menu_font_alt_small, *menu_font_small;
|
||||
|
||||
int fh, fw;
|
||||
|
||||
int msgInfo(char *text, int duration, SDL_Rect *irc)
|
||||
{
|
||||
int len = strlen(text);
|
||||
int X, Y;
|
||||
int X, Y, w, h;
|
||||
SDL_Rect src;
|
||||
SDL_Rect rc;
|
||||
SDL_Rect brc;
|
||||
|
||||
if (RATIO==1) TTF_SizeText(menu_font_large, "Z", &w, &h); else TTF_SizeText(menu_font_small, "Z", &w, &h);
|
||||
|
||||
X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*12/RATIO;
|
||||
Y = (FULL_DISPLAY_Y /2) - 24/RATIO;
|
||||
X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*w;
|
||||
Y = (FULL_DISPLAY_Y /2) - h;
|
||||
|
||||
brc.x = FULL_DISPLAY_X/2-2*12/RATIO;
|
||||
brc.y=Y+42/RATIO;
|
||||
brc.w=48/RATIO;
|
||||
brc.h=20/RATIO;
|
||||
brc.x = FULL_DISPLAY_X/2-2*w-2/RATIO;
|
||||
brc.y=Y+h*2-4/RATIO;
|
||||
brc.w=w*4;
|
||||
brc.h=h*3/2;
|
||||
|
||||
rc.x = X;
|
||||
rc.y=Y;
|
||||
rc.w=12*(len + 2)/RATIO;
|
||||
rc.h=duration >= 0 ? 48/RATIO : 80/RATIO;
|
||||
rc.w=w*(len + 2);
|
||||
rc.h=duration >= 0 ? h*2 : h*4;
|
||||
|
||||
src.x=rc.x+4/RATIO;
|
||||
src.y=rc.y+4/RATIO;
|
||||
src.w=rc.w;
|
||||
src.h=rc.h;
|
||||
src.x=rc.x+2/RATIO;
|
||||
src.y=rc.y+2/RATIO;
|
||||
src.w=rc.w-4/RATIO;
|
||||
src.h=rc.h-4/RATIO;
|
||||
|
||||
|
||||
if (irc)
|
||||
@ -125,10 +127,10 @@ int msgInfo(char *text, int duration, SDL_Rect *irc)
|
||||
irc->y=rc.y;
|
||||
irc->w=src.w;
|
||||
irc->h=src.h;
|
||||
}
|
||||
SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 0, 96, 0));
|
||||
SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 128, 128, 128));
|
||||
menu_print_font(real_screen, 255,255,255, X+12/RATIO, Y+12/RATIO, text,20,64);
|
||||
}
|
||||
SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 220, 220, 0));
|
||||
SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 255, 255, 255));
|
||||
menu_print_font(real_screen, 0,0,0, X+w, Y+h/2, text,20,64);
|
||||
SDL_UpdateRect(real_screen, src.x, src.y, src.w, src.h);
|
||||
SDL_UpdateRect(real_screen, rc.x, rc.y, rc.w,rc.h);
|
||||
if (duration > 0)
|
||||
@ -136,7 +138,7 @@ int msgInfo(char *text, int duration, SDL_Rect *irc)
|
||||
else if (duration < 0)
|
||||
{
|
||||
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00));
|
||||
menu_print_font(real_screen, 0,0,0, FULL_DISPLAY_X/2-12/RATIO, Y+42/RATIO, "OK",20,64);
|
||||
menu_print_font(real_screen, 0,0,0, FULL_DISPLAY_X/2-w, Y+h*2, "OK",20,64);
|
||||
SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w, brc.h);
|
||||
while (!(KEY_SELECT & menu_wait_key_press())) {}
|
||||
|
||||
@ -155,57 +157,59 @@ void msgKill(SDL_Rect *rc)
|
||||
int msgYesNo(char *text, int default_opt, int x, int y)
|
||||
{
|
||||
int len = strlen(text);
|
||||
int X, Y;
|
||||
int X, Y, w, h;
|
||||
SDL_Rect src;
|
||||
SDL_Rect rc;
|
||||
SDL_Rect brc;
|
||||
uint32_t key;
|
||||
|
||||
if (RATIO==1) TTF_SizeText(menu_font_large, "Z", &w, &h); else TTF_SizeText(menu_font_small, "Z", &w, &h);
|
||||
|
||||
if (x < 0)
|
||||
X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*12/RATIO;
|
||||
X = (FULL_DISPLAY_X /2) - (len / 2 + 1)*w;
|
||||
else
|
||||
X = x;
|
||||
|
||||
if (y < 0)
|
||||
Y = (FULL_DISPLAY_Y /2) - 48/RATIO;
|
||||
Y = (FULL_DISPLAY_Y /2) - h*2;
|
||||
else
|
||||
Y = y;
|
||||
|
||||
rc.x=X;
|
||||
rc.y=Y;
|
||||
rc.w=12*(len + 2)/RATIO;
|
||||
rc.h=80/RATIO;
|
||||
rc.w=w*(len + 2);
|
||||
rc.h=h*4;
|
||||
|
||||
src.x=rc.x+4/RATIO;
|
||||
src.y=rc.y+4/RATIO;
|
||||
src.w=rc.w;
|
||||
src.h=rc.h;
|
||||
src.x=rc.x+2/RATIO;
|
||||
src.y=rc.y+2/RATIO;
|
||||
src.w=rc.w-4/RATIO;
|
||||
src.h=rc.h-4/RATIO;
|
||||
|
||||
while (1)
|
||||
{
|
||||
SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 0, 96, 0));
|
||||
SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 128, 128, 128));
|
||||
menu_print_font(real_screen, 255,255,255, X+12/RATIO, Y+12/RATIO, text,20,64);
|
||||
{
|
||||
SDL_FillRect(real_screen, &rc, SDL_MapRGB(real_screen->format, 220, 220, 0));
|
||||
SDL_FillRect(real_screen, &src, SDL_MapRGB(real_screen->format, 255, 255, 255));
|
||||
menu_print_font(real_screen, 0,0,0, X+w, Y+h/2, text,20,64);
|
||||
|
||||
if (default_opt)
|
||||
if (default_opt) //"YES"
|
||||
{
|
||||
brc.x=rc.x + rc.w/2-5*12/RATIO;
|
||||
brc.y=rc.y+42/RATIO;
|
||||
brc.w=12*3/RATIO;
|
||||
brc.h=20/RATIO;
|
||||
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00));
|
||||
brc.x=rc.x + rc.w/2-5*w-2/RATIO;
|
||||
brc.y=rc.y+h*2-4/RATIO;
|
||||
brc.w=w*3;
|
||||
brc.h=h*3/2;
|
||||
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 220, 0x00));
|
||||
}
|
||||
else
|
||||
else //"NO"
|
||||
{
|
||||
brc.x=rc.x + rc.w/2+5*12/RATIO-2*12/RATIO-6/RATIO;
|
||||
brc.y=rc.y+42/RATIO;
|
||||
brc.w=12*3/RATIO;
|
||||
brc.h=20/RATIO;
|
||||
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x80, 0x00, 0x00));
|
||||
brc.x=rc.x + rc.w/2+5*w-2*w-2/RATIO;
|
||||
brc.y=rc.y+h*2-4/RATIO;
|
||||
brc.w=w*2;
|
||||
brc.h=h*3/2;
|
||||
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 255, 0x00, 0x00));
|
||||
}
|
||||
|
||||
menu_print_font(real_screen, 255,255,255, rc.x + rc.w/2-5*12/RATIO, Y+42/RATIO, "YES",20,64);
|
||||
menu_print_font(real_screen, 255,255,255, rc.x + rc.w/2-5*12/RATIO+8*12/RATIO, Y+42/RATIO, "NO",20,64);
|
||||
menu_print_font(real_screen, 0,0,0, rc.x + rc.w/2-5*w, Y+h*2, "YES",20,64);
|
||||
menu_print_font(real_screen, 0,0,0, rc.x + rc.w/2+5*w-2*w, Y+h*2, "NO",20,64);
|
||||
|
||||
SDL_UpdateRect(real_screen, src.x, src.y, src.w, src.h);
|
||||
SDL_UpdateRect(real_screen, rc.x, rc.y, rc.w,rc.h);
|
||||
@ -415,17 +419,18 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
|
||||
SDL_Rect dst = {x, y, 0, 0};
|
||||
SDL_Color color = {r, g, b, 0};
|
||||
char buf[255];
|
||||
unsigned int i, lenght;
|
||||
unsigned int i, length;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
strncpy(buf, msg, 254);
|
||||
if (buf[0] != '|' && buf[0] != '^' && buf[0] != '.'
|
||||
&& buf[0] != '-' && buf[0] != ' ' && !strstr(buf, " \""))
|
||||
{
|
||||
lenght = strlen(buf);
|
||||
if (lenght>max_string)
|
||||
length = strlen(buf);
|
||||
if (length>max_string)
|
||||
{
|
||||
strcpy (buf + max_string-8, buf + lenght-8);
|
||||
if (buf[length-8]== '.') strcpy (buf + max_string-8, buf + length-8);
|
||||
else strcpy (buf + max_string-4, buf + length-4);
|
||||
}
|
||||
}
|
||||
/* Fixup multi-menu option look */
|
||||
@ -437,13 +442,13 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
|
||||
|
||||
if (FULL_DISPLAY_X == 640)
|
||||
{
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font16, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font20, buf, color);
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_large, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font_large, buf, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font8, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font10, buf, color);
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_small, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font_small, buf, color);
|
||||
}
|
||||
|
||||
if (!font_surf)
|
||||
@ -459,7 +464,7 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
|
||||
void print_font(SDL_Surface *screen, int r, int g, int b,
|
||||
int x, int y, const char *msg, int font_size)
|
||||
{
|
||||
#define _MAX_STRING 64
|
||||
#define _MAX_STRING 52
|
||||
SDL_Surface *font_surf;
|
||||
SDL_Rect dst = {x, y, 0, 0};
|
||||
SDL_Color color = {r, g, b, 0};
|
||||
@ -477,13 +482,13 @@ void print_font(SDL_Surface *screen, int r, int g, int b,
|
||||
|
||||
if (FULL_DISPLAY_X == 640)
|
||||
{
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font16, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font20, buf, color);
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_large, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font_large, buf, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font8, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font10, buf, color);
|
||||
if (font_size == 16) font_surf = TTF_RenderUTF8_Blended(menu_font_alt_small, buf, color);
|
||||
else font_surf = TTF_RenderUTF8_Blended(menu_font_small, buf, color);
|
||||
}
|
||||
|
||||
if (!font_surf)
|
||||
@ -552,22 +557,23 @@ void draw_scr_file(int x,int y, char *filename)
|
||||
|
||||
static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_size, int draw_scr)
|
||||
{
|
||||
int font_height = TTF_FontHeight(p_menu->p_font);
|
||||
int line_height = (font_height + font_height / 4);
|
||||
int x_start = p_menu->x1;
|
||||
int y_start = p_menu->y1 + line_height;
|
||||
//int font_height = TTF_FontHeight(p_menu->p_font);
|
||||
//int line_height = (font_height + font_height / 2);
|
||||
int line_height = 22/ RATIO;
|
||||
int x_start = p_menu->x1+4/RATIO;
|
||||
int y_start = p_menu->y1 + line_height+4/RATIO;
|
||||
SDL_Rect r;
|
||||
int entries_visible = (p_menu->y2 - p_menu->y1-5) / line_height - 1;
|
||||
int entries_visible = (p_menu->y2 - p_menu->y1-10/RATIO) / line_height - 1;
|
||||
const char *selected_file = NULL;
|
||||
char filename[MAX_PATH_LENGTH];
|
||||
char name[MAX_PATH_LENGTH];
|
||||
char *ptr;
|
||||
int i, y, length, max_string;
|
||||
|
||||
if (draw_scr) max_string = 35; else max_string = 64;
|
||||
if ((draw_scr)&&(RATIO==1)) max_string = 30; else max_string = 46;
|
||||
|
||||
if ( p_menu->n_entries * line_height > p_menu->y2 )
|
||||
y_start = p_menu->y1 + line_height;
|
||||
//if ( p_menu->n_entries * line_height > p_menu->y2 )
|
||||
//y_start = p_menu->y1 + line_height;
|
||||
|
||||
if (p_menu->cur_sel - p_menu->start_entry_visible > entries_visible)
|
||||
{
|
||||
@ -589,12 +595,12 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
|
||||
r.x = p_menu->x1;
|
||||
r.y = p_menu->y1;
|
||||
r.w = p_menu->x2 - p_menu->x1;
|
||||
r.h = line_height-1;
|
||||
r.h = line_height;
|
||||
if (sel < 0)
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x40, 0x00, 0x00));
|
||||
else
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x00, 0xe7, 0xe7)); //Title
|
||||
menu_print_font(screen, 0,0,0, p_menu->x1, p_menu->y1, p_menu->title, font_size, 52);
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0)); //Title
|
||||
menu_print_font(screen, 0,0,0, p_menu->x1+4/RATIO, p_menu->y1+4/RATIO, p_menu->title, font_size, 50);
|
||||
}
|
||||
|
||||
for (i = p_menu->start_entry_visible; i <= p_menu->start_entry_visible + entries_visible; i++)
|
||||
@ -608,27 +614,37 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
|
||||
else
|
||||
{
|
||||
y = (i - p_menu->start_entry_visible) * line_height;
|
||||
|
||||
r.x = p_menu->x1+2/RATIO;
|
||||
r.y = p_menu->y1 + line_height +y;
|
||||
if ((draw_scr)&&(RATIO==1)) r.w = 365; //Only in 640 mode
|
||||
else r.w = p_menu->x2 - p_menu->x1-4/RATIO;
|
||||
r.h = line_height;
|
||||
|
||||
if (sel < 0)
|
||||
menu_print_font(screen, 0x40,0x40,0x40, //Not used
|
||||
x_start, y_start + y, msg, font_size, max_string);
|
||||
else if (p_menu->cur_sel == i) /* Selected - color */
|
||||
{
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 220, 220));
|
||||
if (msg[0] == ']')
|
||||
menu_print_font(screen, 0,200,0, //Selected menu entry begining with ']' (tape browser)
|
||||
menu_print_font(screen, 0,0,0, //Selected menu entry begining with ']' (tape browser)
|
||||
x_start, y_start + y, msg+1, font_size,max_string ); //do not show ']'
|
||||
else
|
||||
menu_print_font(screen, 0,200,0, //Selected menu entry
|
||||
else
|
||||
menu_print_font(screen, 0,0,0, //Selected menu entry
|
||||
x_start, y_start + y, msg, font_size,max_string );
|
||||
|
||||
selected_file = msg;
|
||||
}
|
||||
else if (IS_SUBMENU(msg))
|
||||
{
|
||||
if (p_menu->cur_sel == i-1)
|
||||
menu_print_font(screen, 0,200,0, //Selected sub menu entry
|
||||
{
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 220, 220));
|
||||
menu_print_font(screen, 0,0,0, //Selected sub menu entry
|
||||
x_start, y_start + y, msg, font_size, max_string);
|
||||
}
|
||||
else
|
||||
menu_print_font(screen, 0x40,0x40,0x40, //Non selected sub menu entry
|
||||
menu_print_font(screen, 255,255,255, //Non selected sub menu entry
|
||||
x_start, y_start + y, msg, font_size, max_string);
|
||||
}
|
||||
else if (msg[0] == '#')
|
||||
@ -636,11 +652,11 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
|
||||
switch (msg[1])
|
||||
{
|
||||
case '1':
|
||||
menu_print_font(screen, 0,0,255, //Text 1
|
||||
menu_print_font(screen, 220,220,0, //Text 1
|
||||
x_start, y_start + y, msg+2, font_size, max_string);
|
||||
break;
|
||||
case '2':
|
||||
menu_print_font(screen, 0x40,0x40,0x40, //Text 2
|
||||
menu_print_font(screen, 255,255,255, //Text 2
|
||||
x_start, y_start + y, msg+2, font_size, max_string);
|
||||
break;
|
||||
default:
|
||||
@ -650,11 +666,11 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
|
||||
}
|
||||
}
|
||||
else if (msg[0] == ']')
|
||||
menu_print_font(screen, 0,0,255, //Non selected menu entry starting with ']' (tape browser)
|
||||
menu_print_font(screen, 220,0,0, //Non selected menu entry starting with ']' (tape browser)
|
||||
x_start, y_start + y, msg+1, font_size, max_string);
|
||||
|
||||
else /* Otherwise white */
|
||||
menu_print_font(screen, 0x40,0x40,0x40, //Non selected menu entry
|
||||
menu_print_font(screen, 255,255,255, //Non selected menu entry
|
||||
x_start, y_start + y, msg, font_size, max_string);
|
||||
if (IS_SUBMENU(msg))
|
||||
{
|
||||
@ -677,21 +693,19 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
|
||||
int w;
|
||||
int h;
|
||||
|
||||
if (TTF_SizeText(p_menu->p_font, "X", &w, &h) < 0)
|
||||
if (TTF_SizeText(p_menu->p_font, "Z", &w, &h) < 0)
|
||||
{
|
||||
fw = w;
|
||||
fh = h;
|
||||
fprintf(stderr, "%s\n", TTF_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
r = (SDL_Rect){ x_start + (n+1) * w-1, y_start + (i+ 1 - p_menu->start_entry_visible) * ((h + h/4)) -3, (n_chars - 1) * w, 2};
|
||||
r = (SDL_Rect){ x_start + (n+1) * w-2/RATIO, y_start + (i+ 1 - p_menu->start_entry_visible) *line_height -8/RATIO, (n_chars - 1) * w, 2/RATIO};
|
||||
if (p_menu->cur_sel == i-1)
|
||||
SDL_FillRect(screen, &r,
|
||||
SDL_MapRGB(screen->format, 255,0,0)); //Underline selected text
|
||||
SDL_MapRGB(screen->format, 220,0,0)); //Underline selected text
|
||||
else
|
||||
SDL_FillRect(screen, &r,
|
||||
SDL_MapRGB(screen->format, 0x40,0x40,0x40));//Underline non selected text
|
||||
SDL_MapRGB(screen->format, 255,255,255));//Underline non selected text
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -702,16 +716,18 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
|
||||
|
||||
if ((draw_scr)&&(RATIO==1)) //Only in 640 mode
|
||||
{
|
||||
r.x = p_menu->x1+ (p_menu->x2 - p_menu->x1)/2 + line_height*3/2+4;
|
||||
r.y = p_menu->y1+line_height-1;
|
||||
r.w = line_height/2;
|
||||
r.h = p_menu->y2 - p_menu->y1 - line_height+1;
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x00, 0xe7, 0xe7)); //Frame for scr preview
|
||||
r.x = r.x + r.w;
|
||||
r.y = p_menu->y1+ (p_menu->y2 - p_menu->y1)/2 + line_height/4+1;
|
||||
r.w = (p_menu->x2 - p_menu->x1)/2 - line_height*2-3;
|
||||
r.h = line_height/2;
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0x00, 0xe7, 0xe7)); //Frame for scr preview
|
||||
r.x = 367;
|
||||
r.y = 39;
|
||||
r.w = 2;
|
||||
r.h = 423;
|
||||
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0)); //Frame for scr preview
|
||||
r.x = 369;
|
||||
r.y = 249;
|
||||
r.w = 270;
|
||||
r.h = 2;
|
||||
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0)); //Frame for scr preview
|
||||
|
||||
if ((!selected_file)||(selected_file[0] == '[')) return; //No dir
|
||||
|
||||
@ -749,7 +765,7 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
|
||||
strcat(filename, "scr2/");
|
||||
strcat(filename, name);
|
||||
strcat(filename, ".scr");
|
||||
draw_scr_file(375,262, filename);
|
||||
draw_scr_file(375,260, filename);
|
||||
}
|
||||
}
|
||||
|
||||
@ -876,7 +892,7 @@ static void menu_init_internal(menu_t *p_menu, const char *title,
|
||||
submenu++;
|
||||
}
|
||||
}
|
||||
p_menu->text_h = p_menu->n_entries * (TTF_FontHeight(p_font) + TTF_FontHeight(p_font) / 4);
|
||||
p_menu->text_h = p_menu->n_entries * (TTF_FontHeight(p_font) + TTF_FontHeight(p_font) / 2);
|
||||
}
|
||||
|
||||
static void menu_fini(menu_t *p_menu)
|
||||
@ -1041,10 +1057,14 @@ static int menu_select_internal(SDL_Surface *screen,
|
||||
{
|
||||
SDL_Rect r = {p_menu->x1, p_menu->y1,
|
||||
p_menu->x2 - p_menu->x1, p_menu->y2 - p_menu->y1};
|
||||
SDL_Rect r_int = {p_menu->x1+2/RATIO, p_menu->y1+2/RATIO,
|
||||
p_menu->x2 - p_menu->x1-4/RATIO, p_menu->y2 - p_menu->y1-4/RATIO};
|
||||
|
||||
uint32_t keys;
|
||||
int sel_last = p_menu->cur_sel;
|
||||
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0xff, 0xff, 0xff));
|
||||
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 220, 220, 0));
|
||||
SDL_FillRect(screen, &r_int, SDL_MapRGB(screen->format, 0, 0, 0));
|
||||
|
||||
menu_draw(screen, p_menu, 0, font_size, draw_scr);
|
||||
SDL_Flip(screen);
|
||||
@ -1052,9 +1072,9 @@ static int menu_select_internal(SDL_Surface *screen,
|
||||
keys = menu_wait_key_press();
|
||||
|
||||
if (keys & KEY_UP)
|
||||
select_next(p_menu, 0, -1, 1);
|
||||
{select_next(p_menu, 0, -1, 1);play_click();}
|
||||
else if (keys & KEY_DOWN)
|
||||
select_next(p_menu, 0, 1, 1);
|
||||
{select_next(p_menu, 0, 1, 1);play_click();}
|
||||
else if (keys & KEY_PAGEUP)
|
||||
select_next(p_menu, 0, -19, 0);
|
||||
else if (keys & KEY_PAGEDOWN)
|
||||
@ -1080,7 +1100,7 @@ static int menu_select_internal(SDL_Surface *screen,
|
||||
select_next_cb(p_menu, select_next_cb_data);
|
||||
}
|
||||
|
||||
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
|
||||
//SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1095,13 +1115,13 @@ int menu_select_sized(const char *title, const char **msgs, int *submenus, int s
|
||||
|
||||
if (FULL_DISPLAY_X == 640)
|
||||
{
|
||||
if (font_size == 16) menu_init_internal(&menu, title, menu_font16, msgs, x, y, x2, y2);
|
||||
else menu_init_internal(&menu, title, menu_font20, msgs, x, y, x2, y2);
|
||||
if (font_size == 16) menu_init_internal(&menu, title, menu_font_alt_large, msgs, x, y, x2, y2);
|
||||
else menu_init_internal(&menu, title, menu_font_large, msgs, x, y, x2, y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (font_size == 16) menu_init_internal(&menu, title, menu_font8, msgs, x, y, x2, y2);
|
||||
else menu_init_internal(&menu, title, menu_font10, msgs, x, y, x2, y2);
|
||||
if (font_size == 16) menu_init_internal(&menu, title, menu_font_alt_small, msgs, x, y, x2, y2);
|
||||
else menu_init_internal(&menu, title, menu_font_small, msgs, x, y, x2, y2);
|
||||
}
|
||||
|
||||
if (sel >= 0)
|
||||
@ -1118,7 +1138,7 @@ int menu_select_title(const char *title, const char **msgs, int *submenus)
|
||||
{
|
||||
SDL_FillRect(real_screen, 0, SDL_MapRGB(real_screen->format, 0, 0, 0));
|
||||
return menu_select_sized(title, msgs, submenus, 0,
|
||||
28/RATIO, 28/RATIO, FULL_DISPLAY_X-28/RATIO, FULL_DISPLAY_Y-28/RATIO,
|
||||
0, 48/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y-48/RATIO,
|
||||
NULL, NULL, 20, 0);
|
||||
}
|
||||
|
||||
@ -1298,7 +1318,7 @@ static const char *menu_select_file_internal(char *dir_path,
|
||||
char *updir;
|
||||
int opt;
|
||||
int i;
|
||||
char buf[64];
|
||||
char buf[80];
|
||||
unsigned int block_pos;
|
||||
|
||||
if (!strcmp(dir_path,"browser")) file_list = get_file_list_browser(tape_pos, &block_pos);
|
||||
@ -1315,7 +1335,7 @@ static const char *menu_select_file_internal(char *dir_path,
|
||||
ptr_selected_file= strrchr(selected_file,'/');
|
||||
if (ptr_selected_file) ptr_selected_file++;
|
||||
else ptr_selected_file = selected_file;
|
||||
snprintf(buf,64,"Selected file:%s",ptr_selected_file);
|
||||
snprintf(buf,80,"Selected file:%s",ptr_selected_file);
|
||||
opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, 16, draw_scr);
|
||||
}
|
||||
else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,16, draw_scr);
|
||||
@ -1399,20 +1419,20 @@ const char *menu_select_file(char *dir_path,const char *selected_file, int draw_
|
||||
if (dir_path == NULL)
|
||||
dir_path = "";
|
||||
return menu_select_file_internal(dir_path,
|
||||
0, 20/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20/RATIO, selected_file, draw_scr, 0);
|
||||
0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, selected_file, draw_scr, 0);
|
||||
}
|
||||
|
||||
const char *menu_select_browser(unsigned int tape_pos)
|
||||
{
|
||||
return menu_select_file_internal("browser",
|
||||
0, 20/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20/RATIO, NULL, 0, tape_pos);
|
||||
0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, tape_pos);
|
||||
}
|
||||
|
||||
const char *menu_select_tape_block()
|
||||
{
|
||||
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
|
||||
return menu_select_file_internal("select_block",
|
||||
0, 20/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20/RATIO, NULL, 0, 0);
|
||||
0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1451,26 +1471,27 @@ static TTF_Font *read_font(const char *path, int font_size)
|
||||
|
||||
void font_init()
|
||||
{
|
||||
char *font_path;
|
||||
char *font_path,*font_path2;
|
||||
|
||||
TTF_Init();
|
||||
|
||||
font_path=myfile("fbzx/FreeMono.ttf");
|
||||
font_path=myfile("fbzx/ZX_Spectrum.ttf");
|
||||
font_path2=myfile("fbzx/ZX_Spectrum_narrow.ttf");
|
||||
|
||||
menu_font16 = read_font(font_path, 16);
|
||||
menu_font20 = read_font(font_path, 20);
|
||||
menu_font8 = read_font(font_path, 8);
|
||||
menu_font10 = read_font(font_path, 10);
|
||||
menu_font_large = read_font(font_path, 16);//Used for menu
|
||||
menu_font_alt_large = read_font(font_path2, 16); //Used for file selection
|
||||
menu_font_small = read_font(font_path, 8);
|
||||
menu_font_alt_small = read_font(font_path2, 8);
|
||||
|
||||
free(font_path);
|
||||
}
|
||||
|
||||
void font_fini()
|
||||
{
|
||||
TTF_CloseFont(menu_font16);
|
||||
TTF_CloseFont(menu_font20);
|
||||
TTF_CloseFont(menu_font8);
|
||||
TTF_CloseFont(menu_font10);
|
||||
TTF_CloseFont(menu_font_alt_large);
|
||||
TTF_CloseFont(menu_font_large);
|
||||
TTF_CloseFont(menu_font_alt_small);
|
||||
TTF_CloseFont(menu_font_small);
|
||||
|
||||
TTF_Quit();
|
||||
}
|
||||
@ -1492,6 +1513,11 @@ int menu_is_inited(void)
|
||||
return is_inited;
|
||||
}
|
||||
|
||||
void play_click(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int ask_value_sdl(int *final_value,int y_coord,int max_value) {
|
||||
|
||||
unsigned char nombre2[50];
|
||||
|
@ -80,4 +80,6 @@ int ask_filename_sdl(char *nombre_final,int y_coord,char *extension, char *path,
|
||||
|
||||
const char *menu_select_tape_block();
|
||||
|
||||
void play_click(void);
|
||||
|
||||
#endif /* !__MENU_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user