From 4b1c10c7be0304334e7fc4a14aae0e3c319e9b54 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 10 Jan 2010 19:57:45 +0000 Subject: [PATCH] Add pause/unpause to the menu --- main_menu.cpp | 33 ++++++++++++++++++++++----------- menu_messages.cpp | 34 +++++++++++++++++++++------------- mocks/C64.h | 23 +++++++++++++++++++++++ 3 files changed, 66 insertions(+), 24 deletions(-) diff --git a/main_menu.cpp b/main_menu.cpp index c7e7ca2..9eeabab 100644 --- a/main_menu.cpp +++ b/main_menu.cpp @@ -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() diff --git a/menu_messages.cpp b/menu_messages.cpp index d80624d..6346e10 100644 --- a/menu_messages.cpp +++ b/menu_messages.cpp @@ -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", diff --git a/mocks/C64.h b/mocks/C64.h index a16f67e..78a572c 100644 --- a/mocks/C64.h +++ b/mocks/C64.h @@ -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;