From f4eb7cbfc5ad4d3c266406b2f93748365df9be95 Mon Sep 17 00:00:00 2001 From: Joseph-Eugene Winzer Date: Thu, 15 Jun 2017 22:57:59 +0200 Subject: SUPERNOVA: Adds Inventory Class --- engines/supernova/supernova.cpp | 31 +++++++++++++++++++++++++++++++ engines/supernova/supernova.h | 15 ++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) (limited to 'engines/supernova') diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index f5967fb5e1..a24af84aca 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -392,4 +392,35 @@ void SupernovaEngine::paletteFadeIn() { _system->updateScreen(); } +Inventory::Inventory() + : _numObjects(0) +{} + +// TODO: Update Inventory surface for scrolling +void Inventory::add(Object &obj) { + if (_numObjects < kMaxCarry) + _inventory[_numObjects] = &obj; +} + +// TODO: Update Inventory surface for scrolling +void Inventory::remove(Object &obj) { + for (size_t i = 0; i < _numObjects; ++i) { + if (_inventory[i] == &obj) { + --_numObjects; + while (i < _numObjects) { + _inventory[i] = _inventory[i + 1]; + ++i; + } + obj.disableProperty(CARRIED); + } + } +} + +Object *Inventory::get(size_t index) { + if (index < _numObjects) + return _inventory[index]; + + return NULL; +} + } diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 017c912f13..2844c2aa6f 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -55,7 +55,7 @@ private: byte _menuBrightness; byte _brightness; uint _delay; - + void initData(); void initPalette(); void paletteFadeIn(); @@ -71,6 +71,19 @@ private: void renderBox(int x, int y, int width, int height, byte color); }; +class Inventory { +public: + Inventory(); + + void add(Object &obj); + void remove(Object &obj); + Object *get(size_t index); + +private: + Object *_inventory[kMaxCarry]; + size_t _numObjects; +}; + } #endif -- cgit v1.2.3