summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-07 16:59:33 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-07 16:59:33 +0300
commit62c5097904bfc6c6e44e776730ea1d01aaf891c2 (patch)
tree57216dc3193690c95152405ba50ab222d431a089 /src/gui/widgets/itemcontainer.cpp
parent8eb2e7d993ad9759da2fbeccea1a924b1b7f64dd (diff)
downloadManaVerse-62c5097904bfc6c6e44e776730ea1d01aaf891c2.tar.gz
ManaVerse-62c5097904bfc6c6e44e776730ea1d01aaf891c2.tar.bz2
ManaVerse-62c5097904bfc6c6e44e776730ea1d01aaf891c2.tar.xz
ManaVerse-62c5097904bfc6c6e44e776730ea1d01aaf891c2.zip
Add partial implimentation for craft inventory. For now almost same with npc inventory.
Diffstat (limited to 'src/gui/widgets/itemcontainer.cpp')
-rw-r--r--src/gui/widgets/itemcontainer.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index bc4ca9b1b..d96d89868 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -598,6 +598,9 @@ void ItemContainer::mousePressed(MouseEvent &event)
case InventoryType::Mail:
src = DragDropSource::Mail;
break;
+ case InventoryType::Craft:
+ src = DragDropSource::Craft;
+ break;
#endif
default:
#ifdef EATHENA_SUPPORT
@@ -705,6 +708,9 @@ void ItemContainer::mouseReleased(MouseEvent &event)
case InventoryType::Cart:
dst = DragDropSource::Cart;
break;
+ case InventoryType::Craft:
+ dst = DragDropSource::Craft;
+ break;
#endif
default:
#ifdef EATHENA_SUPPORT
@@ -848,6 +854,69 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
}
#ifdef EATHENA_SUPPORT
+ else if (src == DragDropSource::Inventory &&
+ dst == DragDropSource::Craft)
+ {
+ inventory = PlayerInfo::getInventory();
+ if (inventory)
+ {
+ Item *const item = inventory->getItem(dragDrop.getTag());
+ if (mInventory->addVirtualItem(
+ item,
+ getSlotByXY(event.getX(), event.getY())))
+ {
+ inventory->virtualRemove(item, 1);
+ }
+ }
+ return;
+ }
+ else if (src == DragDropSource::Craft)
+ {
+ inventory = PlayerInfo::getInventory();
+ if (dst == DragDropSource::Craft)
+ {
+ const Item *const item = mInventory->getItem(
+ dragDrop.getTag());
+ const int index = getSlotByXY(event.getX(), event.getY());
+ if (index == Inventory::NO_SLOT_INDEX)
+ {
+ if (inventory)
+ inventory->virtualRestore(item, 1);
+ 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
+ {
+ if (inventory)
+ {
+ const Item *const item = inventory->getItem(
+ dragDrop.getTag());
+ if (item)
+ {
+ inventory->virtualRestore(item, 1);
+ mInventory->removeItemAt(dragDrop.getTag());
+ }
+ }
+ return;
+ }
+ }
else if (src == DragDropSource::Mail)
{
inventory = PlayerInfo::getInventory();