added quit event
svn-id: r8398
This commit is contained in:
parent
083f4c4845
commit
be9e6e85db
8 changed files with 52 additions and 48 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,9 @@ public:
|
|||
EVENT_RBUTTONDOWN = 6,
|
||||
EVENT_RBUTTONUP = 7,
|
||||
EVENT_WHEELUP = 8,
|
||||
EVENT_WHEELDOWN = 9
|
||||
EVENT_WHEELDOWN = 9,
|
||||
|
||||
EVENT_QUIT = 10
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4488,6 +4488,10 @@ void SimonEngine::delay(uint amount) {
|
|||
else
|
||||
_exit_cutscene = true;
|
||||
break;
|
||||
|
||||
case OSystem::EVENT_QUIT:
|
||||
_system->quit();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue