aboutsummaryrefslogtreecommitdiff
path: root/engines/wage
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-04 00:09:10 +0100
committerEugene Sandulenko2016-01-04 00:09:10 +0100
commitf97c915c7b0f3ef3c34dfea78619d8c17446638b (patch)
treeec32e3b30e57d3e6ff68de2316dfa0d2d3a6d6af /engines/wage
parente95122be6cce38c63d92585adf18084fba59b156 (diff)
downloadscummvm-rg350-f97c915c7b0f3ef3c34dfea78619d8c17446638b.tar.gz
scummvm-rg350-f97c915c7b0f3ef3c34dfea78619d8c17446638b.tar.bz2
scummvm-rg350-f97c915c7b0f3ef3c34dfea78619d8c17446638b.zip
WAGE: Display text input
Diffstat (limited to 'engines/wage')
-rw-r--r--engines/wage/gui.cpp33
-rw-r--r--engines/wage/gui.h2
-rw-r--r--engines/wage/wage.cpp23
-rw-r--r--engines/wage/wage.h3
4 files changed, 59 insertions, 2 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index baf9445b39..2f36270cc5 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -133,7 +133,9 @@ static void cursor_timer_handler(void *refCon) {
y += gui->_consoleTextArea.top;
gui->_screen.vLine(x, y - kCursorHeight, y, gui->_cursorState ? kColorBlack : kColorWhite);
- gui->_cursorState = !gui->_cursorState;
+
+ if (!gui->_cursorOff)
+ gui->_cursorState = !gui->_cursorState;
g_system->copyRectToScreen(gui->_screen.getBasePtr(x, y - kCursorHeight), gui->_screen.pitch, x, y - kCursorHeight, 1, kCursorHeight);
g_system->updateScreen();
@@ -161,6 +163,7 @@ Gui::Gui(WageEngine *engine) {
_cursorX = 0;
_cursorY = 0;
_cursorState = false;
+ _cursorOff = false;
g_system->getPaletteManager()->setPalette(palette, 0, 4);
@@ -500,6 +503,34 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
g_system->copyRectToScreen(g->getBasePtr(r.left, r.top), g->pitch, r.left, r.top, r.width(), r.height());
}
+void Gui::drawInput() {
+ if (!_screen.getPixels())
+ return;
+
+ const Graphics::Font *font = getConsoleFont();
+
+ int x = kConHPadding + _consoleTextArea.left;
+ int y = _cursorY + _consoleTextArea.top;
+ Common::String text(_engine->_inputText);
+ int textW = font->getStringWidth(text);
+
+ // undraw cursor
+ _cursorOff = true;
+ _cursorState = false;
+ cursor_timer_handler(this);
+ _cursorOff = false;
+
+ Common::Rect r(x, y, x + textW + 10, y + font->getFontHeight());
+
+ _screen.fillRect(r, kColorWhite);
+
+ font->drawString(&_screen, text, x, y, _screen.w, kColorBlack);
+
+ g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, textW + 10, font->getFontHeight());
+
+ _cursorX = font->getStringWidth(_engine->_inputText) + 1;
+}
+
void Gui::loadFonts() {
Common::Archive *dat;
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 1a82c8f713..cd918f7bd3 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -71,6 +71,7 @@ public:
void clearOutput();
void mouseMove(int x, int y);
Designed *getClickTarget(int x, int y);
+ void drawInput();
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
@@ -90,6 +91,7 @@ public:
int _cursorX, _cursorY;
bool _cursorState;
Common::Rect _consoleTextArea;
+ bool _cursorOff;
private:
WageEngine *_engine;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index e8658101ef..e3addd1020 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -158,6 +158,29 @@ void WageEngine::processEvents() {
if (obj != NULL)
processTurn(NULL, obj);
}
+ break;
+ case Common::EVENT_KEYDOWN:
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_BACKSPACE:
+ if (_inputText.size()) {
+ _inputText.deleteLastChar();
+ _gui->drawInput();
+ }
+ break;
+
+ default:
+ if (event.kbd.flags)
+ break;
+
+ if (Common::isAlpha(event.kbd.ascii)) {
+ _inputText += (char)event.kbd.ascii;
+ _gui->drawInput();
+ }
+
+ break;
+ }
+ break;
+
default:
break;
}
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 0c6f2e03c8..91d940470b 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -132,7 +132,6 @@ public:
World *_world;
Scene *_lastScene;
- //PrintStream out;
int _loopCount;
int _turn;
Chr *_monster;
@@ -142,6 +141,8 @@ public:
bool _temporarilyHidden;
bool _isGameOver;
+ Common::String _inputText;
+
void playSound(String soundName);
void setMenu(String soundName);
void appendText(String &str);