[Scummvm-git-logs] scummvm master -> 92443667e5d0f5190a679c33ca6858aa311891ad

neuromancer noreply at scummvm.org
Tue Sep 2 19:32:03 UTC 2025


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

Summary:
92443667e5 HYPNO: added support for subtitles in cutscenes


Commit: 92443667e5d0f5190a679c33ca6858aa311891ad
    https://github.com/scummvm/scummvm/commit/92443667e5d0f5190a679c33ca6858aa311891ad
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-09-02T21:35:20+02:00

Commit Message:
HYPNO: added support for subtitles in cutscenes

Changed paths:
    engines/hypno/hypno.cpp
    engines/hypno/hypno.h


diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 87431bfbc45..60cc38d008d 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -61,7 +61,7 @@ HypnoEngine::HypnoEngine(OSystem *syst, const ADGameDescription *gd)
 	  _background(nullptr), _masks(nullptr), _musicRate(0), _musicStereo(false),
 	  _additionalVideo(nullptr), _ammo(0), _maxAmmo(0), _skipNextVideo(false),
 	  _doNotStopSounds(false), _screenW(0), _screenH(0), // Every games initializes its own resolution
-	  _keepTimerDuringScenes(false) {
+	  _keepTimerDuringScenes(false), _subtitles(nullptr) {
 	_rnd = new Common::RandomSource("hypno");
 	_checkpoint = "";
 
@@ -173,6 +173,16 @@ Common::Error HypnoEngine::run() {
 		} else
 			g_system->delayMillis(300);
 	}
+
+	// Only enable if subtitles are available
+	bool useSubtitles = false;
+	if (!Common::parseBool(ConfMan.get("subtitles"), useSubtitles))
+		warning("Failed to parse bool from subtitles options");
+
+	if (useSubtitles) {
+		g_system->showOverlay(false);
+	}
+
 	return Common::kNoError;
 }
 
@@ -284,6 +294,9 @@ void HypnoEngine::runIntros(Videos &videos) {
 					playing = true;
 					if (it->decoder->needsUpdate()) {
 						updateScreen(*it);
+						if (_subtitles && it->decoder && !it->decoder->isPaused())
+							_subtitles->drawSubtitle(it->decoder->getTime(), false, false);
+
 						drawScreen();
 					}
 				}
@@ -301,9 +314,15 @@ void HypnoEngine::runIntros(Videos &videos) {
 }
 
 void HypnoEngine::runIntro(MVideo &video) {
+	Common::Path path(video.path);
+	loadSubtitles(path);
 	Videos tmp;
 	tmp.push_back(video);
 	runIntros(tmp);
+
+	delete _subtitles;
+	_subtitles = nullptr;
+	g_system->clearOverlay();
 }
 
 void HypnoEngine::runCode(Code *code) { error("Function \"%s\" not implemented", __FUNCTION__); }
@@ -548,6 +567,48 @@ void HypnoEngine::drawScreen() {
 
 // Video handling
 
+void HypnoEngine::adjustSubtitleSize() {
+	debugC(1, kHypnoDebugMedia, "%s()", __FUNCTION__);
+	if (_subtitles) {
+		int16 h = g_system->getOverlayHeight();
+		int16 w = g_system->getOverlayWidth();
+		float scale = h / 2160.f;
+		_subtitles->setBBox(Common::Rect(20, h - 160 * scale, w - 20, h - 20));
+		int fontSize = MAX(8, int(50 * scale));
+		_subtitles->setColor(0xff, 0xff, 0x80);
+		_subtitles->setFont("NotoSerif-Regular.ttf", fontSize, "regular");
+		_subtitles->setFont("NotoSerif-Italic.ttf", fontSize, "italic");
+	}
+}
+
+void HypnoEngine::loadSubtitles(const Common::Path &path) {
+	debugC(1, kHypnoDebugMedia, "%s(%s)", __FUNCTION__, path.toString().c_str());
+	debug("Subtitle path: %s", path.toString().c_str());
+	Common::String subPathStr = path.toString() + ".srt";
+	subPathStr.toLowercase();
+	subPathStr.replace('/', '_');
+	subPathStr.replace('\\', '_');
+	Common::String language(Common::getLanguageCode(_language));
+	if (language == "us")
+		language = "en";
+
+	Common::Path subPath = "subtitles";
+	subPath = subPath.appendComponent(language);
+	subPath = subPath.appendComponent(subPathStr);
+	debugC(1, kHypnoDebugMedia, "Loading subtitles from %s", subPath.toString().c_str());
+	if (Common::File::exists(subPath)) {
+		_subtitles = new Video::Subtitles();
+		_subtitles->loadSRTFile(subPath);
+		g_system->showOverlay(false);
+		adjustSubtitleSize();
+	} else {
+		delete _subtitles;
+		_subtitles = nullptr;
+		g_system->clearOverlay();
+	}
+}
+
+
 void HypnoEngine::playVideo(MVideo &video) {
 	debugC(1, kHypnoDebugMedia, "%s(%s)", __FUNCTION__, video.path.c_str());
 	Common::File *file = new Common::File();
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index acd0808e774..9792983c0a2 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -32,6 +32,7 @@
 #include "graphics/font.h"
 #include "graphics/fontman.h"
 #include "graphics/surface.h"
+#include "video/subtitles.h"
 
 #include "hypno/grammar.h"
 #include "hypno/libfile.h"
@@ -197,6 +198,10 @@ public:
 	bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return (isDemo() ? false : true); }
 	Common::String _checkpoint;
 
+	Video::Subtitles *_subtitles;
+	void adjustSubtitleSize();
+	void loadSubtitles(const Common::Path &path);
+
 	Common::Path _prefixDir;
 	Common::Path convertPath(const Common::String &);
 	void playVideo(MVideo &video);




More information about the Scummvm-git-logs mailing list