From 5c706dfb596cae682dcc759c3f18e8d97ff1cd14 Mon Sep 17 00:00:00 2001 From: Joseph-Eugene Winzer Date: Sun, 18 Jun 2017 18:20:46 +0200 Subject: 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. --- engines/supernova/supernova.cpp | 14 +++++++++++++- 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]; -- cgit v1.2.3