diff options
-rw-r--r-- | engines/zvision/script_manager.cpp | 30 | ||||
-rw-r--r-- | engines/zvision/script_manager.h | 3 |
2 files changed, 33 insertions, 0 deletions
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 25cbc6d285..d5fcf81ed5 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -360,6 +360,36 @@ void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) { } } +void ScriptManager::serializeControls(Common::WriteStream *stream) { + // Count how many controls need to save their data + // Because WriteStream isn't seekable + uint32 numberOfControlsNeedingSerialization = 0; + for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { + if ((*iter)->needsSerialization()) { + numberOfControlsNeedingSerialization++; + } + } + stream->writeUint32LE(numberOfControlsNeedingSerialization); + + for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { + (*iter)->serialize(stream); + } +} + +void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) { + uint32 numberOfControls = stream->readUint32LE(); + + for (uint32 i = 0; i < numberOfControls; i++) { + uint32 key = stream->readUint32LE(); + for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { + if ((*iter)->getKey() == key) { + (*iter)->deserialize(stream); + break; + } + } + } +} + Location ScriptManager::getCurrentLocation() const { Location location = _currentLocation; location.offset = _engine->getRenderManager()->getCurrentBackgroundOffset(); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index c5377504a8..d2ad4acfff 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -112,6 +112,9 @@ public: void serializeStateTable(Common::WriteStream *stream); void deserializeStateTable(Common::SeekableReadStream *stream); + void serializeControls(Common::WriteStream *stream); + void deserializeControls(Common::SeekableReadStream *stream); + Location getCurrentLocation() const; private: |