mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 00:45:10 +00:00
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
This commit is contained in:
parent
f445d8c800
commit
9027076e5d
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user