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.
This commit is contained in:
Joseph-Eugene Winzer
2018-01-22 23:32:32 +00:00
committed by Thierry Crozat
parent 8a45d56630
commit 5c706dfb59
2 changed files with 15 additions and 2 deletions
+13 -1
View File
@@ -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) {
}
+2 -1
View File
@@ -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];