aboutsummaryrefslogtreecommitdiff
path: root/engines/toon/subtitles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/toon/subtitles.cpp')
-rw-r--r--engines/toon/subtitles.cpp92
1 files changed, 44 insertions, 48 deletions
diff --git a/engines/toon/subtitles.cpp b/engines/toon/subtitles.cpp
index 8996e3bb41..5861b6cb34 100644
--- a/engines/toon/subtitles.cpp
+++ b/engines/toon/subtitles.cpp
@@ -28,71 +28,67 @@
namespace Toon {
SubtitleRenderer::SubtitleRenderer(ToonEngine *vm) : _vm(vm) {
- _subSurface = new Graphics::Surface();
+ _subSurface = new Graphics::Surface();
_subSurface->create(TOON_SCREEN_WIDTH, TOON_SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8());
- _hasSubtitles = false;
+ _hasSubtitles = false;
}
SubtitleRenderer::~SubtitleRenderer() {
}
-void SubtitleRenderer::render(const Graphics::Surface& frame, uint32 frameNumber, char color) {
- if (!_hasSubtitles || _index > _last) {
- return;
- }
+void SubtitleRenderer::render(const Graphics::Surface &frame, uint32 frameNumber, byte color) {
+ if (!_hasSubtitles || _index > _last) {
+ return;
+ }
- _subSurface->copyFrom(frame);
- // char strf[384] = {0};
- // sprintf(strf, "Time passed: %d", frameNumber);
- // _vm->drawCostumeLine(0, 0, strf, _subSurface);
- // _vm->_system->copyRectToScreen(_subSurface->getBasePtr(0, 0), _subSurface->pitch, 0, 0, _subSurface->w, _subSurface->h);
+ _subSurface->copyFrom(frame);
+ // char strf[384] = {0};
+ // sprintf(strf, "Time passed: %d", frameNumber);
+ // _vm->drawCostumeLine(0, 0, strf, _subSurface);
+ // _vm->_system->copyRectToScreen(_subSurface->getBasePtr(0, 0), _subSurface->pitch, 0, 0, _subSurface->w, _subSurface->h);
- if (frameNumber > _tw[_index].fend) {
- _index++;
- if (_index > _last) {
- return;
- }
- _currentLine = (char*)_fileData + _tw[_index].foffset;
- }
+ if (frameNumber > _tw[_index].fend) {
+ _index++;
+ if (_index > _last) {
+ return;
+ }
+ _currentLine = (char*)_fileData + _tw[_index].foffset;
+ }
- if (frameNumber < _tw[_index].fstart) {
- return;
- }
+ if (frameNumber < _tw[_index].fstart) {
+ return;
+ }
- _vm->drawCustomText(TOON_SCREEN_WIDTH / 2, TOON_SCREEN_HEIGHT, _currentLine, _subSurface, color);
- _vm->_system->copyRectToScreen(_subSurface->getBasePtr(0, 0), _subSurface->pitch, 0, 0, _subSurface->w, _subSurface->h);
+ _vm->drawCustomText(TOON_SCREEN_WIDTH / 2, TOON_SCREEN_HEIGHT, _currentLine, _subSurface, color);
+ _vm->_system->copyRectToScreen(_subSurface->getBasePtr(0, 0), _subSurface->pitch, 0, 0, _subSurface->w, _subSurface->h);
}
bool SubtitleRenderer::load(const Common::String &video) {
- warning(video.c_str());
+ warning(video.c_str());
- _hasSubtitles = false;
- _index = 0;
+ _hasSubtitles = false;
+ _index = 0;
- char srtfile[20] = {0};
- strcpy(srtfile, video.c_str());
- srtfile[19] = '\0';
- int ln = strlen(srtfile);
- srtfile[ln - 3] = 't';
- srtfile[ln - 2] = 's';
- srtfile[ln - 1] = 's';
+ Common::String subfile(video);
+ Common::String ext("tss");
+ subfile.replace(subfile.size() - ext.size(), ext.size(), ext);
- uint32 fileSize = 0;
- uint8 *fileData = _vm->resources()->getFileData(srtfile, &fileSize);
+ uint32 fileSize = 0;
+ uint8 *fileData = _vm->resources()->getFileData(subfile, &fileSize);
if (!fileData) {
- return false;
- }
-
- uint32 numOflines = *((uint32*) fileData);
- uint32 idx_size = numOflines * sizeof(TimeWindow);
- memcpy(_tw, sizeof(numOflines) + fileData, idx_size);
- _fileData = sizeof(numOflines) + fileData + idx_size;
- _last = numOflines - 1;
-
- _currentLine = (char*)_fileData + _tw[0].foffset;
- _hasSubtitles = true;
- return _hasSubtitles;
+ return false;
+ }
+
+ uint32 numOflines = *((uint32 *) fileData);
+ uint32 idx_size = numOflines * sizeof(TimeWindow);
+ memcpy(_tw, sizeof(numOflines) + fileData, idx_size);
+ _fileData = sizeof(numOflines) + fileData + idx_size;
+ _last = numOflines - 1;
+
+ _currentLine = (char *)_fileData + _tw[0].foffset;
+ _hasSubtitles = true;
+ return _hasSubtitles;
}
-} \ No newline at end of file
+}