aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichiesams2013-09-03 23:59:00 -0500
committerrichiesams2013-09-04 00:16:46 -0500
commit23ae67c7776f5f3a2207109e7d6cdaef16940979 (patch)
treed96b8d0368e9f7b870a14378f8636d1ad56e8ebe
parent644af30df572f4965d63e1dba77c574a1d5ad69a (diff)
downloadscummvm-rg350-23ae67c7776f5f3a2207109e7d6cdaef16940979.tar.gz
scummvm-rg350-23ae67c7776f5f3a2207109e7d6cdaef16940979.tar.bz2
scummvm-rg350-23ae67c7776f5f3a2207109e7d6cdaef16940979.zip
ZVISION: Create ScriptManager _activeControls serialization methods
-rw-r--r--engines/zvision/script_manager.cpp30
-rw-r--r--engines/zvision/script_manager.h3
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: