aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorTobia Tesan2014-10-15 20:49:59 +0200
committerTobia Tesan2014-10-15 21:36:45 +0200
commit2eee488e364460772dcb8a85962f6c210810587b (patch)
tree03b4d992de054b51ff17f80701b186f9c099f047 /engines/wintermute
parentf2441da3da9ce4802ce12dc5c815095098e57ee2 (diff)
downloadscummvm-rg350-2eee488e364460772dcb8a85962f6c210810587b.tar.gz
scummvm-rg350-2eee488e364460772dcb8a85962f6c210810587b.tar.bz2
scummvm-rg350-2eee488e364460772dcb8a85962f6c210810587b.zip
WINTERMUTE: Do some refactoring over a bunch of attrs in VideoSubtitle
Conflicts: engines/wintermute/video/video_subtitler.cpp
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/video/video_subtitle.cpp23
-rw-r--r--engines/wintermute/video/video_subtitle.h11
-rw-r--r--engines/wintermute/video/video_subtitler.cpp16
3 files changed, 27 insertions, 23 deletions
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 5be22de592..bcaa293124 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -32,25 +32,26 @@ namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
- _text = NULL;
_startFrame = _endFrame = 0;
}
//////////////////////////////////////////////////////////////////////////
-VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) {
- _text = new char[strlen(text) + 1];
- strcpy(_text, text);
- _gameRef->expandStringByStringTable(&_text);
+VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
+ _gameRef->expandStringByStringTable(&text);
+ _text = Common::String(text);
_startFrame = startFrame;
_endFrame = endFrame;
}
+long VideoSubtitle::getStartFrame() {
+ return _startFrame;
+}
-//////////////////////////////////////////////////////////////////////////
-VideoSubtitle::~VideoSubtitle() {
- if (_text) {
- delete [] _text;
- _text = NULL;
- }
+long VideoSubtitle::getEndFrame() {
+ return _endFrame;
+}
+
+Common::String VideoSubtitle::getText() {
+ return _text;
}
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 6d629b34d0..5df1348465 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -35,12 +35,15 @@ namespace Wintermute {
class VideoSubtitle : public BaseClass {
public:
+ VideoSubtitle(BaseGame *inGame);
+ VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame);
+ long getEndFrame();
+ long getStartFrame();
+ Common::String getText();
+private:
long _endFrame;
long _startFrame;
- char *_text;
- VideoSubtitle(BaseGame *inGame);
- VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame);
- virtual ~VideoSubtitle();
+ Common::String _text;
};
}
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 06b8bab1f4..a1294dd3d4 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -186,8 +186,8 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
bool VideoSubtitler::display() {
if (_showSubtitle) {
BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
- int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->_text, _gameRef->_renderer->getWidth());
- font->drawText((byte *)_subtitles[_currentSubtitle]->_text,
+ int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->getText().c_str(), _gameRef->_renderer->getWidth());
+ font->drawText((byte *)_subtitles[_currentSubtitle]->getText().c_str(),
0,
(_gameRef->_renderer->getHeight() - textHeight - 5),
(_gameRef->_renderer->getWidth(), TAL_CENTER));
@@ -208,11 +208,11 @@ bool VideoSubtitler::update(long frame) {
_showSubtitle = false;
- bool overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
+ bool overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
bool hasNext = (_currentSubtitle + 1 < _subtitles.size());
bool nextStarted = false;
if (hasNext) {
- nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
+ nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
}
while (_currentSubtitle < _subtitles.size() &&
@@ -228,22 +228,22 @@ bool VideoSubtitler::update(long frame) {
_currentSubtitle++;
- overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
+ overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
hasNext = (_currentSubtitle + 1 < _subtitles.size());
if (hasNext) {
- nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
+ nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
} else {
nextStarted = false;
}
}
- bool currentValid = (_subtitles[_currentSubtitle]->_endFrame != 0);
+ bool currentValid = (_subtitles[_currentSubtitle]->getEndFrame() != 0);
/*
* No idea why we do this check, carried over from Mnemonic's code.
* Possibly a workaround for buggy subtitles or some kind of sentinel? :-\
*/
- bool currentStarted = frame >= _subtitles[_currentSubtitle]->_startFrame;
+ bool currentStarted = frame >= _subtitles[_currentSubtitle]->getStartFrame();
if (currentStarted && !overdue && currentValid) {
_showSubtitle = true;