summaryrefslogtreecommitdiff
path: root/src/gui/windowmenu.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-07-15 02:40:07 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-11 02:39:48 +0200
commitbe1300b05a4c6e50fe8f13efa8c66dda00a21016 (patch)
tree4f730238670ea06d386a1928552cd3f549fa015a /src/gui/windowmenu.cpp
parentf3c1994b573a8463ac6f0152b3baa7e3cbd37540 (diff)
downloadmana-be1300b05a4c6e50fe8f13efa8c66dda00a21016.tar.gz
mana-be1300b05a4c6e50fe8f13efa8c66dda00a21016.tar.bz2
mana-be1300b05a4c6e50fe8f13efa8c66dda00a21016.tar.xz
mana-be1300b05a4c6e50fe8f13efa8c66dda00a21016.zip
Added a naive way to display the window keyboard shortcut.
This is not updated once the keys are reassigned but it will do the trick for now.
Diffstat (limited to 'src/gui/windowmenu.cpp')
-rw-r--r--src/gui/windowmenu.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 1c5f2d77..b40a171b 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -51,19 +51,26 @@ WindowMenu::WindowMenu():
int x = 0, h = 0;
addButton(":-)", x, h, "button-icon-smilies.png");
- addButton(N_("Status"), x, h, "button-icon-status.png");
- addButton(N_("Equipment"), x, h, "button-icon-equipment.png");
- addButton(N_("Inventory"), x, h, "button-icon-inventory.png");
+ addButton(N_("Status"), x, h, "button-icon-status.png",
+ KeyboardConfig::KEY_WINDOW_STATUS);
+ addButton(N_("Inventory"), x, h, "button-icon-inventory.png",
+ KeyboardConfig::KEY_WINDOW_INVENTORY);
+ addButton(N_("Equipment"), x, h, "button-icon-equipment.png",
+ KeyboardConfig::KEY_WINDOW_EQUIPMENT);
if (skillDialog->hasSkills())
- addButton(N_("Skills"), x, h, "button-icon-skills.png");
+ addButton(N_("Skills"), x, h, "button-icon-skills.png",
+ KeyboardConfig::KEY_WINDOW_SKILL);
// if (specialsWindow->hasSpecials())
addButton(N_("Specials"), x, h, "button-icon-specials.png");
- addButton(N_("Social"), x, h, "button-icon-social.png");
- addButton(N_("Shortcut"), x, h, "button-icon-shortcut.png");
- addButton(N_("Setup"), x, h, "button-icon-setup.png");
+ addButton(N_("Social"), x, h, "button-icon-social.png",
+ KeyboardConfig::KEY_WINDOW_SOCIAL);
+ addButton(N_("Shortcut"), x, h, "button-icon-shortcut.png",
+ KeyboardConfig::KEY_WINDOW_SHORTCUT);
+ addButton(N_("Setup"), x, h, "button-icon-setup.png",
+ KeyboardConfig::KEY_WINDOW_SETUP);
setDimension(gcn::Rectangle(graphics->getWidth() - x - 3, 3,
x - 3, h));
@@ -157,12 +164,22 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event)
}
void WindowMenu::addButton(const std::string& text, int &x, int &h,
- const std::string& iconPath)
+ const std::string& iconPath,
+ KeyboardConfig::KeyAction key)
{
Button *btn = new Button("", text, this);
if (!iconPath.empty() && btn->setButtonIcon(iconPath))
{
- btn->setButtonPopupText(gettext(text.c_str()));
+ // 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);
}
else
{