From f0267d542f860a2f67f519a1dc5343e020927c81 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 4 Feb 2017 14:34:45 +0100 Subject: MOHAWK: Keep turning pages while the mouse is pressed in Atrus' book --- engines/mohawk/riven_stacks/aspit.cpp | 83 +++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 24 deletions(-) (limited to 'engines/mohawk/riven_stacks/aspit.cpp') diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp index aabd7dba91..f930dfc8cf 100644 --- a/engines/mohawk/riven_stacks/aspit.cpp +++ b/engines/mohawk/riven_stacks/aspit.cpp @@ -99,44 +99,79 @@ void ASpit::xaatrusbookback(uint16 argc, uint16 *argv) { _vm->_inventory->backFromItemScript(); } -void ASpit::xaatrusbookprevpage(uint16 argc, uint16 *argv) { - // Get the page variable - uint32 &page = _vm->_vars["aatruspage"]; +bool ASpit::pageTurn(int16 transition) { + // Wait until the previous page turn sound completes + while (_vm->_sound->isEffectPlaying() && !_vm->shouldQuit()) { + if (!mouseIsDown()) { + return false; + } - // Decrement the page if it's not the first page - if (page == 1) - return; - page--; + _vm->doFrame(); + } // Play the page turning sound - if (_vm->getFeatures() & GF_DEMO) - _vm->_sound->playSound(4); + const char *soundName = nullptr; + if (_vm->_rnd->getRandomBit()) + soundName = "aPage1"; else - _vm->_sound->playSound(3); + soundName = "aPage2"; + + Common::String fullSoundName = Common::String::format("%d_%s_1", _vm->getCard()->getId(), soundName); + + _vm->_sound->playSound(fullSoundName, 51, true); // Now update the screen :) - _vm->_gfx->scheduleTransition(1); - _vm->getCard()->drawPicture(page); + _vm->_gfx->scheduleTransition(transition); + + return true; +} + +void ASpit::xaatrusbookprevpage(uint16 argc, uint16 *argv) { + // Get the page variable + uint32 &page = _vm->_vars["aatruspage"]; + + // Keep turning pages while the mouse is pressed + bool firstPageTurn = true; + while (mouseIsDown() || firstPageTurn) { + // Check for the first page + if (page == 1) + return; + + if (!pageTurn(1)) { + return; + } + + // Update the page number + page--; + firstPageTurn = false; + + _vm->getCard()->drawPicture(page); + _vm->doFrame(); + } } void ASpit::xaatrusbooknextpage(uint16 argc, uint16 *argv) { // Get the page variable uint32 &page = _vm->_vars["aatruspage"]; - // Increment the page if it's not the last page - if (((_vm->getFeatures() & GF_DEMO) && page == 6) || page == 10) - return; - page++; + // Keep turning pages while the mouse is pressed + bool firstPageTurn = true; + while ((mouseIsDown() || firstPageTurn) && !_vm->shouldQuit()) { + // Check for the last page + if (((_vm->getFeatures() & GF_DEMO) && page == 6) || page == 10) + return; - // Play the page turning sound - if (_vm->getFeatures() & GF_DEMO) - _vm->_sound->playSound(5); - else - _vm->_sound->playSound(4); + if (!pageTurn(0)) { + return; + } - // Now update the screen :) - _vm->_gfx->scheduleTransition(0); - _vm->getCard()->drawPicture(page); + // Update the page number + page++; + firstPageTurn = false; + + _vm->getCard()->drawPicture(page); + _vm->doFrame(); + } } void ASpit::xacathopenbook(uint16 argc, uint16 *argv) { -- cgit v1.2.3