mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
MOHAWK: Add a script queue to Riven's script manager
This commit is contained in:
parent
bc01a276f9
commit
3c2ca08877
@ -698,7 +698,7 @@ void MohawkEngine_Riven::runCardScript(uint16 scriptType) {
|
||||
for (uint16 i = 0; i < _cardData.scripts.size(); i++)
|
||||
if (_cardData.scripts[i].type == scriptType) {
|
||||
RivenScriptPtr script = _cardData.scripts[i].script;
|
||||
script->runScript();
|
||||
_scriptMan->runScript(script, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -708,7 +708,7 @@ void MohawkEngine_Riven::runHotspotScript(uint16 hotspot, uint16 scriptType) {
|
||||
for (uint16 i = 0; i < _hotspots[hotspot].scripts.size(); i++)
|
||||
if (_hotspots[hotspot].scripts[i].type == scriptType) {
|
||||
RivenScriptPtr script = _hotspots[hotspot].scripts[i].script;
|
||||
script->runScript();
|
||||
_scriptMan->runScript(script, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ void RivenScriptManager::setStoredMovieOpcode(const StoredMovieOpcode &op) {
|
||||
|
||||
void RivenScriptManager::runStoredMovieOpcode() {
|
||||
if (_storedMovieOpcode.script) {
|
||||
_storedMovieOpcode.script->runScript();
|
||||
runScript(_storedMovieOpcode.script, false);
|
||||
clearStoredMovieOpcode();
|
||||
}
|
||||
}
|
||||
@ -112,6 +112,14 @@ void RivenScriptManager::clearStoredMovieOpcode() {
|
||||
_storedMovieOpcode.id = 0;
|
||||
}
|
||||
|
||||
void RivenScriptManager::runScript(const RivenScriptPtr &script, bool queue) {
|
||||
if (!queue) {
|
||||
script->run();
|
||||
} else {
|
||||
_queue.push_back(script);
|
||||
}
|
||||
}
|
||||
|
||||
RivenScript::RivenScript() {
|
||||
_continueRunning = true;
|
||||
}
|
||||
@ -128,7 +136,7 @@ void RivenScript::dumpScript(const Common::StringArray &varNames, const Common::
|
||||
}
|
||||
}
|
||||
|
||||
void RivenScript::runScript() {
|
||||
void RivenScript::run() {
|
||||
for (uint16 i = 0; i < _commands.size() && _continueRunning; i++) {
|
||||
_commands[i]->execute();
|
||||
}
|
||||
@ -521,7 +529,7 @@ void RivenSimpleCommand::storeMovieOpcode(uint16 op, uint16 argc, uint16 *argv)
|
||||
_vm->_scriptMan->setStoredMovieOpcode(storedOp);
|
||||
} else {
|
||||
// Run immediately if we have no delay
|
||||
script->runScript();
|
||||
_vm->_scriptMan->runScript(script, false);
|
||||
}
|
||||
|
||||
delete scriptStream;
|
||||
@ -712,7 +720,7 @@ void RivenSwitchCommand::execute() {
|
||||
// Look for a case matching the value
|
||||
for (uint i = 0; i < _branches.size(); i++) {
|
||||
if (_branches[i].value == value) {
|
||||
_branches[i].script->runScript();
|
||||
_vm->_scriptMan->runScript(_branches[i].script, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -720,7 +728,7 @@ void RivenSwitchCommand::execute() {
|
||||
// Look for the default case if any
|
||||
for (uint i = 0; i < _branches.size(); i++) {
|
||||
if (_branches[i].value == 0Xffff) {
|
||||
_branches[i].script->runScript();
|
||||
_vm->_scriptMan->runScript(_branches[i].script, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,13 @@ public:
|
||||
/** Append a command to the script */
|
||||
void addCommand(RivenCommand *command);
|
||||
|
||||
/** Run the script */
|
||||
void runScript();
|
||||
/**
|
||||
* Run the script
|
||||
*
|
||||
* Script execution must go through the ScriptManager,
|
||||
* this method should not be called directly.
|
||||
*/
|
||||
void run();
|
||||
|
||||
/** Print script details to the standard output */
|
||||
void dumpScript(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs);
|
||||
@ -107,6 +112,10 @@ public:
|
||||
|
||||
/** Read a list of typed scripts from a stream */
|
||||
RivenScriptList readScripts(Common::ReadStream *stream);
|
||||
|
||||
/** Run a script */
|
||||
void runScript(const RivenScriptPtr &script, bool queue);
|
||||
|
||||
void stopAllScripts();
|
||||
|
||||
struct StoredMovieOpcode {
|
||||
@ -123,6 +132,8 @@ public:
|
||||
|
||||
private:
|
||||
MohawkEngine_Riven *_vm;
|
||||
|
||||
Common::Array<RivenScriptPtr> _queue;
|
||||
StoredMovieOpcode _storedMovieOpcode;
|
||||
|
||||
RivenCommand *readCommand(Common::ReadStream *stream);
|
||||
@ -178,7 +189,7 @@ private:
|
||||
|
||||
DECLARE_OPCODE(empty) { warning ("Unknown Opcode %04x", op); }
|
||||
|
||||
//Opcodes
|
||||
// Opcodes
|
||||
DECLARE_OPCODE(drawBitmap);
|
||||
DECLARE_OPCODE(switchCard);
|
||||
DECLARE_OPCODE(playScriptSLST);
|
||||
|
Loading…
Reference in New Issue
Block a user