[Scummvm-git-logs] scummvm master -> 1b0f1dafbbad4468eb12bc6952b31291d0d8c3e6

bgK bastien.bouclet at gmail.com
Sun Nov 26 15:13:04 CET 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
83b27d263e MOHAWK: RIVEN: Allow turning book pages more quickly
1b0f1dafbb MOHAWK: RIVEN: Ignore key repeat events


Commit: 83b27d263e1433a134b53b66919566c3192ca116
    https://github.com/scummvm/scummvm/commit/83b27d263e1433a134b53b66919566c3192ca116
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2017-11-26T15:11:12+01:00

Commit Message:
MOHAWK: RIVEN: Allow turning book pages more quickly

Fixes #10075

Changed paths:
    engines/mohawk/riven.cpp
    engines/mohawk/riven_stack.cpp
    engines/mohawk/riven_stack.h
    engines/mohawk/riven_stacks/aspit.cpp
    engines/mohawk/riven_stacks/aspit.h
    engines/mohawk/riven_stacks/bspit.cpp
    engines/mohawk/riven_stacks/ospit.cpp


diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index ea3e2ce..0cd6b4f 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -203,8 +203,11 @@ void MohawkEngine_Riven::doFrame() {
 	_sound->updateSLST();
 	_video->updateMovies();
 
-	Common::Event event;
+	if (!_scriptMan->hasQueuedScripts()) {
+		_stack->keyResetAction();
+	}
 
+	Common::Event event;
 	while (_eventMan->pollEvent(event)) {
 		switch (event.type) {
 		case Common::EVENT_MOUSEMOVE:
diff --git a/engines/mohawk/riven_stack.cpp b/engines/mohawk/riven_stack.cpp
index c90642a..7d3d105 100644
--- a/engines/mohawk/riven_stack.cpp
+++ b/engines/mohawk/riven_stack.cpp
@@ -321,7 +321,6 @@ void RivenStack::onKeyPressed(const Common::KeyState &keyState) {
 
 		if (!script->empty()) {
 			_vm->_scriptMan->runScript(script, true);
-			keyResetAction();
 		}
 	}
 }
@@ -414,16 +413,7 @@ void RivenStack::removeTimer() {
 	_timerTime = 0;
 }
 
-bool RivenStack::pageTurn(RivenTransition transition) {
-	// Wait until the previous page turn sound completes
-	while (_vm->_sound->isEffectPlaying() && !_vm->hasGameEnded()) {
-		if (!mouseIsDown()) {
-			return false;
-		}
-
-		_vm->doFrame();
-	}
-
+void RivenStack::pageTurn(RivenTransition transition) {
 	// Play the page turning sound
 	const char *soundName = nullptr;
 	if (_vm->_rnd->getRandomBit())
@@ -435,8 +425,16 @@ bool RivenStack::pageTurn(RivenTransition transition) {
 
 	// Now update the screen :)
 	_vm->_gfx->scheduleTransition(transition);
+}
+
+bool RivenStack::keepTurningPages() {
+	return (mouseIsDown() || keyGetAction() != kKeyActionNone) && !_vm->shouldQuit();
+}
 
-	return true;
+void RivenStack::waitForPageTurnSound() {
+	while (_vm->_sound->isEffectPlaying() && keepTurningPages()) {
+		_vm->doFrame();
+	}
 }
 
 RivenNameList::RivenNameList() {
diff --git a/engines/mohawk/riven_stack.h b/engines/mohawk/riven_stack.h
index ce7d2e2..2af63b2 100644
--- a/engines/mohawk/riven_stack.h
+++ b/engines/mohawk/riven_stack.h
@@ -30,6 +30,7 @@
 #include "common/str-array.h"
 
 #include "mohawk/riven_graphics.h"
+#include "mohawk/riven_stack.h"
 
 namespace Mohawk {
 
@@ -182,7 +183,10 @@ public:
 	void runDemoBoundaryDialog();
 	void runEndGame(uint16 videoCode, uint32 delay);
 	void runCredits(uint16 video, uint32 delay);
-	bool pageTurn(RivenTransition transition);
+
+	void pageTurn(RivenTransition transition);
+	bool keepTurningPages();
+	void waitForPageTurnSound();
 
 protected:
 	typedef Common::Functor1<const ArgumentArray &, void> ExternalCommand;
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index a31aa90..67b416c 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -106,22 +106,19 @@ void ASpit::xaatrusbookprevpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["aatrusbook"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while (mouseIsDown() || firstPageTurn) {
+	while (keepTurningPages()) {
 		// Check for the first page
 		if (page == 1)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeRight)) {
-			return;
-		}
-
 		// Update the page number
 		page--;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeRight);
 		_vm->getCard()->drawPicture(page);
 		_vm->doFrame();
+
+		waitForPageTurnSound();
 	}
 }
 
@@ -130,22 +127,20 @@ void ASpit::xaatrusbooknextpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["aatrusbook"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
+	while (keepTurningPages()) {
 		// Check for the last page
 		if (((_vm->getFeatures() & GF_DEMO) && page == 6) || page == 10)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeLeft)) {
-			return;
-		}
-
 		// Update the page number
 		page++;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeLeft);
 		_vm->getCard()->drawPicture(page);
 		_vm->doFrame();
+
+		// Wait until the previous page turn sound completes
+		waitForPageTurnSound();
 	}
 }
 
@@ -210,23 +205,19 @@ void ASpit::xacathbookprevpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["acathbook"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while (mouseIsDown() || firstPageTurn) {
+	while (keepTurningPages()) {
 		// Check for the first page
 		if (page == 1)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeDown)) {
-			return;
-		}
-
 		// Update the page number
 		page--;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeDown);
 		cathBookDrawPage(page);
-
 		_vm->doFrame();
+
+		waitForPageTurnSound();
 	}
 }
 
@@ -235,23 +226,19 @@ void ASpit::xacathbooknextpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["acathbook"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
+	while (keepTurningPages()) {
 		// Check for the last page
 		if (page == 49)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeUp)) {
-			return;
-		}
-
 		// Update the page number
 		page++;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeUp);
 		cathBookDrawPage(page);
-
 		_vm->doFrame();
+
+		waitForPageTurnSound();
 	}
 }
 
diff --git a/engines/mohawk/riven_stacks/aspit.h b/engines/mohawk/riven_stacks/aspit.h
index 5321db0..b2e5301d 100644
--- a/engines/mohawk/riven_stacks/aspit.h
+++ b/engines/mohawk/riven_stacks/aspit.h
@@ -72,6 +72,7 @@ private:
 	void cathBookDrawTelescopeCombination();
 
 	void cathBookDrawPage(uint32 page);
+
 };
 
 } // End of namespace RivenStacks
diff --git a/engines/mohawk/riven_stacks/bspit.cpp b/engines/mohawk/riven_stacks/bspit.cpp
index 824269a..7a7c36e 100644
--- a/engines/mohawk/riven_stacks/bspit.cpp
+++ b/engines/mohawk/riven_stacks/bspit.cpp
@@ -96,20 +96,15 @@ void BSpit::xblabbookprevpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["blabpage"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while (mouseIsDown() || firstPageTurn) {
+	while (keepTurningPages()) {
 		// Check for the first page
 		if (page == 1)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeRight)) {
-			return;
-		}
-
 		// Update the page number
 		page--;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeRight);
 		_vm->getCard()->drawPicture(page);
 
 		if (page == 14) {
@@ -117,6 +112,8 @@ void BSpit::xblabbookprevpage(const ArgumentArray &args) {
 		}
 
 		_vm->doFrame();
+
+		waitForPageTurnSound();
 	}
 }
 
@@ -125,20 +122,15 @@ void BSpit::xblabbooknextpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["blabpage"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
+	while (keepTurningPages()) {
 		// Check for the last page
 		if (page == 22)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeLeft)) {
-			return;
-		}
-
 		// Update the page number
 		page++;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeLeft);
 		_vm->getCard()->drawPicture(page);
 
 		if (page == 14) {
@@ -146,6 +138,8 @@ void BSpit::xblabbooknextpage(const ArgumentArray &args) {
 		}
 
 		_vm->doFrame();
+
+		waitForPageTurnSound();
 	}
 }
 
diff --git a/engines/mohawk/riven_stacks/ospit.cpp b/engines/mohawk/riven_stacks/ospit.cpp
index 8da1698..beecc05 100644
--- a/engines/mohawk/riven_stacks/ospit.cpp
+++ b/engines/mohawk/riven_stacks/ospit.cpp
@@ -193,22 +193,19 @@ void OSpit::xogehnbookprevpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["ogehnpage"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while (mouseIsDown() || firstPageTurn) {
+	while (keepTurningPages()) {
 		// Check for the first page
 		if (page == 1)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeRight)) {
-			return;
-		}
-
 		// Update the page number
 		page--;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeRight);
 		_vm->getCard()->drawPicture(page);
 		_vm->doFrame();
+
+		waitForPageTurnSound();
 	}
 }
 
@@ -217,22 +214,19 @@ void OSpit::xogehnbooknextpage(const ArgumentArray &args) {
 	uint32 &page = _vm->_vars["ogehnpage"];
 
 	// Keep turning pages while the mouse is pressed
-	bool firstPageTurn = true;
-	while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
+	while (keepTurningPages()) {
 		// Check for the last page
 		if (page == 13)
 			return;
 
-		if (!pageTurn(kRivenTransitionWipeLeft)) {
-			return;
-		}
-
 		// Update the page number
 		page++;
-		firstPageTurn = false;
 
+		pageTurn(kRivenTransitionWipeLeft);
 		_vm->getCard()->drawPicture(page);
 		_vm->doFrame();
+
+		waitForPageTurnSound();
 	}
 }
 


Commit: 1b0f1dafbbad4468eb12bc6952b31291d0d8c3e6
    https://github.com/scummvm/scummvm/commit/1b0f1dafbbad4468eb12bc6952b31291d0d8c3e6
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2017-11-26T15:11:22+01:00

Commit Message:
MOHAWK: RIVEN: Ignore key repeat events

This fixes keyboard book page turning being too fast when holding keys

Changed paths:
    engines/mohawk/riven.cpp


diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 0cd6b4f..266706a 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -258,6 +258,9 @@ void MohawkEngine_Riven::doFrame() {
 				}
 				break;
 			default:
+				if (event.kbdRepeat) {
+					continue;
+				}
 				_stack->onKeyPressed(event.kbd);
 				break;
 			}





More information about the Scummvm-git-logs mailing list