summaryrefslogtreecommitdiff
path: root/src/gui/popups
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-05 17:03:13 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-05 17:03:13 +0300
commitc4274b8b5798ffaee2a783f7a1f10e6f80c93f9e (patch)
tree00d0f73dd35e77fdfc81dae1b7124cefcc6f8364 /src/gui/popups
parentb7400ada5bff3345196a468fc45ac74a6b3775f6 (diff)
downloadmv-c4274b8b5798ffaee2a783f7a1f10e6f80c93f9e.tar.gz
mv-c4274b8b5798ffaee2a783f7a1f10e6f80c93f9e.tar.bz2
mv-c4274b8b5798ffaee2a783f7a1f10e6f80c93f9e.tar.xz
mv-c4274b8b5798ffaee2a783f7a1f10e6f80c93f9e.zip
Remove item object from popup menu, but use item index in inventory.
Diffstat (limited to 'src/gui/popups')
-rw-r--r--src/gui/popups/popupmenu.cpp25
-rw-r--r--src/gui/popups/popupmenu.h2
2 files changed, 15 insertions, 12 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 3bf1a6d9c..d891b19ec 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -108,8 +108,8 @@ PopupMenu::PopupMenu() :
mScrollArea(nullptr),
mBeingId(BeingId_zero),
mFloorItemId(BeingId_zero),
- mItem(nullptr),
mItemId(0),
+ mItemIndex(-1),
mItemColor(ItemColor_one),
mMapItem(nullptr),
mTab(nullptr),
@@ -955,7 +955,8 @@ void PopupMenu::showChangePos(const int x, const int y)
{
mBeingId = BeingId_zero;
mFloorItemId = BeingId_zero;
- mItem = nullptr;
+ mItemIndex = -1;
+ mItemId = 0;
mMapItem = nullptr;
mNick.clear();
mType = ActorType::Unknown;
@@ -1583,8 +1584,8 @@ void PopupMenu::handleLink(const std::string &link,
replaceAll(cmd, "'ITEMCOLOR'", toString(toInt(mItemColor, int)));
replaceAll(cmd, "'BEINGTYPEID'", toString(static_cast<int>(mType)));
replaceAll(cmd, "'PLAYER'", localPlayer->getName());
- if (mItem)
- replaceAll(cmd, "'INVINDEX'", toString(mItem->getInvIndex()));
+ if (mItemIndex >= 0)
+ replaceAll(cmd, "'INVINDEX'", toString(mItemIndex));
else
replaceAll(cmd, "'INVINDEX'", "0");
if (mMapItem)
@@ -1614,8 +1615,8 @@ void PopupMenu::handleLink(const std::string &link,
mBeingId = BeingId_zero;
mFloorItemId = BeingId_zero;
- mItem = nullptr;
mItemId = 0;
+ mItemIndex = -1;
mItemColor = ItemColor_one;
mMapItem = nullptr;
mTab = nullptr;
@@ -1638,8 +1639,8 @@ void PopupMenu::showPopup(Window *const parent,
if (!item)
return;
- mItem = item;
mItemId = item->getId();
+ mItemIndex = item->getInvIndex();
mItemColor = item->getColor();
mWindow = parent;
mX = x;
@@ -1788,8 +1789,8 @@ void PopupMenu::showItemPopup(const int x, const int y,
}
else
{
- mItem = nullptr;
mItemId = itemId;
+ mItemIndex = -1;
mItemColor = color;
mX = x;
mY = y;
@@ -1814,18 +1815,19 @@ void PopupMenu::showItemPopup(const int x, const int y,
void PopupMenu::showItemPopup(const int x, const int y,
Item *const item)
{
- mItem = item;
mX = x;
mY = y;
if (item)
{
mItemId = item->getId();
mItemColor = item->getColor();
+ mItemIndex = item->getInvIndex();
}
else
{
mItemId = 0;
mItemColor = ItemColor_one;
+ mItemIndex = -1;
}
mNick.clear();
mBrowserBox->clearRows();
@@ -1863,7 +1865,6 @@ void PopupMenu::showItemPopup(const int x, const int y,
void PopupMenu::showDropPopup(const int x, const int y, Item *const item)
{
- mItem = item;
mX = x;
mY = y;
mNick.clear();
@@ -1873,6 +1874,7 @@ void PopupMenu::showDropPopup(const int x, const int y, Item *const item)
{
mItemId = item->getId();
mItemColor = item->getColor();
+ mItemIndex = item->getInvIndex();
const bool isProtected = PlayerInfo::isItemProtected(mItemId);
addUseDrop(item, isProtected);
if (InventoryWindow::isStorageActive())
@@ -2134,9 +2136,9 @@ void PopupMenu::showUndressPopup(const int x, const int y,
return;
mBeingId = being->getId();
- mItem = item;
mItemId = item->getId();
mItemColor = item->getColor();
+ mItemIndex = item->getInvIndex();
mX = x;
mY = y;
@@ -2589,7 +2591,8 @@ void PopupMenu::clear()
mDialog->close();
mDialog = nullptr;
}
- mItem = nullptr;
+ mItemIndex = -1;
+ mItemId = 0;
mMapItem = nullptr;
mTab = nullptr;
mSpell = nullptr;
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index a19621c50..5c68254ac 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -213,8 +213,8 @@ class PopupMenu final : public Popup, public LinkHandler
BeingId mBeingId;
BeingId mFloorItemId;
- const Item *mItem;
int mItemId;
+ int mItemIndex;
ItemColor mItemColor;
MapItem *mMapItem;
ChatTab *mTab;