mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 17:57:14 +00:00
LAB: Start to untangle the mess in the event code
This commit is contained in:
parent
60657f9fd2
commit
9c749c7d2e
@ -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;
|
||||
Common::KeyCode EventManager::keyPress() {
|
||||
Common::KeyCode key = Common::KEYCODE_INVALID;
|
||||
|
||||
processInput();
|
||||
|
||||
if (_nextKeyIn != _nextKeyOut) {
|
||||
key = _keyBuf[_nextKeyOut];
|
||||
_nextKeyOut = (_nextKeyOut + 1) % 64;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EventManager::haveNextChar() {
|
||||
processInput();
|
||||
return _nextKeyIn != _nextKeyOut;
|
||||
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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user