summaryrefslogtreecommitdiff
path: root/src/gui/popupmenu.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-23 18:13:36 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-23 18:49:33 +0300
commit593c59c2a45831082a47076e0f94d533ea5f09c8 (patch)
treea51ae666a9406b0125ba92100e3363c36522facb /src/gui/popupmenu.cpp
parent4c57a567eec8b3df0b0009b5520d647cccb83338 (diff)
downloadmv-593c59c2a45831082a47076e0f94d533ea5f09c8.tar.gz
mv-593c59c2a45831082a47076e0f94d533ea5f09c8.tar.bz2
mv-593c59c2a45831082a47076e0f94d533ea5f09c8.tar.xz
mv-593c59c2a45831082a47076e0f94d533ea5f09c8.zip
remove some duplicates in popupmenu.
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),