2009-12-06 20:21:48 +01:00
|
|
|
#include "menu.hh"
|
2009-12-31 14:25:46 +01:00
|
|
|
#include "dialogue_box.hh"
|
2009-12-06 20:21:48 +01:00
|
|
|
|
2009-12-26 11:18:55 +01:00
|
|
|
class KeyboardTypingListener : public KeyboardListener
|
2009-12-26 10:16:19 +01:00
|
|
|
{
|
|
|
|
virtual void stringCallback(const char *str)
|
|
|
|
{
|
|
|
|
printf("string: %s\n", str);
|
|
|
|
/* Remove thyself! */
|
|
|
|
delete this;
|
|
|
|
}
|
2009-12-26 11:18:55 +01:00
|
|
|
|
|
|
|
virtual void keyCallback(bool shift, const char *str)
|
|
|
|
{
|
|
|
|
printf("Vobb: %d: %s\n", shift, str);
|
|
|
|
}
|
2009-12-26 10:16:19 +01:00
|
|
|
};
|
|
|
|
|
2009-12-31 14:25:46 +01:00
|
|
|
class ExitListener : public DialogueListener
|
2009-12-06 10:06:25 +01:00
|
|
|
{
|
2009-12-31 14:25:46 +01:00
|
|
|
void escapeCallback(DialogueBox *which, int selected)
|
2009-12-06 10:06:25 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-31 14:25:46 +01:00
|
|
|
void selectCallback(DialogueBox *which, int selected)
|
2009-12-06 10:06:25 +01:00
|
|
|
{
|
2010-01-02 13:07:35 +01:00
|
|
|
/* Cancel? */
|
|
|
|
if (selected != 1)
|
2009-12-31 14:25:46 +01:00
|
|
|
exit(0);
|
2009-12-06 10:06:25 +01:00
|
|
|
}
|
2009-12-31 14:25:46 +01:00
|
|
|
};
|
2009-12-06 10:06:25 +01:00
|
|
|
|
2009-12-31 14:25:46 +01:00
|
|
|
class MainView;
|
|
|
|
class MainMenu : public Menu
|
|
|
|
{
|
|
|
|
friend class MainView;
|
2009-12-06 10:06:25 +01:00
|
|
|
|
2009-12-31 14:25:46 +01:00
|
|
|
public:
|
|
|
|
MainMenu(Font *font, HelpBox *help) : Menu(font)
|
2009-12-06 10:06:25 +01:00
|
|
|
{
|
2009-12-31 14:25:46 +01:00
|
|
|
this->help = help;
|
2009-12-06 10:06:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void selectCallback(int which)
|
|
|
|
{
|
|
|
|
printf("entry %d selected: %s\n", which, this->pp_msgs[which]);
|
|
|
|
switch (which)
|
|
|
|
{
|
2009-12-28 13:38:41 +01:00
|
|
|
case 0: /* Insert disc */
|
2009-12-13 11:02:27 +01:00
|
|
|
if (this->p_submenus[0].sel == 0) {
|
|
|
|
Gui::gui->dv->setDirectory("discs");
|
|
|
|
Gui::gui->pushView(Gui::gui->dv);
|
|
|
|
}
|
2009-12-06 20:21:48 +01:00
|
|
|
break;
|
2009-12-28 13:38:41 +01:00
|
|
|
case 2: /* Load/save states */
|
|
|
|
break;
|
|
|
|
case 4: /* Keyboard */
|
2010-01-02 13:28:18 +01:00
|
|
|
VirtualKeyboard::kbd->activate();
|
|
|
|
VirtualKeyboard::kbd->registerListener(new KeyboardTypingListener());
|
2009-12-19 20:17:25 +01:00
|
|
|
break;
|
2009-12-28 13:38:41 +01:00
|
|
|
case 7: /* Reset the C64 */
|
|
|
|
printf("Resetting the C64\n");
|
|
|
|
break;
|
|
|
|
case 8: /* Networking */
|
2009-12-29 14:23:01 +01:00
|
|
|
Gui::gui->pushView(Gui::gui->nv);
|
2009-12-28 13:38:41 +01:00
|
|
|
break;
|
|
|
|
case 9: /* Options */
|
|
|
|
Gui::gui->pushView(Gui::gui->ov);
|
|
|
|
break;
|
|
|
|
case 10: /* Help */
|
|
|
|
break;
|
2009-12-06 20:21:48 +01:00
|
|
|
|
2009-12-28 13:38:41 +01:00
|
|
|
case 11: /* Exit */
|
2010-01-02 13:07:35 +01:00
|
|
|
DialogueBox *exit_dialogue = new DialogueBox(exit_dialogue_messages);
|
2009-12-31 14:25:46 +01:00
|
|
|
exit_dialogue->registerListener(new ExitListener());
|
|
|
|
Gui::gui->pushDialogueBox(exit_dialogue);
|
2009-12-06 10:06:25 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void hoverCallback(int which)
|
|
|
|
{
|
|
|
|
this->help->updateHelpMessage(which);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void escapeCallback(int which)
|
|
|
|
{
|
2009-12-13 09:59:06 +01:00
|
|
|
Gui::gui->exitMenu();
|
2009-12-06 10:06:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
HelpBox *help;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class MainView : public GuiView
|
|
|
|
{
|
|
|
|
public:
|
2009-12-13 09:59:06 +01:00
|
|
|
MainView() : GuiView()
|
2009-12-06 10:06:25 +01:00
|
|
|
{
|
|
|
|
this->help = new HelpBox(NULL, main_menu_help);
|
2009-12-28 09:46:18 +01:00
|
|
|
this->menu = new MainMenu(NULL, this->help);
|
2009-12-06 10:06:25 +01:00
|
|
|
this->menu->setText(main_menu_messages);
|
|
|
|
}
|
|
|
|
|
2009-12-06 20:21:48 +01:00
|
|
|
~MainView()
|
|
|
|
{
|
|
|
|
delete this->help;
|
|
|
|
delete this->menu;
|
|
|
|
}
|
|
|
|
|
2009-12-06 10:06:25 +01:00
|
|
|
void updateTheme()
|
|
|
|
{
|
2009-12-13 09:59:06 +01:00
|
|
|
this->menu->setFont(Gui::gui->default_font);
|
|
|
|
this->help->setFont(Gui::gui->small_font);
|
|
|
|
this->menu->setSelectedBackground(Gui::gui->bg_left, Gui::gui->bg_middle,
|
|
|
|
Gui::gui->bg_right, Gui::gui->bg_submenu_left,
|
|
|
|
Gui::gui->bg_submenu_middle, Gui::gui->bg_submenu_right);
|
2009-12-06 10:06:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void runLogic()
|
|
|
|
{
|
|
|
|
this->menu->runLogic();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pushEvent(SDL_Event *ev)
|
|
|
|
{
|
|
|
|
this->menu->pushEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void draw(SDL_Surface *where)
|
|
|
|
{
|
|
|
|
SDL_Rect dst;
|
|
|
|
|
|
|
|
/* Blit the backgrounds */
|
|
|
|
dst = (SDL_Rect){20,45,300,400};
|
2009-12-28 09:46:18 +01:00
|
|
|
SDL_BlitSurface(Gui::gui->main_menu_bg, NULL, where, &dst);
|
2009-12-06 10:06:25 +01:00
|
|
|
|
|
|
|
dst = (SDL_Rect){350,13,0,0};
|
2009-12-28 09:46:18 +01:00
|
|
|
SDL_BlitSurface(Gui::gui->infobox, NULL, where, &dst);
|
2009-12-06 10:06:25 +01:00
|
|
|
|
|
|
|
dst = (SDL_Rect){350,242,0,0};
|
2009-12-28 09:46:18 +01:00
|
|
|
SDL_BlitSurface(Gui::gui->textbox, NULL, where, &dst);
|
2009-12-06 10:06:25 +01:00
|
|
|
|
|
|
|
this->menu->draw(where, 50, 70, 300, 400);
|
|
|
|
this->help->draw(where, 354, 24, 264, 210);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MainMenu *menu;
|
|
|
|
HelpBox *help;
|
|
|
|
};
|