aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2017-06-15 22:57:59 +0200
committerThierry Crozat2018-01-22 23:08:39 +0000
commitf4eb7cbfc5ad4d3c266406b2f93748365df9be95 (patch)
treeddc37738f3a4d93a33a903b6676d2a3a8804f1d5 /engines
parent18ac67f907c82a74ef4a48f310e2d5a2001ebd61 (diff)
downloadscummvm-rg350-f4eb7cbfc5ad4d3c266406b2f93748365df9be95.tar.gz
scummvm-rg350-f4eb7cbfc5ad4d3c266406b2f93748365df9be95.tar.bz2
scummvm-rg350-f4eb7cbfc5ad4d3c266406b2f93748365df9be95.zip
SUPERNOVA: Adds Inventory Class
Diffstat (limited to 'engines')
-rw-r--r--engines/supernova/supernova.cpp31
-rw-r--r--engines/supernova/supernova.h15
2 files changed, 45 insertions, 1 deletions
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