From f2441da3da9ce4802ce12dc5c815095098e57ee2 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 6 Feb 2014 01:00:19 +0100 Subject: WINTERMUTE: Make sure subtitle files could be found before anything else --- engines/wintermute/video/video_subtitler.cpp | 3 ++- engines/wintermute/video/video_theora_player.cpp | 28 +++++++++++++++--------- engines/wintermute/video/video_theora_player.h | 3 ++- 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index e4c55feb03..06b8bab1f4 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -177,8 +177,9 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil } delete[] buffer; + // Succeeded loading subtitles! - return false; + return true; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 600eae8349..2af3ac1638 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -86,6 +86,7 @@ void VideoTheoraPlayer::SetDefaults() { _theoraDecoder = nullptr; _subtitler = new VideoSubtitler(_gameRef); + _subtitles = false; } ////////////////////////////////////////////////////////////////////////// @@ -134,7 +135,13 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: #endif - _subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str()); + if (_subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str())) { + // We have subtitles + _subtitles = true; + } else { + // We couldn't load subtitles... + _subtitles = false; + } _theoraDecoder->loadStream(_file); @@ -220,8 +227,10 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, _state = THEORA_STATE_PLAYING; _looping = looping; _playbackType = type; - _subtitler->update(_theoraDecoder->getFrameCount()); - _subtitler->display(); + if (_subtitler && _subtitles && _gameRef->_subtitles) { + _subtitler->update(_theoraDecoder->getFrameCount()); + _subtitler->display(); + } _startTime = startTime; _volume = volume; _posX = x; @@ -296,8 +305,9 @@ bool VideoTheoraPlayer::update() { } if (_theoraDecoder) { - - _subtitler->update(_theoraDecoder->getCurFrame()); + if (_subtitler && _subtitles && _gameRef->_subtitles) { + _subtitler->update(_theoraDecoder->getCurFrame()); + } if (_theoraDecoder->endOfVideo() && _looping) { warning("Should loop movie %s, hacked for now", _filename.c_str()); @@ -422,12 +432,10 @@ bool VideoTheoraPlayer::display(uint32 alpha) { } else { res = STATUS_FAILED; } - // TODO: Add subtitles-support -/* if (m_Subtitler && _gameRef->m_VideoSubtitles) { - m_Subtitler->display(); - }*/ - _subtitler->display(); + if (_subtitler && _subtitles && _gameRef->_subtitles) { + _subtitler->display(); + } return res; } diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 698326c29c..48f75efd20 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -138,9 +138,10 @@ private: bool _playbackStarted; + bool _subtitles; + // helpers void SetDefaults(); - }; } // End of namespace Wintermute -- cgit v1.2.3