Patch #715991: Quit Confirmation Dialog (feature request #642721) with some tweaks by me

svn-id: r9210
This commit is contained in:
Max Horn 2003-07-28 01:36:16 +00:00
parent e87bc6d89e
commit d592095fb9
6 changed files with 50 additions and 1 deletions

View file

@ -192,6 +192,7 @@ GameDetector::GameDetector() {
_save_slot = 0; _save_slot = 0;
_saveconfig = false; _saveconfig = false;
_confirmExit = false;
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
_gfx_mode = GFX_DOUBLESIZE; _gfx_mode = GFX_DOUBLESIZE;
@ -301,6 +302,8 @@ void GameDetector::updateconfig() {
_talkSpeed = g_config->getInt("talkspeed", _talkSpeed); _talkSpeed = g_config->getInt("talkspeed", _talkSpeed);
_confirmExit = g_config->getBool("confirm_exit", _confirmExit ? true : false);
_multi_midi = g_config->getBool ("multi_midi", _multi_midi); _multi_midi = g_config->getBool ("multi_midi", _multi_midi);
_native_mt32 = g_config->getBool ("native_mt32", _native_mt32); _native_mt32 = g_config->getBool ("native_mt32", _native_mt32);
} }

View file

@ -148,6 +148,7 @@ public:
int _save_slot; int _save_slot;
bool _saveconfig; bool _saveconfig;
bool _confirmExit;
public: public:
OSystem *createSystem(); OSystem *createSystem();

View file

@ -681,6 +681,21 @@ PauseDialog::PauseDialog(NewGui *gui, Scumm *scumm)
: InfoDialog(gui, scumm, 10) { : InfoDialog(gui, scumm, 10) {
} }
ConfirmExitDialog::ConfirmExitDialog(NewGui *gui, Scumm *scumm)
: InfoDialog(gui, scumm, "Do you really want to quit (y/n)?") {
}
void ConfirmExitDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
if (tolower(ascii) == 'n') { // Close exit dialog if n key is pressed
setResult(0);
close();
} else if (tolower(ascii) == 'y') { // Quit if y key is pressed
setResult(1);
close();
} else
ScummDialog::handleKeyDown(ascii, keycode, modifiers);
}
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
#pragma mark - #pragma mark -

View file

@ -167,6 +167,12 @@ public:
} }
}; };
class ConfirmExitDialog : public InfoDialog {
public:
ConfirmExitDialog(NewGui *gui, Scumm *scumm);
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
};
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
class KeysDialog : public ScummDialog { class KeysDialog : public ScummDialog {

View file

@ -387,16 +387,23 @@ public:
// GUI // GUI
NewGui *_newgui; NewGui *_newgui;
protected:
Dialog *_pauseDialog; Dialog *_pauseDialog;
Dialog *_optionsDialog; Dialog *_optionsDialog;
Dialog *_saveLoadDialog; Dialog *_saveLoadDialog;
Dialog *_confirmExitDialog;
public:
// Debugger access this one, too... // Debugger access this one, too...
ConsoleDialog *_debuggerDialog; ConsoleDialog *_debuggerDialog;
protected:
int runDialog(Dialog *dialog); int runDialog(Dialog *dialog);
void confirmexitDialog();
void pauseDialog(); void pauseDialog();
void saveloadDialog(); void saveloadDialog();
void optionsDialog(); public:
void optionsDialog(); // Used by SaveLoadDialog::handleCommand()
protected:
char displayError(bool showCancel, const char *message, ...); char displayError(bool showCancel, const char *message, ...);
protected: protected:
@ -1060,6 +1067,7 @@ protected:
public: public:
bool _noSubtitles; // Whether to skip all subtitles bool _noSubtitles; // Whether to skip all subtitles
bool _confirmExit;
protected: protected:
void initCharset(int charset); void initCharset(int charset);

View file

@ -232,6 +232,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_pauseDialog = NULL; _pauseDialog = NULL;
_optionsDialog = NULL; _optionsDialog = NULL;
_saveLoadDialog = NULL; _saveLoadDialog = NULL;
_confirmExitDialog = NULL;
_debuggerDialog = NULL; _debuggerDialog = NULL;
_fastMode = 0; _fastMode = 0;
memset(&_rnd, 0, sizeof(RandomSource)); memset(&_rnd, 0, sizeof(RandomSource));
@ -394,6 +395,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_charsetBufPos = 0; _charsetBufPos = 0;
memset(_charsetBuffer, 0, sizeof(_charsetBuffer)); memset(_charsetBuffer, 0, sizeof(_charsetBuffer));
_noSubtitles = false; _noSubtitles = false;
_confirmExit = false;
_numInMsgStack = 0; _numInMsgStack = 0;
_msgPtrToAdd = NULL; _msgPtrToAdd = NULL;
_messagePtr = NULL; _messagePtr = NULL;
@ -545,6 +547,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
setFeatures(detector->_game.features); setFeatures(detector->_game.features);
_noSubtitles = detector->_noSubtitles; _noSubtitles = detector->_noSubtitles;
_confirmExit = detector->_confirmExit;
_defaultTalkDelay = detector->_talkSpeed; _defaultTalkDelay = detector->_talkSpeed;
_use_adlib = detector->_use_adlib; _use_adlib = detector->_use_adlib;
_language = detector->_language; _language = detector->_language;
@ -709,6 +712,7 @@ Scumm::~Scumm () {
delete _pauseDialog; delete _pauseDialog;
delete _optionsDialog; delete _optionsDialog;
delete _saveLoadDialog; delete _saveLoadDialog;
delete _confirmExitDialog;
delete _sound; delete _sound;
delete _imuse; delete _imuse;
@ -1459,6 +1463,9 @@ void Scumm::parseEvents() {
break; break;
case OSystem::EVENT_QUIT: case OSystem::EVENT_QUIT:
if(_confirmExit)
confirmexitDialog();
else
_quit = true; _quit = true;
break; break;
@ -2301,6 +2308,15 @@ void Scumm::optionsDialog() {
runDialog(_optionsDialog); runDialog(_optionsDialog);
} }
void Scumm::confirmexitDialog() {
if (!_confirmExitDialog)
_confirmExitDialog = new ConfirmExitDialog(_newgui, this);
if (runDialog(_confirmExitDialog)) {
_quit = true;
}
}
char Scumm::displayError(bool showCancel, const char *message, ...) { char Scumm::displayError(bool showCancel, const char *message, ...) {
#ifdef __PALM_OS__ #ifdef __PALM_OS__
char buf[256], result; // 1024 is too big overflow the stack char buf[256], result; // 1024 is too big overflow the stack