From 820e6b8bd3783f78605f477a6f3f1548ffd8db98 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sat, 18 Jun 2016 21:20:52 -0500 Subject: SCI32: Fixes to GfxText32 1. Inline borderSize constant in createFontBitmap for consistency 2. Fix "DrawTextBox GetLongest=0" warning to only appear in games that actually had this check (SQ6 and MGDX) 3. "Fix" implementation of getTextSize for SCI2.1early, which gave lines with word wrap disabled a height of 0 4. Add inlining hints to some methods in BitmapResource that were missing them for some reason --- engines/sci/graphics/text32.cpp | 21 +++++++++++++-------- engines/sci/graphics/text32.h | 4 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'engines/sci/graphics') diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp index d3b5bf5396..993c5c90ca 100644 --- a/engines/sci/graphics/text32.cpp +++ b/engines/sci/graphics/text32.cpp @@ -121,7 +121,6 @@ reg_t GfxText32::createFontBitmap(const CelInfo32 &celInfo, const Common::Rect & int16 scriptWidth = g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth; int16 scriptHeight = g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight; - int borderSize = 1; mulinc(_textRect, Ratio(_scaledWidth, scriptWidth), Ratio(_scaledHeight, scriptHeight)); CelObjView view(celInfo.resourceId, celInfo.loopNo, celInfo.celNo); @@ -159,7 +158,7 @@ reg_t GfxText32::createFontBitmap(const CelInfo32 &celInfo, const Common::Rect & error("TODO: Implement transparent text"); } else { if (borderColor != -1) { - drawFrame(bitmapRect, borderSize, _borderColor, false); + drawFrame(bitmapRect, 1, _borderColor, false); } drawTextBox(); @@ -237,7 +236,8 @@ void GfxText32::drawTextBox() { int16 textRectWidth = _textRect.width(); _drawPosition.y = _textRect.top; uint charIndex = 0; - if (g_sci->getGameId() != GID_PHANTASMAGORIA) { + + if (g_sci->getGameId() == GID_SQ6 || g_sci->getGameId() == GID_MOTHERGOOSEHIRES) { if (getLongest(&charIndex, textRectWidth) == 0) { error("DrawTextBox GetLongest=0"); } @@ -591,11 +591,16 @@ Common::Rect GfxText32::getTextSize(const Common::String &text, int16 maxWidth, } } else { result.right = getTextWidth(0, 10000); - // NOTE: In the original engine code, the bottom was not decremented - // by 1, which means that the rect was actually a pixel taller than - // the height of the font. This was not the case in the other branch, - // which decremented the bottom by 1 at the end of the loop. - result.bottom = _font->getHeight() + 1; + + if (getSciVersion() < SCI_VERSION_2_1_MIDDLE) { + result.bottom = 0; + } else { + // NOTE: In the original engine code, the bottom was not decremented + // by 1, which means that the rect was actually a pixel taller than + // the height of the font. This was not the case in the other branch, + // which decremented the bottom by 1 at the end of the loop. + result.bottom = _font->getHeight() + 1; + } } if (doScaling) { diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h index 88cf149da7..9892740c42 100644 --- a/engines/sci/graphics/text32.h +++ b/engines/sci/graphics/text32.h @@ -133,7 +133,7 @@ public: setScaledHeight(scaledHeight); } - reg_t getObject() const { + inline reg_t getObject() const { return _object; } @@ -180,7 +180,7 @@ public: return READ_SCI11ENDIAN_UINT32(_bitmap + 20); } - void setHunkPaletteOffset(uint32 hunkPaletteOffset) { + inline void setHunkPaletteOffset(uint32 hunkPaletteOffset) { if (hunkPaletteOffset) { hunkPaletteOffset += getBitmapHeaderSize(); } -- cgit v1.2.3