aboutsummaryrefslogtreecommitdiff
path: root/engines/lab
diff options
context:
space:
mode:
authorFilippos Karapetis2015-12-24 18:12:57 +0200
committerFilippos Karapetis2015-12-24 18:12:57 +0200
commit9c749c7d2e9c60b30274ba63fac44f886574e668 (patch)
treeebf264ddbb1b391cbe702290c535795831ae4a8f /engines/lab
parent60657f9fd22154d6e554a8e5516a489547c70a84 (diff)
downloadscummvm-rg350-9c749c7d2e9c60b30274ba63fac44f886574e668.tar.gz
scummvm-rg350-9c749c7d2e9c60b30274ba63fac44f886574e668.tar.bz2
scummvm-rg350-9c749c7d2e9c60b30274ba63fac44f886574e668.zip
LAB: Start to untangle the mess in the event code
Diffstat (limited to 'engines/lab')
-rw-r--r--engines/lab/eventman.cpp77
-rw-r--r--engines/lab/eventman.h5
-rw-r--r--engines/lab/interface.cpp4
3 files changed, 25 insertions, 61 deletions
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 4947991b87..5dbe60f946 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -108,7 +108,6 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
_leftClick = false;
_rightClick = false;
- _mouseHidden = true;
_lastButtonHit = nullptr;
_screenButtonList = nullptr;
_hitButton = nullptr;
@@ -123,28 +122,21 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
}
void EventManager::updateMouse() {
- bool doUpdateDisplay = false;
+ if (!_hitButton)
+ return;
- if (!_mouseHidden)
- doUpdateDisplay = true;
+ mouseHide();
+ _hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
+ mouseShow();
- if (_hitButton) {
- mouseHide();
- _hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
- mouseShow();
+ for (int i = 0; i < 3; i++)
+ _vm->waitTOF();
- for (int i = 0; i < 3; i++)
- _vm->waitTOF();
-
- mouseHide();
- _hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
- mouseShow();
- doUpdateDisplay = true;
- _hitButton = nullptr;
- }
-
- if (doUpdateDisplay)
- _vm->_graphics->screenUpdate();
+ mouseHide();
+ _hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
+ mouseShow();
+ _hitButton = nullptr;
+ _vm->_graphics->screenUpdate();
}
void EventManager::initMouse() {
@@ -155,20 +147,11 @@ void EventManager::initMouse() {
}
void EventManager::mouseShow() {
- if (_mouseHidden) {
- processInput();
- _mouseHidden = false;
- }
-
_vm->_system->showMouse(true);
}
void EventManager::mouseHide() {
- if (!_mouseHidden) {
- _mouseHidden = true;
-
- _vm->_system->showMouse(false);
- }
+ _vm->_system->showMouse(false);
}
Common::Point EventManager::getMousePos() {
@@ -183,23 +166,19 @@ void EventManager::setMousePos(Common::Point pos) {
_vm->_system->warpMouse(pos.x, pos.y);
else
_vm->_system->warpMouse(pos.x * 2, pos.y);
-
- if (!_mouseHidden)
- processInput();
}
-bool EventManager::keyPress(Common::KeyCode *keyCode) {
- if (haveNextChar()) {
- *keyCode = getNextChar();
- return true;
- }
-
- return false;
-}
+Common::KeyCode EventManager::keyPress() {
+ Common::KeyCode key = Common::KEYCODE_INVALID;
-bool EventManager::haveNextChar() {
processInput();
- return _nextKeyIn != _nextKeyOut;
+
+ if (_nextKeyIn != _nextKeyOut) {
+ key = _keyBuf[_nextKeyOut];
+ _nextKeyOut = (_nextKeyOut + 1) % 64;
+ }
+
+ return key;
}
void EventManager::processInput() {
@@ -262,18 +241,6 @@ void EventManager::processInput() {
_vm->_system->updateScreen();
}
-Common::KeyCode EventManager::getNextChar() {
- Common::KeyCode chr = Common::KEYCODE_INVALID;
-
- processInput();
- if (_nextKeyIn != _nextKeyOut) {
- chr = _keyBuf[_nextKeyOut];
- _nextKeyOut = (_nextKeyOut + 1) % 64;
- }
-
- return chr;
-}
-
Common::Point EventManager::updateAndGetMousePos() {
processInput();
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 963972165d..a5f0e9484f 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -74,7 +74,6 @@ private:
bool _leftClick;
bool _rightClick;
- bool _mouseHidden;
uint16 _nextKeyIn;
uint16 _nextKeyOut;
@@ -96,9 +95,7 @@ private:
/**
* Checks whether or not a key has been pressed.
*/
- bool keyPress(Common::KeyCode *keyCode);
- bool haveNextChar();
- Common::KeyCode getNextChar();
+ Common::KeyCode keyPress();
/**
* Checks whether or not the coords fall within one of the buttons in a list
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 0d03d21fd1..af52a6a2f3 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -118,7 +118,7 @@ IntuiMessage *EventManager::getMsg() {
updateMouse();
- Common::KeyCode curKey;
+ Common::KeyCode curKey = keyPress();
if (_lastButtonHit) {
updateMouse();
@@ -135,7 +135,7 @@ IntuiMessage *EventManager::getMsg() {
message._mouse.x /= 2;
_leftClick = _rightClick = false;
return &message;
- } else if (keyPress(&curKey)) {
+ } else if (curKey != Common::KEYCODE_INVALID) {
message._code = curKey;
Button *curButton = checkNumButtonHit(_screenButtonList, message._code);