From 1ec82e44a0ec44a3d342a68b42b318e4413410dc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 17 Jun 2012 23:07:29 +0300 Subject: Fix double click support in gui class. Add double click support to inventory and storage windows. --- src/gui/inventorywindow.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/gui/inventorywindow.cpp') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index c20dd0036..ccfb12d8a 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -31,6 +31,7 @@ #include "playerinfo.h" #include "units.h" +#include "gui/gui.h" #include "gui/itemamountwindow.h" #include "gui/setup.h" #include "gui/sdlinput.h" @@ -322,7 +323,9 @@ void InventoryWindow::action(const gcn::ActionEvent &event) Net::getInventoryHandler()->equipItem(item); } else + { Net::getInventoryHandler()->useItem(item); + } } if (event.getId() == "equip") { @@ -334,7 +337,9 @@ void InventoryWindow::action(const gcn::ActionEvent &event) Net::getInventoryHandler()->equipItem(item); } else + { Net::getInventoryHandler()->useItem(item); + } } else if (event.getId() == "drop") { @@ -391,6 +396,11 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); + const int clicks = event.getClickCount(); + + if (clicks == 2 && gui) + gui->resetClickCount(); + const bool mod = (isStorageActive() && inputManager.isActionActive( Input::KEY_MOD)); @@ -469,6 +479,44 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) tradeWindow->tradeItem(item, item->getQuantity(), true); } } + else if (clicks == 2) + { + if (mInventory->isMainInventory()) + { + if (isStorageActive()) + { + ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, + inventoryWindow, item); + } + else if (tradeWindow && tradeWindow->isVisible()) + { + ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, + tradeWindow, item); + } + else + { + if (item->isEquipment()) + { + if (item->isEquipped()) + Net::getInventoryHandler()->unequipItem(item); + else + Net::getInventoryHandler()->equipItem(item); + } + else + { + Net::getInventoryHandler()->useItem(item); + } + } + } + else + { + if (isStorageActive()) + { + ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, + inventoryWindow, item); + } + } + } } } -- cgit v1.2.3-70-g09d2