summaryrefslogtreecommitdiff
path: root/src/gui/windows/npcdialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-02 18:10:42 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-02 18:10:42 +0300
commit2127361148d4ea5531a115cc92131a3f956ca528 (patch)
tree668182e046ff19bbacdc8cfc326bc2fab224b62b /src/gui/windows/npcdialog.cpp
parentf89de74b1ac1cd9a02a70dab9221d601296da8cd (diff)
downloadManaVerse-2127361148d4ea5531a115cc92131a3f956ca528.tar.gz
ManaVerse-2127361148d4ea5531a115cc92131a3f956ca528.tar.bz2
ManaVerse-2127361148d4ea5531a115cc92131a3f956ca528.tar.xz
ManaVerse-2127361148d4ea5531a115cc92131a3f956ca528.zip
Allow add items to npc inventory from same slot multiple times.
Added items automatically removed from inventory item amounts.
Diffstat (limited to 'src/gui/windows/npcdialog.cpp')
-rw-r--r--src/gui/windows/npcdialog.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 406e90c1a..539662f51 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -30,6 +30,7 @@
#include "soundmanager.h"
#include "being/being.h"
+#include "being/playerinfo.h"
#include "gui/gui.h"
#include "gui/viewport.h"
@@ -367,6 +368,7 @@ void NpcDialog::action(const ActionEvent &event)
}
case NPC_INPUT_ITEM:
{
+ restoreVirtuals();
if (!PacketLimiter::limitPackets(
PacketType::PACKET_NPC_INPUT))
{
@@ -414,6 +416,7 @@ void NpcDialog::action(const ActionEvent &event)
}
case NPC_INPUT_ITEM_INDEX:
{
+ restoreVirtuals();
if (!PacketLimiter::limitPackets(
PacketType::PACKET_NPC_INPUT))
{
@@ -517,6 +520,7 @@ void NpcDialog::action(const ActionEvent &event)
}
else if (eventId == "close")
{
+ restoreVirtuals();
if (mActionState == NPC_ACTION_INPUT)
{
switch (mInputState)
@@ -541,7 +545,12 @@ void NpcDialog::action(const ActionEvent &event)
else if (eventId == "add")
{
if (inventoryWindow)
- mInventory->addVirtualItem(inventoryWindow->getSelectedItem(), 0);
+ {
+ Item *const item = inventoryWindow->getSelectedItem();
+ Inventory *const inventory = PlayerInfo::getInventory();
+ if (mInventory->addVirtualItem(item, 0) && inventory)
+ inventory->virtualRemove(item, 1);
+ }
}
else if (eventId.find("skin_") == 0)
{
@@ -1244,3 +1253,10 @@ void NpcDialog::createSkinControls()
button->adjustSize();
}
}
+
+void NpcDialog::restoreVirtuals()
+{
+ Inventory *const inventory = PlayerInfo::getInventory();
+ if (inventory)
+ inventory->restoreVirtuals();
+}