diff options
author | Tobia Tesan | 2014-10-15 20:29:41 +0200 |
---|---|---|
committer | Tobia Tesan | 2014-10-15 21:36:38 +0200 |
commit | 621a068c0065783bba0430f57b71112d7e42a5a9 (patch) | |
tree | d7ed108ce65e6a30b81161076eb3cbfef6d25c31 /engines/wintermute/video | |
parent | ad5fde9db3767bee7af4e8c23277a07cad705de7 (diff) | |
download | scummvm-rg350-621a068c0065783bba0430f57b71112d7e42a5a9.tar.gz scummvm-rg350-621a068c0065783bba0430f57b71112d7e42a5a9.tar.bz2 scummvm-rg350-621a068c0065783bba0430f57b71112d7e42a5a9.zip |
WINTERMUTE: Mass ScummVM-style renaming in subtitles code
Diffstat (limited to 'engines/wintermute/video')
-rw-r--r-- | engines/wintermute/video/video_subtitle.cpp | 27 | ||||
-rw-r--r-- | engines/wintermute/video/video_subtitle.h | 15 | ||||
-rw-r--r-- | engines/wintermute/video/video_subtitler.cpp | 180 | ||||
-rw-r--r-- | engines/wintermute/video/video_subtitler.h | 23 | ||||
-rw-r--r-- | engines/wintermute/video/video_theora_player.cpp | 19 | ||||
-rw-r--r-- | engines/wintermute/video/video_theora_player.h | 2 |
6 files changed, 134 insertions, 132 deletions
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index 3d0688d975..0fab6fb2b7 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -31,27 +31,26 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::CVidSubtitle(BaseGame *inGame): BaseClass(inGame) { - m_Text = NULL; - m_StartFrame = m_EndFrame = 0; +VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { + _text = NULL; + _startFrame = _endFrame = 0; } - ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame): BaseClass(inGame) { - m_Text = new char[strlen(Text) + 1]; - strcpy(m_Text, Text); - // _gameRef->m_StringTable->Expand(&m_Text); - m_StartFrame = StartFrame; - m_EndFrame = EndFrame; +VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) { + _text = new char[strlen(text) + 1]; + strcpy(_text, text); + // _gameRef->m_StringTable->Expand(&this->text); + _startFrame = startFrame; + _endFrame = endFrame; } ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::~CVidSubtitle() { - if (m_Text) { - delete [] m_Text; - m_Text = NULL; +VideoSubtitle::~VideoSubtitle() { + if (_text) { + delete [] _text; + _text = NULL; } } } diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index e93007bd3b..6d629b34d0 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -33,15 +33,14 @@ namespace Wintermute { -class CVidSubtitle : public BaseClass { +class VideoSubtitle : public BaseClass { public: - long m_EndFrame; - long m_StartFrame; - char *m_Text; - CVidSubtitle(BaseGame *inGame); - CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame); - virtual ~CVidSubtitle(); - + long _endFrame; + long _startFrame; + char *_text; + VideoSubtitle(BaseGame *inGame); + VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame); + virtual ~VideoSubtitle(); }; } diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index dd657876ba..9d0a066c20 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -35,143 +35,145 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// -CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) { - m_LastSample = -1; - m_CurrentSubtitle = 0; - m_ShowSubtitle = false; +VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) { + _lastSample = -1; + _currentSubtitle = 0; + _showSubtitle = false; } ////////////////////////////////////////////////////////////////////////// -CVidSubtitler::~CVidSubtitler(void) { - for (int i = 0; i < m_Subtitles.size(); i++) { - delete m_Subtitles[i]; +VideoSubtitler::~VideoSubtitler(void) { + for (int i = 0; i < _subtitles.size(); i++) { + delete _subtitles[i]; } - m_Subtitles.clear(); + _subtitles.clear(); } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile) { +bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFile) { if (!Filename) { return false; } - m_Subtitles.clear(); + for (int i = 0; i < _subtitles.size(); i++) { + delete _subtitles[i]; + } + + _subtitles.clear(); - m_LastSample = -1; - m_CurrentSubtitle = 0; - m_ShowSubtitle = false; + _lastSample = -1; + _currentSubtitle = 0; + _showSubtitle = false; - Common::String NewFile; + Common::String newFile; - if (SubtitleFile) { - NewFile = Common::String(SubtitleFile); + if (subtitleFile) { + newFile = Common::String(subtitleFile); } else { Common::String path = PathUtil::getDirectoryName(Filename); Common::String name = PathUtil::getFileNameWithoutExtension(Filename); Common::String ext = ".SUB"; - NewFile = PathUtil::combine(path, name + ext); + newFile = PathUtil::combine(path, name + ext); } - long Size; + long size; - Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false); if (file == nullptr) { return false; // no subtitles } - Size = file->size(); - char *Buffer = new char[Size]; + size = file->size(); + char *buffer = new char[size]; + file->read(buffer, size); - file->read(Buffer, Size); + long start, end; + bool inToken; + char *tokenStart; + int tokenLength; + int tokenPos; + int textLength; - long Start, End; - bool InToken; - char *TokenStart; - int TokenLength; - int TokenPos; - int TextLength; + int pos = 0; + int lineLength = 0; - int Pos = 0; - int LineLength = 0; + while (pos < size) { + start = end = -1; + inToken = false; + tokenPos = -1; + textLength = 0; - while (Pos < Size) { - Start = End = -1; - InToken = false; - TokenPos = -1; - TextLength = 0; + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') { - LineLength++; - } + int realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *Text = new char[realLength + 1]; + char *line = (char *)&buffer[pos]; - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *Text = new char[RealLength + 1]; - char *line = (char *)&Buffer[Pos]; - - for (int i = 0; i < RealLength; i++) { + for (int i = 0; i < realLength; i++) { if (line[i] == '{') { - if (!InToken) { - InToken = true; - TokenStart = line + i + 1; - TokenLength = 0; - TokenPos++; + if (!inToken) { + inToken = true; + tokenStart = line + i + 1; + tokenLength = 0; + tokenPos++; } else { - TokenLength++; + tokenLength++; } } else if (line[i] == '}') { - if (InToken) { - InToken = false; - char *Token = new char[TokenLength + 1]; - strncpy(Token, TokenStart, TokenLength); - Token[TokenLength] = '\0'; - if (TokenPos == 0) { - Start = atoi(Token); - } else if (TokenPos == 1) { - End = atoi(Token); + if (inToken) { + inToken = false; + char *token = new char[tokenLength + 1]; + strncpy(token, tokenStart, tokenLength); + token[tokenLength] = '\0'; + if (tokenPos == 0) { + start = atoi(token); + } else if (tokenPos == 1) { + end = atoi(token); } - delete [] Token; + + delete[] token; } else { - Text[TextLength] = line[i]; - TextLength++; + Text[textLength] = line[i]; + textLength++; } } else { - if (InToken) { - TokenLength++; + if (inToken) { + tokenLength++; } else { - Text[TextLength] = line[i]; - if (Text[TextLength] == '|') { - Text[TextLength] = '\n'; + Text[textLength] = line[i]; + if (Text[textLength] == '|') { + Text[textLength] = '\n'; } - TextLength++; + textLength++; } } } - Text[TextLength] = '\0'; + Text[textLength] = '\0'; - if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) { - m_Subtitles.push_back(new CVidSubtitle(_gameRef, Text, Start, End)); + if (start != -1 && textLength > 0 && (start != 1 || end != 1)) { + _subtitles.push_back(new VideoSubtitle(_gameRef, Text, start, end)); } delete [] Text; - Pos += LineLength + 1; + pos += lineLength + 1; } - delete [] Buffer; + delete[] buffer; return false; } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::Display() { - if (m_ShowSubtitle) { +bool VideoSubtitler::display() { + if (_showSubtitle) { BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont(); - int textHeight = font->getTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, _gameRef->_renderer->getWidth()); - font->drawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, + int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->_text, _gameRef->_renderer->getWidth()); + font->drawText((byte *)_subtitles[_currentSubtitle]->_text, 0, (_gameRef->_renderer->getHeight() - textHeight - 5), (_gameRef->_renderer->getWidth(), TAL_CENTER)); @@ -180,26 +182,26 @@ bool CVidSubtitler::Display() { } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::Update(long Frame) { - if (Frame != m_LastSample) { - m_LastSample = Frame; +bool VideoSubtitler::update(long frame) { + if (frame != _lastSample) { + _lastSample = frame; // process subtitles - m_ShowSubtitle = false; - while (m_CurrentSubtitle < m_Subtitles.size()) { - int End = m_Subtitles[m_CurrentSubtitle]->m_EndFrame; + _showSubtitle = false; + while (_currentSubtitle < _subtitles.size()) { + int end = _subtitles[_currentSubtitle]->_endFrame; - bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size() - 1 && m_Subtitles[m_CurrentSubtitle + 1]->m_StartFrame <= Frame); + bool nextFrameOK = (_currentSubtitle < _subtitles.size() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= frame); - if (Frame > End) { - if (NextFrameOK) { - m_CurrentSubtitle++; + if (frame > end) { + if (nextFrameOK) { + _currentSubtitle++; } else { - m_ShowSubtitle = (End == 0); + _showSubtitle = (end == 0); break; } } else { - m_ShowSubtitle = true; + _showSubtitle = true; break; } } diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 25641bc574..e42fbeb505 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -34,19 +34,18 @@ namespace Wintermute { -class CVidSubtitler : - public BaseClass { +class VideoSubtitler : public BaseClass { public: - CVidSubtitler(BaseGame *inGame); - virtual ~CVidSubtitler(void); - - bool m_ShowSubtitle; - int m_CurrentSubtitle; - bool LoadSubtitles(const char *Filename, const char *SubtitleFile); - bool Display(); - bool Update(long Frame); - long m_LastSample; - Common::Array<CVidSubtitle *> m_Subtitles; + VideoSubtitler(BaseGame *inGame); + virtual ~VideoSubtitler(void); + + bool _showSubtitle; + int _currentSubtitle; + bool loadSubtitles(const char *filename, const char *subtitleFile); + bool display(); + bool update(long frame); + long _lastSample; + Common::Array<VideoSubtitle *> _subtitles; }; } diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 232c4847b1..a90fb02033 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -85,13 +85,16 @@ void VideoTheoraPlayer::SetDefaults() { _volume = 100; _theoraDecoder = nullptr; - _subtitler = new CVidSubtitler(_gameRef); + _subtitler = new VideoSubtitler(_gameRef); } ////////////////////////////////////////////////////////////////////////// VideoTheoraPlayer::~VideoTheoraPlayer(void) { cleanup(); -// SAFE_DELETE(_subtitler); + if(_subtitler) { + delete [] _subtitler; + _subtitler = NULL; + } } ////////////////////////////////////////////////////////////////////////// @@ -131,7 +134,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: #endif - _subtitler->LoadSubtitles(_filename.c_str(), subtitleFile.c_str()); + _subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str()); _theoraDecoder->loadStream(_file); @@ -217,8 +220,8 @@ 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(); + _subtitler->update(_theoraDecoder->getFrameCount()); + _subtitler->display(); _startTime = startTime; _volume = volume; _posX = x; @@ -260,7 +263,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, #if 0 // Stubbed for now as theora isn't seekable if (StartTime) SeekToTime(StartTime); - Update(); + update(); #endif return STATUS_FAILED; } @@ -294,7 +297,7 @@ bool VideoTheoraPlayer::update() { if (_theoraDecoder) { - _subtitler->Update(_theoraDecoder->getCurFrame()); + _subtitler->update(_theoraDecoder->getCurFrame()); if (_theoraDecoder->endOfVideo() && _looping) { warning("Should loop movie %s, hacked for now", _filename.c_str()); @@ -423,7 +426,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) { /* if (m_Subtitler && _gameRef->m_VideoSubtitles) { m_Subtitler->display(); }*/ - _subtitler->Display(); + _subtitler->display(); return res; } diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 2d79c5404b..698326c29c 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -60,7 +60,7 @@ public: Common::String _filename; BaseSurface *_texture; - CVidSubtitler *_subtitler; + VideoSubtitler *_subtitler; // control methods bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String()); |