summaryrefslogtreecommitdiff
path: root/src/gui/windowmenu.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-07-15 20:41:05 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-11 02:39:49 +0200
commit30d2e0c9a16a981c895c070e9f972d577fadc531 (patch)
tree55a3ac596adbc5d93deba2aee0177580c2730c83 /src/gui/windowmenu.cpp
parent3bdb7ebbcc6f7d08ed90f2232f0901b1c0e92d51 (diff)
downloadMana-30d2e0c9a16a981c895c070e9f972d577fadc531.tar.gz
Mana-30d2e0c9a16a981c895c070e9f972d577fadc531.tar.bz2
Mana-30d2e0c9a16a981c895c070e9f972d577fadc531.tar.xz
Mana-30d2e0c9a16a981c895c070e9f972d577fadc531.zip
The shortcuts are now refreshed when reassigning keys.
Diffstat (limited to 'src/gui/windowmenu.cpp')
-rw-r--r--src/gui/windowmenu.cpp69
1 files changed, 61 insertions, 8 deletions
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index a618ae8e..20b6f00c 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -163,6 +163,19 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event)
}
}
+static std::string createShortcutCaption(const std::string& text,
+ KeyboardConfig::KeyAction key)
+{
+ std::string caption = gettext(text.c_str());
+ if (key != KeyboardConfig::KEY_NO_VALUE)
+ {
+ caption += " (";
+ caption += SDL_GetKeyName((SDLKey) keyboard.getKeyValue(key));
+ caption += ")";
+ }
+ return caption;
+}
+
void WindowMenu::addButton(const std::string& text, int &x, int &h,
const std::string& iconPath,
KeyboardConfig::KeyAction key)
@@ -172,14 +185,7 @@ void WindowMenu::addButton(const std::string& text, int &x, int &h,
{
// When in image button mode, we have room to show
// the keyboard shortcut.
- std::string caption = gettext(text.c_str());
- if (key != KeyboardConfig::KEY_NO_VALUE)
- {
- caption += " (";
- caption += SDL_GetKeyName((SDLKey) keyboard.getKeyValue(key));
- caption += ")";
- }
- btn->setButtonPopupText(caption);
+ btn->setButtonPopupText(createShortcutCaption(text, key));
}
else
{
@@ -191,3 +197,50 @@ void WindowMenu::addButton(const std::string& text, int &x, int &h,
x += btn->getWidth() + 3;
h = std::max(h, btn->getHeight());
}
+
+void WindowMenu::updatePopUpCaptions()
+{
+ for (WidgetList::iterator it = mWidgets.begin(); it != mWidgets.end(); ++it)
+ {
+ Button *button = dynamic_cast<Button*> (*it);
+ if (button)
+ {
+ std::string eventId = button->getActionEventId();
+ if (eventId == "Status")
+ {
+ button->setButtonPopupText(createShortcutCaption("Status",
+ KeyboardConfig::KEY_WINDOW_STATUS));
+ }
+ else if (eventId == "Equipment")
+ {
+ button->setButtonPopupText(createShortcutCaption("Equipment",
+ KeyboardConfig::KEY_WINDOW_EQUIPMENT));
+ }
+ else if (eventId == "Inventory")
+ {
+ button->setButtonPopupText(createShortcutCaption("Inventory",
+ KeyboardConfig::KEY_WINDOW_INVENTORY));
+ }
+ else if (eventId == "Skills")
+ {
+ button->setButtonPopupText(createShortcutCaption("Skills",
+ KeyboardConfig::KEY_WINDOW_SKILL));
+ }
+ else if (eventId == "Social")
+ {
+ button->setButtonPopupText(createShortcutCaption("Social",
+ KeyboardConfig::KEY_WINDOW_SOCIAL));
+ }
+ else if (eventId == "Shortcut")
+ {
+ button->setButtonPopupText(createShortcutCaption("Shortcut",
+ KeyboardConfig::KEY_WINDOW_SHORTCUT));
+ }
+ else if (eventId == "Setup")
+ {
+ button->setButtonPopupText(createShortcutCaption("Setup",
+ KeyboardConfig::KEY_WINDOW_SETUP));
+ }
+ }
+ }
+}