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