summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/gui/inventorywindow.cpp9
-rw-r--r--src/gui/itemcontainer.cpp48
3 files changed, 31 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f6859a1..f42c258a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
* data/equipment.xml: Removed obsolete file.
* data/items.xml: Fixed equipment types.
* src/item.h: Fixed invalid item ID.
+ * src/gui/inventorywindow.cpp, src/gui/itemcontainer.cpp: Fixed key
+ special values.
+ * src/gui/itemcontainer.cpp: Reduced amount of spurious item
+ deselections.
2007-10-19 Philipp Sehmisch <tmw@crushnet.org>
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 1e62b130..ec241800 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -35,6 +35,7 @@
#include "item_amount.h"
#include "itemcontainer.h"
#include "scrollarea.h"
+#include "sdlinput.h"
#include "viewport.h"
#include "../item.h"
@@ -263,8 +264,8 @@ void InventoryWindow::keyPressed(gcn::KeyEvent &event)
{
switch (event.getKey().getValue())
{
- case gcn::Key::LEFT_SHIFT:
- case gcn::Key::RIGHT_SHIFT:
+ case Key::LEFT_SHIFT:
+ case Key::RIGHT_SHIFT:
mSplit = true;
}
}
@@ -273,8 +274,8 @@ void InventoryWindow::keyReleased(gcn::KeyEvent &event)
{
switch (event.getKey().getValue())
{
- case gcn::Key::LEFT_SHIFT:
- case gcn::Key::RIGHT_SHIFT:
+ case Key::LEFT_SHIFT:
+ case Key::RIGHT_SHIFT:
mSplit = false;
}
}
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);