Factor out help box to it's own file (and rename it!)

This commit is contained in:
simon.kagstrom 2009-12-06 09:03:09 +00:00
parent 86ef62ed85
commit 269dadfc69
3 changed files with 35 additions and 31 deletions

View File

@ -7,7 +7,8 @@ all: menu
menu.oo: menu.cpp menu.hh utils.hh font.hh Makefile
frodo_menu.oo: frodo_menu.cpp frodo_menu.hh font.hh menu.hh sdl_ttf_font.hh dialogue_box.hh Makefile
frodo_menu.oo: frodo_menu.cpp frodo_menu.hh font.hh menu.hh \
sdl_ttf_font.hh dialogue_box.hh help_box.hh Makefile
utils.oo: utils.cpp utils.hh Makefile

View File

@ -4,6 +4,7 @@
#include "menu.hh"
#include "frodo_menu.hh"
#include "menu_messages.hh"
#include "help_box.hh"
#include "dialogue_box.hh"
#include "sdl_ttf_font.hh"
#include "utils.hh"
@ -23,32 +24,6 @@ const char *get_theme_path(const char *dir, const char *what)
return buf;
}
class HelpMenu : public Menu
{
public:
HelpMenu(Font *font, const char ***all_messages) : Menu(font)
{
this->all_messages = all_messages;
}
void updateHelpMessage(int which)
{
this->setText(this->all_messages[which]);
}
virtual void selectCallback(int which)
{
}
virtual void hoverCallback(int which)
{
}
virtual void escapeCallback(int which)
{
}
protected:
const char ***all_messages;
};
class MainView;
class MainMenu : public Menu
@ -72,7 +47,7 @@ class MainMenu : public Menu
};
public:
MainMenu(Font *font, HelpMenu *help, GuiView *parent) : Menu(font)
MainMenu(Font *font, HelpBox *help, GuiView *parent) : Menu(font)
{
this->parent = parent;
this->help = help;
@ -137,7 +112,7 @@ public:
private:
DialogueBox *dialogue;
GuiView *parent;
HelpMenu *help;
HelpBox *help;
};
@ -146,7 +121,7 @@ class MainView : public GuiView
public:
MainView(Gui *parent) : GuiView(parent)
{
this->help = new HelpMenu(NULL, main_menu_help);
this->help = new HelpBox(NULL, main_menu_help);
this->menu = new MainMenu(NULL, this->help, this);
this->menu->setText(main_menu_messages);
this->bg = NULL;
@ -209,7 +184,7 @@ public:
protected:
MainMenu *menu;
HelpMenu *help;
HelpBox *help;
SDL_Surface *bg;
SDL_Surface *infobox;
SDL_Surface *textbox;

28
help_box.hh Normal file
View File

@ -0,0 +1,28 @@
#include "menu.hh"
class HelpBox : public Menu
{
public:
HelpBox(Font *font, const char ***all_messages) : Menu(font)
{
this->all_messages = all_messages;
}
void updateHelpMessage(int which)
{
this->setText(this->all_messages[which]);
}
virtual void selectCallback(int which)
{
}
virtual void hoverCallback(int which)
{
}
virtual void escapeCallback(int which)
{
}
protected:
const char ***all_messages;
};