diff options
-rw-r--r-- | src/gui/itemcontainer.cpp | 14 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 4779b004..d2712cba 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -320,6 +320,20 @@ void ItemContainer::widgetResized(const gcn::Event &event) setHeight(mGridRows * BOX_HEIGHT); } +Item *ItemContainer::getSelectedItem() +{ + if (!mSelectedItem) + return NULL; + + if (!mInventory->contains(mSelectedItem)) + { + mSelectedItem = NULL; + return NULL; + } + + return mSelectedItem; +} + int ItemContainer::getSlotIndex(int x, int y) const { if (x < getWidth() && y < getHeight()) diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index bc7caf5d..54d7c35e 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -86,8 +86,7 @@ class ItemContainer : public gcn::Widget, /** * Returns the selected item. */ - Item *getSelectedItem() const - { return mSelectedItem; } + Item *getSelectedItem(); /** * Sets selected item to NULL. |