[Scummvm-cvs-logs] SF.net SVN: scummvm: [27801] scummvm/trunk/engines
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sun Jul 1 00:22:26 CEST 2007
Revision: 27801
http://scummvm.svn.sourceforge.net/scummvm/?rev=27801&view=rev
Author: fingolfin
Date: 2007-06-30 15:22:25 -0700 (Sat, 30 Jun 2007)
Log Message:
-----------
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
Modified Paths:
--------------
scummvm/trunk/engines/engine.cpp
scummvm/trunk/engines/engine.h
scummvm/trunk/engines/scumm/scumm.cpp
scummvm/trunk/engines/scumm/scumm.h
Modified: scummvm/trunk/engines/engine.cpp
===================================================================
--- scummvm/trunk/engines/engine.cpp 2007-06-30 22:21:29 UTC (rev 27800)
+++ scummvm/trunk/engines/engine.cpp 2007-06-30 22:22:25 UTC (rev 27801)
@@ -180,3 +180,23 @@
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);
+}
Modified: scummvm/trunk/engines/engine.h
===================================================================
--- scummvm/trunk/engines/engine.h 2007-06-30 22:21:29 UTC (rev 27800)
+++ scummvm/trunk/engines/engine.h 2007-06-30 22:22:25 UTC (rev 27801)
@@ -56,7 +56,18 @@
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,11 +101,19 @@
* 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:
/** Setup the backend's graphics mode. */
@@ -103,11 +122,17 @@
/** 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;
Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp 2007-06-30 22:21:29 UTC (rev 27800)
+++ scummvm/trunk/engines/scumm/scumm.cpp 2007-06-30 22:22:25 UTC (rev 27801)
@@ -121,8 +121,6 @@
}
_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 @@
#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();
Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h 2007-06-30 22:21:29 UTC (rev 27800)
+++ scummvm/trunk/engines/scumm/scumm.h 2007-06-30 22:22:25 UTC (rev 27801)
@@ -435,14 +435,6 @@
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 @@
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();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list