aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBLooperZ2019-10-14 21:09:32 +0300
committerEugene Sandulenko2019-11-18 02:02:14 +0100
commitff039617bb8bfa832efbf4249c84d9e242f19568 (patch)
tree265b39df0aad71d67e9e159dde2586a4088346c3
parentf7e039d3c2d62a51f619e4b4a246fd8b58862609 (diff)
downloadscummvm-rg350-ff039617bb8bfa832efbf4249c84d9e242f19568.tar.gz
scummvm-rg350-ff039617bb8bfa832efbf4249c84d9e242f19568.tar.bz2
scummvm-rg350-ff039617bb8bfa832efbf4249c84d9e242f19568.zip
TOON: formatting
-rw-r--r--engines/toon/font.cpp2
-rw-r--r--engines/toon/font.h2
-rw-r--r--engines/toon/module.mk4
-rw-r--r--engines/toon/subtitles.cpp92
-rw-r--r--engines/toon/subtitles.h29
-rw-r--r--engines/toon/toon.cpp2
-rw-r--r--engines/toon/toon.h4
7 files changed, 64 insertions, 71 deletions
diff --git a/engines/toon/font.cpp b/engines/toon/font.cpp
index 29dbf40b8b..06454ad3d6 100644
--- a/engines/toon/font.cpp
+++ b/engines/toon/font.cpp
@@ -191,7 +191,7 @@ void FontRenderer::setFontColor(int32 fontColor1, int32 fontColor2, int32 fontCo
_currentFontColor[3] = fontColor3;
}
-void FontRenderer::renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode, Graphics::Surface& frame) {
+void FontRenderer::renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode, Graphics::Surface &frame) {
debugC(5, kDebugFont, "renderMultiLineText(%d, %d, %s, %d)", x, y, origText.c_str(), mode);
// divide the text in several lines
diff --git a/engines/toon/font.h b/engines/toon/font.h
index 48d4b8531d..e6cf916fe3 100644
--- a/engines/toon/font.h
+++ b/engines/toon/font.h
@@ -35,7 +35,7 @@ public:
void setFont(Animation *font);
void computeSize(const Common::String &origText, int16 *retX, int16 *retY);
void renderText(int16 x, int16 y, const Common::String &origText, int32 mode);
- void renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode, Graphics::Surface& frame);
+ void renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode, Graphics::Surface &frame);
void setFontColorByCharacter(int32 characterId);
void setFontColor(int32 fontColor1, int32 fontColor2, int32 fontColor3);
protected:
diff --git a/engines/toon/module.mk b/engines/toon/module.mk
index 411b8e7ddf..6387e62f46 100644
--- a/engines/toon/module.mk
+++ b/engines/toon/module.mk
@@ -18,10 +18,10 @@ MODULE_OBJS := \
script.o \
script_func.o \
state.o \
+ subtitles.o \
text.o \
tools.o \
- toon.o \
- subtitles.o
+ toon.o
# This module can be built as a plugin
ifeq ($(ENABLE_TOON), DYNAMIC_PLUGIN)
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
+}
diff --git a/engines/toon/subtitles.h b/engines/toon/subtitles.h
index 7eb7fe12f0..14c7c35658 100644
--- a/engines/toon/subtitles.h
+++ b/engines/toon/subtitles.h
@@ -29,9 +29,9 @@
namespace Toon {
typedef struct {
- uint32 fstart;
- uint32 fend;
- uint32 foffset;
+ uint32 fstart;
+ uint32 fend;
+ uint32 foffset;
} TimeWindow;
class SubtitleRenderer {
@@ -39,21 +39,20 @@ public:
SubtitleRenderer(ToonEngine *vm);
~SubtitleRenderer();
- bool load(const Common::String &video);
- void render(const Graphics::Surface& frame, uint32 frameNumber, char color);
+ bool load(const Common::String &video);
+ void render(const Graphics::Surface &frame, uint32 frameNumber, byte color);
protected:
ToonEngine *_vm;
- Graphics::Surface* _subSurface;
- bool _hasSubtitles;
-
- char* _lines[384];
- TimeWindow _tw[384];
- uint8 *_fileData;
- uint16 _index;
- uint16 _last;
- char* _currentLine;
+ Graphics::Surface *_subSurface;
+ bool _hasSubtitles;
+ char *_lines[384];
+ TimeWindow _tw[384];
+ uint8 *_fileData;
+ uint16 _index;
+ uint16 _last;
+ char *_currentLine;
};
} // End of namespace Toon
-#endif \ No newline at end of file
+#endif
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 4d2578ee59..518110b0ea 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -3294,7 +3294,7 @@ void ToonEngine::drawConversationLine() {
}
}
-void ToonEngine::drawCustomText(int16 x, int16 y, char* line, Graphics::Surface* frame, char color) {
+void ToonEngine::drawCustomText(int16 x, int16 y, char *line, Graphics::Surface *frame, char color) {
if (line) {
byte col = color; // 0xce
_fontRenderer->setFontColor(0, col, col);
diff --git a/engines/toon/toon.h b/engines/toon/toon.h
index cbabaff129..cfb12a7716 100644
--- a/engines/toon/toon.h
+++ b/engines/toon/toon.h
@@ -212,9 +212,7 @@ public:
void playRoomMusic();
void waitForScriptStep();
void doMagnifierEffect();
-
- void drawCustomText(int16 x, int16 y, char* line, Graphics::Surface* frame, char color);
-
+ void drawCustomText(int16 x, int16 y, char *line, Graphics::Surface *frame, char color);
bool canSaveGameStateCurrently();
bool canLoadGameStateCurrently();
void pauseEngineIntern(bool pause);