diff options
author | VelocityRa | 2017-03-31 01:02:01 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-17 23:45:22 +0200 |
commit | b28a4a8c3d4175d90b444cbc0a51508f6f8cc753 (patch) | |
tree | c75bce02c11b2048949f7cfd7295133f9c142e3a | |
parent | a2792531f6f775ec7c99359bf1610f6bf0eea1fd (diff) | |
download | scummvm-rg350-b28a4a8c3d4175d90b444cbc0a51508f6f8cc753.tar.gz scummvm-rg350-b28a4a8c3d4175d90b444cbc0a51508f6f8cc753.tar.bz2 scummvm-rg350-b28a4a8c3d4175d90b444cbc0a51508f6f8cc753.zip |
GRAPHICS: Fix MacText::appendText by resizing _textLines
Also fix an off-by-one error
-rw-r--r-- | graphics/macgui/mactext.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 0f9c120758..672d1f5b6e 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -307,8 +307,8 @@ int MacText::getLineHeight(int line) { return _textLines[line].height; } -void MacText::setInterLinear(int interLinear) { - _interLinear = interLinear; +void MacText::setInterLinear(int interLinear) { + _interLinear = interLinear; recalcDims(); } @@ -339,14 +339,27 @@ void MacText::draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int } void MacText::appendText(Common::String str) { - int oldLen = _textLines.size(); + uint oldLen = _textLines.size(); + uint newLines = 1; + + // Calc newline characters in str + Common::String::iterator p = str.begin(); + while (*p) { + if (*p == '\n') + newLines++; + p++; + } - // TODO: Recalc length + // Resize _textLines appropriately + for (int curLine = 0; curLine < newLines; ++curLine) { + _textLines.resize(oldLen + newLines); + _textLines[oldLen + curLine].chunks.push_back(_currentFormatting); + } splitString(str); recalcDims(); - render(oldLen + 1, _textLines.size()); + render(oldLen, _textLines.size()); } void MacText::replaceLastLine(Common::String str) { |