2010-01-25 14:01:22 +01:00
|
|
|
#include "gui.hh"
|
|
|
|
#include "menu.hh"
|
|
|
|
#include "help_box.hh"
|
|
|
|
#include "status_bar.hh"
|
|
|
|
|
|
|
|
#include <Prefs.h>
|
|
|
|
|
|
|
|
class OptionsView;
|
|
|
|
class OptionsMenu : public Menu
|
|
|
|
{
|
|
|
|
friend class OptionsView;
|
|
|
|
|
|
|
|
public:
|
|
|
|
OptionsMenu(Font *font, HelpBox *help) : Menu(font)
|
|
|
|
{
|
|
|
|
this->help = help;
|
|
|
|
this->setText(options_menu_messages);
|
|
|
|
}
|
|
|
|
|
|
|
|
~OptionsMenu()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void selectCallback(int which)
|
2011-06-17 21:36:52 +02:00
|
|
|
{
|
2010-01-25 14:01:22 +01:00
|
|
|
/* Select theme */
|
2011-06-17 21:36:52 +02:00
|
|
|
|
|
|
|
if (which == 13)
|
2010-01-25 14:01:22 +01:00
|
|
|
{
|
|
|
|
Gui::gui->tv->setDirectory(Gui::gui->theme_base_path);
|
|
|
|
Gui::gui->pushView(Gui::gui->tv);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Doesn't matter which otherwise, it's just selection */
|
|
|
|
this->updatePrefs();
|
|
|
|
Gui::gui->popView();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void hoverCallback(int which)
|
|
|
|
{
|
|
|
|
this->help->updateHelpMessage(which);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void escapeCallback(int which)
|
|
|
|
{
|
|
|
|
this->updatePrefs();
|
|
|
|
Gui::gui->popView();
|
|
|
|
}
|
|
|
|
|
|
|
|
void updatePrefs()
|
|
|
|
{
|
2010-01-25 17:31:20 +01:00
|
|
|
Gui::gui->np->JoystickSwap = !this->p_submenus[0].sel;
|
2010-01-25 14:01:22 +01:00
|
|
|
Gui::gui->np->Emul1541Proc = !this->p_submenus[1].sel;
|
2010-02-28 19:16:41 +01:00
|
|
|
Gui::gui->np->DisplayType = this->p_submenus[2].sel == 0 ? DISPTYPE_WINDOW : DISPTYPE_SCREEN;
|
2010-01-25 14:01:22 +01:00
|
|
|
|
2010-02-28 19:16:41 +01:00
|
|
|
switch (this->p_submenus[3].sel)
|
2010-01-25 14:01:22 +01:00
|
|
|
{
|
|
|
|
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:
|
2011-06-05 15:46:38 +02:00
|
|
|
panic("Impossible submenu value: %d\n", this->p_submenus[3].sel);
|
2010-01-25 14:01:22 +01:00
|
|
|
}
|
2011-06-05 15:46:38 +02:00
|
|
|
Gui::gui->np->Usbport = !this->p_submenus[4].sel;
|
2011-06-17 21:36:52 +02:00
|
|
|
Gui::gui->np->Rumble = !this->p_submenus[5].sel;
|
|
|
|
|
2010-01-25 14:01:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void updateSubmenus()
|
|
|
|
{
|
2011-06-17 21:36:52 +02:00
|
|
|
int submenu_defs[6];
|
2010-01-25 14:01:22 +01:00
|
|
|
|
2010-01-25 17:31:20 +01:00
|
|
|
submenu_defs[0] = Gui::gui->np->JoystickSwap == true ? 0 : 1;
|
2010-01-25 14:01:22 +01:00
|
|
|
submenu_defs[1] = !Gui::gui->np->Emul1541Proc;
|
2010-02-28 19:16:41 +01:00
|
|
|
submenu_defs[2] = Gui::gui->np->DisplayType == DISPTYPE_SCREEN;
|
2010-01-25 14:01:22 +01:00
|
|
|
|
|
|
|
switch (Gui::gui->np->MsPerFrame)
|
|
|
|
{
|
|
|
|
case SPEED_95:
|
2010-02-28 19:16:41 +01:00
|
|
|
submenu_defs[3] = 0; break;
|
2010-01-25 14:01:22 +01:00
|
|
|
case SPEED_110:
|
2010-02-28 19:16:41 +01:00
|
|
|
submenu_defs[3] = 2; break;
|
2010-01-25 14:01:22 +01:00
|
|
|
default:
|
|
|
|
/* If it has some other value... */
|
2010-02-28 19:16:41 +01:00
|
|
|
submenu_defs[3] = 1; break;
|
2010-01-25 14:01:22 +01:00
|
|
|
}
|
2011-06-05 15:46:38 +02:00
|
|
|
|
|
|
|
submenu_defs[4] = !Gui::gui->np->Usbport;
|
2011-06-17 21:36:52 +02:00
|
|
|
submenu_defs[5] = !Gui::gui->np->Rumble;
|
2010-01-25 14:01:22 +01:00
|
|
|
this->setText(options_menu_messages, submenu_defs);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
HelpBox *help;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class OptionsView : public GuiView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OptionsView() : GuiView()
|
|
|
|
{
|
|
|
|
this->help = new HelpBox(Gui::gui->small_font, options_menu_help);
|
|
|
|
this->menu = new OptionsMenu(Gui::gui->default_font, this->help);
|
|
|
|
}
|
|
|
|
|
|
|
|
~OptionsView()
|
|
|
|
{
|
|
|
|
delete this->help;
|
|
|
|
delete this->menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void viewPushCallback()
|
|
|
|
{
|
|
|
|
this->menu->updateSubmenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void runLogic()
|
|
|
|
{
|
|
|
|
this->menu->runLogic();
|
|
|
|
}
|
|
|
|
|
2010-02-28 11:06:59 +01:00
|
|
|
void pushEvent(event_t ev)
|
2010-01-25 14:01:22 +01:00
|
|
|
{
|
|
|
|
this->menu->pushEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void draw(SDL_Surface *where)
|
|
|
|
{
|
|
|
|
SDL_Rect dst;
|
|
|
|
|
|
|
|
/* Blit the backgrounds */
|
|
|
|
dst = (SDL_Rect){20,45,300,400};
|
|
|
|
SDL_BlitSurface(Gui::gui->main_menu_bg, NULL, where, &dst);
|
|
|
|
|
|
|
|
dst = (SDL_Rect){350,13,0,0};
|
|
|
|
SDL_BlitSurface(Gui::gui->infobox, NULL, where, &dst);
|
|
|
|
|
|
|
|
dst = (SDL_Rect){350,242,0,0};
|
2010-02-28 09:02:45 +01:00
|
|
|
SDL_BlitSurface(Gui::gui->network_message_box, NULL, where, &dst);
|
2010-01-25 14:01:22 +01:00
|
|
|
|
|
|
|
this->menu->draw(where, 50, 70, 300, 400);
|
|
|
|
this->help->draw(where, 354, 24, 264, 210);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
OptionsMenu *menu;
|
|
|
|
HelpBox *help;
|
|
|
|
};
|