From e24d00a81b3d0a5dece94d9de3ff30cfabe80be2 Mon Sep 17 00:00:00 2001 From: ysj1173886760 <1173886760@qq.com> Date: Fri, 6 Aug 2021 16:40:42 +0800 Subject: [PATCH] DIRECTOR: implement handling timeOut related values. --- engines/director/events.cpp | 13 +++++++++++-- engines/director/lingo/lingo-the.cpp | 15 +++++++++------ engines/director/movie.cpp | 4 ++++ engines/director/movie.h | 3 +++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/engines/director/events.cpp b/engines/director/events.cpp index b2a85c9a36d..c243a20d2bd 100644 --- a/engines/director/events.cpp +++ b/engines/director/events.cpp @@ -44,13 +44,22 @@ bool DirectorEngine::processEvents(bool captureClick) { debugC(3, kDebugEvents, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); // update and register timeOut event - if (g_director->getMacTicks() - g_director->getCurrentMovie()->_lastTimeOut >= g_director->getCurrentMovie()->_timeOutLength) { + if (getMacTicks() - g_director->getCurrentMovie()->_lastTimeOut >= g_director->getCurrentMovie()->_timeOutLength) { g_director->getCurrentMovie()->registerEvent(kEventTimeout); - g_director->getCurrentMovie()->_lastTimeOut = g_director->getMacTicks(); + g_director->getCurrentMovie()->_lastTimeOut = getMacTicks(); } + if (g_director->getCurrentMovie()->_timeOutPlay && g_director->_playbackPaused) + g_director->getCurrentMovie()->_lastTimeOut = getMacTicks(); + Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { + // update timeOut related values + if (event.type == Common::EVENT_LBUTTONDOWN && g_director->getCurrentMovie()->_timeOutMouse) + g_director->getCurrentMovie()->_lastTimeOut = getMacTicks(); + if (event.type == Common::EVENT_KEYDOWN && g_director->getCurrentMovie()->_timeOutKeyDown) + g_director->getCurrentMovie()->_lastTimeOut = getMacTicks(); + if (!_wm->processEvent(event)) { // We only want to handle these events if the event // wasn't handled by the window manager. diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp index 13d47f4042a..b84e9fbcf69 100644 --- a/engines/director/lingo/lingo-the.cpp +++ b/engines/director/lingo/lingo-the.cpp @@ -841,7 +841,8 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) { d = getTheTime(field); break; case kTheTimeoutKeyDown: - getTheEntitySTUB(kTheTimeoutKeyDown); + d.type = INT; + d.u.i = g_director->getCurrentMovie()->_timeOutKeyDown; break; case kTheTimeoutLapsed: d.type = INT; @@ -852,10 +853,12 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) { d.u.i = g_director->getCurrentMovie()->_timeOutLength; break; case kTheTimeoutMouse: - getTheEntitySTUB(kTheTimeoutMouse); + d.type = INT; + d.u.i = g_director->getCurrentMovie()->_timeOutMouse; break; case kTheTimeoutPlay: - getTheEntitySTUB(kTheTimeoutPlay); + d.type = INT; + d.u.i = g_director->getCurrentMovie()->_timeOutPlay; break; case kTheTimeoutScript: d.type = STRING; @@ -1078,7 +1081,7 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) { setTheEntitySTUB(kTheSwitchColorDepth); break; case kTheTimeoutKeyDown: - setTheEntitySTUB(kTheTimeoutKeyDown); + g_director->getCurrentMovie()->_timeOutKeyDown = d.asInt(); break; case kTheTimeoutLapsed: // timeOutLapsed can be set in D4, but can't in D3. see D3.1 interactivity manual p312 and D4 dictionary p296. @@ -1088,10 +1091,10 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) { g_director->getCurrentMovie()->_timeOutLength = d.asInt(); break; case kTheTimeoutMouse: - setTheEntitySTUB(kTheTimeoutMouse); + g_director->getCurrentMovie()->_timeOutMouse = d.asInt(); break; case kTheTimeoutPlay: - setTheEntitySTUB(kTheTimeoutPlay); + g_director->getCurrentMovie()->_timeOutPlay = d.asInt(); break; case kTheTimeoutScript: movie->setPrimaryEventHandler(kEventTimeout, d.asString()); diff --git a/engines/director/movie.cpp b/engines/director/movie.cpp index 38f464adf59..e77ccd58a36 100644 --- a/engines/director/movie.cpp +++ b/engines/director/movie.cpp @@ -83,6 +83,10 @@ Movie::Movie(Window *window) { _lastTimeOut = _lastEventTime; _timeOutLength = 10800; // D4 dictionary p297, default value is 3minutes + // default value of keydown and mouse is true, for timeOutPlay is false. check D4 dictionary p297 + _timeOutKeyDown = true; + _timeOutMouse = true; + _timeOutPlay = false; } Movie::~Movie() { diff --git a/engines/director/movie.h b/engines/director/movie.h index c00140f5a10..4ff96f515bf 100644 --- a/engines/director/movie.h +++ b/engines/director/movie.h @@ -164,6 +164,9 @@ public: uint _lastTimeOut; uint _timeOutLength; + bool _timeOutKeyDown; + bool _timeOutMouse; + bool _timeOutPlay; private: Window *_window;