mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 01:38:36 +00:00
TOON: formatting
This commit is contained in:
parent
f7e039d3c2
commit
ff039617bb
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
_currentLine = (char *)_fileData + _tw[0].foffset;
|
||||
_hasSubtitles = true;
|
||||
return _hasSubtitles;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
#endif
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user