diff options
author | Eugene Sandulenko | 2019-12-18 14:50:40 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-12-18 22:47:31 +0100 |
commit | 1d1f09f072fe597329a52096f724f848fdb57efa (patch) | |
tree | 70285e20a2910978fd1bd28b3d3415739acd7ae8 | |
parent | 98b8b8d730b55dfd64ebe2b92e4d9e53e970f601 (diff) | |
download | scummvm-rg350-1d1f09f072fe597329a52096f724f848fdb57efa.tar.gz scummvm-rg350-1d1f09f072fe597329a52096f724f848fdb57efa.tar.bz2 scummvm-rg350-1d1f09f072fe597329a52096f724f848fdb57efa.zip |
DIRECTOR: LINGO: Rename dontPassEvent and simplify code
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-events.cpp | 79 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 2 |
4 files changed, 46 insertions, 39 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index c623b2f4a6..3283db5282 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -871,7 +871,7 @@ void Lingo::b_continue(int nargs) { } void Lingo::b_dontPassEvent(int nargs) { - g_lingo->dontPassEvent = true; + g_lingo->_dontPassEvent = true; warning("dontPassEvent raised"); } diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp index 9a270cc824..b48278dd48 100644 --- a/engines/director/lingo/lingo-events.cpp +++ b/engines/director/lingo/lingo-events.cpp @@ -132,7 +132,7 @@ void Lingo::primaryEventHandler(LEvent event) { } #ifdef DEBUG_DONTPASSEVENT // #define DEBUG_DONTPASSEVENT to simulate raising of the dontPassEvent flag - g_lingo->dontPassEvent = true; + g_lingo->_dontPassEvent = true; debugC(3, kDebugLingoExec, "STUB: primaryEventHandler raising dontPassEvent"); #else debugC(3, kDebugLingoExec, "STUB: primaryEventHandler not raising dontPassEvent"); @@ -157,32 +157,35 @@ void Lingo::processInputEvent(LEvent event) { primaryEventHandler(event); - if (g_lingo->dontPassEvent) { - g_lingo->dontPassEvent = false; - } else { - if (_vm->getVersion() > 3) { - if (true) { - // TODO: Check whether occurring over a sprite - g_lingo->processEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_scriptId); - } - g_lingo->processEvent(event, kCastScript, currentFrame->_sprites[spriteId]->_castId); - g_lingo->processEvent(event, kFrameScript, score->_frames[score->getCurrentFrame()]->_actionId); - // TODO: Is the kFrameScript call above correct? - } else if (event == kEventMouseUp) { - // Frame script overrides sprite script - if (!currentFrame->_sprites[spriteId]->_scriptId) { - g_lingo->processEvent(kEventNone, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + 1024); - g_lingo->processEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + 1024); - } else { - g_lingo->processEvent(kEventNone, kFrameScript, currentFrame->_sprites[spriteId]->_scriptId); - } + if (g_lingo->_dontPassEvent) { + g_lingo->_dontPassEvent = false; + + return; + } + + if (_vm->getVersion() > 3) { + if (true) { + // TODO: Check whether occurring over a sprite + g_lingo->processEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_scriptId); } - if (event == kEventKeyDown) { - // TODO: is the above condition necessary or useful? - g_lingo->processEvent(event, kGlobalScript, 0); + g_lingo->processEvent(event, kCastScript, currentFrame->_sprites[spriteId]->_castId); + g_lingo->processEvent(event, kFrameScript, score->_frames[score->getCurrentFrame()]->_actionId); + // TODO: Is the kFrameScript call above correct? + } else if (event == kEventMouseUp) { + // Frame script overrides sprite script + if (!currentFrame->_sprites[spriteId]->_scriptId) { + g_lingo->processEvent(kEventNone, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + 1024); + g_lingo->processEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + 1024); + } else { + g_lingo->processEvent(kEventNone, kFrameScript, currentFrame->_sprites[spriteId]->_scriptId); } - runMovieScript(event); } + if (event == kEventKeyDown) { + // TODO: is the above condition necessary or useful? + g_lingo->processEvent(event, kGlobalScript, 0); + } + if (!g_lingo->_dontPassEvent) + runMovieScript(event); } void Lingo::runMovieScript(LEvent event) { @@ -214,22 +217,24 @@ void Lingo::processFrameEvent(LEvent event) { primaryEventHandler(event); } - if (g_lingo->dontPassEvent) { - g_lingo->dontPassEvent = false; + if (g_lingo->_dontPassEvent) { + g_lingo->_dontPassEvent = false; + + return; + } + + int entity; + + if (event == kEventPrepareFrame || event == kEventIdle) { + entity = score->getCurrentFrame(); } else { - int entity; + assert(score->_frames[score->getCurrentFrame()] != nullptr); + entity = score->_frames[score->getCurrentFrame()]->_actionId; + } + processEvent(event, kFrameScript, entity); - if (event == kEventPrepareFrame || event == kEventIdle) { - entity = score->getCurrentFrame(); - } else { - assert(score->_frames[score->getCurrentFrame()] != nullptr); - entity = score->_frames[score->getCurrentFrame()]->_actionId; - } - processEvent(event, - kFrameScript, - entity); + if (!g_lingo->_dontPassEvent) runMovieScript(event); - } } void Lingo::processGenericEvent(LEvent event) { diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index c998c37a11..54f8243705 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -70,6 +70,8 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) { _localvars = NULL; + _dontPassEvent = false; + initEventHandlerTypes(); initBuiltIns(); diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 3281445f81..f3a8edf35b 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -620,7 +620,7 @@ private: int _floatPrecision; - bool dontPassEvent; + bool _dontPassEvent; public: void executeImmediateScripts(Frame *frame); |