summaryrefslogtreecommitdiff
path: root/src/gui/popupmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r--src/gui/popupmenu.cpp182
1 files changed, 50 insertions, 132 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index ef71160d7..0cd6e0511 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -1831,49 +1831,7 @@ void PopupMenu::showPopup(Window *const parent, const int x, const int y,
mBrowserBox->addRow("##3---");
}
- if (item->isEquipment())
- {
- if (item->isEquipped())
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Unequip"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Equip"));
- }
- }
- else
- {
- if (!isProtected)
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Use"));
- }
- }
-
- if (!isProtected)
- {
- if (cnt > 1)
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop", _("Drop..."));
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop all", _("Drop all"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop", _("Drop"));
- }
- }
-
- if (Net::getInventoryHandler()->canSplit(item))
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("split", _("Split"));
- }
+ addUseDrop(item, isProtected);
}
// Assume in storage for now
else
@@ -1967,50 +1925,7 @@ void PopupMenu::showItemPopup(const int x, const int y, Item *const item)
if (item)
{
const bool isProtected = PlayerInfo::isItemProtected(mItemId);
- if (item->isEquipment())
- {
- if (item->isEquipped())
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Unequip"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Equip"));
- }
- }
- else
- {
- if (!isProtected)
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Use"));
- }
- }
-
- if (!isProtected)
- {
- if (item->getQuantity() > 1)
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop", _("Drop..."));
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop all", _("Drop all"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop", _("Drop"));
- }
- }
-
- if (Net::getInventoryHandler()->canSplit(item))
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("split", _("Split"));
- }
-
+ addUseDrop(item, isProtected);
if (InventoryWindow::isStorageActive())
{
// TRANSLATORS: popup menu item
@@ -2048,51 +1963,7 @@ void PopupMenu::showDropPopup(const int x, const int y, Item *const item)
mItemId = item->getId();
mItemColor = item->getColor();
const bool isProtected = PlayerInfo::isItemProtected(mItemId);
-
- if (item->isEquipment())
- {
- if (item->isEquipped())
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Unequip"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Equip"));
- }
- }
- else
- {
- if (!isProtected)
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("use", _("Use"));
- }
- }
-
- if (!isProtected)
- {
- if (item->getQuantity() > 1)
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop", _("Drop..."));
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop all", _("Drop all"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("drop", _("Drop"));
- }
- }
-
- if (Net::getInventoryHandler()->canSplit(item))
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("split", _("Split"));
- }
-
+ addUseDrop(item, isProtected);
if (InventoryWindow::isStorageActive())
{
// TRANSLATORS: popup menu item
@@ -2694,6 +2565,53 @@ void PopupMenu::addProtection()
}
}
+void PopupMenu::addUseDrop(const Item *const item, const bool isProtected)
+{
+ if (item->isEquipment())
+ {
+ if (item->isEquipped())
+ {
+ // TRANSLATORS: popup menu item
+ mBrowserBox->addRow("use", _("Unequip"));
+ }
+ else
+ {
+ // TRANSLATORS: popup menu item
+ mBrowserBox->addRow("use", _("Equip"));
+ }
+ }
+ else
+ {
+ if (!isProtected)
+ {
+ // TRANSLATORS: popup menu item
+ mBrowserBox->addRow("use", _("Use"));
+ }
+ }
+
+ if (!isProtected)
+ {
+ if (item->getQuantity() > 1)
+ {
+ // TRANSLATORS: popup menu item
+ mBrowserBox->addRow("drop", _("Drop..."));
+ // TRANSLATORS: popup menu item
+ mBrowserBox->addRow("drop all", _("Drop all"));
+ }
+ else
+ {
+ // TRANSLATORS: popup menu item
+ mBrowserBox->addRow("drop", _("Drop"));
+ }
+ }
+
+ if (Net::getInventoryHandler()->canSplit(item))
+ {
+ // TRANSLATORS: popup menu item
+ mBrowserBox->addRow("split", _("Split"));
+ }
+}
+
RenameListener::RenameListener() :
gcn::ActionListener(),
mMapItem(nullptr),