summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-30 22:16:07 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-30 22:16:07 +0300
commitbe1962973deaa161491b6592cbf21eb3e6700cc9 (patch)
tree5ddbba2e492cab6614e815c98f9bee9edc7bf2ba /src/gui/widgets/itemcontainer.cpp
parentce1919c195962ef683ad0af7ee33ce7973c0f03c (diff)
downloadmv-be1962973deaa161491b6592cbf21eb3e6700cc9.tar.gz
mv-be1962973deaa161491b6592cbf21eb3e6700cc9.tar.bz2
mv-be1962973deaa161491b6592cbf21eb3e6700cc9.tar.xz
mv-be1962973deaa161491b6592cbf21eb3e6700cc9.zip
Allow drag&drop items inside npc item container.
Diffstat (limited to 'src/gui/widgets/itemcontainer.cpp')
-rw-r--r--src/gui/widgets/itemcontainer.cpp48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index b7af26a95..ad9f868ad 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -795,11 +795,50 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
return;
}
-#ifdef EATHENA_SUPPORT
- else if (src == DRAGDROP_SOURCE_NPC || src == DRAGDROP_SOURCE_MAIL)
-#else
else if (src == DRAGDROP_SOURCE_NPC)
-#endif
+ {
+ if (dst == DRAGDROP_SOURCE_NPC)
+ {
+ const Item *const item = mInventory->getItem(
+ dragDrop.getTag());
+ const int index = getSlotByXY(event.getX(), event.getY());
+ if (index == Inventory::NO_SLOT_INDEX)
+ {
+ mInventory->removeItemAt(dragDrop.getTag());
+ return;
+ }
+ mInventory->removeItemAt(index);
+ mInventory->setItem(index,
+ item->getId(),
+ item->getType(),
+ 1,
+ 1,
+ item->getColor(),
+ item->getIdentified(),
+ item->getDamaged(),
+ item->getFavorite(),
+ Equipm_false,
+ Equipped_false);
+ Item *const item2 = mInventory->getItem(index);
+ if (item2)
+ item2->setTag(item->getTag());
+ mInventory->removeItemAt(dragDrop.getTag());
+ }
+ else
+ {
+ inventory = PlayerInfo::getInventory();
+ if (inventory)
+ {
+ const Item *const item = inventory->getItem(
+ dragDrop.getTag());
+ if (item)
+ mInventory->removeItemAt(dragDrop.getTag());
+ }
+ return;
+ }
+ }
+#ifdef EATHENA_SUPPORT
+ else if (src == DRAGDROP_SOURCE_MAIL)
{
inventory = PlayerInfo::getInventory();
if (inventory)
@@ -810,6 +849,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
return;
}
+#endif
if (inventory)
{