Finish the options menu implementation (hooray!)

This commit is contained in:
simon.kagstrom 2010-01-02 16:00:00 +00:00
parent 8aaeee4327
commit 292d107d72
3 changed files with 66 additions and 20 deletions

View File

@ -13,7 +13,7 @@ widget.oo: widget.cpp widget.hh
gui.oo: gui.cpp gui.hh Makefile font.hh menu.hh sdl_ttf_font.hh \
dialogue_box.hh help_box.hh main_menu.cpp disc_menu.cpp \
file_browser.hh timer.hh game_info.hh widget.hh options_menu.cpp \
network_menu.cpp mocks/Prefs.h
network_menu.cpp mocks/Prefs.h mocks/C64.h
virtual_keyboard.oo: virtual_keyboard.hh virtual_keyboard.cpp widget.hh listener.hh

View File

@ -3,6 +3,10 @@
#include <string.h>
#define SPEED_95 30
#define SPEED_100 20
#define SPEED_110 18
class Prefs
{
public:
@ -11,11 +15,20 @@ public:
strcpy(this->NetworkName, "Unset name");
strcpy(this->NetworkServer, "play.c64-network.org");
this->NetworkPort = 46214;
this->Emul1541Proc = 0;
this->ShowLEDs = 0;
this->DisplayOption = 0;
this->MsPerFrame = SPEED_100;
}
char NetworkName[32];
char NetworkServer[128];
int NetworkPort;
int Emul1541Proc;
int ShowLEDs;
int DisplayOption;
unsigned int MsPerFrame;
};
#endif /* __MOCK_PREFS_HH__ */

View File

@ -11,6 +11,7 @@ public:
OptionsMenu(Font *font, HelpBox *help) : Menu(font)
{
this->help = help;
this->setText(options_menu_messages);
}
~OptionsMenu()
@ -19,24 +20,9 @@ public:
virtual void selectCallback(int which)
{
printf("option entry %d selected: %s\n", which, this->pp_msgs[which]);
switch (which)
{
case 0: /* Insert disc */
break;
case 2: /* Load/save states */
break;
case 4: /* Keyboard */
break;
case 7: /* Reset the C64 */
break;
case 8: /* Networking */
break;
case 9: /* Options */
break;
case 10: /* Help */
break;
}
/* Doesn't matter which, it's just selection */
this->updatePrefs();
Gui::gui->popView();
}
virtual void hoverCallback(int which)
@ -46,9 +32,52 @@ public:
virtual void escapeCallback(int which)
{
this->updatePrefs();
Gui::gui->popView();
}
void updatePrefs()
{
Gui::gui->np->Emul1541Proc = !this->p_submenus[1].sel;
Gui::gui->np->ShowLEDs = !this->p_submenus[2].sel;
Gui::gui->np->DisplayOption = this->p_submenus[3].sel;
switch (this->p_submenus[4].sel)
{
case 0:
Gui::gui->np->MsPerFrame = SPEED_95; break;
case 1:
Gui::gui->np->MsPerFrame = SPEED_100; break;
case 2:
Gui::gui->np->MsPerFrame = SPEED_110; break;
default:
panic("Impossible submenu value: %d\n", this->p_submenus[4].sel);
}
}
void updateSubmenus()
{
int submenu_defs[5];
submenu_defs[0] = 0;
submenu_defs[1] = !Gui::gui->np->Emul1541Proc;
submenu_defs[2] = !Gui::gui->np->ShowLEDs;
submenu_defs[3] = Gui::gui->np->DisplayOption;
switch (Gui::gui->np->MsPerFrame)
{
case SPEED_95:
submenu_defs[4] = 0; break;
case SPEED_110:
submenu_defs[4] = 2; break;
default:
/* If it has some other value... */
submenu_defs[4] = 1; break;
}
this->setText(options_menu_messages, submenu_defs);
}
private:
HelpBox *help;
};
@ -61,7 +90,6 @@ public:
{
this->help = new HelpBox(NULL, options_menu_help);
this->menu = new OptionsMenu(NULL, this->help);
this->menu->setText(options_menu_messages);
}
~OptionsView()
@ -79,6 +107,11 @@ public:
Gui::gui->bg_submenu_middle, Gui::gui->bg_submenu_right);
}
void viewPushCallback()
{
this->menu->updateSubmenus();
}
void runLogic()
{
this->menu->runLogic();