summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-24 16:48:14 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-24 16:48:14 +0300
commit7dc4dea6109eb8592db5bfc2ab81a6b59fdd83f7 (patch)
tree523ee84b12297a855e31f1b7456c0379c384f071 /src/gui/widgets/itemcontainer.cpp
parent5de322cf706004227fd0ebec59e0ebb50631df3a (diff)
downloadmv-7dc4dea6109eb8592db5bfc2ab81a6b59fdd83f7.tar.gz
mv-7dc4dea6109eb8592db5bfc2ab81a6b59fdd83f7.tar.bz2
mv-7dc4dea6109eb8592db5bfc2ab81a6b59fdd83f7.tar.xz
mv-7dc4dea6109eb8592db5bfc2ab81a6b59fdd83f7.zip
Add support for drag and drop from/to cart.
Diffstat (limited to 'src/gui/widgets/itemcontainer.cpp')
-rw-r--r--src/gui/widgets/itemcontainer.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 528e751fb..0ca5231e1 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -423,6 +423,9 @@ void ItemContainer::mousePressed(MouseEvent &event)
case InventoryType::NPC:
src = DRAGDROP_SOURCE_NPC;
break;
+ case InventoryType::CART:
+ src = DRAGDROP_SOURCE_CART;
+ break;
default:
break;
}
@@ -518,6 +521,9 @@ void ItemContainer::mouseReleased(MouseEvent &event)
case InventoryType::NPC:
dst = DRAGDROP_SOURCE_NPC;
break;
+ case InventoryType::CART:
+ dst = DRAGDROP_SOURCE_CART;
+ break;
default:
break;
}
@@ -540,6 +546,34 @@ void ItemContainer::mouseReleased(MouseEvent &event)
inventory = PlayerInfo::getStorageInventory();
}
if (src == DRAGDROP_SOURCE_INVENTORY
+ && dst == DRAGDROP_SOURCE_CART)
+ {
+ srcContainer = InventoryType::INVENTORY;
+ dstContainer = InventoryType::CART;
+ inventory = PlayerInfo::getInventory();
+ }
+ else if (src == DRAGDROP_SOURCE_CART
+ && dst == DRAGDROP_SOURCE_INVENTORY)
+ {
+ srcContainer = InventoryType::CART;
+ dstContainer = InventoryType::INVENTORY;
+ inventory = PlayerInfo::getCartInventory();
+ }
+ else if (src == DRAGDROP_SOURCE_CART
+ && dst == DRAGDROP_SOURCE_STORAGE)
+ {
+ srcContainer = InventoryType::CART;
+ dstContainer = InventoryType::STORAGE;
+ inventory = PlayerInfo::getCartInventory();
+ }
+ else if (src == DRAGDROP_SOURCE_STORAGE
+ && dst == DRAGDROP_SOURCE_CART)
+ {
+ srcContainer = InventoryType::STORAGE;
+ dstContainer = InventoryType::CART;
+ inventory = PlayerInfo::getStorageInventory();
+ }
+ if (src == DRAGDROP_SOURCE_INVENTORY
&& dst == DRAGDROP_SOURCE_TRADE)
{
checkProtection = true;
@@ -575,7 +609,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
if (item)
{
if (srcContainer != -1)
- { // inventory <--> storage
+ { // inventory <--> storage, cart
inventoryHandler->moveItem2(srcContainer,
item->getInvIndex(), item->getQuantity(),
dstContainer);