aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/dialogs_input.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2017-11-25 20:54:25 -0500
committerPaul Gilbert2017-11-25 20:54:25 -0500
commit1425096dd7a7098a3a7517d1e6f893785ed7f1e3 (patch)
treec0a07264310fc2c5ffcb15e7ca4ebefdf14ff1e3 /engines/xeen/dialogs_input.cpp
parent8a8e16698befd7ec70a67d54f680163dceb2aaad (diff)
downloadscummvm-rg350-1425096dd7a7098a3a7517d1e6f893785ed7f1e3.tar.gz
scummvm-rg350-1425096dd7a7098a3a7517d1e6f893785ed7f1e3.tar.bz2
scummvm-rg350-1425096dd7a7098a3a7517d1e6f893785ed7f1e3.zip
XEEN: Add animated cursor for text input
Diffstat (limited to 'engines/xeen/dialogs_input.cpp')
-rw-r--r--engines/xeen/dialogs_input.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/engines/xeen/dialogs_input.cpp b/engines/xeen/dialogs_input.cpp
index f66bd242f5..6ffec501a1 100644
--- a/engines/xeen/dialogs_input.cpp
+++ b/engines/xeen/dialogs_input.cpp
@@ -42,7 +42,7 @@ int Input::getString(Common::String &line, uint maxLen, int maxWidth, bool isNum
_window->update();
while (!_vm->shouldQuit()) {
- Common::KeyCode keyCode = doCursor(msg);
+ Common::KeyCode keyCode = waitForKey(msg);
bool refresh = false;
if ((keyCode == Common::KEYCODE_BACKSPACE || keyCode == Common::KEYCODE_DELETE)
@@ -72,7 +72,7 @@ int Input::getString(Common::String &line, uint maxLen, int maxWidth, bool isNum
return line.size();
}
-Common::KeyCode Input::doCursor(const Common::String &msg) {
+Common::KeyCode Input::waitForKey(const Common::String &msg) {
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Screen &screen = *_vm->_screen;
@@ -92,12 +92,14 @@ Common::KeyCode Input::doCursor(const Common::String &msg) {
if (flag)
intf.draw3d(false);
_window->writeString(msg);
+ animateCursor();
_window->update();
if (flag)
screen._windows[3].update();
events.wait(1);
+
if (events.isKeyPending()) {
Common::KeyState keyState;
events.getKey(keyState);
@@ -115,6 +117,22 @@ Common::KeyCode Input::doCursor(const Common::String &msg) {
return ch;
}
+void Input::animateCursor() {
+ Screen &screen = *_vm->_screen;
+
+ // Iterate through each frame
+ _cursorAnimIndex = _cursorAnimIndex ? _cursorAnimIndex - 1 : 5;
+ static const int CURSOR_ANIMATION_IDS[] = { 32, 124, 126, 127, 126, 124 };
+
+ // Form a string for the cursor and write it out
+ Common::String cursorStr = Common::String::format("%c",
+ CURSOR_ANIMATION_IDS[_cursorAnimIndex]);
+
+ Common::Point writePos = screen._writePos;
+ _window->writeString(cursorStr);
+ screen._writePos = writePos;
+}
+
/*------------------------------------------------------------------------*/
StringInput::StringInput(XeenEngine *vm): Input(vm, &vm->_screen->_windows[6]) {