diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index baf9445b390d..2f36270cc523 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 1a82c8f71319..cd918f7bd311 100644 --- a/engines/wage/gui.h +++ b/engines/wage/gui.h @@ -71,6 +71,7 @@ class Gui { 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 @@ class Gui { 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 e8658101eff4..e3addd102059 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 0c6f2e03c89a..91d940470bd7 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -132,7 +132,6 @@ class WageEngine : public Engine { World *_world; Scene *_lastScene; - //PrintStream out; int _loopCount; int _turn; Chr *_monster; @@ -142,6 +141,8 @@ class WageEngine : public Engine { bool _temporarilyHidden; bool _isGameOver; + Common::String _inputText; + void playSound(String soundName); void setMenu(String soundName); void appendText(String &str);