From 9bf3338f82bfbd425debb2855d015c7bd0e33989 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sun, 17 Jul 2005 21:10:44 +0000 Subject: Added Item and Equipment class and made the appropriate places make use of them. Plus some cleanups. --- src/gui/itemcontainer.h | 83 ++++++++++--------------------------------------- 1 file changed, 16 insertions(+), 67 deletions(-) (limited to 'src/gui/itemcontainer.h') diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index a0e3b79a..6e72eba0 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -26,22 +26,15 @@ #include #include + +#include "../item.h" + +#include "../item.h" #include "../resources/image.h" #include "../graphic/spriteset.h" #define INVENTORY_SIZE 100 -/** - * The holder of a item. - */ -struct ITEM_HOLDER -{ - int id; /**< The id of the item */ - int quantity; /**< The number of items */ - bool equipment; /**< Whether this item is equipment */ - bool equipped; /**< Whether this item is equipped */ -}; - /** * An item container. Used to show items in inventory and trade dialog. * @@ -49,13 +42,6 @@ struct ITEM_HOLDER */ class ItemContainer : public gcn::Widget, public gcn::MouseListener { - private: - Spriteset *itemset; - Image *selImg; - int selectedItem; - int itemNumber; - ITEM_HOLDER items[INVENTORY_SIZE]; /**< The holder of items */ - public: /** * Constructor. Initializes the graphic. @@ -83,35 +69,20 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener */ void mousePress(int mx, int my, int button); - /** - * Returns index of the selected item. - */ - int getIndex(); - /** * Finds the index of an item. */ int getIndex(int id); /** - * Returns the id of the selected item. - */ - int getId(); - - /** - * Returns the id of an item. + * Returns the selected item. */ - int getId(int index); + Item* getItem(); /** - * Returns the quantity of the selected item. + * Returns the item at the specified index. */ - int getQuantity(); - - /** - * Returns the quantity of an item. - */ - int getQuantity(int index); + Item* getItem(int index); /** * Returns id of next free slot or -1 if all occupied. @@ -138,40 +109,18 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener */ void removeItem(int id); - /** - * Change quantity of an item. - */ - void changeQuantity(int index, int quantity); - - /** - * Increase quantity of an item. - */ - void increaseQuantity(int index, int quantity); - - /** - * Returns whether the item at the specified index is equipment. - */ - bool isEquipment(int index); - - /** - * Returns whether the item at the specified index is equipped. - */ - bool isEquipped(int index); - - /** - * Sets whether the item at the specified index is equipped. - */ - void setEquipped(int index, bool equipped); - - /** - * Sets whether the item at the specified index is equipment. - */ - void setEquipment(int index, bool equipment); - /** * Get the number of slots filled with an item */ int getNumberOfSlotsUsed(); + + private: + Spriteset *itemset; + Image *selImg; + Item *selectedItem; + int itemNumber; + Item items[INVENTORY_SIZE]; /**< The holder of items */ + }; #endif -- cgit v1.2.3-70-g09d2