diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-03-24 23:10:51 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-03-25 11:31:55 -0600 |
commit | bf6cb46d9b06b06470efd5ad3ebae7e274f6906f (patch) | |
tree | 281cdf6d017477f07e02e73acef175f937c18eed /src/inventory.h | |
parent | 83077364f8b67fb9fc57e8b04a1feff0e243848d (diff) | |
download | mana-bf6cb46d9b06b06470efd5ad3ebae7e274f6906f.tar.gz mana-bf6cb46d9b06b06470efd5ad3ebae7e274f6906f.tar.bz2 mana-bf6cb46d9b06b06470efd5ad3ebae7e274f6906f.tar.xz mana-bf6cb46d9b06b06470efd5ad3ebae7e274f6906f.zip |
Eliminate the logic methods from InventoryWindow and StorageWindow
Diffstat (limited to 'src/inventory.h')
-rw-r--r-- | src/inventory.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/inventory.h b/src/inventory.h index 59da9ba0..0529d504 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -22,11 +22,27 @@ #ifndef INVENTORY_H #define INVENTORY_H +#include <list> + +class Inventory; class Item; +class InventoryListener +{ +public: + virtual ~InventoryListener() {} + + virtual void slotsChanged(Inventory* inventory) = 0; + +protected: + InventoryListener() {} +}; + class Inventory { public: + static const int NO_SLOT_INDEX = -1; /**< Slot has no index. */ + /** * Constructor. * @@ -95,18 +111,27 @@ class Inventory /** * Get the number of slots filled with an item */ - int getNumberOfSlotsUsed() const; + int getNumberOfSlotsUsed() const + { return mUsed; } /** * Returns the index of the last occupied slot or 0 if none occupied. */ int getLastUsedSlot() const; - static const int NO_SLOT_INDEX = -1; /**< Slot has no index. */ + void addInventoyListener(InventoryListener* listener); + + void removeInventoyListener(InventoryListener* listener); protected: + typedef std::list<InventoryListener*> InventoryListenerList; + InventoryListenerList mInventoryListeners; + + void distributeSlotsChangedEvent(); + Item **mItems; /**< The holder of items */ int mSize; /**< The max number of inventory items */ + int mUsed; /**< THe number of slots in use */ }; #endif |