diff options
author | Max Horn | 2003-06-08 12:11:14 +0000 |
---|---|---|
committer | Max Horn | 2003-06-08 12:11:14 +0000 |
commit | be9e6e85db6ecbaaefcc8fe46066e0ac34bf1201 (patch) | |
tree | 482155e803af627d1d335605c1e93bece8ea541b | |
parent | 083f4c48455d2bdeb84877c7f3ce2b0169bff94e (diff) | |
download | scummvm-rg350-be9e6e85db6ecbaaefcc8fe46066e0ac34bf1201.tar.gz scummvm-rg350-be9e6e85db6ecbaaefcc8fe46066e0ac34bf1201.tar.bz2 scummvm-rg350-be9e6e85db6ecbaaefcc8fe46066e0ac34bf1201.zip |
added quit event
svn-id: r8398
-rw-r--r-- | backends/sdl/sdl-common.cpp | 44 | ||||
-rw-r--r-- | common/system.h | 4 | ||||
-rw-r--r-- | gui/newgui.cpp | 3 | ||||
-rw-r--r-- | scumm/dialogs.cpp | 4 | ||||
-rw-r--r-- | scumm/scumm.h | 6 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 31 | ||||
-rw-r--r-- | simon/simon.cpp | 4 | ||||
-rw-r--r-- | sky/sky.cpp | 4 |
8 files changed, 52 insertions, 48 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index e6a4069356..cbf48c0819 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -41,12 +41,6 @@ #define JOY_BUT_SPACE 4 #define JOY_BUT_F5 5 -bool atexit_proc_installed = false; -void atexit_proc() { - SDL_ShowCursor(SDL_ENABLE); - SDL_Quit(); -} - OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen) { return OSystem_SDL_Common::create(gfx_mode, full_screen); } @@ -80,12 +74,6 @@ void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen) { setup_icon(); #endif -#ifndef MACOSX // Work around a bug in OS X - // Clean up on exit - atexit_proc_installed = true; - atexit(atexit_proc); -#endif - // enable joystick if (SDL_NumJoysticks() > 0) { printf("Using joystick: %s\n", SDL_JoystickName(0)); @@ -118,11 +106,16 @@ OSystem_SDL_Common::OSystem_SDL_Common() } OSystem_SDL_Common::~OSystem_SDL_Common() { +// unload_gfx_mode(); + if (_dirty_checksums) free(_dirty_checksums); free(_currentPalette); free(_mouseBackup); SDL_DestroyMutex(_mutex); + + SDL_ShowCursor(SDL_ENABLE); + SDL_Quit(); } void OSystem_SDL_Common::init_size(uint w, uint h) { @@ -139,13 +132,6 @@ void OSystem_SDL_Common::init_size(uint w, uint h) { unload_gfx_mode(); load_gfx_mode(); - -#ifdef MACOSX // Work around a bug in OS X 10.1 related to OpenGL in windowed mode - if (!atexit_proc_installed) { - atexit_proc_installed = true; - atexit(atexit_proc); - } -#endif } void OSystem_SDL_Common::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) { @@ -549,15 +535,15 @@ bool OSystem_SDL_Common::poll_event(Event *event) { // Ctrl-z and Alt-X quit if ((b == KBD_CTRL && ev.key.keysym.sym=='z') || (b == KBD_ALT && ev.key.keysym.sym=='x')) { - quit(); - break; + event->event_code = EVENT_QUIT; + return true;; } #ifdef MACOSX // On Macintosh', Cmd-Q quits if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym=='q') { - quit(); - break; + event->event_code = EVENT_QUIT; + return true;; } #endif // Ctr-Alt-<key> will change the GFX mode @@ -578,8 +564,8 @@ bool OSystem_SDL_Common::poll_event(Event *event) { #ifdef QTOPIA // quit on fn+backspace on zaurus if (ev.key.keysym.sym == 127) { - quit(); - break; + event->event_code = EVENT_QUIT; + return true;; } // map menu key (f11) to f5 (scumm menu) @@ -825,8 +811,8 @@ bool OSystem_SDL_Common::poll_event(Event *event) { break; case SDL_QUIT: - quit(); - break; + event->event_code = EVENT_QUIT; + return true;; } } return false; @@ -890,6 +876,10 @@ void OSystem_SDL_Common::quit() { SDL_CDClose(_cdrom); } unload_gfx_mode(); + + SDL_ShowCursor(SDL_ENABLE); + SDL_Quit(); + exit(0); } diff --git a/common/system.h b/common/system.h index 21cfb29fd2..d8c06d1ef0 100644 --- a/common/system.h +++ b/common/system.h @@ -57,7 +57,9 @@ public: EVENT_RBUTTONDOWN = 6, EVENT_RBUTTONUP = 7, EVENT_WHEELUP = 8, - EVENT_WHEELDOWN = 9 + EVENT_WHEELDOWN = 9, + + EVENT_QUIT = 10 }; enum { diff --git a/gui/newgui.cpp b/gui/newgui.cpp index f1292d49bc..f45f599e44 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -190,6 +190,9 @@ void NewGui::runLoop() { case OSystem::EVENT_WHEELDOWN: activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1); break; + case OSystem::EVENT_QUIT: + _system->quit(); + break; } } 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 + } } } diff --git a/simon/simon.cpp b/simon/simon.cpp index ee6926d38c..d209fddeed 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -4488,6 +4488,10 @@ void SimonEngine::delay(uint amount) { else _exit_cutscene = true; break; + + case OSystem::EVENT_QUIT: + _system->quit(); + break; default: break; diff --git a/sky/sky.cpp b/sky/sky.cpp index bd402f826c..1effbef8f9 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -296,6 +296,10 @@ void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp _skyMouse->buttonPressed(2); break; + case OSystem::EVENT_QUIT: + _system->quit(); + break; + default: break; } |