From 972a29060fb65b058bf0aedbcaa4f563d189a9c1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Jan 2015 14:43:47 +0300 Subject: Impliment context menu support for different inventory types. --- src/gui/popups/popupmenu.cpp | 157 +++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 74 deletions(-) (limited to 'src/gui/popups/popupmenu.cpp') diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 88e83b200..365970fa4 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1609,8 +1609,10 @@ void PopupMenu::handleLink(const std::string &link, mY = 0; } -void PopupMenu::showPopup(Window *const parent, const int x, const int y, - Item *const item, const bool isInventory) +void PopupMenu::showPopup(Window *const parent, + const int x, const int y, + Item *const item, + const int type) { if (!item) return; @@ -1627,98 +1629,105 @@ void PopupMenu::showPopup(Window *const parent, const int x, const int y, const int cnt = item->getQuantity(); const bool isProtected = PlayerInfo::isItemProtected(mItemId); - if (isInventory) + switch (type) { - if (tradeWindow && tradeWindow->isWindowVisible() && !isProtected) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: add item to trade - mBrowserBox->addRow("/addtrade 'INVINDEX'", _("Add to trade")); - if (cnt > 1) + case Inventory::INVENTORY: + if (tradeWindow && tradeWindow->isWindowVisible() && !isProtected) { - if (cnt > 10) + // TRANSLATORS: popup menu item + // TRANSLATORS: add item to trade + mBrowserBox->addRow("/addtrade 'INVINDEX'", _("Add to trade")); + if (cnt > 1) { + if (cnt > 10) + { + // TRANSLATORS: popup menu item + // TRANSLATORS: add 10 item amount to trade + mBrowserBox->addRow("/addtrade 'INVINDEX' 10", + _("Add to trade 10")); + } + // TRANSLATORS: popup menu item + // TRANSLATORS: add half item amount to trade + mBrowserBox->addRow("/addtrade 'INVINDEX' /", + _("Add to trade half")); + // TRANSLATORS: popup menu item + // TRANSLATORS: add all amount except one item to trade + mBrowserBox->addRow("/addtrade 'INVINDEX' -1", + _("Add to trade all-1")); // TRANSLATORS: popup menu item - // TRANSLATORS: add 10 item amount to trade - mBrowserBox->addRow("/addtrade 'INVINDEX' 10", - _("Add to trade 10")); + // TRANSLATORS: add all amount item to trade + mBrowserBox->addRow("/addtrade 'INVINDEX' all", + _("Add to trade all")); } + mBrowserBox->addRow("##3---"); + } + if (InventoryWindow::isStorageActive()) + { // TRANSLATORS: popup menu item - // TRANSLATORS: add half item amount to trade - mBrowserBox->addRow("/addtrade 'INVINDEX' /", - _("Add to trade half")); - // TRANSLATORS: popup menu item - // TRANSLATORS: add all amount except one item to trade - mBrowserBox->addRow("/addtrade 'INVINDEX' -1", - _("Add to trade all-1")); - // TRANSLATORS: popup menu item - // TRANSLATORS: add all amount item to trade - mBrowserBox->addRow("/addtrade 'INVINDEX' all", - _("Add to trade all")); + // TRANSLATORS: add item to storage + mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store")); + if (cnt > 1) + { + if (cnt > 10) + { + // TRANSLATORS: popup menu item + // TRANSLATORS: add 10 item amount to storage + mBrowserBox->addRow("/invtostorage 'INVINDEX' 10", + _("Store 10")); + } + // TRANSLATORS: popup menu item + // TRANSLATORS: add half item amount to storage + mBrowserBox->addRow("/invtostorage 'INVINDEX' /", + _("Store half")); + // TRANSLATORS: popup menu item + // TRANSLATORS: add all except one item amount to storage + mBrowserBox->addRow("/invtostorage 'INVINDEX' -1", + _("Store all-1")); + // TRANSLATORS: popup menu item + // TRANSLATORS: add all item amount to storage + mBrowserBox->addRow("/invtostorage 'INVINDEX' all", + _("Store all")); + } + mBrowserBox->addRow("##3---"); } - mBrowserBox->addRow("##3---"); - } - if (InventoryWindow::isStorageActive()) - { + addUseDrop(item, isProtected); + break; + + case Inventory::STORAGE: // TRANSLATORS: popup menu item - // TRANSLATORS: add item to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store")); + // TRANSLATORS: get item from storage + mBrowserBox->addRow("/storagetoinv 'INVINDEX'", _("Retrieve")); if (cnt > 1) { if (cnt > 10) { // TRANSLATORS: popup menu item - // TRANSLATORS: add 10 item amount to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX' 10", - _("Store 10")); + // TRANSLATORS: get 10 item amount from storage + mBrowserBox->addRow("/storagetoinv 'INVINDEX' 10", + _("Retrieve 10")); } // TRANSLATORS: popup menu item - // TRANSLATORS: add half item amount to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX' /", - _("Store half")); + // TRANSLATORS: get half item amount from storage + mBrowserBox->addRow("/storagetoinv 'INVINDEX' /", + _("Retrieve half")); // TRANSLATORS: popup menu item - // TRANSLATORS: add all except one item amount to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX' -1", - _("Store all-1")); + // TRANSLATORS: get all except one item amount from storage + mBrowserBox->addRow("/storagetoinv 'INVINDEX' -1", + _("Retrieve all-1")); // TRANSLATORS: popup menu item - // TRANSLATORS: add all item amount to storage - mBrowserBox->addRow("/invtostorage 'INVINDEX' all", - _("Store all")); + // TRANSLATORS: get all item amount from storage + mBrowserBox->addRow("/storagetoinv 'INVINDEX' all", + _("Retrieve all")); } - mBrowserBox->addRow("##3---"); - } + break; - addUseDrop(item, isProtected); - } - // Assume in storage for now - else - { - // TRANSLATORS: popup menu item - // TRANSLATORS: get item from storage - mBrowserBox->addRow("/storagetoinv 'INVINDEX'", _("Retrieve")); - if (cnt > 1) - { - if (cnt > 10) - { - // TRANSLATORS: popup menu item - // TRANSLATORS: get 10 item amount from storage - mBrowserBox->addRow("/storagetoinv 'INVINDEX' 10", - _("Retrieve 10")); - } - // TRANSLATORS: popup menu item - // TRANSLATORS: get half item amount from storage - mBrowserBox->addRow("/storagetoinv 'INVINDEX' /", - _("Retrieve half")); - // TRANSLATORS: popup menu item - // TRANSLATORS: get all except one item amount from storage - mBrowserBox->addRow("/storagetoinv 'INVINDEX' -1", - _("Retrieve all-1")); - // TRANSLATORS: popup menu item - // TRANSLATORS: get all item amount from storage - mBrowserBox->addRow("/storagetoinv 'INVINDEX' all", - _("Retrieve all")); - } + case Inventory::CART: + case Inventory::TRADE: + default: + break; } + + addProtection(); if (config.getBoolValue("enablePickupFilter")) { -- cgit v1.2.3-70-g09d2