void MadsScene::updateState() { if (!_abortTimers && !_madsVm->_player._unk3) { if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); // int v = (_madsVm->_player._stepEnabled && !_action._startWalkFlag && !_abortTimers2) ? 1 : 0; // _screenObjects.check(v, false); } // Handle starting off any selected action bool doPreAction = false; if ((_action._selectedAction != 0) && _madsVm->_player._stepEnabled && !_action._startWalkFlag && !_abortTimers && !_madsVm->_player._unk3) { // Start the action _action.startAction(); if (_action._action.verbId == kVerbLookAt) { _action._action.verbId = kVerbLook; _action._savedFields.selectedRow = 0; } doPreAction = true; } if (doPreAction || ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_2))) doPreactions(); checkStartWalk(); if (_action._inProgress && !_madsVm->_player._moving && !_action._startWalkFlag && (_madsVm->_player._newDirection == _madsVm->_player._direction)) { // Reached the end of action movement, so ready to actually do action doAction(); } else if ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_0)) // Do an action designated by scripts doAction(); bool freeFlag = false; if (_currentScene != _nextScene) freeFlag = true; else { doSceneStep(); if (_currentScene != _nextScene) freeFlag = true; else { // Update the player _madsVm->_player.nextFrame(); // Handle updating the animation if (!_abortTimers && (_activeAnimation)) _activeAnimation->update(); // Handle refreshing the mouse position display if (_mouseMsgIndex != -1) _madsVm->scene()->_kernelMessages.remove(_mouseMsgIndex); if (_showMousePos) { char buffer[20]; sprintf(buffer, "(%d,%d)", _madsVm->_mouse->currentPos().x, _madsVm->_mouse->currentPos().y); _mouseMsgIndex = _madsVm->scene()->_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, buffer); } } } if (_madsVm->globals()->_config.easyMouse) _action.refresh(); if ((_activeAnimation) && !_abortTimers) { _activeAnimation->update(); if (((MadsAnimation *) _activeAnimation)->freeFlag() || freeFlag) { delete _activeAnimation; _activeAnimation = NULL; } } MadsView::update(); // Remove the animation if it's been completed if ((_activeAnimation) && ((MadsAnimation *)_activeAnimation)->freeFlag()) freeAnimation(); if ((_action._selectedAction != 0) || !_madsVm->_player._stepEnabled) { _action.clear(); _action._selectedAction = 0; } }
void Scene::doFrame() { Player &player = _vm->_game->_player; bool flag = false; if (_action._selectedAction || !player._stepEnabled) { _action.clear(); _action._selectedAction = 0; } if (!_vm->_game->_trigger && !player._trigger) { // Refresh the dynamic hotspots if they've changed if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); // Check all on-screen visual objects _vm->_game->_screenObjects.check(player._stepEnabled && !player._needToWalk && !_vm->_game->_fx); } if (_action._selectedAction && player._stepEnabled && !player._needToWalk && !_vm->_game->_trigger && !player._trigger) { _action.startAction(); if (_action._activeAction._verbId == Nebular::VERB_LOOK_AT) { _action._activeAction._verbId = VERB_LOOK; _action._savedFields._command = false; } flag = true; } if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == SEQUENCE_TRIGGER_PREPARE)) { doPreactions(); } player.newWalk(); if (!_vm->_game->_fx) _frameStartTime = _vm->_events->getFrameCounter(); // Handle parser actions as well as game triggers if ((_action._inProgress && !player._moving && !player._needToWalk && (player._facing == player._turnToFacing) && !_vm->_game->_trigger) || (_vm->_game->_trigger && (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER))) { doAction(); } if (_currentSceneId != _nextSceneId) { _freeAnimationFlag = true; } else { doSceneStep(); checkKeyboard(); if (_currentSceneId != _nextSceneId) { _freeAnimationFlag = true; } else { player.nextFrame(); // Cursor update code updateCursor(); if (!_vm->_game->_trigger) { // Handle any active sequences _sequences.tick(); // Handle any active animation if (_activeAnimation) _activeAnimation->update(); } // If the debugget flag is set, show the mouse position int mouseTextIndex = 0; if (_vm->_debugger->_showMousePos) { Common::Point pt = _vm->_events->mousePos(); Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y); mouseTextIndex = _kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg); } if (!_vm->_game->_trigger) { if (_reloadSceneFlag || _currentSceneId != _nextSceneId) _kernelMessages.reset(); _kernelMessages.update(); } _userInterface._uiSlots.draw(!_vm->_game->_fx, _vm->_game->_fx); // Write any text needed by the interface if (_vm->_game->_fx) _userInterface.drawTextElements(); // Draw any elements drawElements((ScreenTransition)_vm->_game->_fx, _vm->_game->_fx); // Handle message updates if (_vm->_game->_fx) { uint32 priorTime = _vm->_game->_priorFrameTimer; uint32 newTime = _vm->_events->getFrameCounter(); _sequences.delay(priorTime, newTime); _kernelMessages.delay(priorTime, newTime); } if (_vm->_debugger->_showMousePos) // Mouse position display isn't persistent, so remove it _kernelMessages.remove(mouseTextIndex); // Original had a debugger check/call here to allow pausing after // drawing each frame. Not implemented under ScummVM } } if (_vm->_game->_fx) _cyclingActive = true; _vm->_game->_fx = kTransitionNone; // Handle freeing animation if necessary if (_activeAnimation && _activeAnimation->freeFlag()) _freeAnimationFlag = true; if (_freeAnimationFlag) freeAnimation(); }