diff options
author | Dennis Friis <peavey@placid.dk> | 2008-04-24 20:49:30 +0000 |
---|---|---|
committer | Dennis Friis <peavey@placid.dk> | 2008-04-24 20:49:30 +0000 |
commit | 3676b78c6e6e8089c0b6e38c0983bd99ea22e756 (patch) | |
tree | 30dadd8b4e00f70245279eeee04c71347f7dbc60 /src/gui/itemshortcutcontainer.cpp | |
parent | 8c0964dbb59a10c47d2040686b03201ab5688092 (diff) | |
download | mana-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.gz mana-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.bz2 mana-3676b78c6e6e8089c0b6e38c0983bd99ea22e756.tar.xz mana-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/itemshortcutcontainer.cpp')
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
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) |