From ea86df6407e6d3e21644f97202ee751b8f87107e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 15 Jul 2011 03:53:09 +0300 Subject: Add quick keys to add items to trade. --- src/gui/inventorywindow.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'src/gui/inventorywindow.cpp') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 5e1accc09..27fbf7760 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -33,6 +33,7 @@ #include "gui/sdlinput.h" #include "gui/shopwindow.h" #include "gui/theme.h" +#include "gui/tradewindow.h" #include "gui/viewport.h" #include "gui/widgets/button.h" @@ -351,9 +352,13 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); - bool mod = (isStorageActive() && keyboard.isKeyActive(keyboard.KEY_MOD)); + const bool mod = (isStorageActive() && keyboard.isKeyActive( + keyboard.KEY_MOD)); - if (!mod && event.getButton() == gcn::MouseEvent::RIGHT) + const bool mod2 = (tradeWindow && tradeWindow->isVisible() + && keyboard.isKeyActive(keyboard.KEY_MOD)); + + if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT) { Item *item = mItems->getSelectedItem(); @@ -370,16 +375,19 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) viewport->showPopup(this, mx, my, item, isMainInventory()); } + if (!mInventory) + return; + if (event.getButton() == gcn::MouseEvent::LEFT || event.getButton() == gcn::MouseEvent::RIGHT) { - if (mod) - { - Item *item = mItems->getSelectedItem(); + Item *item = mItems->getSelectedItem(); - if (!item || !mInventory) - return; + if (!item) + return; + if (mod) + { if (mInventory->isMainInventory()) { if (event.getButton() == gcn::MouseEvent::RIGHT) @@ -409,6 +417,19 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) } } } + else if (mod2 && mInventory->isMainInventory()) + { + if (event.getButton() == gcn::MouseEvent::RIGHT) + { + ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, + tradeWindow, item); + } + else + { + if (tradeWindow) + tradeWindow->tradeItem(item, item->getQuantity()); + } + } } } -- cgit v1.2.3-60-g2f50