summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-30 14:38:47 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-30 14:38:47 +0300
commitecbd0c78c59a5660189e3ee03bc9cd545fb12f46 (patch)
tree79efba31c901940784e9a1ca1f53f7d7c379ed2f
parent3e773eb1fd05777c1fb56e6c8c2e56c1b1f4b11f (diff)
downloadmv-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.tar.gz
mv-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.tar.bz2
mv-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.tar.xz
mv-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.zip
Equip items also if drag it from inventory to player box in equipment window.
-rw-r--r--src/gui/windows/equipmentwindow.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 193c13c8d..fe4592649 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -145,6 +145,8 @@ void EquipmentWindow::postInit()
add(mPlayerBox);
add(mUnequip);
enableVisibleSound(true);
+ mPlayerBox->setActionEventId("playerbox");
+ mPlayerBox->addActionListener(this);
}
EquipmentWindow::~EquipmentWindow()
@@ -301,6 +303,32 @@ void EquipmentWindow::action(const ActionEvent &event)
mSelectedTab = button->getTag();
updatePage();
}
+ else if (eventId == "playerbox")
+ {
+ const DragDropSource src = dragDrop.getSource();
+ if (dragDrop.isEmpty() || (src != DRAGDROP_SOURCE_INVENTORY
+ && src != DRAGDROP_SOURCE_EQUIPMENT))
+ {
+ return;
+ }
+ Inventory *const inventory = localPlayer
+ ? PlayerInfo::getInventory() : nullptr;
+ if (!inventory)
+ return;
+ Item *const item = inventory->findItem(dragDrop.getItem(),
+ dragDrop.getItemColor());
+ if (!item)
+ return;
+
+ if (dragDrop.getSource() == DRAGDROP_SOURCE_INVENTORY)
+ {
+ if (item->isEquipment())
+ {
+ if (!item->isEquipped())
+ PlayerInfo::equipItem(item, true);
+ }
+ }
+ }
}
void EquipmentWindow::updatePage()