aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
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
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')
-rw-r--r--engines/xeen/dialogs_input.cpp22
-rw-r--r--engines/xeen/dialogs_input.h13
2 files changed, 30 insertions, 5 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]) {
diff --git a/engines/xeen/dialogs_input.h b/engines/xeen/dialogs_input.h
index 26fdb47f4b..c6b0e69423 100644
--- a/engines/xeen/dialogs_input.h
+++ b/engines/xeen/dialogs_input.h
@@ -32,18 +32,25 @@ namespace Xeen {
class Input : public ButtonContainer {
private:
/**
- * Draws the cursor and waits until the user presses a key
+ * Draws the text input and cursor and waits until the user presses a key
*/
- Common::KeyCode doCursor(const Common::String &msg);
+ Common::KeyCode waitForKey(const Common::String &msg);
+
+ /**
+ * Animates the box text cursor
+ */
+ void animateCursor();
protected:
Window *_window;
+ int _cursorAnimIndex;
/**
* Allows the user to enter a string
*/
int getString(Common::String &line, uint maxLen, int maxWidth, bool isNumeric);
- Input(XeenEngine *vm, Window *window) : ButtonContainer(vm), _window(window) {}
+ Input(XeenEngine *vm, Window *window) : ButtonContainer(vm),
+ _window(window), _cursorAnimIndex(0) {}
public:
static int show(XeenEngine *vm, Window *window, Common::String &line,
uint maxLen, int maxWidth, bool isNumeric = false);