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

View File

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

View File

@ -13,7 +13,30 @@ enum
class C64 class C64
{ {
public: 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; int network_connection_type;
private:
bool have_a_break;
}; };
extern C64 *TheC64; extern C64 *TheC64;