summaryrefslogtreecommitdiff
path: root/src/gui/inventorywindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-06-17 23:07:29 +0300
committerAndrei Karas <akaras@inbox.ru>2012-06-17 23:07:29 +0300
commit1ec82e44a0ec44a3d342a68b42b318e4413410dc (patch)
treef3010c20fd90440c81921c612267d8a58e4f1ee3 /src/gui/inventorywindow.cpp
parent1f66ae673801e76f3574944628a7980b9bfbabda (diff)
downloadmanaplus-1ec82e44a0ec44a3d342a68b42b318e4413410dc.tar.gz
manaplus-1ec82e44a0ec44a3d342a68b42b318e4413410dc.tar.bz2
manaplus-1ec82e44a0ec44a3d342a68b42b318e4413410dc.tar.xz
manaplus-1ec82e44a0ec44a3d342a68b42b318e4413410dc.zip
Fix double click support in gui class.
Add double click support to inventory and storage windows.
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r--src/gui/inventorywindow.cpp48
1 files changed, 48 insertions, 0 deletions
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);
+ }
+ }
+ }
}
}