mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 01:07:22 +00:00
NANCY: Change where states are entered and exited
Moved the calls to onStateEnter() and onStateExit() inside the main game loop.
This commit is contained in:
parent
846bee430b
commit
4b3b81eb52
@ -219,8 +219,6 @@ void NancyEngine::setState(NancyState::NancyState state, NancyState::NancyState
|
||||
break;
|
||||
}
|
||||
|
||||
_graphicsManager->clearObjects();
|
||||
|
||||
if (overridePrevious != NancyState::kNone) {
|
||||
_gameFlow.prevState = overridePrevious;
|
||||
} else {
|
||||
@ -228,22 +226,7 @@ void NancyEngine::setState(NancyState::NancyState state, NancyState::NancyState
|
||||
}
|
||||
|
||||
_gameFlow.curState = state;
|
||||
|
||||
bool shouldDestroyLastState = false;
|
||||
|
||||
State::State *s = getStateObject(_gameFlow.prevState);
|
||||
if (s) {
|
||||
shouldDestroyLastState = s->onStateExit(_gameFlow.curState);
|
||||
}
|
||||
|
||||
s = getStateObject(_gameFlow.curState);
|
||||
if (s) {
|
||||
s->onStateEnter(_gameFlow.prevState);
|
||||
}
|
||||
|
||||
if (shouldDestroyLastState) {
|
||||
destroyState(_gameFlow.prevState);
|
||||
}
|
||||
_gameFlow.changingState = true;
|
||||
}
|
||||
|
||||
void NancyEngine::setToPreviousState() {
|
||||
@ -274,13 +257,35 @@ Common::Error NancyEngine::run() {
|
||||
_cursorManager->setCursorType(CursorManager::kNormalArrow);
|
||||
_input->processEvents();
|
||||
|
||||
State::State *s = getStateObject(_gameFlow.curState);
|
||||
State::State *s;
|
||||
|
||||
if (_gameFlow.changingState) {
|
||||
s = getStateObject(_gameFlow.curState);
|
||||
if (s) {
|
||||
s->onStateEnter(_gameFlow.curState);
|
||||
}
|
||||
|
||||
_gameFlow.changingState = false;
|
||||
}
|
||||
|
||||
s = getStateObject(_gameFlow.curState);
|
||||
if (s) {
|
||||
s->process();
|
||||
}
|
||||
|
||||
_graphicsManager->draw();
|
||||
|
||||
if (_gameFlow.changingState) {
|
||||
_graphicsManager->clearObjects();
|
||||
|
||||
s = getStateObject(_gameFlow.prevState);
|
||||
if (s) {
|
||||
if(s->onStateExit(_gameFlow.prevState)) {
|
||||
destroyState(_gameFlow.prevState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_system->updateScreen();
|
||||
_system->delayMillis(16);
|
||||
}
|
||||
|
@ -133,6 +133,7 @@ private:
|
||||
struct GameFlow {
|
||||
NancyState::NancyState curState = NancyState::kNone;
|
||||
NancyState::NancyState prevState = NancyState::kNone;
|
||||
bool changingState = true;
|
||||
};
|
||||
|
||||
void bootGameEngine();
|
||||
|
Loading…
x
Reference in New Issue
Block a user