diff options
author | Joseph-Eugene Winzer | 2017-06-18 18:20:46 +0200 |
---|---|---|
committer | Thierry Crozat | 2018-01-22 23:32:32 +0000 |
commit | 5c706dfb596cae682dcc759c3f18e8d97ff1cd14 (patch) | |
tree | ad356603b90bb3bf233e673bf9ca61932043689c /engines | |
parent | 8a45d56630cf6dc2199f6d9621e715ea67b33635 (diff) | |
download | scummvm-rg350-5c706dfb596cae682dcc759c3f18e8d97ff1cd14.tar.gz scummvm-rg350-5c706dfb596cae682dcc759c3f18e8d97ff1cd14.tar.bz2 scummvm-rg350-5c706dfb596cae682dcc759c3f18e8d97ff1cd14.zip |
SUPERNOVA: Extends Inventory::get()
The code added as comments to Inventory::add() is the original code to
check if scrolling in inventory is needed and redraw it.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/supernova/supernova.cpp | 14 | ||||
-rw-r--r-- | engines/supernova/supernova.h | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index b3c0adb8a0..6c2bd688c3 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -418,6 +418,9 @@ Inventory::Inventory() void Inventory::add(Object &obj) { if (_numObjects < kMaxCarry) _inventory[_numObjects] = &obj; + +// if (inventory_amount>8) inventory_scroll = ((inventory_amount+1)/2)*2-8; +// show_inventory(); } // TODO: Update Inventory surface for scrolling @@ -434,13 +437,22 @@ void Inventory::remove(Object &obj) { } } -Object *Inventory::get(size_t index) { +Object *Inventory::get(size_t index) const { if (index < _numObjects) return _inventory[index]; return NULL; } +Object *Inventory::get(ObjectID id) const { + for (size_t i = 0; i < _numObjects; ++i) { + if (_inventory[i]->_id == id) + return _inventory[i]; + } + + return NULL; +} + ScreenBufferStack::ScreenBufferStack() : _last(_buffer) { } diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 9370e900b4..f1f5b4a442 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -107,7 +107,8 @@ public: void add(Object &obj); void remove(Object &obj); - Object *get(size_t index); + Object *get(size_t index) const; + Object *get(ObjectID id) const; private: Object *_inventory[kMaxCarry]; |