Add pause/unpause to the menu

This commit is contained in:
simon.kagstrom 2010-01-10 19:57:45 +00:00
parent 197e7aadb6
commit 4b1c10c7be
3 changed files with 66 additions and 24 deletions

View File

@ -39,6 +39,8 @@ public:
MainMenu(Font *font, HelpBox *help) : Menu(font)
{
this->help = help;
this->updatePauseState();
}
virtual void selectCallback(int which)
@ -46,15 +48,19 @@ public:
printf("entry %d selected: %s\n", which, this->pp_msgs[which]);
switch (which)
{
case 0: /* Insert disc */
case 0:
TheC64->IsPaused() ? TheC64->Resume() : TheC64->Pause();
this->updatePauseState();
break;
case 2: /* Insert disc */
if (this->p_submenus[0].sel == 0) {
Gui::gui->dv->setDirectory("discs");
Gui::gui->pushView(Gui::gui->dv);
}
break;
case 2: /* Load/save states */
case 4: /* Load/save states */
break;
case 4: /* Keyboard */
case 6: /* Keyboard */
switch(this->p_submenus[2].sel)
{
case 0:
@ -70,19 +76,16 @@ public:
panic("Illegal selection\n");
}
break;
case 7: /* Reset the C64 */
case 9: /* Reset the C64 */
printf("Resetting the C64\n");
break;
case 8: /* Networking */
case 10: /* Networking */
Gui::gui->pushView(Gui::gui->nv);
break;
case 9: /* Options */
case 11: /* Options */
Gui::gui->pushView(Gui::gui->ov);
break;
case 10: /* Help */
break;
case 11: /* Exit */
case 12: /* Exit */
DialogueBox *exit_dialogue = new DialogueBox(exit_dialogue_messages);
exit_dialogue->registerListener(new ExitListener());
Gui::gui->pushDialogueBox(exit_dialogue);
@ -101,6 +104,15 @@ public:
}
private:
void updatePauseState()
{
if (TheC64->IsPaused())
main_menu_messages[0] = "Resume";
else
main_menu_messages[0] = "Pause";
this->setText(main_menu_messages);
}
HelpBox *help;
};
@ -112,7 +124,6 @@ public:
{
this->help = new HelpBox(NULL, main_menu_help);
this->menu = new MainMenu(NULL, this->help);
this->menu->setText(main_menu_messages);
}
~MainView()

View File

@ -60,22 +60,31 @@ const char **select_analogue_dlg = (const char*[]){
const char **main_menu_messages = (const char*[]){
/*00*/ "File",
/*01*/ "^|Insert|Start",
/*02*/ "States",
/*03*/ "^|Load|Save|Delete",
/*04*/ "Keyboard",
/*05*/ "^|Type|Macro|Bind",
/*06*/ " ",
/*07*/ "Reset the C=64",
/*08*/ "Networking",
/*09*/ "Options",
/*10*/ "Help",
/*11*/ "Quit",
/*00*/ NULL, /* Setup dynamically */
/*01*/ " ",
/*02*/ "File",
/*03*/ "^|Insert|Start",
/*04*/ "States",
/*05*/ "^|Load|Save|Delete",
/*06*/ "Keyboard",
/*07*/ "^|Type|Macro|Bind",
/*08*/ " ",
/*09*/ "Reset the C=64",
/*10*/ "Networking",
/*11*/ "Options",
/*12*/ "Quit",
NULL
};
const char **main_menu_help[] = {
(const char*[]){
"Pause or resume the C64",
"emulation. Not available",
"when running in networked",
"mode.",
NULL,
},
NULL,
(const char*[]){
"Insert a disc/tape or",
"start it",
@ -97,7 +106,6 @@ const char **main_menu_help[] = {
},
NULL,
NULL,
NULL,
(const char*[]){
"Network setup for playing",
"C64 games against other",

View File

@ -13,7 +13,30 @@ enum
class C64
{
public:
C64()
{
this->have_a_break = false;
}
void Pause()
{
this->have_a_break = true;
}
void Resume()
{
this->have_a_break = false;
}
bool IsPaused()
{
return this->have_a_break;
}
int network_connection_type;
private:
bool have_a_break;
};
extern C64 *TheC64;