From b2ce88bae2b95adb612456d9659669d6b686de7b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 7 Feb 2011 18:03:09 +0200 Subject: Add ability to show/hide buttons in top right window corner. --- src/gui/popupmenu.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'src/gui/popupmenu.cpp') 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 names = windowMenu->getButtons(); + std::list ::iterator it, it_end; + for (it = names.begin(), it_end = names.end(); it != it_end; ++it) + { + Button *btn = dynamic_cast(*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) -- cgit v1.2.3-60-g2f50