aboutsummaryrefslogtreecommitdiff
path: root/engines/wage
diff options
context:
space:
mode:
authorEugene Sandulenko2016-02-08 18:26:16 +0100
committerEugene Sandulenko2016-02-14 17:13:03 +0100
commitab20b96f604f6819dfe6f03286a01bb899fde291 (patch)
treeea3ae21ebf05671c5407bde37b69b2b374b91d29 /engines/wage
parent5e002c4fe2e1019e2d4f33b335d41eabb41ed63f (diff)
downloadscummvm-rg350-ab20b96f604f6819dfe6f03286a01bb899fde291.tar.gz
scummvm-rg350-ab20b96f604f6819dfe6f03286a01bb899fde291.tar.bz2
scummvm-rg350-ab20b96f604f6819dfe6f03286a01bb899fde291.zip
WAGE: Improve text entry
Diffstat (limited to 'engines/wage')
-rw-r--r--engines/wage/gui.cpp41
-rw-r--r--engines/wage/gui.h2
-rw-r--r--engines/wage/wage.cpp8
3 files changed, 31 insertions, 20 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index d158d480f8..d7e1233c8a 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -159,6 +159,8 @@ Gui::Gui(WageEngine *engine) {
_selectionStartX = _selectionStartY = -1;
_selectionEndX = _selectionEndY = -1;
+ _inputTextLineNum = 0;
+
g_system->getPaletteManager()->setPalette(palette, 0, 4);
CursorMan.replaceCursorPalette(palette, 0, 4);
@@ -432,14 +434,14 @@ void Gui::flowText(Common::String &str) {
_lines.push_back(*j);
uint pos = _scrollPos;
- _scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
+ _scrollPos = MAX<int>(0, (_lines.size() - 1 - _consoleNumLines) * _consoleLineHeight);
_cursorX = kConWPadding;
if (_scrollPos)
_cursorY = (_consoleNumLines) * _consoleLineHeight + kConHPadding;
else
- _cursorY = (_lines.size()) * _consoleLineHeight + kConHPadding;
+ _cursorY = (_lines.size() - 1) * _consoleLineHeight + kConHPadding;
if (pos != _scrollPos)
_consoleFullRedraw = true;
@@ -576,28 +578,33 @@ void Gui::drawInput() {
_bordersDirty = true;
}
- const Graphics::Font *font = getConsoleFont();
+ _lines.pop_back();
+ appendText(_engine->_inputText.c_str());
+ _inputTextLineNum = _lines.size() - 1;
- int x = kConWPadding + _consoleTextArea.left;
- int y = _cursorY + _consoleTextArea.top;
- Common::String text(_engine->_inputText);
- int textW = font->getStringWidth(text);
+ const Graphics::Font *font = getConsoleFont();
- // undraw cursor
- _cursorOff = true;
- _cursorState = false;
- cursorTimerHandler(this);
- _cursorOff = false;
+ if (_engine->_inputText.contains('\n')) {
+ _consoleDirty = true;
+ } else {
+ int x = kConWPadding + _consoleTextArea.left;
+ int y = _cursorY + _consoleTextArea.top;
- Common::Rect r(x, y, x + textW + 10, y + font->getFontHeight());
+ Common::Rect r(x, y, x + _consoleTextArea.width(), y + font->getFontHeight());
+ _screen.fillRect(r, kColorWhite);
- _screen.fillRect(r, kColorWhite);
+ // undraw cursor
+ _cursorOff = true;
+ _cursorState = false;
+ cursorTimerHandler(this);
+ _cursorOff = false;
- font->drawString(&_screen, text, x, y, _screen.w, kColorBlack);
+ font->drawString(&_screen, _lines[_inputTextLineNum], x, y, _screen.w, kColorBlack);
- g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, textW + 10, font->getFontHeight());
+ g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, _consoleTextArea.width(), font->getFontHeight());
+ }
- _cursorX = font->getStringWidth(_engine->_inputText) + kConHPadding;
+ _cursorX = font->getStringWidth(_lines[_inputTextLineNum]) + kConHPadding;
}
void Gui::loadFonts() {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 6d33abb948..2353a59795 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -162,6 +162,8 @@ private:
Common::String _clipboard;
Common::String _undobuffer;
+
+ int _inputTextLineNum;
};
} // End of namespace Wage
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index c1d70331ff..1c9a9828aa 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -209,10 +209,12 @@ void WageEngine::setMenu(Common::String menu) {
}
void WageEngine::appendText(const char *str) {
- if (_inputText.size())
- _gui->appendText(_inputText.c_str());
+ if (_inputText.size()) {
+ _inputText += '\n';
+ _gui->drawInput();
- _inputText = "";
+ _inputText = "";
+ }
_gui->appendText(str);
}