summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-08 20:27:29 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-08 20:27:29 +0300
commit5d0b4c09a67f279847337aa06bc3066c07f63114 (patch)
treeb2f8bbdb3252222c9bc50efa04a5689faa3b1760 /src/gui/widgets
parent4b014aa3f403ae02587f6a3d89180f75161d4b78 (diff)
downloadmv-5d0b4c09a67f279847337aa06bc3066c07f63114.tar.gz
mv-5d0b4c09a67f279847337aa06bc3066c07f63114.tar.bz2
mv-5d0b4c09a67f279847337aa06bc3066c07f63114.tar.xz
mv-5d0b4c09a67f279847337aa06bc3066c07f63114.zip
Impliment craft inventory for moving items one by one.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/itemcontainer.cpp33
-rw-r--r--src/gui/widgets/itemcontainer.h3
2 files changed, 15 insertions, 21 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index d96d89868..af614bcb1 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -799,7 +799,8 @@ void ItemContainer::mouseReleased(MouseEvent &event)
Item *const item = inventory->getItem(dragDrop.getTag());
if (mInventory->addVirtualItem(
item,
- getSlotByXY(event.getX(), event.getY())))
+ getSlotByXY(event.getX(), event.getY()),
+ 1))
{
inventory->virtualRemove(item, 1);
}
@@ -863,7 +864,8 @@ void ItemContainer::mouseReleased(MouseEvent &event)
Item *const item = inventory->getItem(dragDrop.getTag());
if (mInventory->addVirtualItem(
item,
- getSlotByXY(event.getX(), event.getY())))
+ getSlotByXY(event.getX(), event.getY()),
+ 1))
{
inventory->virtualRemove(item, 1);
}
@@ -881,26 +883,14 @@ void ItemContainer::mouseReleased(MouseEvent &event)
if (index == Inventory::NO_SLOT_INDEX)
{
if (inventory)
- inventory->virtualRestore(item, 1);
- mInventory->removeItemAt(dragDrop.getTag());
+ {
+ inventory->virtualRestore(item,
+ item->getQuantity());
+ 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());
+ mInventory->moveItem(index, dragDrop.getTag());
}
else
{
@@ -910,7 +900,8 @@ void ItemContainer::mouseReleased(MouseEvent &event)
dragDrop.getTag());
if (item)
{
- inventory->virtualRestore(item, 1);
+ inventory->virtualRestore(item,
+ item->getQuantity());
mInventory->removeItemAt(dragDrop.getTag());
}
}
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index a7b62bbd6..e40ad4f17 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -138,6 +138,9 @@ class ItemContainer final : public Widget,
void unsetInventory()
{ mInventory = nullptr; }
+ void setInventory(Inventory *const inventory)
+ { mInventory = inventory; }
+
void setCellBackgroundImage(const std::string &xmlName);
void setMaxColumns(const int maxColumns);