mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-16 20:39:15 +01:00
Add theme selection menu
This commit is contained in:
parent
3bce2ac0a0
commit
a286b4b355
2
Makefile
2
Makefile
@ -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 mocks/C64.h
|
||||
network_menu.cpp theme_menu.cpp mocks/Prefs.h mocks/C64.h
|
||||
|
||||
virtual_keyboard.oo: virtual_keyboard.hh virtual_keyboard.cpp widget.hh listener.hh
|
||||
|
||||
|
@ -72,7 +72,6 @@ public:
|
||||
virtual void escapeCallback(int which)
|
||||
{
|
||||
Gui::gui->timerController->disarm(this);
|
||||
Gui::gui->exitMenu();
|
||||
}
|
||||
};
|
||||
|
||||
|
4
gui.cpp
4
gui.cpp
@ -30,6 +30,7 @@ static const char *get_theme_path(const char *dir, const char *what)
|
||||
|
||||
/* These are a bit of special cases... */
|
||||
#include "disc_menu.cpp"
|
||||
#include "theme_menu.cpp"
|
||||
#include "options_menu.cpp"
|
||||
#include "network_menu.cpp"
|
||||
#include "main_menu.cpp"
|
||||
@ -88,10 +89,10 @@ Gui::Gui()
|
||||
this->dv = new DiscView();
|
||||
this->ov = new OptionsView();
|
||||
this->nv = new NetworkView();
|
||||
this->tv = new ThemeView();
|
||||
this->pushView(mv);
|
||||
}
|
||||
|
||||
|
||||
bool Gui::setTheme(const char *path)
|
||||
{
|
||||
this->bg_left = this->loadThemeImage(path, "bg_left.png");
|
||||
@ -151,6 +152,7 @@ bool Gui::setTheme(const char *path)
|
||||
this->dv->updateTheme();
|
||||
this->ov->updateTheme();
|
||||
this->nv->updateTheme();
|
||||
this->tv->updateTheme();
|
||||
|
||||
VirtualKeyboard::kbd->updateTheme();
|
||||
|
||||
|
7
gui.hh
7
gui.hh
@ -11,11 +11,14 @@
|
||||
/* Frodo stuff */
|
||||
#include <Prefs.h>
|
||||
|
||||
class MainView;
|
||||
class DialogueBox;
|
||||
|
||||
class MainView;
|
||||
class DiscView;
|
||||
class OptionsView;
|
||||
class NetworkView;
|
||||
class ThemeView;
|
||||
|
||||
class VirtualKeyboard;
|
||||
|
||||
class Gui
|
||||
@ -90,6 +93,8 @@ public:
|
||||
DiscView *dv;
|
||||
OptionsView *ov;
|
||||
NetworkView *nv;
|
||||
ThemeView *tv;
|
||||
|
||||
GuiView **views;
|
||||
int n_views;
|
||||
|
||||
|
@ -35,6 +35,19 @@ const char **network_unset_name_dlg = (const char*[]){
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **broken_theme_dlg = (const char*[]){
|
||||
/*00*/ "The selected theme cannot be",
|
||||
/*01*/ "loaded, probably something is",
|
||||
/*02*/ "broken in it. Reverting to",
|
||||
/*03*/ "default theme.",
|
||||
/*04*/ "#",
|
||||
/*05*/ "#",
|
||||
/*06*/ "#",
|
||||
/*07*/ "^|OK",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
const char **main_menu_messages = (const char*[]){
|
||||
/*00*/ "File",
|
||||
/*01*/ "^|Insert|Start",
|
||||
@ -90,16 +103,32 @@ const char **main_menu_help[] = {
|
||||
|
||||
|
||||
const char **options_menu_messages = (const char*[]){
|
||||
/*00*/ "Map Wiimote 1 to:",
|
||||
/*00*/ "Map Controller 1 to:",
|
||||
/*01*/ "^|Port 1|Port 2",
|
||||
/*03*/ "True 1541 emulation",
|
||||
/*04*/ "^|ON|OFF",
|
||||
/*06*/ "1541 Floppy Drive LED",
|
||||
/*07*/ "^|ON|OFF",
|
||||
/*09*/ "Display resolution",
|
||||
/*10*/ "^|double-center|stretched",
|
||||
/*12*/ "Speed (approx. %)",
|
||||
/*13*/ "^|95|100|110",
|
||||
/*02*/ "True 1541 emulation",
|
||||
/*03*/ "^|ON|OFF",
|
||||
/*04*/ "1541 Floppy Drive LED",
|
||||
/*05*/ "^|ON|OFF",
|
||||
/*06*/ "Display resolution",
|
||||
/*07*/ "^|double-center|stretched",
|
||||
/*08*/ "Speed (approx. %)",
|
||||
/*09*/ "^|95|100|110",
|
||||
/*10*/ " ",
|
||||
/*11*/ "Setup GUI theme",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char **bind_key_menu_messages = (const char*[]){
|
||||
/*00*/ "Bind Wiimote",
|
||||
/*01*/ "^|Up|Down|Left|Right|A|B|+|-",
|
||||
/*03*/ "Bind Nunchuk",
|
||||
/*04*/ "^|Up|Down|Z",
|
||||
/*06*/ "Bind Classic controller",
|
||||
/*07*/ "^|Up|Down|Left|X|Y|A|B|+|-|Zr|Zl",
|
||||
/*08*/ "Bind Classic controller (left analogue)",
|
||||
/*09*/ "^|Up|Down|Left|Right",
|
||||
/*08*/ "Bind Classic controller (right analogue)",
|
||||
/*09*/ "^|Up|Down|Left|Right",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -143,6 +172,13 @@ const char **options_menu_help[] = {
|
||||
NULL,
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
(const char*[]){
|
||||
"Setup theme for the Frodo",
|
||||
"menus.",
|
||||
NULL,
|
||||
},
|
||||
NULL,
|
||||
};
|
||||
|
||||
const char **network_menu_help[] = {
|
||||
|
@ -12,5 +12,6 @@ extern const char **options_menu_help[];
|
||||
extern const char **network_menu_help[];
|
||||
extern const char **network_port_dialogue_messages;
|
||||
extern const char **network_unset_name_dlg;
|
||||
extern const char **broken_theme_dlg;
|
||||
|
||||
#endif
|
||||
|
@ -7,11 +7,28 @@
|
||||
#define SPEED_100 20
|
||||
#define SPEED_110 18
|
||||
|
||||
enum
|
||||
{
|
||||
/* ASCII values before these */
|
||||
JOY_NONE = 0,
|
||||
JOY_HORIZ = 256,
|
||||
JOY_VERT = 258,
|
||||
JOY_FIRE = 259,
|
||||
};
|
||||
|
||||
/* Insanely high, but the Wii has insanely many of these */
|
||||
#define MAX_JOYSTICK_AXES 32
|
||||
#define MAX_JOYSTICK_BUTTONS 32
|
||||
|
||||
class Prefs
|
||||
{
|
||||
public:
|
||||
Prefs()
|
||||
{
|
||||
/* Set to NONE by default */
|
||||
memset(this->JoystickAxes, 0, sizeof(this->JoystickAxes));
|
||||
memset(this->JoystickButtons, 0, sizeof(this->JoystickButtons));
|
||||
|
||||
strcpy(this->NetworkName, "Unset name");
|
||||
strcpy(this->NetworkServer, "play.c64-network.org");
|
||||
this->NetworkPort = 46214;
|
||||
@ -29,6 +46,10 @@ public:
|
||||
int ShowLEDs;
|
||||
int DisplayOption;
|
||||
unsigned int MsPerFrame;
|
||||
|
||||
/* This is borrowed from UAE */
|
||||
int JoystickAxes[2][MAX_JOYSTICK_AXES];
|
||||
int JoystickButtons[2][MAX_JOYSTICK_BUTTONS];
|
||||
};
|
||||
|
||||
#endif /* __MOCK_PREFS_HH__ */
|
||||
|
@ -20,7 +20,15 @@ public:
|
||||
|
||||
virtual void selectCallback(int which)
|
||||
{
|
||||
/* Doesn't matter which, it's just selection */
|
||||
/* Select theme */
|
||||
if (which == 11)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
109
theme_menu.cpp
Normal file
109
theme_menu.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
#include "menu.hh"
|
||||
#include "file_browser.hh"
|
||||
|
||||
class ThemeMenu;
|
||||
|
||||
class ThemeView : public GuiView
|
||||
{
|
||||
public:
|
||||
ThemeView();
|
||||
|
||||
~ThemeView();
|
||||
|
||||
void pushEvent(SDL_Event *ev);
|
||||
|
||||
void setDirectory(const char *path);
|
||||
|
||||
/* Inherited */
|
||||
void updateTheme();
|
||||
|
||||
void runLogic();
|
||||
|
||||
void draw(SDL_Surface *where);
|
||||
|
||||
protected:
|
||||
ThemeMenu *menu;
|
||||
};
|
||||
|
||||
|
||||
class ThemeMenu : public FileBrowser
|
||||
{
|
||||
friend class ThemeView;
|
||||
|
||||
public:
|
||||
ThemeMenu(Font *font) :
|
||||
FileBrowser(NULL, font)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void selectCallback(int which)
|
||||
{
|
||||
char *p = xstrdup(this->pp_msgs[this->cur_sel]);
|
||||
|
||||
p[strlen(p) - 1] = '\0';
|
||||
if (!Gui::gui->setTheme(p + 1))
|
||||
{
|
||||
/* Something is wrong, reset to default */
|
||||
Gui::gui->setTheme("default");
|
||||
Gui::gui->pushDialogueBox(new DialogueBox(broken_theme_dlg));
|
||||
}
|
||||
free(p);
|
||||
Gui::gui->popView();
|
||||
}
|
||||
|
||||
virtual void hoverCallback(int which)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void escapeCallback(int which)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ThemeView::ThemeView() : GuiView()
|
||||
{
|
||||
this->menu = new ThemeMenu(NULL);
|
||||
}
|
||||
|
||||
ThemeView::~ThemeView()
|
||||
{
|
||||
delete this->menu;
|
||||
}
|
||||
|
||||
void ThemeView::setDirectory(const char *path)
|
||||
{
|
||||
this->menu->setDirectory(path);
|
||||
}
|
||||
|
||||
void ThemeView::updateTheme()
|
||||
{
|
||||
this->menu->setFont(Gui::gui->default_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);
|
||||
}
|
||||
|
||||
void ThemeView::runLogic()
|
||||
{
|
||||
this->menu->runLogic();
|
||||
}
|
||||
|
||||
void ThemeView::pushEvent(SDL_Event *ev)
|
||||
{
|
||||
this->menu->pushEvent(ev);
|
||||
}
|
||||
|
||||
void ThemeView::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);
|
||||
|
||||
this->menu->draw(where, 50, 70, 280, 375);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user