diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-02-07 18:03:09 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-02-07 18:03:09 +0200 |
commit | b2ce88bae2b95adb612456d9659669d6b686de7b (patch) | |
tree | b165a1f2a98c4c99ce1c0a142a53e71f3d0b3b00 /src/gui/popupmenu.cpp | |
parent | 2c765dc21314b1b32f7a75686571127f8af38bf9 (diff) | |
download | mv-b2ce88bae2b95adb612456d9659669d6b686de7b.tar.gz mv-b2ce88bae2b95adb612456d9659669d6b686de7b.tar.bz2 mv-b2ce88bae2b95adb612456d9659669d6b686de7b.tar.xz mv-b2ce88bae2b95adb612456d9659669d6b686de7b.zip |
Add ability to show/hide buttons in top right window corner.
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r-- | src/gui/popupmenu.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 90813ed80..db9e8447a 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -48,6 +48,7 @@ #include "gui/textdialog.h" #include "gui/trade.h" #include "gui/viewport.h" +#include "gui/windowmenu.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" @@ -85,6 +86,7 @@ PopupMenu::PopupMenu(): mTab(0), mSpell(0), mDialog(0), + mButton(0), mNick("") { mBrowserBox = new BrowserBox; @@ -1037,6 +1039,16 @@ void PopupMenu::handleLink(const std::string &link, return; } } + else if (!link.find("hide button_")) + { + if (windowMenu) + windowMenu->showButton(link.substr(12), false); + } + else if (!link.find("show button_")) + { + if (windowMenu) + windowMenu->showButton(link.substr(12), true); + } // Unknown actions else if (link != "cancel") { @@ -1237,11 +1249,37 @@ void PopupMenu::showDropPopup(int x, int y, Item *item) showPopup(x, y); } -void PopupMenu::showPopup(int x _UNUSED_, int y _UNUSED_, Button *button) +void PopupMenu::showPopup(int x, int y, Button *button) { - if (!button) + if (!button || !windowMenu) return; + mButton = button; + + mBrowserBox->clearRows(); + std::list <gcn::Button*> names = windowMenu->getButtons(); + std::list <gcn::Button*>::iterator it, it_end; + for (it = names.begin(), it_end = names.end(); it != it_end; ++it) + { + Button *btn = dynamic_cast<Button*>(*it); + if (!btn || btn->getActionEventId() == "SET") + continue; + + if (btn->isVisible()) + { + mBrowserBox->addRow(strprintf("@@hide button_%s|Hide %s@@", + btn->getActionEventId().c_str(), btn->getCaption().c_str())); + } + else + { + mBrowserBox->addRow(strprintf("@@show button_%s|Show %s@@", + btn->getActionEventId().c_str(), btn->getCaption().c_str())); + } + } + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + + showPopup(x, y); } void PopupMenu::showPopup(int x, int y) |