diff options
-rw-r--r-- | engines/mohawk/riven.cpp | 53 | ||||
-rw-r--r-- | engines/mohawk/riven.h | 3 | ||||
-rw-r--r-- | engines/mohawk/riven_external.cpp | 22 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 9 |
4 files changed, 39 insertions, 48 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index 677b1ae12c..2c5f849ba9 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -127,16 +127,13 @@ Common::Error MohawkEngine_Riven::run() { needsUpdate = true; break; case Common::EVENT_LBUTTONDOWN: - if (_curHotspot >= 0) { + if (_curHotspot >= 0) runHotspotScript(_curHotspot, kMouseDownScript); - //scheduleScript(_hotspots[_curHotspot].script, kMouseMovedPressedReleasedScript); - } break; case Common::EVENT_LBUTTONUP: - if (_curHotspot >= 0) { + if (_curHotspot >= 0) runHotspotScript(_curHotspot, kMouseUpScript); - //scheduleScript(_hotspots[_curHotspot].script, kMouseMovedPressedReleasedScript); - } else + else checkInventoryClick(); break; case Common::EVENT_KEYDOWN: @@ -156,9 +153,8 @@ Common::Error MohawkEngine_Riven::run() { for (uint16 i = 0; i < _hotspotCount; i++) _gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled); needsUpdate = true; - } else { - changeToCard(); - } + } else + refreshCard(); break; case Common::KEYCODE_F5: runDialog(*_optionsDialog); @@ -180,10 +176,8 @@ Common::Error MohawkEngine_Riven::run() { } } - if (_curHotspot >= 0) { + if (_curHotspot >= 0) runHotspotScript(_curHotspot, kMouseInsideScript); - //scheduleScript(_hotspots[_curHotspot].script, kMouseMovedPressedReleasedScript); - } if (shouldQuit()) { if (_eventMan->shouldRTL() && (getFeatures() & GF_DEMO) && !(_curStack == aspit && _curCard == 12)) { @@ -274,29 +268,26 @@ struct RivenSpecialChange { { tspit, 0x21b69, ospit, 0x2e76 } // Dome Linking Book }; -void MohawkEngine_Riven::changeToCard(uint16 n) { - bool refreshMode = (n == 0); - - // While this could be run without harm, it doesn't need to be. This should add a speed boost. - if (!refreshMode) { - debug (1, "Changing to card %d", n); - _curCard = n; +void MohawkEngine_Riven::changeToCard(uint16 dest) { + _curCard = dest; + debug (1, "Changing to card %d", _curCard); - if (!(getFeatures() & GF_DEMO)) { - for (byte i = 0; i < 13; i++) - if (_curStack == rivenSpecialChange[i].startStack && _curCard == matchRMAPToCard(rivenSpecialChange[i].startCardRMAP)) { - changeToStack(rivenSpecialChange[i].targetStack); - _curCard = matchRMAPToCard(rivenSpecialChange[i].targetCardRMAP); - } - } + if (!(getFeatures() & GF_DEMO)) { + for (byte i = 0; i < 13; i++) + if (_curStack == rivenSpecialChange[i].startStack && _curCard == matchRMAPToCard(rivenSpecialChange[i].startCardRMAP)) { + changeToStack(rivenSpecialChange[i].targetStack); + _curCard = matchRMAPToCard(rivenSpecialChange[i].targetCardRMAP); + } + } - if (_cardData.hasData) - runCardScript(kCardLeaveScript); + if (_cardData.hasData) + runCardScript(kCardLeaveScript); - loadCard(_curCard); - } + loadCard(_curCard); + refreshCard(); // Handles hotspots and scripts +} - // We need to reload hotspots when refreshing, however +void MohawkEngine_Riven::refreshCard() { loadHotspots(_curCard); _gfx->_updatesEnabled = true; diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 2d50fc0db5..3ecb971ccd 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -149,8 +149,9 @@ public: bool _activatedSLST; void runLoadDialog(); - void changeToCard(uint16 = 0); + void changeToCard(uint16 dest); void changeToStack(uint16); + void refreshCard(); Common::String getName(uint16 nameResource, uint16 nameID); Common::String getStackName(uint16 stack); void runCardScript(uint16 scriptType); diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index 6e056e5079..99afacc5ce 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -357,13 +357,13 @@ void RivenExternal::xtrapbookback(uint16 argc, uint16 *argv) { void RivenExternal::xatrapbookclose(uint16 argc, uint16 *argv) { // Close the trap book *_vm->matchVarToString("atrap") = 0; - _vm->changeToCard(); // Refresh + _vm->refreshCard(); } void RivenExternal::xatrapbookopen(uint16 argc, uint16 *argv) { // Open the trap book *_vm->matchVarToString("atrap") = 1; - _vm->changeToCard(); // Refresh + _vm->refreshCard(); } void RivenExternal::xarestoregame(uint16 argc, uint16 *argv) { @@ -523,7 +523,7 @@ void RivenExternal::xbupdateboiler(uint16 argc, uint16 *argv) { // TODO: Stop MLST's 7 and 8 } - _vm->changeToCard(); + _vm->refreshCard(); } void RivenExternal::xbsettrap(uint16 argc, uint16 *argv) { @@ -659,21 +659,21 @@ void RivenExternal::xvalvecontrol(uint16 argc, uint16 *argv) { if (*valve == 0 && changeY <= -10) { *valve = 1; // TODO: Play movie - _vm->changeToCard(); // Refresh + _vm->refreshCard(); } else if (*valve == 1) { if (changeX >= 0 && changeY >= 10) { *valve = 0; // TODO: Play movie - _vm->changeToCard(); // Refresh + _vm->refreshCard(); } else if (changeX <= -10 && changeY <= 10) { *valve = 2; // TODO: Play movie - _vm->changeToCard(); // Refresh + _vm->refreshCard(); } } else if (*valve == 2 && changeX >= 10) { *valve = 1; // TODO: Play movie - _vm->changeToCard(); // Refresh + _vm->refreshCard(); } return; default: @@ -1150,7 +1150,7 @@ void RivenExternal::xooffice30_closebook(uint16 argc, uint16 *argv) { // We now need to draw PLST 1 and refresh, but PLST 1 is // drawn when refreshing anyway, so don't worry about that. - _vm->changeToCard(); + _vm->refreshCard(); } void RivenExternal::xobedroom5_closedrawer(uint16 argc, uint16 *argv) { @@ -1230,7 +1230,7 @@ void RivenExternal::xgwatch(uint16 argc, uint16 *argv) { _vm->_video->playMovieBlocking(1); // And, finally, refresh - _vm->changeToCard(); + _vm->refreshCard(); } // ------------------------------------------------------------------------------------ @@ -1369,7 +1369,7 @@ void RivenExternal::xtexterior300_telescopedown(uint16 argc, uint16 *argv) { // Now move the telescope down a position and refresh *telescopePos -= 1; - _vm->changeToCard(); + _vm->refreshCard(); } } @@ -1393,7 +1393,7 @@ void RivenExternal::xtexterior300_telescopeup(uint16 argc, uint16 *argv) { // Now move the telescope up a position and refresh *telescopePos += 1; - _vm->changeToCard(); + _vm->refreshCard(); } void RivenExternal::xtisland390_covercombo(uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index 7e3d4f77da..911ee16028 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -417,17 +417,16 @@ void RivenScript::runExternalCommand(uint16 op, uint16 argc, uint16 *argv) { // Parameter 0: transition type // Parameters 1-4: transition rectangle void RivenScript::transition(uint16 op, uint16 argc, uint16 *argv) { - if (argc == 1) { + if (argc == 1) _vm->_gfx->scheduleTransition(argv[0]); - } else { + else _vm->_gfx->scheduleTransition(argv[0], Common::Rect(argv[1], argv[2], argv[3], argv[4])); - } } // Command 19: reload card void RivenScript::refreshCard(uint16 op, uint16 argc, uint16 *argv) { - debug(2, "Reloading card"); - _vm->changeToCard(); + debug(2, "Refreshing card"); + _vm->refreshCard(); } // Command 20: disable screen update |