diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-19 10:06:39 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-19 10:06:39 +0000 |
commit | 7965fc105191a74a9b8c26ee8b646c7394434a9a (patch) | |
tree | 3530857b97b85b5340599e90a4ce1438ebf34c0c /src/gui/itemcontainer.cpp | |
parent | 77944e37304cd1b282d4ba31ef624810631d58a3 (diff) | |
download | mana-7965fc105191a74a9b8c26ee8b646c7394434a9a.tar.gz mana-7965fc105191a74a9b8c26ee8b646c7394434a9a.tar.bz2 mana-7965fc105191a74a9b8c26ee8b646c7394434a9a.tar.xz mana-7965fc105191a74a9b8c26ee8b646c7394434a9a.zip |
Fixed key special values. Reduced amount of spurious item deselections.
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r-- | src/gui/itemcontainer.cpp | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index c7ba2949..78b62a28 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -25,6 +25,7 @@ #include <guichan/mouseinput.hpp> +#include "sdlinput.h" #include "selectionlistener.h" #include "../graphics.h" @@ -173,23 +174,23 @@ ItemContainer::keyPressed(gcn::KeyEvent &event) { switch (event.getKey().getValue()) { - case gcn::Key::LEFT: + case Key::LEFT: moveHighlight(ItemContainer::MOVE_SELECTED_LEFT); break; - case gcn::Key::RIGHT: + case Key::RIGHT: moveHighlight(ItemContainer::MOVE_SELECTED_RIGHT); break; - case gcn::Key::UP: + case Key::UP: moveHighlight(ItemContainer::MOVE_SELECTED_UP); break; - case gcn::Key::DOWN: + case Key::DOWN: moveHighlight(ItemContainer::MOVE_SELECTED_DOWN); break; - case gcn::Key::SPACE: + case Key::SPACE: keyAction(); break; - case gcn::Key::LEFT_ALT: - case gcn::Key::RIGHT_ALT: + case Key::LEFT_ALT: + case Key::RIGHT_ALT: mSwapItems = true; } } @@ -199,8 +200,8 @@ ItemContainer::keyReleased(gcn::KeyEvent &event) { switch (event.getKey().getValue()) { - case gcn::Key::LEFT_ALT: - case gcn::Key::RIGHT_ALT: + case Key::LEFT_ALT: + case Key::RIGHT_ALT: mSwapItems = false; } } @@ -244,23 +245,18 @@ ItemContainer::mouseDragged(gcn::MouseEvent &event) } } -void -ItemContainer::mouseReleased(gcn::MouseEvent &event) +void ItemContainer::mouseReleased(gcn::MouseEvent &event) { - if (mDragged) - { - mDragged = false; - - const int index = getSlotIndex(event.getX(), event.getY()); - if (index == Inventory::NO_SLOT_INDEX) { - return; - } - - if (mSelectedItem) { - player_node->moveInvItem(mSelectedItem, index); - setSelectedItem(NULL); - } - } + if (!mDragged) return; + mDragged = false; + if (!mSelectedItem) return; + int index = getSlotIndex(event.getX(), event.getY()); + if (index == Inventory::NO_SLOT_INDEX) return; + Item *item = mInventory->getItem(index); + if (item == mSelectedItem) return; + player_node->moveInvItem(mSelectedItem, index); + item = mInventory->getItem(index); + setSelectedItem(item->getId() ? item : NULL); } int @@ -296,7 +292,7 @@ ItemContainer::keyAction() mSelectedItem, mHighlightedItem->getInvIndex()); setSelectedItem(mHighlightedItem); } - // If the highlight is on an item the select it. + // If the highlight is on an item then select it. else if (mHighlightedItem->getId()) { setSelectedItem(mHighlightedItem); |