diff options
author | Torbjörn Andersson | 2008-05-23 17:54:47 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2008-05-23 17:54:47 +0000 |
commit | 4b06f42ff339cc79eb17aa75140987c1426e405a (patch) | |
tree | 277e4da99e55eaa6bb912b871afbeda9c5f6d3c3 | |
parent | 18b3e3a4ba09a886e7ad78c5b3d17ece3ee97940 (diff) | |
download | scummvm-rg350-4b06f42ff339cc79eb17aa75140987c1426e405a.tar.gz scummvm-rg350-4b06f42ff339cc79eb17aa75140987c1426e405a.tar.bz2 scummvm-rg350-4b06f42ff339cc79eb17aa75140987c1426e405a.zip |
Initial implementation of pauseEngineIntern(). There are issues, though, since
the engine doesn't always allow the game to be paused, and some things (GUI,
movie cutscenes, credits, ...) are outside the main engine loop.
svn-id: r32232
-rw-r--r-- | engines/sword2/mouse.cpp | 24 | ||||
-rw-r--r-- | engines/sword2/mouse.h | 3 | ||||
-rw-r--r-- | engines/sword2/sword2.cpp | 79 | ||||
-rw-r--r-- | engines/sword2/sword2.h | 3 |
4 files changed, 55 insertions, 54 deletions
diff --git a/engines/sword2/mouse.cpp b/engines/sword2/mouse.cpp index 44d2383f78..af4f121e96 100644 --- a/engines/sword2/mouse.cpp +++ b/engines/sword2/mouse.cpp @@ -1462,19 +1462,19 @@ void Mouse::checkPlayerActivity(uint32 seconds) { _vm->_logic->writeVar(RESULT, 0); } -void Mouse::pauseGame() { - // Make the mouse cursor normal. This is the only place where we are - // allowed to clear the luggage this way. +void Mouse::pauseEngine(bool pause) { + if (pause) { + // Make the mouse cursor normal. This is the only place where + // we are allowed to clear the luggage this way. - clearPointerText(); - setLuggageAnim(NULL, 0); - setMouse(0); - setMouseTouching(1); -} - -void Mouse::unpauseGame() { - if (_vm->_logic->readVar(OBJECT_HELD) && _realLuggageItem) - setLuggage(_realLuggageItem); + clearPointerText(); + setLuggageAnim(NULL, 0); + setMouse(0); + setMouseTouching(1); + } else { + if (_vm->_logic->readVar(OBJECT_HELD) && _realLuggageItem) + setLuggage(_realLuggageItem); + } } #define MOUSEFLASHFRAME 6 diff --git a/engines/sword2/mouse.h b/engines/sword2/mouse.h index 09ac9ced20..b87129ac7f 100644 --- a/engines/sword2/mouse.h +++ b/engines/sword2/mouse.h @@ -211,8 +211,7 @@ public: uint32 getMouseTouching() { return _mouseTouching; } void setMouseTouching(uint32 touching) { _mouseTouching = touching; } - void pauseGame(); - void unpauseGame(); + void pauseEngine(bool pause); void setMouse(uint32 res); void setLuggage(uint32 res); diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 0601d11791..26fd598d9d 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -392,7 +392,7 @@ int Sword2Engine::go() { #ifdef SWORD2_DEBUG if (_stepOneCycle) { - pauseGame(); + pauseEngineIntern(true); _stepOneCycle = false; } #endif @@ -406,9 +406,9 @@ int Sword2Engine::go() { switch (ke->kbd.keycode) { case Common::KEYCODE_p: if (_gamePaused) - unpauseGame(); + pauseEngineIntern(false); else - pauseGame(); + pauseEngineIntern(true); break; case Common::KEYCODE_c: if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) { @@ -421,7 +421,7 @@ int Sword2Engine::go() { case Common::KEYCODE_SPACE: if (_gamePaused) { _stepOneCycle = true; - unpauseGame(); + pauseEngineIntern(false); } break; case Common::KEYCODE_s: @@ -689,53 +689,56 @@ void Sword2Engine::sleepUntil(uint32 time) { } } -void Sword2Engine::pauseGame() { - // Don't allow Pause while screen fading or while black - if (_screen->getFadeStatus() != RDFADE_NONE) - return; +void Sword2Engine::pauseEngineIntern(bool pause) { + if (pause) { + // FIXME: We should never disallow pausing, and we need to do + // something about pausing during cutscene moves, credits, etc. - _sound->pauseAllSound(); - _mouse->pauseGame(); + // Don't allow Pause while screen fading or while black + if (_screen->getFadeStatus() != RDFADE_NONE) + return; - // If render level is at max, turn it down because palette-matching - // won't work when the palette is dimmed. + _sound->pauseAllSound(); + _mouse->pauseEngine(true); - if (_screen->getRenderLevel() == 3) { - _screen->setRenderLevel(2); - _graphicsLevelFudged = true; - } + // If render level is at max, turn it down because palette- + // matching won't work when the palette is dimmed. + + if (_screen->getRenderLevel() == 3) { + _screen->setRenderLevel(2); + _graphicsLevelFudged = true; + } #ifdef SWORD2_DEBUG - // Don't dim it if we're single-stepping through frames - // dim the palette during the pause + // Don't dim it if we're single-stepping through frames + // dim the palette during the pause - if (!_stepOneCycle) - _screen->dimPalette(); + if (!_stepOneCycle) + _screen->dimPalette(); #else - _screen->dimPalette(); + _screen->dimPalette(); #endif - _gamePaused = true; -} - -void Sword2Engine::unpauseGame() { - _mouse->unpauseGame(); - _sound->unpauseAllSound(); + _gamePaused = true; + } else { + _mouse->pauseEngine(false); + _sound->unpauseAllSound(); - // Put back game screen palette; see screen.cpp - _screen->setFullPalette(-1); + // Put back game screen palette; see screen.cpp + _screen->setFullPalette(-1); - // If graphics level at max, turn up again - if (_graphicsLevelFudged) { - _screen->setRenderLevel(3); - _graphicsLevelFudged = false; - } + // If graphics level at max, turn up again + if (_graphicsLevelFudged) { + _screen->setRenderLevel(3); + _graphicsLevelFudged = false; + } - _gamePaused = false; + _gamePaused = false; - // If mouse is about or we're in a chooser menu - if (!_mouse->getMouseStatus() || _mouse->isChoosing()) - _mouse->setMouse(NORMAL_MOUSE_ID); + // If mouse is about or we're in a chooser menu + if (!_mouse->getMouseStatus() || _mouse->isChoosing()) + _mouse->setMouse(NORMAL_MOUSE_ID); + } } uint32 Sword2Engine::getMillis() { diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h index a9a1e21875..ba59772a71 100644 --- a/engines/sword2/sword2.h +++ b/engines/sword2/sword2.h @@ -113,8 +113,7 @@ private: uint32 calcChecksum(byte *buffer, uint32 size); - void pauseGame(); - void unpauseGame(); + virtual void pauseEngineIntern(bool pause); uint32 _totalStartups; uint32 _totalScreenManagers; |