aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorathrxx2020-01-08 17:45:56 +0100
committerathrxx2020-01-08 20:27:54 +0100
commitec872b8dc8fffc631b9b5e84c701800a20d02220 (patch)
treec1c8e5bbefb52882a6ffc9fd914a3287b1f27e37
parent2f919d39e4b9ae0cb1f66b97b29a00525619b4c1 (diff)
downloadscummvm-rg350-ec872b8dc8fffc631b9b5e84c701800a20d02220.tar.gz
scummvm-rg350-ec872b8dc8fffc631b9b5e84c701800a20d02220.tar.bz2
scummvm-rg350-ec872b8dc8fffc631b9b5e84c701800a20d02220.zip
KYRA: (LOK) - shakeScreen() improvement
(maintain smooth mouse cursor movement during shakes)
-rw-r--r--engines/kyra/graphics/screen.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/engines/kyra/graphics/screen.cpp b/engines/kyra/graphics/screen.cpp
index dd264a1551..bbcada5991 100644
--- a/engines/kyra/graphics/screen.cpp
+++ b/engines/kyra/graphics/screen.cpp
@@ -3175,7 +3175,7 @@ void Screen::shakeScreen(int times) {
const int8 *data = _shakeParaPC;
int steps = ARRAYSIZE(_shakeParaPC) / 3;
-
+
// The FM-TOWNS version has a slightly better shake animation
// TODO: check PC-98 version
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
@@ -3183,16 +3183,28 @@ void Screen::shakeScreen(int times) {
steps = ARRAYSIZE(_shakeParaFMTOWNS) / 3;
}
+ Common::Event event;
+
while (times--) {
for (int i = 0; i < steps; ++i) {
- // The original PC version did not need an artificial delay, but we do.
- // Or the shake will be too fast to be actually seen.
- uint32 delayuntil = _system->getMillis() + data[0];
+ // The original PC version did not need an artificial delay, but we do or the shake will be
+ // too fast to be actually seen.
+ uint32 end = _system->getMillis() + data[0];
_system->setShakePos(data[1], data[2]);
- _system->updateScreen();
- int diff = delayuntil - _system->getMillis();
- if (diff > 0)
- _system->delayMillis(diff);
+
+ for (uint32 now = _system->getMillis(); now < end; ) {
+ // Update the event manager to keep smooth mouse pointer movement.
+ while (_vm->getEventManager()->pollEvent(event)) {
+ if (event.type == Common::EVENT_KEYDOWN) {
+ // This is really the only thing that should be handled.
+ if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.hasFlags(Common::KBD_CTRL))
+ _vm->quitGame();
+ }
+ }
+ _system->updateScreen();
+ now = _system->getMillis();
+ _system->delayMillis(MIN<uint>(end - now, 10));
+ }
data += 3;
}
}