mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-23 11:59:23 +01:00
110 lines
1.8 KiB
C++
110 lines
1.8 KiB
C++
|
#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);
|
||
|
}
|