From 7dc4dea6109eb8592db5bfc2ab81a6b59fdd83f7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Jan 2015 16:48:14 +0300 Subject: Add support for drag and drop from/to cart. --- src/gui/widgets/itemcontainer.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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; } @@ -539,6 +545,34 @@ void ItemContainer::mouseReleased(MouseEvent &event) dstContainer = InventoryType::INVENTORY; 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) { @@ -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); -- cgit v1.2.3-70-g09d2