From be9e6e85db6ecbaaefcc8fe46066e0ac34bf1201 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 8 Jun 2003 12:11:14 +0000 Subject: added quit event svn-id: r8398 --- scumm/dialogs.cpp | 4 +--- scumm/scumm.h | 6 +++--- scumm/scummvm.cpp | 31 +++++++++++++++++-------------- 3 files changed, 21 insertions(+), 20 deletions(-) (limited to 'scumm') diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index 55ac8447b4..c3c9539cdf 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -298,10 +298,8 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat _scumm->optionsDialog(); break; case kQuitCmd: -#ifdef __PALM_OS__ + _scumm->_quit = true; close(); -#endif - _scumm->_system->quit(); break; default: ScummDialog::handleCommand(sender, cmd, data); diff --git a/scumm/scumm.h b/scumm/scumm.h index 58d6638796..a3b1c728d9 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -354,9 +354,9 @@ public: void shutDown(); void setOptions(void); -#ifdef __PALM_OS__ - bool _quit; // try to exit properly -#endif + /** We keep running until this is set to true. */ + bool _quit; + // GUI NewGui *_newgui; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 6b23232c1a..e4b952050d 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -231,16 +231,14 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _objs = NULL; _debugger = NULL; _bundle = NULL; - _sound= NULL; + _sound = NULL; memset(&res, 0, sizeof(res)); memset(&vm, 0, sizeof(vm)); _smushFrameRate = 0; - _insaneState = 0; - _videoFinished = 0; - _smushPlay = 0; -#ifdef __PALM_OS__ + _insaneState = false; + _videoFinished = false; + _smushPlay = false; _quit = false; -#endif _newgui = NULL; _pauseDialog = NULL; _optionsDialog = NULL; @@ -249,7 +247,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _fastMode = 0; memset(&_rnd, 0, sizeof(RandomSource)); _gameId = 0; - memset(&gdi,0,sizeof(Gdi)); + memset(&gdi, 0, sizeof(Gdi)); _actors = NULL; _inventory = NULL; _newNames = NULL; @@ -1878,8 +1876,7 @@ char Scumm::displayError(bool showCancel, const char *message, ...) { } void Scumm::shutDown() { - // FIXME: This is ugly - _system->quit(); + _quit = true; } void Scumm::restart() { @@ -2342,6 +2339,10 @@ void Scumm::parseEvents() { _rightBtnPressed &= ~msDown; break; + case OSystem::EVENT_QUIT: + _quit = true; + break; + default: break; } @@ -2403,11 +2404,8 @@ void Scumm::mainRun() { int delta = 0; int diff = _system->get_msecs(); - for (;;) { -#ifdef __PALM_OS__ - if (_quit) // palmfixme : need to check for autosave on exit - return; -#endif + while (!_quit) { + updatePalette(); _system->update_screen(); @@ -2418,6 +2416,11 @@ void Scumm::mainRun() { if (delta < 1) // Ensure we don't get into a loop delta = 1; // by not decreasing sleepers. + + if (_quit) { + // TODO: Maybe perform an autosave on exit? + // TODO: Also, we could optionally show a "Do you really want to quit?" dialog here + } } } -- cgit v1.2.3