diff options
author | richiesams | 2013-07-03 17:21:21 -0500 |
---|---|---|
committer | richiesams | 2013-08-04 13:31:57 -0500 |
commit | 187c119e934fd5887fb26e2dada5e1a4c856e056 (patch) | |
tree | d0beca52f673e49d2d20fdc2ae2b1f3da1d8a083 /engines/zvision | |
parent | c0c4ee65339285652b7966afa66a48d012d6ea27 (diff) | |
download | scummvm-rg350-187c119e934fd5887fb26e2dada5e1a4c856e056.tar.gz scummvm-rg350-187c119e934fd5887fb26e2dada5e1a4c856e056.tar.bz2 scummvm-rg350-187c119e934fd5887fb26e2dada5e1a4c856e056.zip |
ZVISION: Create ResultAction 's for Add and Random.
Create class templates for PlayAnimation, PreloadAnimation, and Attenuate
Diffstat (limited to 'engines/zvision')
-rw-r--r-- | engines/zvision/result_action.cpp | 30 | ||||
-rw-r--r-- | engines/zvision/result_action.h | 38 | ||||
-rw-r--r-- | engines/zvision/scr_file_handling.cpp | 7 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 4 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 3 |
5 files changed, 77 insertions, 5 deletions
diff --git a/engines/zvision/result_action.cpp b/engines/zvision/result_action.cpp index 375dcd2f59..de439db1b9 100644 --- a/engines/zvision/result_action.cpp +++ b/engines/zvision/result_action.cpp @@ -26,6 +26,9 @@ namespace ZVision { +// ActionAdd +////////////////////////////////////////////////////////////////////////////// + ActionAdd::ActionAdd(Common::String line) { sscanf(line.c_str(), ":add(%u,%hhu)", &_key, &_value); } @@ -35,4 +38,31 @@ bool ActionAdd::execute(ZVision *zVision) { return true; } + +// ActionAssign +////////////////////////////////////////////////////////////////////////////// + +ActionAssign::ActionAssign(Common::String line) { + sscanf(line.c_str(), ":assign(%u, %hhu)", &_key, &_value); +} + +bool ActionAssign::execute(ZVision *zVision) { + zVision->getScriptManager()->setStateValue(_key, _value); + return true; +} + + +// ActionRandom +////////////////////////////////////////////////////////////////////////////// + +ActionRandom::ActionRandom(Common::String line) { + sscanf(line.c_str(), ":random:%u, %u)", &_key, &_max); +} + +bool ActionRandom::execute(ZVision *zVision) { + uint32 randNumber = zVision->getRandomSource()->getRandomNumber(_max); + zVision->getScriptManager()->setStateValue(_key, randNumber); + return true; +} + } // End of namespace ZVision diff --git a/engines/zvision/result_action.h b/engines/zvision/result_action.h index 4fd589d7cc..7ab896d510 100644 --- a/engines/zvision/result_action.h +++ b/engines/zvision/result_action.h @@ -87,6 +87,44 @@ private: byte _value; }; +class ActionPlayAnimation : public ResultAction { +public: + ActionPlayAnimation(Common::String line); + bool execute(ZVision *zVision); +}; + +class ActionPreloadAnimation : public ResultAction { +public: + ActionPreloadAnimation(Common::String line); + bool execute(ZVision *zVision); +}; + +class ActionAttenuate : public ResultAction { +public: + ActionAttenuate(Common::String line); + bool execute(ZVision *zVision); +}; + +class ActionAssign : public ResultAction { +public: + ActionAssign(Common::String line); + bool execute(ZVision *zVision); + +private: + uint32 _key; + byte _value; +}; + +class ActionRandom : public ResultAction { +public: + ActionRandom(Common::String line); + bool execute(ZVision *zVision); + +private: + uint32 _key; + uint32 _max; +}; + } // End of namespace ZVision #endif diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 073d0eaaa4..3171492717 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -131,16 +131,15 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(line); + // TODO: Re-order the if-then statements in order of highest occurrence while (!line.contains('}')) { // Parse for the action type if (line.matchString("*:add*", true)) { actionList.push_back(ActionAdd(line)); } else if (line.matchString("*:animplay*", true)) { - - + actionList.push_back(ActionPlayAnimation(line)); } else if (line.matchString("*:animpreload*", true)) { - - + actionList.push_back(ActionPreloadAnimation(line)); } else if (line.matchString("*:animunload*", true)) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 5af1cbb1a2..479bf2379a 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -142,4 +142,8 @@ ScriptManager *ZVision::getScriptManager() const { return _scriptManager;
}
+Common::RandomSource *ZVision::getRandomSource() const {
+ return _rnd;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 166d3c023f..ac5796ad91 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -70,6 +70,7 @@ public: Common::Language getLanguage() const;
virtual Common::Error run();
ScriptManager *getScriptManager() const;
+ Common::RandomSource *getRandomSource() const;
private:
void initialize();
@@ -89,7 +90,7 @@ public: Console(ZVision *vm) {}
virtual ~Console(void) {}
};
-
+
} // End of namespace ZVision
#endif
|