summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.h
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-11-29 19:58:41 +0000
committerIra Rice <irarice@gmail.com>2008-11-29 19:58:41 +0000
commitd628724789db142c529af8c25e115dd7ea0626a7 (patch)
treec3799c68b66c5dd29dfeb5417520c7cbd0fcffb0 /src/gui/itemcontainer.h
parentc6adb930edd2d0a88d7c5ca4edd58d95382a5abf (diff)
downloadmana-client-d628724789db142c529af8c25e115dd7ea0626a7.tar.gz
mana-client-d628724789db142c529af8c25e115dd7ea0626a7.tar.bz2
mana-client-d628724789db142c529af8c25e115dd7ea0626a7.tar.xz
mana-client-d628724789db142c529af8c25e115dd7ea0626a7.zip
Imported patch that Fate made on TMW which which changes the item
container to guarantee that the inventory window always reports what the player has correctly, getting rid of the stale item references that could occur from time to time.
Diffstat (limited to 'src/gui/itemcontainer.h')
-rw-r--r--src/gui/itemcontainer.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 54e0c1ca..5d22b658 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -43,8 +43,9 @@ namespace gcn {
*
* \ingroup GUI
*/
-class ItemContainer : public gcn::Widget, public gcn::MouseListener,
- public gcn::WidgetListener
+class ItemContainer : public gcn::Widget,
+ public gcn::MouseListener,
+ public gcn::WidgetListener
{
public:
/**
@@ -80,7 +81,7 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener,
/**
* Returns the selected item.
*/
- Item* getSelectedItem() const;
+ Item* getSelectedItem();
/**
* Sets selected item to NULL.
@@ -107,9 +108,14 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener,
private:
/**
- * Sets the currently selected item.
+ * Find the current item index by the most recently used item ID
*/
- void setSelectedItem(Item *item);
+ void refindSelectedItem(void);
+
+ /**
+ * Sets the currently selected item. Invalid (e.g., negative) indices set `no item'.
+ */
+ void setSelectedItemIndex(int index);
/**
* Determine and set the height of the container.
@@ -123,7 +129,8 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener,
Inventory *mInventory;
Image *mSelImg;
- Item *mSelectedItem;
+ int mSelectedItemIndex;
+ int mLastSelectedItemId; // last selected item ID. If we lose the item, find again by ID.
int mMaxItems;
int mOffset;