diff options
-rw-r--r-- | graphics/macgui/mactext.cpp | 16 | ||||
-rw-r--r-- | graphics/macgui/mactext.h | 4 | ||||
-rw-r--r-- | graphics/macgui/mactextwindow.cpp | 9 | ||||
-rw-r--r-- | graphics/macgui/mactextwindow.h | 2 |
4 files changed, 19 insertions, 12 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 925f21beac..7fd129f968 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -378,15 +378,17 @@ uint getNewlinesInString(const Common::String &str) { return newLines; } -void MacText::appendText(Common::String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular) { +void MacText::appendText(Common::String str, int fontId, int fontSize, int fontSlant, bool skipAdd) { uint oldLen = _textLines.size(); MacFontRun fontRun = MacFontRun(_wm, fontId, fontSlant, fontSize, 0, 0, 0); _currentFormatting = fontRun; - _str += fontRun.toString(); - _str += str; + if (!skipAdd) { + _str += fontRun.toString(); + _str += str; + } splitString(str); recalcDims(); @@ -394,13 +396,15 @@ void MacText::appendText(Common::String str, int fontId = kMacFontChicago, int f render(oldLen - 1, _textLines.size()); } -void MacText::appendTextDefault(Common::String str) { +void MacText::appendTextDefault(Common::String str, bool skipAdd) { uint oldLen = _textLines.size(); _currentFormatting = _defaultFormatting; - _str += _defaultFormatting.toString(); - _str += str; + if (!skipAdd) { + _str += _defaultFormatting.toString(); + _str += str; + } splitString(str); recalcDims(); diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index 98bfd64e57..d93ad13049 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -102,8 +102,8 @@ public: } void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff); - void appendText(Common::String str, int fontId, int fontSize, int fontSlant); - void appendTextDefault(Common::String str); + void appendText(Common::String str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false); + void appendTextDefault(Common::String str, bool skipAdd = false); void clearText(); void replaceLastLine(Common::String str); void removeLastLine(); diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp index 3a90908b5c..7b1c1e59c4 100644 --- a/graphics/macgui/mactextwindow.cpp +++ b/graphics/macgui/mactextwindow.cpp @@ -78,8 +78,8 @@ void MacTextWindow::resize(int w, int h) { MacWindow::resize(w, h); } -void MacTextWindow::appendText(Common::String str, const MacFont *macFont) { - _mactext->appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant()); +void MacTextWindow::appendText(Common::String str, const MacFont *macFont, bool skipAdd) { + _mactext->appendText(str, macFont->getId(), macFont->getSize(), macFont->getSlant(), skipAdd); _contentIsDirty = true; @@ -188,6 +188,9 @@ void MacTextWindow::undrawInput() { for (uint i = 0; i < _inputTextHeight; i++) _mactext->removeLastLine(); + if (_inputTextHeight) + appendText("\n", _font, true); + _inputTextHeight = 0; } @@ -201,7 +204,7 @@ void MacTextWindow::drawInput() { _inputTextHeight = MAX(1u, text.size()); // We always have line to clean // And add new input line to the text - appendText(_inputText, _font); + appendText(_inputText, _font, true); _cursorX = _inputText.empty() ? 0 : _fontRef->getStringWidth(text[_inputTextHeight - 1]); diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h index d52e969022..a005ad93e8 100644 --- a/graphics/macgui/mactextwindow.h +++ b/graphics/macgui/mactextwindow.h @@ -65,7 +65,7 @@ public: void setTextWindowFont(const MacFont *macFont); const MacFont *getTextWindowFont(); - void appendText(Common::String str, const MacFont *macFont); + void appendText(Common::String str, const MacFont *macFont, bool skipAdd = false); void clearText(); void setSelection(int selStartX, int selStartY, int selEndX, int selEndY); |