aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEugene Sandulenko2017-08-02 21:46:25 +0200
committerEugene Sandulenko2017-08-04 21:54:19 +0200
commit4e044d7bd3272e95a95feefb407bb2b1ffba23c8 (patch)
tree6a8f1f663186fbb770a80f0e5119414c1e07cffc /graphics
parent59d6b63b0f63949717e9621578b97c58c1d09ce6 (diff)
downloadscummvm-rg350-4e044d7bd3272e95a95feefb407bb2b1ffba23c8.tar.gz
scummvm-rg350-4e044d7bd3272e95a95feefb407bb2b1ffba23c8.tar.bz2
scummvm-rg350-4e044d7bd3272e95a95feefb407bb2b1ffba23c8.zip
GRAPHICS: MACGUI: Do not add input line to the original MacText content
During resize we were replaying all MacText appends, which was including whole history of the input. Eek.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/mactext.cpp16
-rw-r--r--graphics/macgui/mactext.h4
-rw-r--r--graphics/macgui/mactextwindow.cpp9
-rw-r--r--graphics/macgui/mactextwindow.h2
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);