diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-15 03:53:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-15 03:53:09 +0300 |
commit | ea86df6407e6d3e21644f97202ee751b8f87107e (patch) | |
tree | 1735a696458c0d9bedb2dbfd698601ff4a0e11cb | |
parent | 1716afe170d8c51024be78b01b651f44c73c8afa (diff) | |
download | manaverse-ea86df6407e6d3e21644f97202ee751b8f87107e.tar.gz manaverse-ea86df6407e6d3e21644f97202ee751b8f87107e.tar.bz2 manaverse-ea86df6407e6d3e21644f97202ee751b8f87107e.tar.xz manaverse-ea86df6407e6d3e21644f97202ee751b8f87107e.zip |
Add quick keys to add items to trade.
-rw-r--r-- | src/gui/inventorywindow.cpp | 35 |
1 files changed, 28 insertions, 7 deletions
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()); + } + } } } |