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

hax0kartik noreply at scummvm.org
Fri Nov 24 06:04:25 UTC 2023


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:
566d848c08 CRAB: Enable TTS for Chapter Introduction
460054e163 CRAB: Enable tts for dialogues and replies
df3acd267d CRAB: Add a separate class named TTSHandler


Commit: 566d848c088e46b996684258fce2ac85b91b94f9
    https://github.com/scummvm/scummvm/commit/566d848c088e46b996684258fce2ac85b91b94f9
Author: Aditya (adityamurali003 at gmail.com)
Date: 2023-11-24T11:34:21+05:30

Commit Message:
CRAB: Enable TTS for Chapter Introduction

Changed paths:
    engines/crab/event/gameeventmanager.cpp
    engines/crab/ui/ChapterIntro.cpp
    engines/crab/ui/ChapterIntro.h


diff --git a/engines/crab/event/gameeventmanager.cpp b/engines/crab/event/gameeventmanager.cpp
index 892198767c1..09b1554d242 100644
--- a/engines/crab/event/gameeventmanager.cpp
+++ b/engines/crab/event/gameeventmanager.cpp
@@ -163,9 +163,10 @@ void Manager::handleEvents(Info &info, const Common::String &playerId, Common::E
 				if (hud._back.handleEvents(event) == BUAC_LCLICK || hud._pausekey.handleEvents(event))
 					_intro._showTraits = false;
 			} else {
-				if (_intro.handleEvents(event))
+				if (_intro.handleEvents(event)) {
 					_eventMap[info.curLocID()].nextEvent(_activeSeq, info, playerId, result, _endSeq);
-
+					_intro.onExit();
+				}
 				if (_intro._showTraits)
 					_per.Cache(info, level.playerId(), level);
 			}
@@ -288,6 +289,9 @@ void Manager::calcActiveSeq(Info &info, pyrodactyl::level::Level &level, const R
 		case EVENT_REPLY:
 			_reply.cache(info, g_engine->_eventStore->_con[_curEvent->_special]);
 			break;
+		case EVENT_SPLASH:
+			_intro.onEntry(_curEvent->_dialog);
+			break;
 		default:
 			break;
 		}
diff --git a/engines/crab/ui/ChapterIntro.cpp b/engines/crab/ui/ChapterIntro.cpp
index 5ad805a667f..04862a9e459 100644
--- a/engines/crab/ui/ChapterIntro.cpp
+++ b/engines/crab/ui/ChapterIntro.cpp
@@ -30,6 +30,7 @@
 
 #include "crab/animation/sprite.h"
 #include "crab/ui/ChapterIntro.h"
+#include "common/text-to-speech.h"
 
 namespace Crab {
 
@@ -67,4 +68,21 @@ void ChapterIntro::draw(pyrodactyl::event::Info &info, Common::String &text,
 	}
 }
 
+void ChapterIntro::onEntry(const Common::String &dialog) const {
+	Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
+
+	_ttsMan->enable(true);   // Enable text-to-speech
+	_ttsMan->setPitch(50);   // Set pitch level
+	_ttsMan->setVolume(100); // Set volume level
+	_ttsMan->setRate(20);    // Set speech rate
+	_ttsMan->setVoice(1);
+	_ttsMan->say(dialog);
+}
+
+void ChapterIntro::onExit() const {
+	Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
+
+	_ttsMan->stop();
+}
+
 } // End of namespace Crab
diff --git a/engines/crab/ui/ChapterIntro.h b/engines/crab/ui/ChapterIntro.h
index 2fe4fd45ba9..90ecd3418b2 100644
--- a/engines/crab/ui/ChapterIntro.h
+++ b/engines/crab/ui/ChapterIntro.h
@@ -66,6 +66,10 @@ public:
 
 	void draw(pyrodactyl::event::Info &info, Common::String &text,
 			  pyrodactyl::anim::Sprite *curSp, const pyrodactyl::people::PersonState &state);
+
+	void onEntry(const Common::String &dialog) const;
+	void onExit() const;
+
 };
 } // End of namespace ui
 } // End of namespace pyrodactyl


Commit: 460054e163691163d984bc6e5695f1f8288fb917
    https://github.com/scummvm/scummvm/commit/460054e163691163d984bc6e5695f1f8288fb917
Author: Aditya (adityamurali003 at gmail.com)
Date: 2023-11-24T11:34:21+05:30

Commit Message:
CRAB: Enable tts for dialogues and replies

Changed paths:
    engines/crab/event/gameeventmanager.cpp


diff --git a/engines/crab/event/gameeventmanager.cpp b/engines/crab/event/gameeventmanager.cpp
index 09b1554d242..e42f8d6dd90 100644
--- a/engines/crab/event/gameeventmanager.cpp
+++ b/engines/crab/event/gameeventmanager.cpp
@@ -120,6 +120,7 @@ void Manager::handleEvents(Info &info, const Common::String &playerId, Common::E
 				if (_oh.handleDlboxEvents(event)) {
 					_eventMap[info.curLocID()].nextEvent(_activeSeq, info, playerId, result, _endSeq);
 					_oh._showJournal = false;
+					_intro.onExit();
 				}
 			}
 			break;
@@ -140,10 +141,16 @@ void Manager::handleEvents(Info &info, const Common::String &playerId, Common::E
 					if (info.personValid(_curEvent->_title))
 						info._journal.open(playerId, JE_PEOPLE, info.personGet(_curEvent->_title)._name);
 
+				int option = _reply.hoverIndex();
+				if (option >= 0 && option < g_engine->_eventStore->_con[_curEvent->_special]._reply.size()) {
+					_intro.onEntry(g_engine->_eventStore->_con[_curEvent->_special]._reply[option]._text);
+				}
+
 				int choice = _reply.handleEvents(info, g_engine->_eventStore->_con[_curEvent->_special], _curEvent->_title, _oh, event);
 				if (choice >= 0) {
 					_eventMap[info.curLocID()].nextEvent(_activeSeq, info, playerId, result, _endSeq, choice);
 					_oh._showJournal = false;
+					_intro.onExit();
 				}
 			}
 			break;
@@ -283,11 +290,15 @@ void Manager::calcActiveSeq(Info &info, pyrodactyl::level::Level &level, const R
 		_player = (_curEvent->_title == level.playerId());
 
 		switch (_curEvent->_type) {
+		case EVENT_DIALOG:
+			_intro.onEntry(_curEvent->_dialog);
+			break;
 		case EVENT_ANIM:
 			g_engine->_eventStore->_anim[_curEvent->_special].start();
 			break;
 		case EVENT_REPLY:
 			_reply.cache(info, g_engine->_eventStore->_con[_curEvent->_special]);
+			_intro.onEntry(_curEvent->_dialog);
 			break;
 		case EVENT_SPLASH:
 			_intro.onEntry(_curEvent->_dialog);


Commit: df3acd267d220c73193443df5bdbaa893b1e34f9
    https://github.com/scummvm/scummvm/commit/df3acd267d220c73193443df5bdbaa893b1e34f9
Author: Aditya (adityamurali003 at gmail.com)
Date: 2023-11-24T11:34:21+05:30

Commit Message:
CRAB: Add a separate class named TTSHandler

Changed paths:
  A engines/crab/TTSHandler.cpp
  A engines/crab/TTSHandler.h
    engines/crab/event/gameeventmanager.cpp
    engines/crab/module.mk
    engines/crab/ui/ChapterIntro.cpp
    engines/crab/ui/ChapterIntro.h
    engines/crab/ui/PersonHandler.h
    engines/crab/ui/ReplyMenu.h


diff --git a/engines/crab/TTSHandler.cpp b/engines/crab/TTSHandler.cpp
new file mode 100644
index 00000000000..844a6a6d3d4
--- /dev/null
+++ b/engines/crab/TTSHandler.cpp
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "crab/TTSHandler.h"
+#include "common/system.h"
+
+namespace Crab {
+void TTSHandler::onEntry(const Common::String &dialog) const {
+	Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
+
+	_ttsMan->enable(true);
+	_ttsMan->setPitch(50);
+	_ttsMan->setVolume(100);
+	_ttsMan->setRate(20);
+	_ttsMan->setVoice(1);
+	_ttsMan->say(dialog);
+}
+
+void TTSHandler::onExit() const {
+	Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
+
+	_ttsMan->stop();
+}
+
+} // End of namespace Crab
diff --git a/engines/crab/TTSHandler.h b/engines/crab/TTSHandler.h
new file mode 100644
index 00000000000..4e67fc5e0ea
--- /dev/null
+++ b/engines/crab/TTSHandler.h
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef CRAB_TTSHANDLER_H
+#define CRAB_TTSHANDLER_H
+
+#include "common/text-to-speech.h"
+
+namespace Crab {
+class TTSHandler {
+public:
+	void onEntry(const Common::String &dialog) const;
+
+	void onExit() const;
+};
+
+} // End of namespace Crab
+
+#endif // CRAB_TTSHANDLER_H
diff --git a/engines/crab/event/gameeventmanager.cpp b/engines/crab/event/gameeventmanager.cpp
index e42f8d6dd90..75d3ded4be8 100644
--- a/engines/crab/event/gameeventmanager.cpp
+++ b/engines/crab/event/gameeventmanager.cpp
@@ -118,9 +118,9 @@ void Manager::handleEvents(Info &info, const Common::String &playerId, Common::E
 				}
 
 				if (_oh.handleDlboxEvents(event)) {
+					_oh.onExit();
 					_eventMap[info.curLocID()].nextEvent(_activeSeq, info, playerId, result, _endSeq);
 					_oh._showJournal = false;
-					_intro.onExit();
 				}
 			}
 			break;
@@ -141,16 +141,17 @@ void Manager::handleEvents(Info &info, const Common::String &playerId, Common::E
 					if (info.personValid(_curEvent->_title))
 						info._journal.open(playerId, JE_PEOPLE, info.personGet(_curEvent->_title)._name);
 
-				int option = _reply.hoverIndex();
-				if (option >= 0 && option < g_engine->_eventStore->_con[_curEvent->_special]._reply.size()) {
-					_intro.onEntry(g_engine->_eventStore->_con[_curEvent->_special]._reply[option]._text);
+				unsigned int option = static_cast<unsigned int>(_reply.hoverIndex());
+				const auto &replyChoice = g_engine->_eventStore->_con[_curEvent->_special]._reply;
+				if (option < replyChoice.size()) {
+					_intro.onEntry(replyChoice[option]._text);
 				}
 
 				int choice = _reply.handleEvents(info, g_engine->_eventStore->_con[_curEvent->_special], _curEvent->_title, _oh, event);
 				if (choice >= 0) {
+					_reply.onExit();
 					_eventMap[info.curLocID()].nextEvent(_activeSeq, info, playerId, result, _endSeq, choice);
 					_oh._showJournal = false;
-					_intro.onExit();
 				}
 			}
 			break;
@@ -171,8 +172,8 @@ void Manager::handleEvents(Info &info, const Common::String &playerId, Common::E
 					_intro._showTraits = false;
 			} else {
 				if (_intro.handleEvents(event)) {
-					_eventMap[info.curLocID()].nextEvent(_activeSeq, info, playerId, result, _endSeq);
 					_intro.onExit();
+					_eventMap[info.curLocID()].nextEvent(_activeSeq, info, playerId, result, _endSeq);
 				}
 				if (_intro._showTraits)
 					_per.Cache(info, level.playerId(), level);
@@ -291,14 +292,14 @@ void Manager::calcActiveSeq(Info &info, pyrodactyl::level::Level &level, const R
 
 		switch (_curEvent->_type) {
 		case EVENT_DIALOG:
-			_intro.onEntry(_curEvent->_dialog);
+			_oh.onEntry(_curEvent->_dialog);
 			break;
 		case EVENT_ANIM:
 			g_engine->_eventStore->_anim[_curEvent->_special].start();
 			break;
 		case EVENT_REPLY:
+			_reply.onEntry(_curEvent->_dialog);
 			_reply.cache(info, g_engine->_eventStore->_con[_curEvent->_special]);
-			_intro.onEntry(_curEvent->_dialog);
 			break;
 		case EVENT_SPLASH:
 			_intro.onEntry(_curEvent->_dialog);
diff --git a/engines/crab/module.mk b/engines/crab/module.mk
index cc11458dafc..7caed781655 100644
--- a/engines/crab/module.mk
+++ b/engines/crab/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS = \
 	splash.o \
 	timer.o \
 	XMLDoc.o \
+	TTSHandler.o \
 	ai/moveeffect.o \
 	ai/movement.o \
 	ai/spriteai.o \
diff --git a/engines/crab/ui/ChapterIntro.cpp b/engines/crab/ui/ChapterIntro.cpp
index 04862a9e459..5ad805a667f 100644
--- a/engines/crab/ui/ChapterIntro.cpp
+++ b/engines/crab/ui/ChapterIntro.cpp
@@ -30,7 +30,6 @@
 
 #include "crab/animation/sprite.h"
 #include "crab/ui/ChapterIntro.h"
-#include "common/text-to-speech.h"
 
 namespace Crab {
 
@@ -68,21 +67,4 @@ void ChapterIntro::draw(pyrodactyl::event::Info &info, Common::String &text,
 	}
 }
 
-void ChapterIntro::onEntry(const Common::String &dialog) const {
-	Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
-
-	_ttsMan->enable(true);   // Enable text-to-speech
-	_ttsMan->setPitch(50);   // Set pitch level
-	_ttsMan->setVolume(100); // Set volume level
-	_ttsMan->setRate(20);    // Set speech rate
-	_ttsMan->setVoice(1);
-	_ttsMan->say(dialog);
-}
-
-void ChapterIntro::onExit() const {
-	Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
-
-	_ttsMan->stop();
-}
-
 } // End of namespace Crab
diff --git a/engines/crab/ui/ChapterIntro.h b/engines/crab/ui/ChapterIntro.h
index 90ecd3418b2..6925f8bf1ea 100644
--- a/engines/crab/ui/ChapterIntro.h
+++ b/engines/crab/ui/ChapterIntro.h
@@ -33,6 +33,7 @@
 
 #include "crab/ui/button.h"
 #include "crab/ui/dialogbox.h"
+#include "crab/TTSHandler.h"
 
 namespace Crab {
 
@@ -42,7 +43,7 @@ class Sprite;
 } // End of namespace anim
 
 namespace ui {
-class ChapterIntro {
+class ChapterIntro : public TTSHandler {
 	// This contains the background image info and start button
 	GameDialogBox _dialog;
 
@@ -66,10 +67,6 @@ public:
 
 	void draw(pyrodactyl::event::Info &info, Common::String &text,
 			  pyrodactyl::anim::Sprite *curSp, const pyrodactyl::people::PersonState &state);
-
-	void onEntry(const Common::String &dialog) const;
-	void onExit() const;
-
 };
 } // End of namespace ui
 } // End of namespace pyrodactyl
diff --git a/engines/crab/ui/PersonHandler.h b/engines/crab/ui/PersonHandler.h
index eeb047fcd99..23b9bfcd5b2 100644
--- a/engines/crab/ui/PersonHandler.h
+++ b/engines/crab/ui/PersonHandler.h
@@ -35,6 +35,7 @@
 #include "crab/event/GameEventInfo.h"
 #include "crab/ui/ProgressBar.h"
 #include "crab/ui/dialogbox.h"
+#include "crab/TTSHandler.h"
 
 namespace Crab {
 
@@ -44,7 +45,7 @@ class Sprite;
 } // End of namespace Sprite
 
 namespace ui {
-class PersonHandler {
+class PersonHandler : public TTSHandler {
 	// The positions of various elements
 	// img = player image position
 	Element _img;
diff --git a/engines/crab/ui/ReplyMenu.h b/engines/crab/ui/ReplyMenu.h
index e92f4cc797b..e44fb2d4cab 100644
--- a/engines/crab/ui/ReplyMenu.h
+++ b/engines/crab/ui/ReplyMenu.h
@@ -38,12 +38,13 @@
 #include "crab/ui/ImageData.h"
 #include "crab/ui/PersonHandler.h"
 #include "crab/ui/ReplyButton.h"
+#include "crab/TTSHandler.h"
 
 namespace Crab {
 
 namespace pyrodactyl {
 namespace ui {
-class ReplyMenu : public Menu<ReplyButton> {
+class ReplyMenu : public Menu<ReplyButton>, public TTSHandler {
 	// Data about the background image
 	ImageData _bg;
 




More information about the Scummvm-git-logs mailing list