aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2007-06-30 22:22:25 +0000
committerMax Horn2007-06-30 22:22:25 +0000
commit9027076e5d1f7dbf8677cd7f919bab77ef30461b (patch)
treeb43d605de812bc987e200cec4cde009c7ed596d1 /engines
parentf445d8c8004536d12b049ec189ea6dd218295c88 (diff)
downloadscummvm-rg350-9027076e5d1f7dbf8677cd7f919bab77ef30461b.tar.gz
scummvm-rg350-9027076e5d1f7dbf8677cd7f919bab77ef30461b.tar.bz2
scummvm-rg350-9027076e5d1f7dbf8677cd7f919bab77ef30461b.zip
Split Engine::pauseEngine: It now does pauseLevel handling, while engines can provide a simpler pauseEngineIntern method; provided default implementation of the latter which simply (un)pauses the mixer
svn-id: r27801
Diffstat (limited to 'engines')
-rw-r--r--engines/engine.cpp20
-rw-r--r--engines/engine.h31
-rw-r--r--engines/scumm/scumm.cpp23
-rw-r--r--engines/scumm/scumm.h10
4 files changed, 54 insertions, 30 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 05e2235cc9..c5766afd88 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -180,3 +180,23 @@ void Engine::GUIErrorMessage(const Common::String msg) {
GUI::MessageDialog dialog(msg);
dialog.runModal();
}
+
+void Engine::pauseEngine(bool pause) {
+ assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel));
+
+ if (pause)
+ _pauseLevel++;
+ else
+ _pauseLevel--;
+
+ if (_pauseLevel == 1) {
+ pauseEngineIntern(true);
+ } else if (_pauseLevel == 0) {
+ pauseEngineIntern(false);
+ }
+}
+
+void Engine::pauseEngineIntern(bool pause) {
+ // By default, just (un)pause all digital sounds
+ _mixer->pauseAll(pause);
+}
diff --git a/engines/engine.h b/engines/engine.h
index 45a8ef7d87..f9aeb7718f 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -56,7 +56,18 @@ protected:
const Common::String _gameDataPath;
private:
+ /**
+ * The autosave interval, given in second. Used by shouldPerformAutoSave.
+ */
int _autosavePeriod;
+
+ /**
+ * 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;
public:
Engine(OSystem *syst);
@@ -90,10 +101,18 @@ public:
* and other stuff. Called right before the system runs a global dialog
* (like a global pause, main menu, options or 'confirm exit' dialog).
*
+ * This is a convenience tracker which automatically keeps track on how
+ * often the engine has been paused, ensuring that after pausing an engine
+ * e.g. twice, it has to be unpaused twice before actuallying resuming.
+ *
* @param pause true to pause the engine, false to resume it
*/
- virtual void pauseEngine(bool pause) {}
-
+ void pauseEngine(bool pause);
+
+ /**
+ * Return whether the engine is currently paused or not.
+ */
+ bool isPaused() const { return _pauseLevel != 0; }
public:
@@ -103,11 +122,17 @@ public:
/** On some systems, check if the game appears to be run from CD. */
void checkCD();
- /** Indicate if an autosave should be performed. */
+ /** Indicate whether an autosave should be performed. */
bool shouldPerformAutoSave(int lastSaveTime);
/** Initialized graphics and shows error message. */
void GUIErrorMessage(const Common::String msg);
+
+ /**
+ * Actual implementation of pauseEngine by subclasses. See there
+ * for details.
+ */
+ virtual void pauseEngineIntern(bool pause);
};
extern Engine *g_engine;
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index aa6bea45bf..2140b15544 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -121,8 +121,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
}
_res = new ResourceManager(this);
- _pauseLevel = 0;
-
// Convert MD5 checksum back into a digest
for (int i = 0; i < 16; ++i) {
char tmpStr[3] = "00";
@@ -2238,28 +2236,17 @@ void ScummEngine::startManiac() {
#pragma mark --- GUI ---
#pragma mark -
-void ScummEngine::pauseEngine(bool pause) {
- assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel));
-
- if (pause)
- _pauseLevel++;
- else
- _pauseLevel--;
-
- if (_pauseLevel == 1) {
+void ScummEngine::pauseEngineIntern(bool pause) {
+ if (pause) {
+ // Record start of the pause, so that we can later
+ // adjust _engineStartTime accordingly.
_pauseStartTime = _system->getMillis();
// 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);
-
+ } else {
// 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();
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 5c2249d198..4146846856 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -435,14 +435,6 @@ 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:
@@ -455,7 +447,7 @@ public:
virtual int go();
virtual void errorString(const char *buf_input, char *buf_output);
virtual GUI::Debugger *getDebugger();
- virtual void pauseEngine(bool pause);
+ virtual void pauseEngineIntern(bool pause);
protected:
virtual void setupScumm();