diff options
author | Tobia Tesan | 2017-04-30 00:58:56 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-04-30 09:48:08 +0200 |
commit | 23b6dbbede9a1990e30d48d90af5017e8b7dd473 (patch) | |
tree | 08226c426725977a1f9eb199ccc40881ca5348e7 | |
parent | 03831698ac508a4cb210fb6835565782f7a49a08 (diff) | |
download | scummvm-rg350-23b6dbbede9a1990e30d48d90af5017e8b7dd473.tar.gz scummvm-rg350-23b6dbbede9a1990e30d48d90af5017e8b7dd473.tar.bz2 scummvm-rg350-23b6dbbede9a1990e30d48d90af5017e8b7dd473.zip |
DIRECTOR: clean up renderText: separate reading & actual rendering
-rw-r--r-- | engines/director/frame.cpp | 93 | ||||
-rw-r--r-- | engines/director/frame.h | 1 |
2 files changed, 51 insertions, 43 deletions
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index ec22cc1580..0caaf59ad1 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -737,41 +737,10 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, uint1 renderText(surface, spriteId, textStream, NULL); } -void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize) { - if (textStream == NULL) - return; - - TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast; - int x = _sprites[spriteId]->_startPoint.x; // +rectLeft; - int y = _sprites[spriteId]->_startPoint.y; // +rectTop; - int height = textCast->initialRect.height(); //_sprites[spriteId]->_height; - int width; - - if (_vm->getVersion() >= 4) { - if (textSize == NULL) - width = textCast->initialRect.right; - else { - width = textSize->width(); - } - } else { - width = textCast->initialRect.width(); //_sprites[spriteId]->_width; - } - - if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) { - // We need to make sure that the Shared Cast fonts have been loaded in? - // might need a mapping table here of our own. - // textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]); - } - - if (width == 0 || height == 0) { - warning("renderText: Requested to draw on an empty surface: %d x %d", width, height); - return; - } - - Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant); - - debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont)); - +Common::String Frame::readTextStream(Common::SeekableSubReadStreamEndian *textStream, TextCast *textCast) { + // TODO: move me somewhere more appropriate + // TODO: remove ugly side effects on textStream? + Common::String ftext; uint32 unk1 = textStream->readUint32(); uint32 strLen = textStream->readUint32(); uint32 dataLen = textStream->readUint32(); @@ -785,8 +754,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo text += ch; } - Common::String ftext; - debugC(3, kDebugText, "renderText: unk1: %d strLen: %d dataLen: %d textlen: %u", unk1, strLen, dataLen, text.size()); if (strLen < 200) debugC(3, kDebugText, "text: '%s'", text.c_str()); @@ -832,12 +799,12 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo debugCN(4, kDebugText, "*"); ftext += Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c%c", - (textCast->fontId >> 8) & 0xff, textCast->fontId & 0xff, - textCast->textSlant & 0xff, unk3f & 0xff, - (textCast->fontSize >> 8) & 0xff, textCast->fontSize & 0xff, - (textCast->palinfo1 >> 8) & 0xff, textCast->palinfo1 & 0xff, - (textCast->palinfo2 >> 8) & 0xff, textCast->palinfo2 & 0xff, - (textCast->palinfo3 >> 8) & 0xff, textCast->palinfo3 & 0xff); + (textCast->fontId >> 8) & 0xff, textCast->fontId & 0xff, + textCast->textSlant & 0xff, unk3f & 0xff, + (textCast->fontSize >> 8) & 0xff, textCast->fontSize & 0xff, + (textCast->palinfo1 >> 8) & 0xff, textCast->palinfo1 & 0xff, + (textCast->palinfo2 >> 8) & 0xff, textCast->palinfo2 & 0xff, + (textCast->palinfo3 >> 8) & 0xff, textCast->palinfo3 & 0xff); formattingCount--; } @@ -846,6 +813,46 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo debugC(4, kDebugText, "%s", text.c_str()); + return ftext; +} + +void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize) { + if (textStream == NULL) + return; + + TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast; + int x = _sprites[spriteId]->_startPoint.x; // +rectLeft; + int y = _sprites[spriteId]->_startPoint.y; // +rectTop; + int height = textCast->initialRect.height(); //_sprites[spriteId]->_height; + int width; + + if (_vm->getVersion() >= 4) { + if (textSize == NULL) + width = textCast->initialRect.right; + else { + width = textSize->width(); + } + } else { + width = textCast->initialRect.width(); //_sprites[spriteId]->_width; + } + + if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) { + // We need to make sure that the Shared Cast fonts have been loaded in? + // might need a mapping table here of our own. + // textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]); + } + + if (width == 0 || height == 0) { + warning("renderText: Requested to draw on an empty surface: %d x %d", width, height); + return; + } + + Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant); + + debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont)); + + Common::String ftext = readTextStream(textStream, textCast); + uint16 boxShadow = (uint16)textCast->boxShadow; uint16 borderSize = (uint16)textCast->borderSize; if (textSize != NULL) diff --git a/engines/director/frame.h b/engines/director/frame.h index e2a4a1f37b..6b0c5803c5 100644 --- a/engines/director/frame.h +++ b/engines/director/frame.h @@ -135,6 +135,7 @@ private: void readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size); void readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size); Image::ImageDecoder *getImageFrom(uint16 spriteId); + Common::String readTextStream(Common::SeekableSubReadStreamEndian *textStream, TextCast *textCast); void drawBackgndTransSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); void drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); void drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); |