mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-10 12:55:24 +00:00
DIRECTOR: Better handling of empty STXT resources
This commit is contained in:
parent
5d2d393c4b
commit
77582aa823
@ -68,6 +68,8 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
|
||||
|
||||
debugC(3, kDebugText, "Stxt init: formattingCount: %u", formattingCount);
|
||||
|
||||
uint16 totalFormatting = formattingCount;
|
||||
|
||||
Common::U32String logText;
|
||||
|
||||
while (formattingCount) {
|
||||
@ -94,13 +96,16 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
|
||||
_ftext += u32TextPart;
|
||||
logText += Common::toPrintable(u32TextPart);
|
||||
|
||||
// Do not add formatting of empty blocks
|
||||
if (textPart.size()) {
|
||||
Common::String format = Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _style.fontId, _style.textSlant, _style.fontSize, _style.r, _style.g, _style.b);
|
||||
_ftext += format;
|
||||
logText += Common::toPrintable(format);
|
||||
// Reset formatting if the text is completely empty
|
||||
if (totalFormatting == 1 && textPart.empty()) {
|
||||
_style = FontStyle();
|
||||
debugC(4, kDebugText, "Stxt init: the font formatting was reset due to empty string");
|
||||
}
|
||||
|
||||
Common::String format = Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _style.fontId, _style.textSlant, _style.fontSize, _style.r, _style.g, _style.b);
|
||||
_ftext += format;
|
||||
logText += Common::toPrintable(format);
|
||||
|
||||
formattingCount--;
|
||||
}
|
||||
|
||||
@ -111,12 +116,6 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
|
||||
_ftext += u32Text;
|
||||
logText += Common::toPrintable(u32Text);
|
||||
|
||||
// Reset style if there is no text
|
||||
if (_ftext.empty()) {
|
||||
debugC(4, kDebugText, "Stxt init: the font formatting was reset due to empty string");
|
||||
_style = FontStyle();
|
||||
}
|
||||
|
||||
debugC(4, kDebugText, "#### text:\n%s\n####", logText.encode(Common::kUtf8).c_str());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user