diff options
author | sluicebox | 2019-07-07 19:18:04 -0700 |
---|---|---|
committer | Filippos Karapetis | 2019-07-09 09:51:10 +0300 |
commit | ca66a776b0444a4af5cde844a924b8f25baffb77 (patch) | |
tree | 6c4773fbeaefd85be715982ce5af7d707f2a0973 /engines/sci/graphics | |
parent | 14fe8ac3a0243fe356a604127e60c6104dd66cc4 (diff) | |
download | scummvm-rg350-ca66a776b0444a4af5cde844a924b8f25baffb77.tar.gz scummvm-rg350-ca66a776b0444a4af5cde844a924b8f25baffb77.tar.bz2 scummvm-rg350-ca66a776b0444a4af5cde844a924b8f25baffb77.zip |
SCI: Implement early GetLongest() behavior, bug #10000
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r-- | engines/sci/graphics/text16.cpp | 20 | ||||
-rw-r--r-- | engines/sci/graphics/text16.h | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index a661de63f9..cdb7c260d4 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -25,6 +25,7 @@ #include "graphics/primitives.h" #include "sci/sci.h" +#include "sci/engine/features.h" #include "sci/engine/state.h" #include "sci/graphics/cache.h" #include "sci/graphics/coordadjuster.h" @@ -50,6 +51,7 @@ void GfxText16::init() { _codeFontsCount = 0; _codeColors = NULL; _codeColorsCount = 0; + _useEarlyGetLongestTextCalculations = g_sci->_features->useEarlyGetLongestTextCalculations(); } GuiResourceId GfxText16::GetFontId() { @@ -250,6 +252,14 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId if (tempWidth > maxWidth) break; + // the previous greater than test was originally a greater than or equals when + // no space character had been reached yet + if (_useEarlyGetLongestTextCalculations) { + if (lastSpaceCharCount == 0 && tempWidth == maxWidth) { + break; + } + } + // still fits, remember width curWidth = tempWidth; @@ -273,7 +283,7 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId } else { // Break without spaces found, we split the very first word - may also be Kanji/Japanese if (curChar > 0xFF) { - // current charracter is Japanese + // current character is Japanese // PC-9801 SCI actually added the last character, which shouldn't fit anymore, still onto the // screen in case maxWidth wasn't fully reached with the last character @@ -330,6 +340,14 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId // (game mentions Mixed Up Fairy Tales and uses English letters for that) textPtr += 2; } + } else { + // Add a character to the count for games whose interpreter would count the + // character that exceeded the width if a space hadn't been reached yet. + // Fixes #10000 where the notebook in LB1 room 786 displays "INCOMPLETE" with + // a width that's too short which would have otherwise wrapped the last "E". + if (_useEarlyGetLongestTextCalculations) { + curCharCount++; textPtr++; + } } // We split the word in that case diff --git a/engines/sci/graphics/text16.h b/engines/sci/graphics/text16.h index cb3deb0c60..32d5481dcc 100644 --- a/engines/sci/graphics/text16.h +++ b/engines/sci/graphics/text16.h @@ -90,6 +90,8 @@ private: int _codeColorsCount; uint16 *_codeColors; + bool _useEarlyGetLongestTextCalculations; + Common::Rect _codeRefTempRect; CodeRefRectArray _codeRefRects; }; |