diff options
author | Eugene Sandulenko | 2017-01-31 18:44:18 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2017-01-31 18:46:33 +0100 |
commit | c4f73012e5f4792aca573c89d80323973e0c8c58 (patch) | |
tree | c28950f2a593d94f2fb0234a08855966a3feb470 | |
parent | 95be2f2b2383f0f8835d1a21f6fbcf86fe5a1667 (diff) | |
download | scummvm-rg350-c4f73012e5f4792aca573c89d80323973e0c8c58.tar.gz scummvm-rg350-c4f73012e5f4792aca573c89d80323973e0c8c58.tar.bz2 scummvm-rg350-c4f73012e5f4792aca573c89d80323973e0c8c58.zip |
DIRECTOR: Generate font style runs for MacText
-rw-r--r-- | graphics/macgui/mactext.cpp | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index e9253b535b..e7abcc6d01 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -68,9 +68,7 @@ void MacText::splitString(Common::String &str) { if (_textLines.empty()) { _textLines.resize(1); - _textLines[0].resize(1); - - _textLines[0][0] = _defaultFormatting; + _textLines[0].push_back(_defaultFormatting); } int curLine = _textLines.size() - 1; @@ -99,7 +97,12 @@ void MacText::splitString(Common::String &str) { _currentFormatting.setValues(_wm, fontId, textSlant, unk3f, fontSize, palinfo1, palinfo2, palinfo3); - _textLines[curLine].push_back(_currentFormatting); + if ((_textLines[curLine])[curChunk].text.empty()) { + (_textLines[curLine])[curChunk] = _currentFormatting; + continue; + } else { + _textLines[curLine].push_back(_currentFormatting); + } nextChunk = true; } @@ -117,28 +120,36 @@ void MacText::splitString(Common::String &str) { _textMaxWidth = MAX(_font->wordWrapText(tmp, _maxWidth, text), _textMaxWidth); - _textLines[curLine][curChunk].text = text[0]; + if (text.size()) { + (_textLines[curLine])[curChunk].text = text[0]; - if (nextChunk) { - curChunk++; - nextChunk = false; + if (nextChunk) { + curChunk++; - _text[curLine] += text[0]; - } else { - _text.push_back(text[0]); + _text[curLine] += text[0]; + } else { + _text.push_back(text[0]); + } } if (text.size() > 1) { for (uint i = 1; i < text.size(); i++) { _text.push_back(text[i]); - //curLine++; + curLine++; + _textLines.resize(curLine + 1); + _textLines[curLine].push_back(_currentFormatting); + (_textLines[curLine])[0].text = text[i]; + curChunk = 0; } } tmp.clear(); - s++; + if (!nextChunk) // Don't skip next character + s++; + + nextChunk = false; continue; } @@ -146,8 +157,26 @@ void MacText::splitString(Common::String &str) { s++; } - if (tmp.size()) - _textMaxWidth = MAX(_font->wordWrapText(tmp, _maxWidth, _text), _textMaxWidth); + if (tmp.size()) { + Common::Array<Common::String> text; + + _textMaxWidth = MAX(_font->wordWrapText(tmp, _maxWidth, text), _textMaxWidth); + + (_textLines[curLine])[curChunk].text = text[0]; + + _text.push_back(text[0]); + + if (text.size() > 1) { + for (uint i = 1; i < text.size(); i++) { + _text.push_back(text[i]); + + curLine++; + _textLines.resize(curLine + 1); + _textLines[curLine].push_back(_currentFormatting); + (_textLines[curLine])[0].text = text[i]; + } + } + } } void MacText::reallocSurface() { |