summaryrefslogtreecommitdiff
path: root/src/gui/itemshortcutcontainer.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-11-01 14:55:54 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-11-01 14:55:54 +0000
commit55e0ddd7e1d60a56ece679a4c2563bef854e892b (patch)
tree322df9b8661f379990b3b526e5aa41f0e23ec9e2 /src/gui/itemshortcutcontainer.cpp
parent3d85803d9a43c779f522a936df068a24ca6f7f2d (diff)
downloadmana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.tar.gz
mana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.tar.bz2
mana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.tar.xz
mana-55e0ddd7e1d60a56ece679a4c2563bef854e892b.zip
Merged revisions 4180-4181 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0 ........ r4180 | peaveydk | 2008-04-24 22:49:30 +0200 (Thu, 24 Apr 2008) | 1 line Make shortcut container ID based instead of slot based. Fixes items shifting around often causing equipment to be lost. ........ r4181 | peaveydk | 2008-04-25 02:25:59 +0200 (Fri, 25 Apr 2008) | 1 line Document anti-trade function. ........
Diffstat (limited to 'src/gui/itemshortcutcontainer.cpp')
-rw-r--r--src/gui/itemshortcutcontainer.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index e8cc5711..a54e3678 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->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)