diff options
-rw-r--r-- | src/gui/windows/equipmentwindow.cpp | 28 |
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() |