aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/inventory.h
diff options
context:
space:
mode:
authorNicola Mettifogo2007-09-23 20:17:50 +0000
committerNicola Mettifogo2007-09-23 20:17:50 +0000
commit05abbf49a2990fb16070682ab177aa88e823a382 (patch)
treeebe9980cf25252e4725ed68a533289133c697d5e /engines/parallaction/inventory.h
parent7da28f6129cf8b0fb06bbbc0f9d5e848c1695e9c (diff)
downloadscummvm-rg350-05abbf49a2990fb16070682ab177aa88e823a382.tar.gz
scummvm-rg350-05abbf49a2990fb16070682ab177aa88e823a382.tar.bz2
scummvm-rg350-05abbf49a2990fb16070682ab177aa88e823a382.zip
Moved most of inventory-related code inside classes Inventory and InventoryRenderer. Shift is not completed, as new code doesn't handle selections yet (falling back to existent code).
svn-id: r29060
Diffstat (limited to 'engines/parallaction/inventory.h')
-rw-r--r--engines/parallaction/inventory.h70
1 files changed, 64 insertions, 6 deletions
diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h
index 2ca3559b8f..442b97b41c 100644
--- a/engines/parallaction/inventory.h
+++ b/engines/parallaction/inventory.h
@@ -30,6 +30,7 @@
namespace Parallaction {
+class Parallaction;
struct InventoryItem {
uint32 _id; // object name (lowest 16 bits are always zero)
@@ -42,19 +43,76 @@ struct InventoryItem {
#define MAKE_INVENTORY_ID(x) (((x) & 0xFFFF) << 16)
-
-extern InventoryItem _inventory[];
-
void initInventory();
void destroyInventory();
+
+
+
void openInventory();
void closeInventory();
-void cleanInventory();
-void addInventoryItem(uint16 item);
+void highlightInventoryItem(int16 pos, byte color);
+
+void cleanInventory(bool keepVerbs = true);
+const InventoryItem* getInventoryItem(int16 pos);
int16 getInventoryItemIndex(int16 pos);
-void highlightInventoryItem(int16 pos, byte color);
+typedef int16 ItemPosition;
+typedef uint16 ItemName;
+
+class Inventory {
+
+protected:
+ InventoryItem *_items;
+ uint16 _maxItems;
+ uint16 _numItems;
+
+public:
+ Inventory(uint16 maxItems);
+ virtual ~Inventory();
+
+ ItemPosition addItem(ItemName name, uint32 value);
+ ItemPosition addItem(ItemName item);
+ void removeItem(ItemName name);
+ void clear(bool keepVerbs = true);
+
+ const InventoryItem* getItem(ItemPosition pos) const;
+ ItemName getItemName(ItemPosition pos) const;
+
+ ItemPosition findItem(ItemName name) const;
+
+ int16 getNumItems() const { return _numItems; }
+};
+
+
+
+class InventoryRenderer {
+ Parallaction *_vm;
+ Inventory *_inv;
+ Common::Point _pos;
+
+ byte *_buffer;
+
+protected:
+ void drawItem(ItemPosition pos, ItemName name);
+ void refresh();
+
+public:
+ InventoryRenderer(Parallaction *vm);
+ virtual ~InventoryRenderer();
+
+ void bindInventory(Inventory *inv) { _inv = inv; }
+
+ void showInventory();
+ void hideInventory();
+
+ ItemPosition hitTest(const Common::Point &p) const;
+
+ byte* getData() const { return _buffer; }
+
+ void getRect(Common::Rect &r) const;
+ int16 getNumLines() const;
+};
} // namespace Parallaction