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
This commit is contained in:
Max Horn 2007-06-30 18:22:21 +00:00
parent 6064b87625
commit fed38a794f
4 changed files with 87 additions and 45 deletions

View file

@ -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 -
void ScummEngine::pauseEngine(bool pause) {
assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel));
if (pause)
_pauseLevel++;
else
_pauseLevel--;
if (_pauseLevel == 1) {
_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);
// 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);
// Adjust engine start time
_engineStartTime += (_system->getMillis() - _pauseStartTime) / 1000;
_pauseStartTime = 0;
}
}
int ScummEngine::runDialog(Dialog &dialog) {
_dialogStartTime = _system->getMillis() / 1000;
// Pause sound & video
bool old_soundsPaused = _sound->_soundsPaused;
_sound->pauseSounds(true);
bool visible = CursorMan.isVisible();
// Pause engine
pauseEngine(true);
// Open & run the dialog
int result = dialog.runModal();
// 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();
// Resume sound & video
_sound->pauseSounds(old_soundsPaused);
_engineStartTime += (_system->getMillis() / 1000) - _dialogStartTime;
_dialogStartTime = 0;
// Resume engine
pauseEngine(false);
// Return the result
return result;