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

sev- noreply at scummvm.org
Wed Sep 28 15:10:25 UTC 2022


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:
c809c7be13 MOHAWK: MYST: Add support for video subtitles


Commit: c809c7be13c182716e3e68a6ff757107169dfe8f
    https://github.com/scummvm/scummvm/commit/c809c7be13c182716e3e68a6ff757107169dfe8f
Author: BLooperZ (blooperz at users.noreply.github.com)
Date: 2022-09-28T17:10:21+02:00

Commit Message:
MOHAWK: MYST: Add support for video subtitles

Changed paths:
    engines/mohawk/video.cpp
    engines/mohawk/video.h


diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index 889aa4e62ce..222a787a7b0 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -140,6 +140,12 @@ void VideoEntry::setVolume(int volume) {
 VideoManager::VideoManager(MohawkEngine *vm) : _vm(vm) {
 	// Set dithering enabled, if required
 	_enableDither = (_vm->getGameType() == GType_MYST || _vm->getGameType() == GType_MAKINGOF) && !_vm->isGameVariant(GF_ME);
+
+	int16 h = g_system->getOverlayHeight();
+
+	_subtitles.setBBox(Common::Rect(20, h - 120, g_system->getOverlayWidth() - 20, h - 20));
+	_subtitles.setColor(0xff, 0xff, 0xff);
+	_subtitles.setFont("FreeSans.ttf");
 }
 
 VideoManager::~VideoManager() {
@@ -168,6 +174,10 @@ VideoEntryPtr VideoManager::playMovie(const Common::String &fileName, Audio::Mix
 	if (!ptr)
 		return VideoEntryPtr();
 
+
+	Common::String subtitlesName = Common::String::format("%s.srt", fileName.substr(0, fileName.size() - 4).c_str());
+	loadSubtitles(subtitlesName.c_str());
+
 	ptr->start();
 	return ptr;
 }
@@ -184,9 +194,13 @@ VideoEntryPtr VideoManager::playMovie(uint16 id) {
 bool VideoManager::updateMovies() {
 	bool updateScreen = false;
 
+	g_system->showOverlay();
+	g_system->clearOverlay();
+
 	for (VideoList::iterator it = _videos.begin(); it != _videos.end(); ) {
 		// Check of the video has reached the end
 		if ((*it)->endOfVideo()) {
+			g_system->hideOverlay();
 			if ((*it)->isLooping()) {
 				// Seek back if looping
 				(*it)->seek((*it)->getStart());
@@ -206,6 +220,8 @@ bool VideoManager::updateMovies() {
 			continue;
 		}
 
+		_subtitles.drawSubtitle(video->getTime(), true);
+
 		// Check if we need to draw a frame
 		if (video->needsUpdate()) {
 			if (drawNextFrame(*it)) {
diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h
index 44f90263b76..2f3e8c31774 100644
--- a/engines/mohawk/video.h
+++ b/engines/mohawk/video.h
@@ -30,6 +30,7 @@
 #include "common/ptr.h"
 #include "common/rational.h"
 #include "graphics/pixelformat.h"
+#include "video/subtitles.h"
 
 namespace Video {
 class VideoDecoder;
@@ -253,6 +254,7 @@ public:
 	VideoEntryPtr findVideo(const Common::String &fileName);
 	void drawVideoFrame(const VideoEntryPtr &video, const Audio::Timestamp &time);
 	void removeEntry(const VideoEntryPtr &video);
+	void loadSubtitles(const char *fname) { _subtitles.loadSRTFile(fname); }
 
 protected:
 	MohawkEngine *_vm;
@@ -272,6 +274,8 @@ protected:
 	// Dithering control
 	bool _enableDither;
 	void checkEnableDither(VideoEntryPtr &entry);
+
+	Video::Subtitles _subtitles;
 };
 
 } // End of namespace Mohawk




More information about the Scummvm-git-logs mailing list