[Scummvm-git-logs] scummvm master -> b73892e441bc3fde3b36f76aa675c59a652ca95c

dreammaster dreammaster at scummvm.org
Fri Nov 10 21:35:37 CET 2017


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

Summary:
b73892e441 XEEN: Fix event handling for town messages


Commit: b73892e441bc3fde3b36f76aa675c59a652ca95c
    https://github.com/scummvm/scummvm/commit/b73892e441bc3fde3b36f76aa675c59a652ca95c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-11-10T15:35:33-05:00

Commit Message:
XEEN: Fix event handling for town messages

Changed paths:
    engines/xeen/dialogs.cpp
    engines/xeen/town.cpp


diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp
index 3304689..92082b4 100644
--- a/engines/xeen/dialogs.cpp
+++ b/engines/xeen/dialogs.cpp
@@ -77,6 +77,11 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) {
 				return true;
 			}
 		}
+
+		if (Common::Rect(8, 8, 224, 135).contains(pt)) {
+			_buttonValue = 1;
+			return true;
+		}
 	} else if (events.isKeyPending()) {
 		Common::KeyState keyState;
 		events.getKey(keyState);
diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp
index 097b1c3..fb5df83 100644
--- a/engines/xeen/town.cpp
+++ b/engines/xeen/town.cpp
@@ -1219,19 +1219,20 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common
 
 	int result = -1;
 	Common::String msgText = text;
-	for (;;) {
+	do {
 		Common::String msg = Common::String::format("\r\v014\x03c\t125%s\t000\v054%s",
 			name.c_str(), msgText.c_str());
+
+		// Count the number of words
 		const char *msgEnd = w.writeString(msg.c_str());
 		int wordCount = 0;
 
-		const char *msgP = msg.c_str();
-		do {
+		for (const char *msgP = msg.c_str(); msgP != msgEnd && *msgP; ++msgP) {
 			if (*msgP == ' ')
 				++wordCount;
-		} while (msgP != msgEnd && *++msgP);
+		}
 
-		town._drawCtr2 = wordCount * 2;
+		town._drawCtr2 = wordCount * 2;	// Set timeout
 		town._townSprites[1].draw(screen, 0, Common::Point(16, 16));
 		town._townSprites[0].draw(screen, town._drawFrameIndex, Common::Point(23, 22));
 		w.update();
@@ -1258,28 +1259,31 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common
 				clearButtons();
 
 			do {
-				events.wait(3);
+				events.pollEventsAndWait();
 				checkEvents(_vm);
+
 				if (_vm->shouldQuit())
 					return false;
 
-				town.drawTownAnim(false);
-				events.updateGameCounter();
+				while (events.timeElapsed() >= 3) {
+					town.drawTownAnim(false);
+					events.updateGameCounter();
+				}
 			} while (!_buttonValue);
 
 			if (msgEnd)
+				// Another screen of text remaining
 				break;
 
-			if (!msgEnd) {
-				if (confirm || _buttonValue == Common::KEYCODE_ESCAPE ||
-						_buttonValue == Common::KEYCODE_n)
-					result = 0;
-				else if (_buttonValue == Common::KEYCODE_y)
-					result = 1;
-			}
+			if (confirm || _buttonValue == Common::KEYCODE_ESCAPE ||
+					_buttonValue == Common::KEYCODE_n)
+				result = 0;
+			else if (_buttonValue == Common::KEYCODE_y)
+				result = 1;
 		} while (result == -1);
 
 		if (msgEnd) {
+			// Text remaining, so cut off already displayed page's
 			msgText = Common::String(msgEnd);
 			town._drawCtr2 = wordCount;
 			continue;
@@ -1292,6 +1296,7 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common
 
 	town._townSprites[0].clear();
 	town._townSprites[1].clear();
+	events.clearEvents();
 	return result == 1;
 }
 





More information about the Scummvm-git-logs mailing list