diff options
author | Jaromir Wysoglad | 2019-05-30 08:06:34 +0200 |
---|---|---|
committer | Thierry Crozat | 2019-07-28 15:09:14 +0100 |
commit | 777040557d7a48eb6c408ea5b66d3048434afdfb (patch) | |
tree | b21032986f149c28463ab009981d21e76caa3941 /engines/supernova2/state.cpp | |
parent | 977d67b27216a98be36e128432f09f0bbcc8e9f1 (diff) | |
download | scummvm-rg350-777040557d7a48eb6c408ea5b66d3048434afdfb.tar.gz scummvm-rg350-777040557d7a48eb6c408ea5b66d3048434afdfb.tar.bz2 scummvm-rg350-777040557d7a48eb6c408ea5b66d3048434afdfb.zip |
SUPERNOVA2: Add inventory from supernova
Diffstat (limited to 'engines/supernova2/state.cpp')
-rw-r--r-- | engines/supernova2/state.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/engines/supernova2/state.cpp b/engines/supernova2/state.cpp index 71adbf0af9..2d44b2a479 100644 --- a/engines/supernova2/state.cpp +++ b/engines/supernova2/state.cpp @@ -42,8 +42,59 @@ namespace Supernova2 { // kStringStatusCommandPress, kStringStatusCommandPull, kStringStatusCommandUse, kStringStatusCommandTalk, kStringStatusCommandGive //}; +void Inventory::add(Object &obj) { + if (_numObjects < kMaxCarry) { + _inventory[_numObjects++] = &obj; + obj.setProperty(CARRIED); + } + + if (getSize() > _inventoryScroll + 8) { + _inventoryScroll = getSize() - 8; + _inventoryScroll += _inventoryScroll % 2; + } +} + +void Inventory::remove(Object &obj) { + for (int i = 0; i < _numObjects; ++i) { + if (_inventory[i] == &obj) { + if (_inventoryScroll >= 2 && getSize() % 2) + _inventoryScroll -= 2; + + --_numObjects; + while (i < _numObjects) { + _inventory[i] = _inventory[i + 1]; + ++i; + } + obj.disableProperty(CARRIED); + } + } +} + +void Inventory::clear() { + for (int i = 0; i < _numObjects; ++i) + _inventory[i]->disableProperty(CARRIED); + _numObjects = 0; + _inventoryScroll = 0; +} + +Object *Inventory::get(int index) const { + if (index < _numObjects) + return _inventory[index]; + + return _nullObject; +} + +Object *Inventory::get(ObjectId id) const { + for (int i = 0; i < _numObjects; ++i) { + if (_inventory[i]->_id == id) + return _inventory[i]; + } + + return _nullObject; +} GameManager::GameManager(Supernova2Engine *vm) - : _vm(vm) + : _inventory(&_nullObject, _inventoryScroll) + , _vm(vm) , _mouseClickType(Common::EVENT_INVALID) { initRooms(); changeRoom(INTRO); @@ -54,6 +105,9 @@ GameManager::~GameManager() { } void GameManager::initState() { + _currentInputObject = &_nullObject; + _inputObject[0] = &_nullObject; + _inputObject[1] = &_nullObject; _processInput = false; _guiEnabled = true; _animationEnabled = true; |