[Scummvm-git-logs] scummvm master -> 5d3457aa948a3182607e8d7810019eeaba498a1a

criezy criezy at scummvm.org
Wed Jul 21 20:36:07 UTC 2021


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

Summary:
c72b895af9 CGE: Change declaration place and descriptions
9a797a765e CGE: Futher cleanup of the text-to-speech code
5d3457aa94 CGE: Fix check to skip redrawing the infoline again and again with the same text


Commit: c72b895af9663d805e422aebaff323a3108ad302
    https://github.com/scummvm/scummvm/commit/c72b895af9663d805e422aebaff323a3108ad302
Author: taylorzhancher (taylorzhancher at gmail.com)
Date: 2021-07-21T21:36:00+01:00

Commit Message:
CGE: Change declaration place and descriptions

Changed paths:
    engines/cge/cge.h
    engines/cge/detection.cpp
    engines/cge/talk.cpp
    engines/cge/talk.h


diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index 27d87822c8..f70dbde27c 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -34,7 +34,6 @@
 #include "cge/console.h"
 #include "cge/bitmap.h"
 #include "cge/sound.h"
-#include "common/text-to-speech.h"
 
 struct ADGameDescription;
 
diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp
index 8e14b89a3e..e191a3dfbd 100644
--- a/engines/cge/detection.cpp
+++ b/engines/cge/detection.cpp
@@ -117,7 +117,7 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 		GAMEOPTION_TTS,
 		{
 			_s("Enable Text to Speech"),
-			_s("Use TTS to read the descriptions (if TTS is available)"),
+			_s("Use TTS to read text in the game (if TTS is available)"),
 			"tts_enabled",
 			false
 		}
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 7669ebb96c..be9bdc0726 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -91,12 +91,12 @@ Talk::Talk(CGEEngine *vm)
 	_wideSpace = false;
 }
 
-const char *lastText = "";
+const char *lastText = nullptr;
 
-void textToSpeech(const char *text) {
+void Talk::textToSpeech(const char *text) {
 	Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
 	if (lastText != text && ttsMan != nullptr && ConfMan.getBool("tts_enabled")) {
-		ttsMan->say(text, Common::TextToSpeechManager::INTERRUPT);
+		ttsMan->say(text);
 		lastText = text;
 	}
 }
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index 494924c18b..5845e66c1a 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -46,7 +46,6 @@ namespace CGE {
 #define kFontExt           ".CFT"
 
 enum TextBoxStyle { kTBPure, kTBRect, kTBRound };
-void textToSpeech(const char *text);
 
 class Talk : public Sprite {
 protected:
@@ -58,6 +57,7 @@ public:
 	Talk(CGEEngine *vm, const char *text, TextBoxStyle mode, bool wideSpace = false);
 	Talk(CGEEngine *vm);
 
+	virtual void textToSpeech(const char *text);
 	virtual void update(const char *text);
 private:
 	CGEEngine *_vm;


Commit: 9a797a765ec78c69aa511ebf4d0e3e625d01e99e
    https://github.com/scummvm/scummvm/commit/9a797a765ec78c69aa511ebf4d0e3e625d01e99e
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-07-21T21:36:00+01:00

Commit Message:
CGE: Futher cleanup of the text-to-speech code

Changed paths:
    engines/cge/talk.cpp
    engines/cge/talk.h


diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index be9bdc0726..ebf81d477b 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -77,7 +77,6 @@ uint16 Font::width(const char *text) {
 
 Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode, bool wideSpace)
 	: Sprite(vm, NULL), _mode(mode), _wideSpace(wideSpace), _vm(vm) {
-	textToSpeech(text);
 	_ts = NULL;
 	_flags._syst = true;
 	update(text);
@@ -91,17 +90,15 @@ Talk::Talk(CGEEngine *vm)
 	_wideSpace = false;
 }
 
-const char *lastText = nullptr;
-
 void Talk::textToSpeech(const char *text) {
 	Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
-	if (lastText != text && ttsMan != nullptr && ConfMan.getBool("tts_enabled")) {
+	if (text != nullptr && ttsMan != nullptr && ConfMan.getBool("tts_enabled"))
 		ttsMan->say(text);
-		lastText = text;
-	}
 }
 
 void Talk::update(const char *text) {
+	textToSpeech(text);
+
 	const uint16 vmarg = (_mode) ? kTextVMargin : 0;
 	const uint16 hmarg = (_mode) ? kTextHMargin : 0;
 	uint16 mw = 0;
@@ -205,7 +202,7 @@ Bitmap *Talk::box(uint16 w, uint16 h) {
 	return new Bitmap(_vm, w, h, b);
 }
 
-InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm) {
+InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _lastText(NULL), _vm(vm) {
 	if (!_ts) {
 		_ts = new BitmapPtr[2];
 		_ts[1] = NULL;
@@ -216,11 +213,19 @@ InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm)
 }
 
 void InfoLine::update(const char *text) {
-	textToSpeech(text);
-
 	if (text == _oldText)
 		return;
 
+	// As we increment text in the loop below and only set _oldText at the end of the loop,
+	// _oldText actually point to the end of the previous text and not the start. So calling
+	// this function twice with the same pointer will not return immediately.
+	// I suspect this is a bug (already present in the original).
+	// If we fix this we can get rid of the _lastText variable and the check below.
+	if (text != _lastText) {
+		textToSpeech(text);
+		_lastText = text;
+	}
+
 	uint16 w = _ts[0]->_w;
 	uint16 h = _ts[0]->_h;
 	uint8 *v = (uint8 *)_ts[0]->_v;
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index 5845e66c1a..310ef8fd76 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -57,14 +57,14 @@ public:
 	Talk(CGEEngine *vm, const char *text, TextBoxStyle mode, bool wideSpace = false);
 	Talk(CGEEngine *vm);
 
-	virtual void textToSpeech(const char *text);
+	void textToSpeech(const char *text);
 	virtual void update(const char *text);
 private:
 	CGEEngine *_vm;
 };
 
 class InfoLine : public Talk {
-	const char *_oldText;
+	const char *_oldText, *_lastText;
 public:
 	InfoLine(CGEEngine *vm, uint16 wid);
 	void update(const char *text) override;


Commit: 5d3457aa948a3182607e8d7810019eeaba498a1a
    https://github.com/scummvm/scummvm/commit/5d3457aa948a3182607e8d7810019eeaba498a1a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-07-21T21:36:00+01:00

Commit Message:
CGE: Fix check to skip redrawing the infoline again and again with the same text

There was a check in place to avoid redrawing the infoline when
calling the update() function with the same text multiple times.
Such calls happen when the cursor moves over an object (or menu
option) without leaving that object. The check was however
incorrect and did nothing because it was keeping the pointer
from the end of the previous text and not the start.

>From the log it seems that the bug was present from the start,
and probably in the original source code. It was however fixed
in Sfinx (CGE2 engine), and this commit uses the same logic.

Changed paths:
    engines/cge/talk.cpp
    engines/cge/talk.h


diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index ebf81d477b..78b1901f57 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -202,7 +202,7 @@ Bitmap *Talk::box(uint16 w, uint16 h) {
 	return new Bitmap(_vm, w, h, b);
 }
 
-InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _lastText(NULL), _vm(vm) {
+InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm) {
 	if (!_ts) {
 		_ts = new BitmapPtr[2];
 		_ts[1] = NULL;
@@ -216,15 +216,9 @@ void InfoLine::update(const char *text) {
 	if (text == _oldText)
 		return;
 
-	// As we increment text in the loop below and only set _oldText at the end of the loop,
-	// _oldText actually point to the end of the previous text and not the start. So calling
-	// this function twice with the same pointer will not return immediately.
-	// I suspect this is a bug (already present in the original).
-	// If we fix this we can get rid of the _lastText variable and the check below.
-	if (text != _lastText) {
-		textToSpeech(text);
-		_lastText = text;
-	}
+	_oldText = text;
+
+	textToSpeech(text);
 
 	uint16 w = _ts[0]->_w;
 	uint16 h = _ts[0]->_h;
@@ -272,8 +266,6 @@ void InfoLine::update(const char *text) {
 			text++;
 		}
 	}
-
-	_oldText = text;
 }
 
 } // End of namespace CGE
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index 310ef8fd76..e3d7656b1a 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -64,7 +64,7 @@ private:
 };
 
 class InfoLine : public Talk {
-	const char *_oldText, *_lastText;
+	const char *_oldText;
 public:
 	InfoLine(CGEEngine *vm, uint16 wid);
 	void update(const char *text) override;




More information about the Scummvm-git-logs mailing list