DIRECTOR: implement handling timeOut related values.

This commit is contained in:
ysj1173886760 2021-08-06 16:40:42 +08:00
parent 5466511dce
commit e24d00a81b
4 changed files with 27 additions and 8 deletions

View File

@ -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.

View File

@ -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());

View File

@ -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() {

View File

@ -164,6 +164,9 @@ public:
uint _lastTimeOut;
uint _timeOutLength;
bool _timeOutKeyDown;
bool _timeOutMouse;
bool _timeOutPlay;
private:
Window *_window;