diff options
-rw-r--r-- | engines/supernova/state.cpp | 35 | ||||
-rw-r--r-- | engines/supernova/state.h | 7 | ||||
-rw-r--r-- | engines/supernova/supernova.cpp | 11 | ||||
-rw-r--r-- | engines/supernova/supernova.h | 2 |
4 files changed, 33 insertions, 22 deletions
diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index 4dffde570e..bc4eeeafdd 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -325,6 +325,8 @@ void GameManager::initState() { _mouseField = -1; _inventoryScroll = 0; _oldTime = 0; + _timerPaused = 0; + _timePaused = false; _timer1 = 0; _animationTimer = 0; @@ -1193,14 +1195,6 @@ void GameManager::roomBrightness() { _vm->paletteBrightness(); } -void GameManager::loadTime() { - warning("STUB: loadTime"); -} - -void GameManager::saveTime() { - warning("STUB: saveTime"); -} - bool GameManager::saveGame(int number) { warning("STUB: savegame %d", number); return false; @@ -1254,6 +1248,8 @@ void GameManager::setAnimationTimer(int ticks) { } void GameManager::handleTime() { + if (_timerPaused) + return; int32 delta = g_system->getMillis() - _oldTime; _state._time += delta; if (_state._time > 86400000) @@ -1266,6 +1262,29 @@ void GameManager::handleTime() { _oldTime = g_system->getMillis(); } +void GameManager::pauseTimer(bool pause) { + if (pause == _timerPaused) + return; + + if (pause) { + _timerPaused = true; + int32 delta = g_system->getMillis() - _oldTime; + _timePaused = _state._time + delta; + } else { + _state._time = _timePaused; + _oldTime = g_system->getMillis(); + _timerPaused = false; + } +} + +void GameManager::loadTime() { + pauseTimer(false); +} + +void GameManager::saveTime() { + pauseTimer(true); +} + void GameManager::screenShake() { for (int i = 0; i < 12; ++i) { _vm->_system->setShakePos(8); diff --git a/engines/supernova/state.h b/engines/supernova/state.h index bc442593c8..1b993d145b 100644 --- a/engines/supernova/state.h +++ b/engines/supernova/state.h @@ -125,6 +125,8 @@ public: bool _waitEvent; bool _newRoom; int32 _oldTime; + uint _timePaused; + bool _timerPaused; int32 _timer1; int32 _animationTimer; int _inventoryScroll; @@ -162,8 +164,6 @@ public: void turnOff(); void turnOn(); void screenShake(); - void loadTime(); - void saveTime(); bool saveGame(int number); void errorTemp(); void roomBrightness(); @@ -184,6 +184,9 @@ public: void resetInputState(); void handleInput(); void handleTime(); + void pauseTimer(bool pause); + void loadTime(); + void saveTime(); void setAnimationTimer(int ticks); void dead(const char *message); void dead(StringID messageId); diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index d61c75e5c7..aaa898fcb6 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -264,16 +264,7 @@ bool SupernovaEngine::hasFeature(EngineFeature f) const { void SupernovaEngine::pauseEngineIntern(bool pause) { _mixer->pauseAll(pause); - pauseTimer(pause); -} - -void SupernovaEngine::pauseTimer(bool pause) { - if (pause) { - _timePaused = _gm->_state._time; - } else { - _gm->_state._time = _timePaused; - _gm->_oldTime = _system->getMillis(); - } + _gm->pauseTimer(pause); } Common::Error SupernovaEngine::loadGameStrings() { diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index c296c0ee84..45705a679b 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -108,7 +108,6 @@ public: byte _imageIndex; byte _menuBrightness; byte _brightness; - uint _timePaused; uint _delay; bool _messageDisplayed; int _textSpeed; @@ -116,7 +115,6 @@ public: int _textCursorY; int _textColor; - void pauseTimer(bool pause); int textWidth(const char *text); int textWidth(const uint16 key); Common::Error loadGameStrings(); |