diff options
author | Max Horn | 2007-06-30 18:22:21 +0000 |
---|---|---|
committer | Max Horn | 2007-06-30 18:22:21 +0000 |
commit | fed38a794f8cd810e7b50f59d71b4c0fc581d6fc (patch) | |
tree | 39972f0dfb98966035fb999a520848c39ccc2aed /engines/scumm | |
parent | 6064b876259ce7beca2c32d1b48ea0817149136b (diff) | |
download | scummvm-rg350-fed38a794f8cd810e7b50f59d71b4c0fc581d6fc.tar.gz scummvm-rg350-fed38a794f8cd810e7b50f59d71b4c0fc581d6fc.tar.bz2 scummvm-rg350-fed38a794f8cd810e7b50f59d71b4c0fc581d6fc.zip |
Added Engine::pauseEngine method (allows outside code, like the backend, to pause/resume the active engine); made the global 'confirm exit' dialog use that feature; implemented ScummEngine::pauseEngine
svn-id: r27797
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/scumm.cpp | 57 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 26 |
2 files changed, 56 insertions, 27 deletions
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 4b3a365394..aa6bea45bf 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -120,6 +120,8 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _gdi = new Gdi(this); } _res = new ResourceManager(this); + + _pauseLevel = 0; // Convert MD5 checksum back into a digest for (int i = 0; i < 16; ++i) { @@ -2236,31 +2238,50 @@ void ScummEngine::startManiac() { #pragma mark --- GUI --- #pragma mark - -int ScummEngine::runDialog(Dialog &dialog) { - _dialogStartTime = _system->getMillis() / 1000; +void ScummEngine::pauseEngine(bool pause) { + assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel)); - // Pause sound & video - bool old_soundsPaused = _sound->_soundsPaused; - _sound->pauseSounds(true); + if (pause) + _pauseLevel++; + else + _pauseLevel--; - bool visible = CursorMan.isVisible(); + if (_pauseLevel == 1) { + _pauseStartTime = _system->getMillis(); - // Open & run the dialog - int result = dialog.runModal(); + // Pause sound & video + _oldSoundsPaused = _sound->_soundsPaused; + _sound->pauseSounds(true); + + //bool visible = CursorMan.isVisible(); + + } else if (_pauseLevel == 0) { + // Restore old cursor -- FIXME: Should be obsolete thanks to CursorMan + //updateCursor(); + //CursorMan.showMouse(visible); - // Restore old cursor - updateCursor(); - CursorMan.showMouse(visible); + // Update the screen to make it less likely that the player will see a + // brief cursor palette glitch when the GUI is disabled. + _system->updateScreen(); - // Update the screen to make it less likely that the player will see a - // brief cursor palette glitch when the GUI is disabled. - _system->updateScreen(); + // Resume sound & video + _sound->pauseSounds(_oldSoundsPaused); - // Resume sound & video - _sound->pauseSounds(old_soundsPaused); + // Adjust engine start time + _engineStartTime += (_system->getMillis() - _pauseStartTime) / 1000; + _pauseStartTime = 0; + } +} + +int ScummEngine::runDialog(Dialog &dialog) { + // Pause engine + pauseEngine(true); + + // Open & run the dialog + int result = dialog.runModal(); - _engineStartTime += (_system->getMillis() / 1000) - _dialogStartTime; - _dialogStartTime = 0; + // Resume engine + pauseEngine(false); // Return the result return result; diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 3a5e9fb1ba..5c2249d198 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -406,9 +406,6 @@ class ScummEngine : public Engine { friend class CharsetRenderer; friend class ResourceManager; - GUI::Debugger *getDebugger(); - void errorString(const char *buf_input, char *buf_output); - public: /* Put often used variables at the top. * That results in a shorter form of the opcode @@ -437,17 +434,28 @@ public: protected: VirtualMachineState vm; + + /** + * The pause level, 0 means 'running', a positive value indicates + * how often the engine has been paused (and hence how often it has + * to be un-paused before it resumes running). This makes it possible + * to nest code which pauses the engine. + */ + int _pauseLevel; + + bool _oldSoundsPaused; public: // Constructor / Destructor ScummEngine(OSystem *syst, const DetectorResult &dr); virtual ~ScummEngine(); - /** Startup function, main loop. */ - int go(); - - // Init functions - int init(); + // Engine APIs + virtual int init(); + virtual int go(); + virtual void errorString(const char *buf_input, char *buf_output); + virtual GUI::Debugger *getDebugger(); + virtual void pauseEngine(bool pause); protected: virtual void setupScumm(); @@ -638,7 +646,7 @@ protected: void saveInfos(Common::OutSaveFile* file); int32 _engineStartTime; - int32 _dialogStartTime; + int32 _pauseStartTime; protected: /* Script VM - should be in Script class */ |