mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-01 06:58:34 +00:00
WINTERMUTE: Do some refactoring over a bunch of attrs in VideoSubtitle
Conflicts: engines/wintermute/video/video_subtitler.cpp
This commit is contained in:
parent
f2441da3da
commit
2eee488e36
@ -32,25 +32,26 @@ namespace Wintermute {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
|
VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
|
||||||
_text = NULL;
|
|
||||||
_startFrame = _endFrame = 0;
|
_startFrame = _endFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) {
|
VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
|
||||||
_text = new char[strlen(text) + 1];
|
_gameRef->expandStringByStringTable(&text);
|
||||||
strcpy(_text, text);
|
_text = Common::String(text);
|
||||||
_gameRef->expandStringByStringTable(&_text);
|
|
||||||
_startFrame = startFrame;
|
_startFrame = startFrame;
|
||||||
_endFrame = endFrame;
|
_endFrame = endFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long VideoSubtitle::getStartFrame() {
|
||||||
|
return _startFrame;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
long VideoSubtitle::getEndFrame() {
|
||||||
VideoSubtitle::~VideoSubtitle() {
|
return _endFrame;
|
||||||
if (_text) {
|
}
|
||||||
delete [] _text;
|
|
||||||
_text = NULL;
|
Common::String VideoSubtitle::getText() {
|
||||||
}
|
return _text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,15 @@ namespace Wintermute {
|
|||||||
|
|
||||||
class VideoSubtitle : public BaseClass {
|
class VideoSubtitle : public BaseClass {
|
||||||
public:
|
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 _endFrame;
|
||||||
long _startFrame;
|
long _startFrame;
|
||||||
char *_text;
|
Common::String _text;
|
||||||
VideoSubtitle(BaseGame *inGame);
|
|
||||||
VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame);
|
|
||||||
virtual ~VideoSubtitle();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,8 +186,8 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
|
|||||||
bool VideoSubtitler::display() {
|
bool VideoSubtitler::display() {
|
||||||
if (_showSubtitle) {
|
if (_showSubtitle) {
|
||||||
BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
|
BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
|
||||||
int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->_text, _gameRef->_renderer->getWidth());
|
int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->getText().c_str(), _gameRef->_renderer->getWidth());
|
||||||
font->drawText((byte *)_subtitles[_currentSubtitle]->_text,
|
font->drawText((byte *)_subtitles[_currentSubtitle]->getText().c_str(),
|
||||||
0,
|
0,
|
||||||
(_gameRef->_renderer->getHeight() - textHeight - 5),
|
(_gameRef->_renderer->getHeight() - textHeight - 5),
|
||||||
(_gameRef->_renderer->getWidth(), TAL_CENTER));
|
(_gameRef->_renderer->getWidth(), TAL_CENTER));
|
||||||
@ -208,11 +208,11 @@ bool VideoSubtitler::update(long frame) {
|
|||||||
|
|
||||||
_showSubtitle = false;
|
_showSubtitle = false;
|
||||||
|
|
||||||
bool overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
|
bool overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
|
||||||
bool hasNext = (_currentSubtitle + 1 < _subtitles.size());
|
bool hasNext = (_currentSubtitle + 1 < _subtitles.size());
|
||||||
bool nextStarted = false;
|
bool nextStarted = false;
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
|
nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_currentSubtitle < _subtitles.size() &&
|
while (_currentSubtitle < _subtitles.size() &&
|
||||||
@ -228,22 +228,22 @@ bool VideoSubtitler::update(long frame) {
|
|||||||
|
|
||||||
_currentSubtitle++;
|
_currentSubtitle++;
|
||||||
|
|
||||||
overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
|
overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
|
||||||
hasNext = (_currentSubtitle + 1 < _subtitles.size());
|
hasNext = (_currentSubtitle + 1 < _subtitles.size());
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
|
nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
|
||||||
} else {
|
} else {
|
||||||
nextStarted = false;
|
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.
|
* No idea why we do this check, carried over from Mnemonic's code.
|
||||||
* Possibly a workaround for buggy subtitles or some kind of sentinel? :-\
|
* 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) {
|
if (currentStarted && !overdue && currentValid) {
|
||||||
_showSubtitle = true;
|
_showSubtitle = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user