diff options
author | stevenhoefel | 2017-01-17 22:16:27 +1100 |
---|---|---|
committer | stevenhoefel | 2017-01-17 22:16:27 +1100 |
commit | d391932ac4cc231723b935a295c8f176cd089bac (patch) | |
tree | 20bade33433bcf926f42089b3e3aa0f051a0281d | |
parent | 837b3b22e59cdda0d82e53bb58206162e595d9bc (diff) | |
download | scummvm-rg350-d391932ac4cc231723b935a295c8f176cd089bac.tar.gz scummvm-rg350-d391932ac4cc231723b935a295c8f176cd089bac.tar.bz2 scummvm-rg350-d391932ac4cc231723b935a295c8f176cd089bac.zip |
DIRECTOR: Refactor Text Rendering. Use alignment of MacText. Render to temporary surface to allow ink blitting.
-rw-r--r-- | engines/director/frame.cpp | 92 | ||||
-rw-r--r-- | engines/director/frame.h | 2 | ||||
-rw-r--r-- | engines/director/score.cpp | 4 |
3 files changed, 45 insertions, 53 deletions
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 9b8f25f4fa..265f3eff96 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -875,8 +875,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo const Graphics::Font *font = _vm->_wm->_fontMan->getFont(macFont); - height = font->getFontHeight(); - 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; @@ -885,7 +883,15 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo else alignment++; - uint16 textX = x, textY = y; + Graphics::MacText mt(text, font, 0x00, 0xff, width, (Graphics::TextAlign)alignment); + mt.setInterLinear(1); + mt.render(); + const Graphics::ManagedSurface *textSurface = mt.getSurface(); + + height = textSurface->h; + + uint16 textX = 0, textY = 0; + if (!isButtonLabel) { if (borderSize > 0) { if (_vm->getVersion() <= 3) @@ -895,71 +901,55 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo textX += (borderSize + 1); textY += borderSize; - } else - textX += 1; + } else { + x += 1; + } if (padding > 0) { width += padding * 2; height += padding; - - if (textCast->textAlign == kTextAlignLeft) - textX += padding; - else if (textCast->textAlign == kTextAlignRight) - textX -= padding; - //TODO: alignment issue with odd-size-width center-aligned text - //else if (textCast->textAlign == kTextAlignCenter && ((borderSize + padding) % 2 == 1)) - // textX--; - textY += padding / 2; } - if (textCast->textAlign == kTextAlignRight) textX -= 1; + if (textCast->textAlign == kTextAlignRight) + textX -= 1; - if (textShadow > 0) { - if (borderSize == 0 && _vm->getVersion() > 3) - textX += 1; - if (_vm->getVersion() > 3) - height -= (textShadow - 1); - } + if (textShadow > 0) + textX--; } else { - textY += 2; + y += 2; } - Graphics::MacText mt(text, font, 0x00, 0xff, width); - mt.render(); - Graphics::ManagedSurface *textSurface = mt.getSurface(); - - if (isButtonLabel) { - uint16 borderX = x + borderSize - 1, borderY = y + borderSize - 1, borderHeight = height, borderWidth = width; - if (borderSize != kSizeNone) { - while (borderSize) { - borderWidth += 2; - borderHeight += 2; - textSurface->frameRect(Common::Rect(borderX, borderY, borderX + borderWidth, borderY + borderHeight), 0); - borderSize--; - borderX--; - borderY--; - } - } + switch (textCast->textAlign) { + case kTextAlignCenter: + textX = (width / 2) - (textSurface->w / 2) + (padding / 2) + borderSize; + break; + case kTextAlignRight: + textX = width - (textSurface->w + 1) + (borderSize * 2) - (textShadow * 2) - (padding); + break; + } - if (boxShadow > 0) { - borderSize = (uint16)textCast->borderSize; - uint baseOffsetX = x + boxShadow; - uint baseOffsetY = y + height + (borderSize * 2); - uint sideOffsetX = x + borderWidth; - uint sideOffsetY = y + boxShadow; - while (boxShadow) { - textSurface->drawLine(baseOffsetX, baseOffsetY + (boxShadow - 1), baseOffsetX + borderWidth - 1, baseOffsetY + (boxShadow - 1), 0); - textSurface->drawLine(sideOffsetX + (boxShadow - 1), sideOffsetY, sideOffsetX + (boxShadow - 1), sideOffsetY + borderHeight - 1, 0); - boxShadow--; - } + Graphics::ManagedSurface textWithFeatures(width + (borderSize * 2) + boxShadow + textShadow, height + borderSize + boxShadow + textShadow); + textWithFeatures.fillRect(Common::Rect(textWithFeatures.w, textWithFeatures.h), 0xff); + + if (!isButtonLabel && boxShadow > 0) { + textWithFeatures.fillRect(Common::Rect(boxShadow, boxShadow, textWithFeatures.w + boxShadow, textWithFeatures.h), 0); + } + + if (!isButtonLabel && borderSize != kSizeNone) { + for (int bb = 0; bb < borderSize; bb++) { + Common::Rect borderRect(bb, bb, textWithFeatures.w - bb - boxShadow - textShadow, textWithFeatures.h - bb - boxShadow - textShadow); + textWithFeatures.fillRect(borderRect, 0xff); + textWithFeatures.frameRect(borderRect, 0); } } if (textShadow > 0) - inkBasedBlit(surface, *textSurface, spriteId, Common::Rect(textX + textShadow, textY + textShadow, textX + textShadow + width, textY + textShadow + height)); + textWithFeatures.transBlitFrom(textSurface->rawSurface(), Common::Point(textX + textShadow, textY + textShadow), 0xff); - inkBasedBlit(surface, *textSurface, spriteId, Common::Rect(textX, textY, textX + width, textY + height)); + textWithFeatures.transBlitFrom(textSurface->rawSurface(), Common::Point(textX, textY), 0xff); + + inkBasedBlit(surface, textWithFeatures, spriteId, Common::Rect(x, y, x + width, y + height)); } void Frame::drawBackgndTransSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect) { diff --git a/engines/director/frame.h b/engines/director/frame.h index b41ee832ae..f822a83fdb 100644 --- a/engines/director/frame.h +++ b/engines/director/frame.h @@ -33,7 +33,7 @@ namespace Director { class Sprite; -#define CHANNEL_COUNT 24 +#define CHANNEL_COUNT 30 enum { kChannelDataSize = (25 * 50) diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 18cfd534c7..e5e137c881 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -406,7 +406,9 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id, if (stream.size() == 0) return; - if (stream.size() < 26) { + //TODO: Determine if there really is a minimum size. + //This value was too small for Shape Casts. + if (stream.size() < 10) { warning("CAST data id %d is too small", id); return; } |