diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-03-08 18:47:17 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-03-08 19:13:31 -0700 |
commit | d92524b7c8548bb6e2970a757e440ecf197c2b6d (patch) | |
tree | a0c6ee668729953f3243f43ad00026cb4f6b3092 /src | |
parent | 30668a131bb2c93127385fbbbba34d47f7bf80e3 (diff) | |
download | mana-d92524b7c8548bb6e2970a757e440ecf197c2b6d.tar.gz mana-d92524b7c8548bb6e2970a757e440ecf197c2b6d.tar.bz2 mana-d92524b7c8548bb6e2970a757e440ecf197c2b6d.tar.xz mana-d92524b7c8548bb6e2970a757e440ecf197c2b6d.zip |
Only show skill and special buttons in WindowMenu when needed
Reviewed-by: Chuck Miller
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/skilldialog.h | 2 | ||||
-rw-r--r-- | src/gui/specialswindow.h | 2 | ||||
-rw-r--r-- | src/gui/windowmenu.cpp | 49 | ||||
-rw-r--r-- | src/gui/windowmenu.h | 2 |
4 files changed, 31 insertions, 24 deletions
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 6423d56b..95f8ef25 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -69,6 +69,8 @@ class SkillDialog : public Window, public gcn::ActionListener void setModifiable(int id, bool modifiable); + bool hasSkills() { return !mSkills.empty(); } + private: typedef std::map<int, SkillInfo*> SkillMap; SkillMap mSkills; diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h index 86d89462..81384856 100644 --- a/src/gui/specialswindow.h +++ b/src/gui/specialswindow.h @@ -56,6 +56,8 @@ class SpecialsWindow : public Window, public gcn::ActionListener { void loadSpecials(const std::string &file); + bool hasSpecials() { return !mSpecials.empty(); } + private: std::vector<gcn::Button *> mSpellButtons; typedef std::map<int, SpecialInfo*> SpecialMap; diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 81e96fb2..5af5a202 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -24,6 +24,8 @@ #include "graphics.h" #include "gui/emotepopup.h" +#include "gui/skilldialog.h" +#include "gui/specialswindow.h" #include "gui/widgets/button.h" #include "gui/widgets/window.h" @@ -40,38 +42,28 @@ extern Window *equipmentWindow; extern Window *inventoryWindow; extern Window *itemShortcutWindow; extern Window *setupWindow; -extern Window *skillDialog; -extern Window *specialsWindow; extern Window *statusWindow; extern Window *socialWindow; WindowMenu::WindowMenu(): mEmotePopup(0) { - // Buttons - static const char *buttonNames[] = - { - ":-)", - N_("Status"), - N_("Equipment"), - N_("Inventory"), - N_("Skills"), - N_("Specials"), - N_("Social"), - N_("Shortcut"), - N_("Setup"), - 0 - }; int x = 0, h = 0; - for (const char **curBtn = buttonNames; *curBtn; curBtn++) - { - gcn::Button *btn = new Button(gettext(*curBtn), *curBtn, this); - btn->setPosition(x, 0); - add(btn); - x += btn->getWidth() + 3; - h = btn->getHeight(); - } + addButton(":-)", x, h); + addButton(N_("Status"), x, h); + addButton(N_("Equipment"), x, h); + addButton(N_("Inventory"), x, h); + + if (skillDialog->hasSkills()) + addButton(N_("Skills"), x, h); + + if (specialsWindow->hasSpecials()) + addButton(N_("Specials"), x, h); + + addButton(N_("Social"), x, h); + addButton(N_("Shortcut"), x, h); + addButton(N_("Setup"), x, h); setDimension(gcn::Rectangle(graphics->getWidth() - x - 3, 3, x - 3, h)); @@ -162,3 +154,12 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event) mEmotePopup = 0; } } + +void WindowMenu::addButton(const char* text, int &x, int &h) +{ + gcn::Button *btn = new Button(gettext(text), text, this); + btn->setPosition(x, 0); + add(btn); + x += btn->getWidth() + 3; + h = btn->getHeight(); +} diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index d20d1f8d..2bb3e764 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -48,6 +48,8 @@ class WindowMenu : public Container, void valueChanged(const gcn::SelectionEvent &event); private: + inline void addButton(const char* text, int &x, int &h); + EmotePopup *mEmotePopup; }; |