diff options
author | Paul Gilbert | 2017-11-10 15:35:33 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-11-10 15:35:33 -0500 |
commit | b73892e441bc3fde3b36f76aa675c59a652ca95c (patch) | |
tree | 507ca8f56f19744d6f89e4f50c054c229d865011 /engines/xeen | |
parent | 1b955ae6daf8d4f21677faaad85214241034acbe (diff) | |
download | scummvm-rg350-b73892e441bc3fde3b36f76aa675c59a652ca95c.tar.gz scummvm-rg350-b73892e441bc3fde3b36f76aa675c59a652ca95c.tar.bz2 scummvm-rg350-b73892e441bc3fde3b36f76aa675c59a652ca95c.zip |
XEEN: Fix event handling for town messages
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/dialogs.cpp | 5 | ||||
-rw-r--r-- | engines/xeen/town.cpp | 35 |
2 files changed, 25 insertions, 15 deletions
diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp index 3304689416..92082b4e0b 100644 --- a/engines/xeen/dialogs.cpp +++ b/engines/xeen/dialogs.cpp @@ -77,6 +77,11 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) { return true; } } + + if (Common::Rect(8, 8, 224, 135).contains(pt)) { + _buttonValue = 1; + return true; + } } else if (events.isKeyPending()) { Common::KeyState keyState; events.getKey(keyState); diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp index 097b1c3953..fb5df83303 100644 --- a/engines/xeen/town.cpp +++ b/engines/xeen/town.cpp @@ -1219,19 +1219,20 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common int result = -1; Common::String msgText = text; - for (;;) { + do { Common::String msg = Common::String::format("\r\v014\x03c\t125%s\t000\v054%s", name.c_str(), msgText.c_str()); + + // Count the number of words const char *msgEnd = w.writeString(msg.c_str()); int wordCount = 0; - const char *msgP = msg.c_str(); - do { + for (const char *msgP = msg.c_str(); msgP != msgEnd && *msgP; ++msgP) { if (*msgP == ' ') ++wordCount; - } while (msgP != msgEnd && *++msgP); + } - town._drawCtr2 = wordCount * 2; + town._drawCtr2 = wordCount * 2; // Set timeout town._townSprites[1].draw(screen, 0, Common::Point(16, 16)); town._townSprites[0].draw(screen, town._drawFrameIndex, Common::Point(23, 22)); w.update(); @@ -1258,28 +1259,31 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common clearButtons(); do { - events.wait(3); + events.pollEventsAndWait(); checkEvents(_vm); + if (_vm->shouldQuit()) return false; - town.drawTownAnim(false); - events.updateGameCounter(); + while (events.timeElapsed() >= 3) { + town.drawTownAnim(false); + events.updateGameCounter(); + } } while (!_buttonValue); if (msgEnd) + // Another screen of text remaining break; - if (!msgEnd) { - if (confirm || _buttonValue == Common::KEYCODE_ESCAPE || - _buttonValue == Common::KEYCODE_n) - result = 0; - else if (_buttonValue == Common::KEYCODE_y) - result = 1; - } + if (confirm || _buttonValue == Common::KEYCODE_ESCAPE || + _buttonValue == Common::KEYCODE_n) + result = 0; + else if (_buttonValue == Common::KEYCODE_y) + result = 1; } while (result == -1); if (msgEnd) { + // Text remaining, so cut off already displayed page's msgText = Common::String(msgEnd); town._drawCtr2 = wordCount; continue; @@ -1292,6 +1296,7 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common town._townSprites[0].clear(); town._townSprites[1].clear(); + events.clearEvents(); return result == 1; } |