aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/riven_stacks/aspit.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2017-02-04 14:34:45 +0100
committerEugene Sandulenko2017-07-03 08:50:10 +0200
commitf0267d542f860a2f67f519a1dc5343e020927c81 (patch)
treebd4dac2d31f30dbe1512baf3738c315d16469240 /engines/mohawk/riven_stacks/aspit.cpp
parent7609ec0de81d7be4ed6d0e3e6e0303f42d54ad52 (diff)
downloadscummvm-rg350-f0267d542f860a2f67f519a1dc5343e020927c81.tar.gz
scummvm-rg350-f0267d542f860a2f67f519a1dc5343e020927c81.tar.bz2
scummvm-rg350-f0267d542f860a2f67f519a1dc5343e020927c81.zip
MOHAWK: Keep turning pages while the mouse is pressed in Atrus' book
Diffstat (limited to 'engines/mohawk/riven_stacks/aspit.cpp')
-rw-r--r--engines/mohawk/riven_stacks/aspit.cpp83
1 files changed, 59 insertions, 24 deletions
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) {