summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorDennis Friis <peavey@placid.dk>2008-04-24 20:49:30 +0000
committerDennis Friis <peavey@placid.dk>2008-04-24 20:49:30 +0000
commit3676b78c6e6e8089c0b6e38c0983bd99ea22e756 (patch)
tree30dadd8b4e00f70245279eeee04c71347f7dbc60 /src/gui
parent8c0964dbb59a10c47d2040686b03201ab5688092 (diff)
downloadmana-client-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.gz
mana-client-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.bz2
mana-client-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.xz
mana-client-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.zip
Make shortcut container ID based instead of slot based. Fixes items shifting around often causing equipment to be lost.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/itemcontainer.cpp4
-rw-r--r--src/gui/itemshortcutcontainer.cpp14
2 files changed, 11 insertions, 7 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index ad0674f4..a6348d01 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -197,7 +197,7 @@ ItemContainer::mousePressed(gcn::MouseEvent &event)
int my = event.getY();
int index = mx / gridWidth + ((my / gridHeight) * columns) + 2;
- itemShortcut->setItemSelected(NULL);
+ itemShortcut->setItemSelected(-1);
// Fix for old server, it should be: if (index >= mMaxItems)
if (index > mMaxItems + 1)
{
@@ -208,7 +208,7 @@ ItemContainer::mousePressed(gcn::MouseEvent &event)
setSelectedItem(item);
if (!item->isEquipment())
{
- itemShortcut->setItemSelected(item);
+ itemShortcut->setItemSelected(item->getId());
}
}
}
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 3c03d85a..4c376718 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -23,6 +23,7 @@
#include "itemshortcutcontainer.h"
+#include "../localplayer.h"
#include "../graphics.h"
#include "../item.h"
#include "../itemshortcut.h"
@@ -87,7 +88,10 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics)
(SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0+i));
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
- Item *item = itemShortcut->getItem(i);
+ if (itemShortcut->getItem(i) < 0)
+ continue;
+
+ Item *item = player_node->searchForItem(itemShortcut->getItem(i));
if (item) {
// Draw item icon.
Image* image = item->getInfo().getImage();
@@ -145,7 +149,7 @@ ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
if (index == -1) {
return;
}
- Item *item = itemShortcut->getItem(index);
+ Item *item = player_node->searchForItem(itemShortcut->getItem(index));
if (item)
{
mItemMoved = item;
@@ -170,7 +174,7 @@ ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
// Stores the selected item if theirs one.
if (itemShortcut->isItemSelected()) {
itemShortcut->setItem(index);
- itemShortcut->setItemSelected(NULL);
+ itemShortcut->setItemSelected(-1);
}
else if (itemShortcut->getItem(index)) {
mItemClicked = true;
@@ -184,7 +188,7 @@ ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
{
if (itemShortcut->isItemSelected())
{
- itemShortcut->setItemSelected(NULL);
+ itemShortcut->setItemSelected(-1);
}
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1) {
@@ -192,7 +196,7 @@ ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
return;
}
if (mItemMoved) {
- itemShortcut->setItems(index, mItemMoved);
+ itemShortcut->setItems(index, mItemMoved->getId());
mItemMoved = NULL;
}
else if (itemShortcut->getItem(index) && mItemClicked)