From b6eb8a1a6697ba068590e50164cb5e4f37a1c1df Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sun, 30 Apr 2017 00:56:52 +0200 Subject: DIRECTOR: consolidate font, width instructions in renderText --- engines/director/frame.cpp | 62 ++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'engines/director') diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 49c755ce23..8911a60728 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -742,6 +742,38 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo 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 && textSize != NULL) + width = textCast->initialRect.right; + else + width = textCast->initialRect.width(); //_sprites[spriteId]->_width; + + if (width == 0 || height == 0) { + warning("renderText: Requested to draw on an empty surface: %d x %d", width, height); + return; + } + + if (_vm->getVersion() >= 4) { + if (textSize == NULL) + width = textCast->initialRect.right; + else { + width = textSize->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]); + } + + 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)); uint32 unk1 = textStream->readUint32(); uint32 strLen = textStream->readUint32(); @@ -827,28 +859,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo //uint32 rectLeft = textCast->initialRect.left; //uint32 rectTop = textCast->initialRect.top; - int x = _sprites[spriteId]->_startPoint.x; // +rectLeft; - int y = _sprites[spriteId]->_startPoint.y; // +rectTop; - int height = textCast->initialRect.height(); //_sprites[spriteId]->_height; - int width = textCast->initialRect.width(); //_sprites[spriteId]->_width; - - if (_vm->getVersion() >= 4 && textSize != NULL) - width = textCast->initialRect.right; - - 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)); int alignment = (int)textCast->textAlign; if (alignment == -1) @@ -856,14 +866,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo else alignment++; - if (_vm->getVersion() >= 4) { - if (textSize == NULL) - width = textCast->initialRect.right; - else { - width = textSize->width(); - } - } - Graphics::MacText mt(ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment); mt.setInterLinear(1); mt.render(); -- cgit v1.2.3