aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-07-28 01:36:16 +0000
committerMax Horn2003-07-28 01:36:16 +0000
commitd592095fb942e961773e8177056d973eb1cff092 (patch)
treea5b0889b20ec589d56fc17c2c6edd3ad01150743
parente87bc6d89e260afd6e116c7eace991876cfa4acf (diff)
downloadscummvm-rg350-d592095fb942e961773e8177056d973eb1cff092.tar.gz
scummvm-rg350-d592095fb942e961773e8177056d973eb1cff092.tar.bz2
scummvm-rg350-d592095fb942e961773e8177056d973eb1cff092.zip
Patch #715991: Quit Confirmation Dialog (feature request #642721) with some tweaks by me
svn-id: r9210
-rw-r--r--common/gameDetector.cpp3
-rw-r--r--common/gameDetector.h1
-rw-r--r--scumm/dialogs.cpp15
-rw-r--r--scumm/dialogs.h6
-rw-r--r--scumm/scumm.h10
-rw-r--r--scumm/scummvm.cpp16
6 files changed, 50 insertions, 1 deletions
diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp
index feef3aa2dc..7e04296129 100644
--- a/common/gameDetector.cpp
+++ b/common/gameDetector.cpp
@@ -192,6 +192,7 @@ GameDetector::GameDetector() {
_save_slot = 0;
_saveconfig = false;
+ _confirmExit = false;
#ifndef _WIN32_WCE
_gfx_mode = GFX_DOUBLESIZE;
@@ -301,6 +302,8 @@ void GameDetector::updateconfig() {
_talkSpeed = g_config->getInt("talkspeed", _talkSpeed);
+ _confirmExit = g_config->getBool("confirm_exit", _confirmExit ? true : false);
+
_multi_midi = g_config->getBool ("multi_midi", _multi_midi);
_native_mt32 = g_config->getBool ("native_mt32", _native_mt32);
}
diff --git a/common/gameDetector.h b/common/gameDetector.h
index d65072b6cb..226ffe3ea0 100644
--- a/common/gameDetector.h
+++ b/common/gameDetector.h
@@ -148,6 +148,7 @@ public:
int _save_slot;
bool _saveconfig;
+ bool _confirmExit;
public:
OSystem *createSystem();
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp
index e7f6fe8d54..bdaef6383e 100644
--- a/scumm/dialogs.cpp
+++ b/scumm/dialogs.cpp
@@ -681,6 +681,21 @@ PauseDialog::PauseDialog(NewGui *gui, Scumm *scumm)
: 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
#pragma mark -
diff --git a/scumm/dialogs.h b/scumm/dialogs.h
index e1cf535080..e9ae03d38a 100644
--- a/scumm/dialogs.h
+++ b/scumm/dialogs.h
@@ -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
class KeysDialog : public ScummDialog {
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 6f85d6bb76..06d2c087ee 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -387,16 +387,23 @@ public:
// GUI
NewGui *_newgui;
+protected:
Dialog *_pauseDialog;
Dialog *_optionsDialog;
Dialog *_saveLoadDialog;
+ Dialog *_confirmExitDialog;
+public:
// Debugger access this one, too...
ConsoleDialog *_debuggerDialog;
+protected:
int runDialog(Dialog *dialog);
+ void confirmexitDialog();
void pauseDialog();
void saveloadDialog();
- void optionsDialog();
+public:
+ void optionsDialog(); // Used by SaveLoadDialog::handleCommand()
+protected:
char displayError(bool showCancel, const char *message, ...);
protected:
@@ -1060,6 +1067,7 @@ protected:
public:
bool _noSubtitles; // Whether to skip all subtitles
+ bool _confirmExit;
protected:
void initCharset(int charset);
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 80f6e33ca8..45f24c8003 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -232,6 +232,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_pauseDialog = NULL;
_optionsDialog = NULL;
_saveLoadDialog = NULL;
+ _confirmExitDialog = NULL;
_debuggerDialog = NULL;
_fastMode = 0;
memset(&_rnd, 0, sizeof(RandomSource));
@@ -394,6 +395,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_charsetBufPos = 0;
memset(_charsetBuffer, 0, sizeof(_charsetBuffer));
_noSubtitles = false;
+ _confirmExit = false;
_numInMsgStack = 0;
_msgPtrToAdd = NULL;
_messagePtr = NULL;
@@ -545,6 +547,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
setFeatures(detector->_game.features);
_noSubtitles = detector->_noSubtitles;
+ _confirmExit = detector->_confirmExit;
_defaultTalkDelay = detector->_talkSpeed;
_use_adlib = detector->_use_adlib;
_language = detector->_language;
@@ -709,6 +712,7 @@ Scumm::~Scumm () {
delete _pauseDialog;
delete _optionsDialog;
delete _saveLoadDialog;
+ delete _confirmExitDialog;
delete _sound;
delete _imuse;
@@ -1459,6 +1463,9 @@ void Scumm::parseEvents() {
break;
case OSystem::EVENT_QUIT:
+ if(_confirmExit)
+ confirmexitDialog();
+ else
_quit = true;
break;
@@ -2301,6 +2308,15 @@ void Scumm::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, ...) {
#ifdef __PALM_OS__
char buf[256], result; // 1024 is too big overflow the stack