aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorVelocityRa2017-03-31 01:02:01 +0200
committerEugene Sandulenko2017-07-17 23:45:22 +0200
commitb28a4a8c3d4175d90b444cbc0a51508f6f8cc753 (patch)
treec75bce02c11b2048949f7cfd7295133f9c142e3a /graphics
parenta2792531f6f775ec7c99359bf1610f6bf0eea1fd (diff)
downloadscummvm-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
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/mactext.cpp23
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) {