From cb568dbbbe6ff335bbc884192a553751da5f16fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Aug 2015 08:35:27 -0400 Subject: SHERLOCK: RT: Fix using Escape in darts minigame --- engines/sherlock/tattoo/tattoo_darts.cpp | 21 +++++++++++++++------ engines/sherlock/tattoo/tattoo_darts.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/engines/sherlock/tattoo/tattoo_darts.cpp b/engines/sherlock/tattoo/tattoo_darts.cpp index e2fa4f6de8..806b3ff32c 100644 --- a/engines/sherlock/tattoo/tattoo_darts.cpp +++ b/engines/sherlock/tattoo/tattoo_darts.cpp @@ -68,6 +68,7 @@ Darts::Darts(SherlockEngine *vm) : _vm(vm) { _oldDartButtons = false; _handX = 0; _compPlay = 1; + _escapePressed = false; } void Darts::playDarts(GameType gameType) { @@ -208,12 +209,9 @@ void Darts::playDarts(GameType gameType) { events.clearEvents(); if ((playerNum == 0 && _compPlay == 1) || _compPlay == 0 || done) { - if (events.kbHit()) { - Common::KeyState keyState = events.getKey(); - if (keyState.keycode == Common::KEYCODE_ESCAPE) { - done = true; - idx = 10; - } + if (_escapePressed) { + done = true; + idx = 10; } } else { events.wait(20); @@ -245,6 +243,7 @@ void Darts::playDarts(GameType gameType) { void Darts::initDarts() { _dartInfo = Common::Rect(430, 245, 430 + 205, 245 + 150); + _escapePressed = false; if (_gameType == GAME_CRICKET) { _dartInfo = Common::Rect(430, 245, 430 + 205, 245 + 150); @@ -406,6 +405,9 @@ bool Darts::dartHit() { // Keyboard check if (events.kbHit()) { + if (events.getKey().keycode == Common::KEYCODE_ESCAPE) + _escapePressed = true; + events.clearEvents(); return true; } @@ -889,6 +891,8 @@ int Darts::throwDart(int dartNum, int computer) { // Wait for a hit while (!dartHit() && !_vm->shouldQuit()) ; + if (_escapePressed) + return 0; } else { events.wait(1); } @@ -907,7 +911,12 @@ int Darts::throwDart(int dartNum, int computer) { } horiz = drawHand(targetPos.x, computer); + if (_escapePressed) + return 0; + height = doPowerBar(Common::Point(DART_BAR_VX, DART_HEIGHT_Y), DART_COLOR_FORE, targetPos.y, 1); + if (_escapePressed) + return 0; // Invert height height = 101 - height; diff --git a/engines/sherlock/tattoo/tattoo_darts.h b/engines/sherlock/tattoo/tattoo_darts.h index f65ec19d10..ab6b1c8204 100644 --- a/engines/sherlock/tattoo/tattoo_darts.h +++ b/engines/sherlock/tattoo/tattoo_darts.h @@ -55,6 +55,7 @@ private: bool _oldDartButtons; int _handX; Common::Point _handSize; + bool _escapePressed; /** * Initialize game variables -- cgit v1.2.3