diff options
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/pregob/pregob.cpp | 44 | ||||
-rw-r--r-- | engines/gob/pregob/pregob.h | 9 |
2 files changed, 53 insertions, 0 deletions
diff --git a/engines/gob/pregob/pregob.cpp b/engines/gob/pregob/pregob.cpp index 18aac50352..1c3fb8221c 100644 --- a/engines/gob/pregob/pregob.cpp +++ b/engines/gob/pregob/pregob.cpp @@ -137,4 +137,48 @@ bool PreGob::isCursorVisible() const { return CursorMan.isVisible(); } +void PreGob::endFrame(bool doInput) { + _vm->_draw->blitInvalidated(); + _vm->_util->waitEndFrame(); + + if (doInput) + _vm->_util->processInput(); +} + +int16 PreGob::checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) { + _vm->_util->getMouseState(&mouseX, &mouseY, &mouseButtons); + _vm->_util->forceMouseUp(); + + return _vm->_util->checkKey(); +} + +int16 PreGob::waitInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) { + bool finished = false; + + int16 key = 0; + while (!_vm->shouldQuit() && !finished) { + endFrame(true); + + key = checkInput(mouseX, mouseY, mouseButtons); + + finished = (mouseButtons != kMouseButtonsNone) || (key != 0); + } + + return key; +} + +int16 PreGob::waitInput() { + int16 mouseX, mouseY; + MouseButtons mouseButtons; + + return waitInput(mouseX, mouseY, mouseButtons); +} + +bool PreGob::hasInput() { + int16 mouseX, mouseY; + MouseButtons mouseButtons; + + return checkInput(mouseX, mouseY, mouseButtons) || (mouseButtons != kMouseButtonsNone); +} + } // End of namespace Gob diff --git a/engines/gob/pregob/pregob.h b/engines/gob/pregob/pregob.h index e0f7ca907d..4cf4a39fdb 100644 --- a/engines/gob/pregob/pregob.h +++ b/engines/gob/pregob/pregob.h @@ -23,6 +23,8 @@ #ifndef GOB_PREGOB_PREGOB_H #define GOB_PREGOB_PREGOB_H +#include "gob/util.h" + namespace Gob { class GobEngine; @@ -62,6 +64,13 @@ protected: bool isCursorVisible() const; + void endFrame(bool doInput); + + int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons); + int16 waitInput (int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons); + int16 waitInput(); + bool hasInput(); + GobEngine *_vm; |