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_SPACE 4
|
||||||
#define JOY_BUT_F5 5
|
#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) {
|
OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen) {
|
||||||
return OSystem_SDL_Common::create(gfx_mode, 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();
|
setup_icon();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MACOSX // Work around a bug in OS X
|
|
||||||
// Clean up on exit
|
|
||||||
atexit_proc_installed = true;
|
|
||||||
atexit(atexit_proc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// enable joystick
|
// enable joystick
|
||||||
if (SDL_NumJoysticks() > 0) {
|
if (SDL_NumJoysticks() > 0) {
|
||||||
printf("Using joystick: %s\n", SDL_JoystickName(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() {
|
OSystem_SDL_Common::~OSystem_SDL_Common() {
|
||||||
|
// unload_gfx_mode();
|
||||||
|
|
||||||
if (_dirty_checksums)
|
if (_dirty_checksums)
|
||||||
free(_dirty_checksums);
|
free(_dirty_checksums);
|
||||||
free(_currentPalette);
|
free(_currentPalette);
|
||||||
free(_mouseBackup);
|
free(_mouseBackup);
|
||||||
SDL_DestroyMutex(_mutex);
|
SDL_DestroyMutex(_mutex);
|
||||||
|
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSystem_SDL_Common::init_size(uint w, uint h) {
|
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();
|
unload_gfx_mode();
|
||||||
load_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) {
|
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
|
// Ctrl-z and Alt-X quit
|
||||||
if ((b == KBD_CTRL && ev.key.keysym.sym=='z') || (b == KBD_ALT && ev.key.keysym.sym=='x')) {
|
if ((b == KBD_CTRL && ev.key.keysym.sym=='z') || (b == KBD_ALT && ev.key.keysym.sym=='x')) {
|
||||||
quit();
|
event->event_code = EVENT_QUIT;
|
||||||
break;
|
return true;;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
// On Macintosh', Cmd-Q quits
|
// On Macintosh', Cmd-Q quits
|
||||||
if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym=='q') {
|
if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym=='q') {
|
||||||
quit();
|
event->event_code = EVENT_QUIT;
|
||||||
break;
|
return true;;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Ctr-Alt-<key> will change the GFX mode
|
// Ctr-Alt-<key> will change the GFX mode
|
||||||
|
@ -578,8 +564,8 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
|
||||||
#ifdef QTOPIA
|
#ifdef QTOPIA
|
||||||
// quit on fn+backspace on zaurus
|
// quit on fn+backspace on zaurus
|
||||||
if (ev.key.keysym.sym == 127) {
|
if (ev.key.keysym.sym == 127) {
|
||||||
quit();
|
event->event_code = EVENT_QUIT;
|
||||||
break;
|
return true;;
|
||||||
}
|
}
|
||||||
|
|
||||||
// map menu key (f11) to f5 (scumm menu)
|
// map menu key (f11) to f5 (scumm menu)
|
||||||
|
@ -825,8 +811,8 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
quit();
|
event->event_code = EVENT_QUIT;
|
||||||
break;
|
return true;;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -890,6 +876,10 @@ void OSystem_SDL_Common::quit() {
|
||||||
SDL_CDClose(_cdrom);
|
SDL_CDClose(_cdrom);
|
||||||
}
|
}
|
||||||
unload_gfx_mode();
|
unload_gfx_mode();
|
||||||
|
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,9 @@ public:
|
||||||
EVENT_RBUTTONDOWN = 6,
|
EVENT_RBUTTONDOWN = 6,
|
||||||
EVENT_RBUTTONUP = 7,
|
EVENT_RBUTTONUP = 7,
|
||||||
EVENT_WHEELUP = 8,
|
EVENT_WHEELUP = 8,
|
||||||
EVENT_WHEELDOWN = 9
|
EVENT_WHEELDOWN = 9,
|
||||||
|
|
||||||
|
EVENT_QUIT = 10
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -190,6 +190,9 @@ void NewGui::runLoop() {
|
||||||
case OSystem::EVENT_WHEELDOWN:
|
case OSystem::EVENT_WHEELDOWN:
|
||||||
activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1);
|
activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1);
|
||||||
break;
|
break;
|
||||||
|
case OSystem::EVENT_QUIT:
|
||||||
|
_system->quit();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,10 +298,8 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
_scumm->optionsDialog();
|
_scumm->optionsDialog();
|
||||||
break;
|
break;
|
||||||
case kQuitCmd:
|
case kQuitCmd:
|
||||||
#ifdef __PALM_OS__
|
_scumm->_quit = true;
|
||||||
close();
|
close();
|
||||||
#endif
|
|
||||||
_scumm->_system->quit();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ScummDialog::handleCommand(sender, cmd, data);
|
ScummDialog::handleCommand(sender, cmd, data);
|
||||||
|
|
|
@ -354,9 +354,9 @@ public:
|
||||||
void shutDown();
|
void shutDown();
|
||||||
void setOptions(void);
|
void setOptions(void);
|
||||||
|
|
||||||
#ifdef __PALM_OS__
|
/** We keep running until this is set to true. */
|
||||||
bool _quit; // try to exit properly
|
bool _quit;
|
||||||
#endif
|
|
||||||
// GUI
|
// GUI
|
||||||
NewGui *_newgui;
|
NewGui *_newgui;
|
||||||
|
|
||||||
|
|
|
@ -231,16 +231,14 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
|
||||||
_objs = NULL;
|
_objs = NULL;
|
||||||
_debugger = NULL;
|
_debugger = NULL;
|
||||||
_bundle = NULL;
|
_bundle = NULL;
|
||||||
_sound= NULL;
|
_sound = NULL;
|
||||||
memset(&res, 0, sizeof(res));
|
memset(&res, 0, sizeof(res));
|
||||||
memset(&vm, 0, sizeof(vm));
|
memset(&vm, 0, sizeof(vm));
|
||||||
_smushFrameRate = 0;
|
_smushFrameRate = 0;
|
||||||
_insaneState = 0;
|
_insaneState = false;
|
||||||
_videoFinished = 0;
|
_videoFinished = false;
|
||||||
_smushPlay = 0;
|
_smushPlay = false;
|
||||||
#ifdef __PALM_OS__
|
|
||||||
_quit = false;
|
_quit = false;
|
||||||
#endif
|
|
||||||
_newgui = NULL;
|
_newgui = NULL;
|
||||||
_pauseDialog = NULL;
|
_pauseDialog = NULL;
|
||||||
_optionsDialog = NULL;
|
_optionsDialog = NULL;
|
||||||
|
@ -249,7 +247,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
|
||||||
_fastMode = 0;
|
_fastMode = 0;
|
||||||
memset(&_rnd, 0, sizeof(RandomSource));
|
memset(&_rnd, 0, sizeof(RandomSource));
|
||||||
_gameId = 0;
|
_gameId = 0;
|
||||||
memset(&gdi,0,sizeof(Gdi));
|
memset(&gdi, 0, sizeof(Gdi));
|
||||||
_actors = NULL;
|
_actors = NULL;
|
||||||
_inventory = NULL;
|
_inventory = NULL;
|
||||||
_newNames = NULL;
|
_newNames = NULL;
|
||||||
|
@ -1878,8 +1876,7 @@ char Scumm::displayError(bool showCancel, const char *message, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::shutDown() {
|
void Scumm::shutDown() {
|
||||||
// FIXME: This is ugly
|
_quit = true;
|
||||||
_system->quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::restart() {
|
void Scumm::restart() {
|
||||||
|
@ -2342,6 +2339,10 @@ void Scumm::parseEvents() {
|
||||||
_rightBtnPressed &= ~msDown;
|
_rightBtnPressed &= ~msDown;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OSystem::EVENT_QUIT:
|
||||||
|
_quit = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2403,11 +2404,8 @@ void Scumm::mainRun() {
|
||||||
int delta = 0;
|
int delta = 0;
|
||||||
int diff = _system->get_msecs();
|
int diff = _system->get_msecs();
|
||||||
|
|
||||||
for (;;) {
|
while (!_quit) {
|
||||||
#ifdef __PALM_OS__
|
|
||||||
if (_quit) // palmfixme : need to check for autosave on exit
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
updatePalette();
|
updatePalette();
|
||||||
_system->update_screen();
|
_system->update_screen();
|
||||||
|
|
||||||
|
@ -2418,6 +2416,11 @@ void Scumm::mainRun() {
|
||||||
|
|
||||||
if (delta < 1) // Ensure we don't get into a loop
|
if (delta < 1) // Ensure we don't get into a loop
|
||||||
delta = 1; // by not decreasing sleepers.
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4489,6 +4489,10 @@ void SimonEngine::delay(uint amount) {
|
||||||
_exit_cutscene = true;
|
_exit_cutscene = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OSystem::EVENT_QUIT:
|
||||||
|
_system->quit();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,6 +296,10 @@ void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp
|
||||||
_skyMouse->buttonPressed(2);
|
_skyMouse->buttonPressed(2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OSystem::EVENT_QUIT:
|
||||||
|
_system->quit();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue