From 26dd2f5f603b10b3b54664b6589c8feb6c4f7b82 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 3 Sep 2011 17:21:25 +0200 Subject: [PATCH] GOB: Move keyPressed() to Util --- engines/gob/inter.h | 2 -- engines/gob/inter_geisha.cpp | 14 +------------- engines/gob/util.cpp | 12 ++++++++++++ engines/gob/util.h | 1 + 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/engines/gob/inter.h b/engines/gob/inter.h index c84cc384ce3..d1c28fcb2f5 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -362,8 +362,6 @@ protected: void oGeisha_caress2(OpGobParams ¶ms); int16 loadSound(int16 slot); - - bool keyPressed(); }; class Inter_v2 : public Inter_v1 { diff --git a/engines/gob/inter_geisha.cpp b/engines/gob/inter_geisha.cpp index 6c3e97c2a7a..d72dd798a41 100644 --- a/engines/gob/inter_geisha.cpp +++ b/engines/gob/inter_geisha.cpp @@ -82,18 +82,6 @@ void Inter_Geisha::oGeisha_loadCursor(OpFuncParams ¶ms) { o1_loadCursor(params); } -bool Inter_Geisha::keyPressed() { - int16 key = _vm->_util->checkKey(); - if (key) - return true; - - int16 x, y; - MouseButtons buttons; - - _vm->_util->getMouseState(&x, &y, &buttons); - return buttons != kMouseButtonsNone; -} - struct TOTTransition { const char *to; const char *from; @@ -134,7 +122,7 @@ void Inter_Geisha::oGeisha_loadTot(OpFuncParams ¶ms) { } if (needWait) - while (!keyPressed()) + while (!_vm->_util->keyPressed()) _vm->_util->longDelay(1); } diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 58dfc9c7ad2..7f9c6131fdc 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -257,6 +257,18 @@ bool Util::checkKey(int16 &key) { return true; } +bool Util::keyPressed() { + int16 key = checkKey(); + if (key) + return true; + + int16 x, y; + MouseButtons buttons; + + getMouseState(&x, &y, &buttons); + return buttons != kMouseButtonsNone; +} + void Util::getMouseState(int16 *pX, int16 *pY, MouseButtons *pButtons) { Common::Point mouse = g_system->getEventManager()->getMousePos(); *pX = mouse.x + _vm->_video->_scrollOffsetX - _vm->_video->_screenDeltaX; diff --git a/engines/gob/util.h b/engines/gob/util.h index 7c1e44c0f62..4228dac7686 100644 --- a/engines/gob/util.h +++ b/engines/gob/util.h @@ -108,6 +108,7 @@ public: int16 getKey(); int16 checkKey(); bool checkKey(int16 &key); + bool keyPressed(); void getMouseState(int16 *pX, int16 *pY, MouseButtons *pButtons); void setMousePos(int16 x, int16 y);