Singleton refactoring, part 2

This commit is contained in:
simon.kagstrom 2009-12-13 08:59:06 +00:00
parent 337921d2ab
commit eeb03b75e4
3 changed files with 17 additions and 18 deletions

View File

@ -31,6 +31,10 @@ static const char *get_theme_path(const char *dir, const char *what)
/* These are a bit of special cases... */ /* These are a bit of special cases... */
#include "main_menu.cpp" #include "main_menu.cpp"
GuiView::GuiView()
{
}
Gui::Gui() Gui::Gui()
{ {
this->focus = NULL; this->focus = NULL;
@ -53,7 +57,7 @@ Gui::Gui()
this->views = NULL; this->views = NULL;
/* Create the views */ /* Create the views */
MainView *mv = new MainView(this); MainView *mv = new MainView();
this->pushView(mv); this->pushView(mv);
} }

7
gui.hh
View File

@ -11,10 +11,7 @@ class Gui;
class GuiView class GuiView
{ {
public: public:
GuiView(Gui *parent) GuiView();
{
this->parent = parent;
}
virtual void pushEvent(SDL_Event *ev) = 0; virtual void pushEvent(SDL_Event *ev) = 0;
@ -23,8 +20,6 @@ public:
virtual void updateTheme() = 0; virtual void updateTheme() = 0;
virtual void draw(SDL_Surface *where) = 0; virtual void draw(SDL_Surface *where) = 0;
Gui *parent;
}; };
class Gui class Gui

View File

@ -86,7 +86,7 @@ public:
virtual void escapeCallback(int which) virtual void escapeCallback(int which)
{ {
this->parent->parent->exitMenu(); Gui::gui->exitMenu();
} }
private: private:
@ -99,7 +99,7 @@ private:
class MainView : public GuiView class MainView : public GuiView
{ {
public: public:
MainView(Gui *parent) : GuiView(parent) MainView() : GuiView()
{ {
this->help = new HelpBox(NULL, main_menu_help); this->help = new HelpBox(NULL, main_menu_help);
this->menu = new MainMenu(NULL, this->help, this); this->menu = new MainMenu(NULL, this->help, this);
@ -118,16 +118,16 @@ public:
void updateTheme() void updateTheme()
{ {
this->bg = parent->main_menu_bg; this->bg = Gui::gui->main_menu_bg;
this->infobox = parent->infobox; this->infobox = Gui::gui->infobox;
this->textbox = parent->textbox; this->textbox = Gui::gui->textbox;
this->dialogue_bg = parent->dialogue_bg; this->dialogue_bg = Gui::gui->dialogue_bg;
this->menu->setFont(this->parent->default_font); this->menu->setFont(Gui::gui->default_font);
this->help->setFont(this->parent->small_font); this->help->setFont(Gui::gui->small_font);
this->menu->setSelectedBackground(this->parent->bg_left, this->parent->bg_middle, this->menu->setSelectedBackground(Gui::gui->bg_left, Gui::gui->bg_middle,
this->parent->bg_right, this->parent->bg_submenu_left, Gui::gui->bg_right, Gui::gui->bg_submenu_left,
this->parent->bg_submenu_middle, this->parent->bg_submenu_right); Gui::gui->bg_submenu_middle, Gui::gui->bg_submenu_right);
} }
void runLogic() void runLogic()