Skip to content

Commit

Permalink
XEEN: Fix animated text cursor partialy overlapping prior char
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Dec 25, 2017
1 parent ee1da05 commit 6b5eab6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 2 additions & 5 deletions engines/xeen/dialogs_input.cpp
Expand Up @@ -120,14 +120,11 @@ Common::KeyCode Input::waitForKey(const Common::String &msg) {
void Input::animateCursor() {
// Iterate through each frame
_cursorAnimIndex = _cursorAnimIndex ? _cursorAnimIndex - 1 : 5;
static const int CURSOR_ANIMATION_IDS[] = { 32, 124, 126, 127, 126, 124 };
static const char 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 = _window->_writePos;
_window->writeString(cursorStr);
_window->writeCharacter(CURSOR_ANIMATION_IDS[_cursorAnimIndex]);
_window->_writePos = writePos;
}

Expand Down
7 changes: 7 additions & 0 deletions engines/xeen/font.cpp
Expand Up @@ -247,6 +247,13 @@ const char *FontSurface::writeString(const Common::String &s, const Common::Rect
return _displayString;
}

void FontSurface::writeCharacter(char c, const Common::Rect &clipRect) {
Justify justify = _fontJustify;
_fontJustify = JUSTIFY_NONE;
writeString(Common::String::format("%c", c), clipRect);
_fontJustify = justify;
}

char FontSurface::getNextChar() {
return *_displayString++ & 0x7f;
}
Expand Down
7 changes: 7 additions & 0 deletions engines/xeen/font.h
Expand Up @@ -96,6 +96,13 @@ class FontSurface: public XSurface, public FontData {
* justification is set, the message will be written at _writePos
*/
const char *writeString(const Common::String &s, const Common::Rect &clipRect);

/**
* Write a charcter to the window
* @param c Character
* @param clipRect Window bounds to display string within
*/
void writeCharacter(char c, const Common::Rect &clipRect);
};

} // End of namespace Xeen
Expand Down
8 changes: 8 additions & 0 deletions engines/xeen/window.h
Expand Up @@ -148,6 +148,14 @@ class Window: public FontSurface {
const char *writeString(const Common::String &s) {
return FontSurface::writeString(s, _innerBounds);
}

/**
* Write a charcter to the window
* @param c Character
*/
void writeCharacter(char c) {
FontSurface::writeCharacter(c, _innerBounds);
}
};

} // End of namespace Xeen
Expand Down

0 comments on commit 6b5eab6

Please sign in to comment.