diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-30 14:38:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-30 14:38:47 +0300 |
commit | ecbd0c78c59a5660189e3ee03bc9cd545fb12f46 (patch) | |
tree | 79efba31c901940784e9a1ca1f53f7d7c379ed2f /src/gui/windows/equipmentwindow.cpp | |
parent | 3e773eb1fd05777c1fb56e6c8c2e56c1b1f4b11f (diff) | |
download | plus-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.tar.gz plus-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.tar.bz2 plus-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.tar.xz plus-ecbd0c78c59a5660189e3ee03bc9cd545fb12f46.zip |
Equip items also if drag it from inventory to player box in equipment window.
Diffstat (limited to 'src/gui/windows/equipmentwindow.cpp')
-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() |