summaryrefslogtreecommitdiff
path: root/src/inventory.h
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-03-24 23:10:51 -0600
committerJared Adams <jaxad0127@gmail.com>2010-03-25 11:31:55 -0600
commitbf6cb46d9b06b06470efd5ad3ebae7e274f6906f (patch)
tree281cdf6d017477f07e02e73acef175f937c18eed /src/inventory.h
parent83077364f8b67fb9fc57e8b04a1feff0e243848d (diff)
downloadMana-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.h29
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