mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 03:19:24 +01:00
Create views when the theme is loaded
This commit is contained in:
parent
108f069478
commit
9b138afacc
@ -414,8 +414,8 @@ class BindKeysView : public GuiView
|
||||
public:
|
||||
BindKeysView() : GuiView()
|
||||
{
|
||||
this->help = new HelpBox(NULL, NULL);
|
||||
this->menu = new BindKeysMenu(NULL, this->help);
|
||||
this->help = new HelpBox(Gui::gui->small_font, NULL);
|
||||
this->menu = new BindKeysMenu(Gui::gui->small_font, this->help);
|
||||
}
|
||||
|
||||
~BindKeysView()
|
||||
@ -424,15 +424,6 @@ public:
|
||||
delete this->menu;
|
||||
}
|
||||
|
||||
void updateTheme()
|
||||
{
|
||||
this->menu->setFont(Gui::gui->small_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);
|
||||
}
|
||||
|
||||
void viewPushCallback()
|
||||
{
|
||||
this->menu->updateHelpMessages();
|
||||
|
@ -22,8 +22,6 @@ public:
|
||||
void setDirectory(const char *path);
|
||||
|
||||
/* Inherited */
|
||||
void updateTheme();
|
||||
|
||||
void runLogic();
|
||||
|
||||
void draw(SDL_Surface *where);
|
||||
@ -79,6 +77,7 @@ public:
|
||||
{
|
||||
this->gi = NULL;
|
||||
memset(this->gi_messages, 0, sizeof(this->gi_messages));
|
||||
this->setSelectedBackground(NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
void loadGameInfo(const char *what)
|
||||
@ -150,8 +149,8 @@ private:
|
||||
|
||||
DiscView::DiscView() : GuiView()
|
||||
{
|
||||
this->menu = new DiscMenu(NULL);
|
||||
this->gameInfo = new GameInfoBox(NULL);
|
||||
this->menu = new DiscMenu(Gui::gui->default_font);
|
||||
this->gameInfo = new GameInfoBox(Gui::gui->default_font);
|
||||
}
|
||||
|
||||
DiscView::~DiscView()
|
||||
@ -170,15 +169,6 @@ void DiscView::setDirectory(const char *path)
|
||||
this->menu->setDirectory(path);
|
||||
}
|
||||
|
||||
void DiscView::updateTheme()
|
||||
{
|
||||
this->gameInfo->setFont(Gui::gui->small_font);
|
||||
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 DiscView::runLogic()
|
||||
{
|
||||
this->menu->runLogic();
|
||||
|
@ -7,10 +7,13 @@
|
||||
#include "utils.hh"
|
||||
|
||||
#define VERSION_BASE (0x1978)
|
||||
#define VERSION_MAGIC (VERSION_BASE + 0)
|
||||
#define VERSION_MAGIC (VERSION_BASE + 1)
|
||||
|
||||
GameInfo::GameInfo(const char *name, const char *author, SDL_Surface *image)
|
||||
GameInfo::GameInfo(const char *filename,
|
||||
const char *name, const char *author,
|
||||
SDL_Surface *image)
|
||||
{
|
||||
this->filename = filename;
|
||||
this->name = name;
|
||||
this->author = author;
|
||||
this->screenshot = image;
|
||||
|
@ -10,13 +10,17 @@ struct game_info
|
||||
uint16_t author_off;
|
||||
uint16_t name_off;
|
||||
uint16_t screenshot_off; /* In PNG format */
|
||||
uint16_t filename_off;
|
||||
uint16_t flags;
|
||||
uint8_t data[]; /* 4-byte aligned */
|
||||
};
|
||||
|
||||
class GameInfo
|
||||
{
|
||||
public:
|
||||
GameInfo(const char *name = NULL, const char *author = NULL, SDL_Surface *image = NULL);
|
||||
GameInfo(const char *filename = NULL, const char *name = NULL,
|
||||
const char *author = NULL,
|
||||
SDL_Surface *image = NULL);
|
||||
|
||||
~GameInfo();
|
||||
|
||||
@ -33,6 +37,7 @@ public:
|
||||
/* Should perhaps be protected but I trust you - just be careful! */
|
||||
const char *name;
|
||||
const char *author;
|
||||
const char *filename;
|
||||
SDL_Surface *screenshot;
|
||||
};
|
||||
|
||||
|
40
gui.cpp
40
gui.cpp
@ -85,14 +85,12 @@ Gui::Gui()
|
||||
this->dlg = NULL;
|
||||
this->kbd = NULL;
|
||||
|
||||
/* Create the views */
|
||||
this->mv = new MainView();
|
||||
this->dv = new DiscView();
|
||||
this->ov = new OptionsView();
|
||||
this->nv = new NetworkView();
|
||||
this->tv = new ThemeView();
|
||||
this->bkv = new BindKeysView();
|
||||
this->pushView(mv);
|
||||
this->mv = NULL;
|
||||
this->dv = NULL;
|
||||
this->ov = NULL;
|
||||
this->nv = NULL;
|
||||
this->tv = NULL;
|
||||
this->bkv = NULL;
|
||||
}
|
||||
|
||||
bool Gui::setTheme(const char *path)
|
||||
@ -150,12 +148,26 @@ bool Gui::setTheme(const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
this->mv->updateTheme();
|
||||
this->dv->updateTheme();
|
||||
this->ov->updateTheme();
|
||||
this->nv->updateTheme();
|
||||
this->tv->updateTheme();
|
||||
this->bkv->updateTheme();
|
||||
/* Create the views */
|
||||
if (!this->mv)
|
||||
{
|
||||
this->mv = new MainView();
|
||||
this->dv = new DiscView();
|
||||
this->ov = new OptionsView();
|
||||
this->nv = new NetworkView();
|
||||
this->tv = new ThemeView();
|
||||
this->bkv = new BindKeysView();
|
||||
this->pushView(mv);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->mv->updateTheme();
|
||||
this->dv->updateTheme();
|
||||
this->ov->updateTheme();
|
||||
this->nv->updateTheme();
|
||||
this->tv->updateTheme();
|
||||
this->bkv->updateTheme();
|
||||
}
|
||||
|
||||
VirtualKeyboard::kbd->updateTheme();
|
||||
|
||||
|
@ -9,6 +9,7 @@ public:
|
||||
HelpBox(Font *font, const char ***all_messages) : Menu(font)
|
||||
{
|
||||
this->setHelpMessages(all_messages);
|
||||
this->setSelectedBackground(NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
void setHelpMessages(const char ***all_messages)
|
||||
|
@ -122,8 +122,11 @@ class MainView : public GuiView
|
||||
public:
|
||||
MainView() : GuiView()
|
||||
{
|
||||
this->help = new HelpBox(NULL, main_menu_help);
|
||||
this->menu = new MainMenu(NULL, this->help);
|
||||
panic_if(!Gui::gui->default_font,
|
||||
"Theme does not seem correctly loaded\n");
|
||||
|
||||
this->help = new HelpBox(Gui::gui->small_font, main_menu_help);
|
||||
this->menu = new MainMenu(Gui::gui->default_font, this->help);
|
||||
}
|
||||
|
||||
~MainView()
|
||||
@ -132,15 +135,6 @@ public:
|
||||
delete this->menu;
|
||||
}
|
||||
|
||||
void updateTheme()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void runLogic()
|
||||
{
|
||||
this->menu->runLogic();
|
||||
|
12
menu.cpp
12
menu.cpp
@ -15,6 +15,7 @@
|
||||
#include "menu.hh"
|
||||
#include "font.hh"
|
||||
#include "utils.hh"
|
||||
#include "gui.hh"
|
||||
|
||||
#define IS_SUBMENU(p_msg) ( (p_msg)[0] == '^' )
|
||||
#define IS_EMPTY(p_msg) ( (p_msg)[0] == '#' )
|
||||
@ -344,13 +345,6 @@ Menu::Menu(Font *font) : Widget()
|
||||
this->setTextColor((SDL_Color){0xff,0xff,0xff,0});
|
||||
this->font = font;
|
||||
|
||||
this->text_bg_left = NULL;
|
||||
this->text_bg_middle = NULL;
|
||||
this->text_bg_right = NULL;
|
||||
this->submenu_bg_left = NULL;
|
||||
this->submenu_bg_middle = NULL;
|
||||
this->submenu_bg_right = NULL;
|
||||
|
||||
this->pp_msgs = NULL;
|
||||
this->n_entries = 0;
|
||||
this->p_submenus = NULL;
|
||||
@ -359,6 +353,10 @@ Menu::Menu(Font *font) : Widget()
|
||||
this->cur_sel = 0;
|
||||
this->mouse_x = -1;
|
||||
this->mouse_y = -1;
|
||||
|
||||
this->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 Menu::setTextColor(SDL_Color clr)
|
||||
|
@ -123,8 +123,8 @@ class NetworkView : public GuiView
|
||||
public:
|
||||
NetworkView() : GuiView()
|
||||
{
|
||||
this->help = new HelpBox(NULL, network_menu_help);
|
||||
this->menu = new NetworkMenu(NULL, this->help);
|
||||
this->help = new HelpBox(Gui::gui->small_font, network_menu_help);
|
||||
this->menu = new NetworkMenu(Gui::gui->default_font, this->help);
|
||||
}
|
||||
|
||||
~NetworkView()
|
||||
@ -133,15 +133,6 @@ public:
|
||||
delete this->menu;
|
||||
}
|
||||
|
||||
void updateTheme()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void runLogic()
|
||||
{
|
||||
this->menu->runLogic();
|
||||
|
@ -96,8 +96,8 @@ class OptionsView : public GuiView
|
||||
public:
|
||||
OptionsView() : GuiView()
|
||||
{
|
||||
this->help = new HelpBox(NULL, options_menu_help);
|
||||
this->menu = new OptionsMenu(NULL, this->help);
|
||||
this->help = new HelpBox(Gui::gui->small_font, options_menu_help);
|
||||
this->menu = new OptionsMenu(Gui::gui->default_font, this->help);
|
||||
}
|
||||
|
||||
~OptionsView()
|
||||
@ -106,15 +106,6 @@ public:
|
||||
delete this->menu;
|
||||
}
|
||||
|
||||
void updateTheme()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void viewPushCallback()
|
||||
{
|
||||
this->menu->updateSubmenus();
|
||||
|
@ -15,8 +15,6 @@ public:
|
||||
void setDirectory(const char *path);
|
||||
|
||||
/* Inherited */
|
||||
void updateTheme();
|
||||
|
||||
void runLogic();
|
||||
|
||||
void draw(SDL_Surface *where);
|
||||
@ -63,7 +61,7 @@ public:
|
||||
|
||||
ThemeView::ThemeView() : GuiView()
|
||||
{
|
||||
this->menu = new ThemeMenu(NULL);
|
||||
this->menu = new ThemeMenu(Gui::gui->default_font);
|
||||
}
|
||||
|
||||
ThemeView::~ThemeView()
|
||||
@ -76,14 +74,6 @@ 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();
|
||||
|
Loading…
Reference in New Issue
Block a user