From ecbd0c78c59a5660189e3ee03bc9cd545fb12f46 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 30 Dec 2014 14:38:47 +0300 Subject: Equip items also if drag it from inventory to player box in equipment window. --- src/gui/windows/equipmentwindow.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/gui') 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() -- cgit v1.2.3-70-g09d2