DIRECTOR: Fix where timeout events are handled

This commit is contained in:
djsrv 2021-08-06 10:58:05 -04:00
parent ecd02afeda
commit bae70bf784
2 changed files with 13 additions and 16 deletions

View File

@ -43,24 +43,8 @@ bool DirectorEngine::processEvents(bool captureClick) {
debugC(3, kDebugEvents, "@@@@ Processing events");
debugC(3, kDebugEvents, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
Movie *currentMovie = g_director->getCurrentMovie();
// update and register timeOut event
if (currentMovie && getMacTicks() - currentMovie->_lastTimeOut >= currentMovie->_timeOutLength) {
currentMovie->registerEvent(kEventTimeout);
currentMovie->_lastTimeOut = getMacTicks();
}
if (currentMovie && currentMovie->_timeOutPlay && g_director->_playbackPaused)
currentMovie->_lastTimeOut = getMacTicks();
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
// update timeOut related values
if (currentMovie && event.type == Common::EVENT_LBUTTONDOWN && g_director->getCurrentMovie()->_timeOutMouse)
currentMovie->_lastTimeOut = getMacTicks();
if (currentMovie && event.type == Common::EVENT_KEYDOWN && g_director->getCurrentMovie()->_timeOutKeyDown)
currentMovie->_lastTimeOut = getMacTicks();
if (!_wm->processEvent(event)) {
// We only want to handle these events if the event
// wasn't handled by the window manager.
@ -197,6 +181,8 @@ bool Movie::processEvent(Common::Event &event) {
_lastEventTime = g_director->getMacTicks();
_lastClickTime = _lastEventTime;
_lastClickPos = pos;
if (_timeOutMouse)
_lastTimeOut = _lastEventTime;
debugC(3, kDebugEvents, "event: Button Down @(%d, %d), movie '%s', sprite id: %d", pos.x, pos.y, _macName.c_str(), spriteId);
registerEvent(kEventMouseDown, spriteId);
@ -247,6 +233,9 @@ bool Movie::processEvent(Common::Event &event) {
_lastEventTime = g_director->getMacTicks();
_lastKeyTime = _lastEventTime;
if (_timeOutKeyDown)
_lastTimeOut = _lastEventTime;
registerEvent(kEventKeyDown);
return true;

View File

@ -427,9 +427,17 @@ void Score::update() {
// but this is incorrect. The frame script is executed first.
_movie->processEvent(kEventStepMovie);
}
if (_movie->_timeOutPlay)
_movie->_lastTimeOut = _vm->getMacTicks();
}
// TODO Director 6 - another order
// TODO: Figure out when exactly timeout events are processed
if (_vm->getMacTicks() - _movie->_lastTimeOut >= _movie->_timeOutLength) {
_movie->processEvent(kEventTimeout);
_movie->_lastTimeOut = _vm->getMacTicks();
}
// If we have more call stack frames than we started with, then we have a newly
// added frozen context. We'll deal with that later.
if (_window->_callstack.size() == initialCallStackSize) {