Integrate new menu system from Holger

This commit is contained in:
simon.kagstrom 2009-04-19 12:57:29 +00:00
parent fb7de09d4c
commit b424598a6b
4 changed files with 111 additions and 75 deletions

View File

@ -210,15 +210,16 @@ public:
void network_vblank();
void select_disc(Prefs *np);
void select_fake_key_sequence(Prefs *np);
void select_disc(Prefs *np, bool start);
void start_fake_key_sequence(const char *str);
void run_fake_key_sequence();
char * bind_one_key(Prefs *np, int which);
void bind_keys(Prefs *np);
void select_fake_key_sequence(Prefs *np);
void advanced_options(Prefs *np);
void other_options(Prefs *np);
void networking_menu(Prefs *np);
void save_load_state(Prefs *np);
void save_load_state(Prefs *np, int do_what);
#endif
#ifdef WIN32

View File

@ -101,9 +101,15 @@ void C64::c64_dtor(void)
{
}
void C64::select_disc(Prefs *np)
void C64::select_disc(Prefs *np, bool start)
{
const char *name = menu_select_file(IMAGE_PATH);
const char *name;
const char *d64_name = NULL;
if (!start)
name = menu_select_file(IMAGE_PATH);
else
name = menu_select_file_start(IMAGE_PATH, &d64_name);
if (name== NULL)
return;
@ -155,6 +161,18 @@ void C64::select_disc(Prefs *np)
/* Cleanup*/
free((void*)name);
/* And maybe start the game */
if (d64_name)
{
static char buf[255];
snprintf(buf, 255, "\nLOAD \"%s\",8,1\nRUN\n", d64_name);
this->start_fake_key_sequence((const char*)buf);
free((void*)d64_name);
}
else if (start)
this->start_fake_key_sequence("\nLOAD \"*\",8,1\nRUN\n");
}
@ -275,10 +293,10 @@ void C64::networking_menu(Prefs *np)
this->prefs_changed = true;
}
void C64::other_options(Prefs *np)
void C64::advanced_options(Prefs *np)
{
int submenus[3] = { np->DisplayOption, 0, !np->Emul1541Proc };
int submenus[4] = { np->DisplayOption, 0,
np->SpriteCollisions, 0 };
#define SPEED_95 30
#define SPEED_100 20
@ -294,11 +312,13 @@ void C64::other_options(Prefs *np)
/* If it has some other value... */
submenus[1] = 1; break;
}
int opt = menu_select(other_options_messages, submenus);
int opt = menu_select(new_advanced_options_menu_messages,
submenus);
if (opt >= 0)
{
np->DisplayOption = submenus[0];
np->Emul1541Proc = submenus[2] == 0 ? true : false;
np->SpriteCollisions = submenus[2];
switch(submenus[1])
{
@ -311,8 +331,20 @@ void C64::other_options(Prefs *np)
np->MsPerFrame = SPEED_110; break;
}
if (opt == 6)
Reset();
this->prefs_changed = true;
}
}
void C64::other_options(Prefs *np)
{
int old_swap = ThePrefs.JoystickSwap == true ? 1 : 0;
int submenus[3] = { old_swap, !np->Emul1541Proc, 0 };
int opt = menu_select(new_options_menu_messages,
submenus);
if (opt >= 0)
{
np->Emul1541Proc = submenus[1] == 0 ? true : false;
this->prefs_changed = true;
}
@ -358,7 +390,6 @@ void C64::select_fake_key_sequence(Prefs *np)
"LOAD \"*\",8,1 and RUN",
"LOAD \"$\",8",
"LIST",
"Type with virtual keyboard",
NULL};
int opt;
@ -366,20 +397,11 @@ void C64::select_fake_key_sequence(Prefs *np)
if (opt < 0)
return;
if (opt == 3)
{
const char *seq = this->virtual_keyboard->get_string();
if (seq != NULL)
this->start_fake_key_sequence(seq);
}
else
this->start_fake_key_sequence(fake_key_sequences[opt]);
this->start_fake_key_sequence(fake_key_sequences[opt]);
}
void C64::save_load_state(Prefs *np)
void C64::save_load_state(Prefs *np, int opt)
{
int opt = menu_select(save_load_state_messages, NULL);
switch(opt)
{
case 1: /* save */
@ -626,40 +648,57 @@ void C64::VBlank(bool draw_frame)
}
if (this->have_a_break) {
int submenus[1];
int submenus[3] = {1, 0, 0};
int opt;
int old_swap = ThePrefs.JoystickSwap == true ? 1 : 0;
Prefs np = ThePrefs;
this->prefs_changed = false;
TheSID->PauseSound();
submenus[0] = old_swap;
opt = menu_select(main_menu_messages, submenus);
opt = menu_select(new_main_menu_messages, submenus);
switch(opt)
{
case 0: /* Load disc/tape */
this->select_fake_key_sequence(&np);
case 2: /* Insert disc/tape */
this->select_disc(&np, submenus[0] == 1);
break;
case 1: /* Insert disc/tape */
this->select_disc(&np);
case 4: /* Save / load game */
this->save_load_state(&np, submenus[1]);
break;
case 2: /* Bind keys to joystick */
this->bind_keys(&np);
case 6: /* Bind keys to joystick */
switch (submenus[2])
{
case 0: /* type */
{
const char *seq = this->virtual_keyboard->get_string();
if (seq != NULL)
this->start_fake_key_sequence(seq);
} break;
case 1: /* Macro */
this->select_fake_key_sequence(&np); break;
default:
case 2: /* Bind to controller */
this->bind_keys(&np); break;
}
break;
case 3: /* Other options */
this->other_options(&np);
case 9: /* Reset the C64 */
Reset();
break;
case 4: /* Networking */
case 10: /* Networking */
this->networking_menu(&np);
break;
case 5: /* Swap joysticks */
case 11: /* Other options */
this->other_options(&np);
break;
case 7: /* Save / load game */
this->save_load_state(&np);
case 12: /* Advanced options */
this->advanced_options(&np);
break;
case 9: /* Quit */
case 13:
{
menu_select(welcome, NULL);
} break;
case 15: /* Quit */
quit_thyself = true;
break;
case -1:
@ -670,8 +709,6 @@ void C64::VBlank(bool draw_frame)
np.JoystickSwap = false;
else
np.JoystickSwap = true;
if (submenus[0] != old_swap)
this->prefs_changed = true;
if (this->prefs_changed)
{
@ -683,7 +720,7 @@ void C64::VBlank(bool draw_frame)
this->have_a_break = false;
if (this->quit_thyself)
ThePrefs.Save(PREFS_PATH);
ThePrefs.Save((const char*)PREFS_PATH);
}
this->network_vblank();

View File

@ -311,7 +311,7 @@ static submenu_t *find_submenu(menu_t *p_menu, int index)
void menu_print_font(SDL_Surface *screen, int r, int g, int b,
int x, int y, const char *msg)
{
#define _MAX_STRING 24
#define _MAX_STRING 64
SDL_Surface *font_surf;
SDL_Rect dst = {x, y, 0, 0};
SDL_Color color = {r, g, b};
@ -353,7 +353,7 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
void menu_print_font64(SDL_Surface *screen, int r, int g, int b, int x, int y, const char *msg)
{
#undef _MAX_STRING
#define _MAX_STRING 26
#define _MAX_STRING 64
SDL_Surface *font_surf;
SDL_Rect dst = {x, y, 0, 0};
SDL_Color color = {r, g, b};
@ -1010,10 +1010,12 @@ const char *menu_select_file_start(const char *dir_path, const char **d64_name)
{
const char *file = menu_select_file_internal(dir_path,
0, 0, FULL_DISPLAY_X/2, FULL_DISPLAY_Y);
const char *exts[] = {".d64", ".D64", NULL};
if (!file)
return NULL;
*d64_name = get_d64_file(file);
if (ext_matches_list(file, exts))
*d64_name = get_d64_file(file);
return file;
}

View File

@ -10,37 +10,36 @@ const char *welcome[] = {
/*05*/ " PRG image. Use the virtual keyboard or assign the ",
/*06*/ " key strokes to buttons on the Wiimote. ",
/*07*/ " Save the game state in the main menu of the game. ",
/*08*/ " Next time you can load that state instead of the ",
/*09*/ " game to have all configured stuff along with that ",
/*10*/ " game. ",
/*11*/ " ",
/*12*/ " This version features USB-keyboard support and ",
/*13*/ " D64 content listing. Use first Wiimote as port 1 ",
/*14*/ " joystick and the second as port 2 joystick. ",
/*08*/ " Next time you can load that state instead and have",
/*09*/ " the game and everything configured directly. ",
/*10*/ " ",
/*11*/ " In the networking menu, you can host a game over ",
/*12*/ " the network or browse for active games. During ",
/*13*/ " network play, you can send messages to your peer ",
/*14*/ " by pressing ScrLk on the USB keyboard. ",
/*15*/ " ",
/*16*/ ".-------------------------------------------------.",
/*17*/ "^| Enter Frodo | Don't show again ",
NULL
};
const char *new_main_menu_messages[] = {
/*00*/ "#1.MAIN MENU ",
/*01*/ "#1-------------------------------------",
/*02*/ ".Image",
/*03*/ "^|Load|Start|Remove",
/*02*/ ".File",
/*03*/ "^|Insert|Start",
/*04*/ ".States",
/*05*/ "^|Load|Save|Delete|Rename ",
/*05*/ "^|Load|Save|Delete",
/*06*/ ".Keyboard",
/*07*/ "^|Type|Macro|Bind",
/*08*/ "#1-------------------------------------",
/*09*/ ".Reset the C=64",
/*10*/ ".Options",
/*11*/ ".Advanced Options",
/*12*/ ".Controls",
/*13*/ "#1-------------------------------------",
/*14*/ ".Quit",
/*15*/ "#1-------------------------------------",
/*16*/ "#1'2'=SELECT, '1'=CANCEL",
/*10*/ ".Networking",
/*11*/ ".Options",
/*12*/ ".Advanced Options",
/*13*/ ".Help",
/*14*/ "#1-------------------------------------",
/*15*/ ".Quit",
/*17*/ "#1'2'=SELECT, '1'=CANCEL",
NULL
};
const char *new_options_menu_messages[] = {
@ -52,8 +51,8 @@ const char *new_options_menu_messages[] = {
/*05*/ ".True 1541 emulation",
/*06*/ "^|NO|YES",
/*07*/ " ",
/*08*/ ".1541 Floppy Drive LED", /* 0 */
/*09*/ "^|OFF|ON",
/*08*/ ".1541 Floppy Drive LED", /* 0 */
/*09*/ "^|OFF|ON",
/*10*/ "#1-------------------------------------",
/*11*/ "#1'2'=SELECT, '1'=CANCEL",
NULL
@ -61,23 +60,20 @@ const char *new_options_menu_messages[] = {
const char *new_advanced_options_menu_messages[] = {
/*00*/ "#1.ADVANCED OPTIONS MENU ",
/*01*/ "#1-------------------------------------",
/*02*/ ".Display resolution", /* 0 */
/*02*/ ".Display resolution",
/*03*/ "^|double-center|stretched",
/*04*/ " ",
/*05*/ ".Speed (approx.)", /* 2 */
/*05*/ ".Speed (approx.)",
/*06*/ "^|95|100|110",
/*07*/ " ",
/*08*/ ".Sprite collisions", /* 0 */
/*07*/ " ",
/*08*/ ".Sprite collisions",
/*09*/ "^|OFF|ON",
/*10*/ " ",
/*11*/ ".Autostart", /* 0 */
/*12*/ "^|Save|Clear", /* 0 */
/*13*/ "#1-------------------------------------",
/*14*/ "#1'2'=SELECT, '1'=CANCEL",
NULL
};
const char *new_help_menu_messages[] = {
/*00*/ "#1.CONTROLS MENU ",
/*00*/ "#1.HELP MENU ",
/*01*/ "#1-------------------------------------",
/*02*/ ".Wiimote key mappings", /* 0 */
/*03*/ "^|Wiimote Info|Set Default", /* 0 */