[Scummvm-cvs-logs] CVS: scummvm/scumm dialogs.cpp,1.63,1.64 dialogs.h,1.20,1.21 scumm.h,1.274,1.275 scummvm.cpp,2.297,2.298

Max Horn fingolfin at users.sourceforge.net
Sun Jul 27 18:37:11 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv1135/scumm

Modified Files:
	dialogs.cpp dialogs.h scumm.h scummvm.cpp 
Log Message:
Patch #715991: Quit Confirmation Dialog (feature request #642721) with some tweaks by me

Index: dialogs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/dialogs.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- dialogs.cpp	22 Jul 2003 16:05:51 -0000	1.63
+++ dialogs.cpp	28 Jul 2003 01:36:16 -0000	1.64
@@ -681,6 +681,21 @@
 	: 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 -

Index: dialogs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/dialogs.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- dialogs.h	22 Jul 2003 16:05:51 -0000	1.20
+++ dialogs.h	28 Jul 2003 01:36:16 -0000	1.21
@@ -167,6 +167,12 @@
 		}
 };
 
+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 {

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.274
retrieving revision 1.275
diff -u -d -r1.274 -r1.275
--- scumm.h	22 Jul 2003 20:53:01 -0000	1.274
+++ scumm.h	28 Jul 2003 01:36:16 -0000	1.275
@@ -387,16 +387,23 @@
 	// 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 @@
 
 public:
 	bool _noSubtitles;	// Whether to skip all subtitles
+	bool _confirmExit;
 protected:
 
 	void initCharset(int charset);

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.297
retrieving revision 2.298
diff -u -d -r2.297 -r2.298
--- scummvm.cpp	22 Jul 2003 20:53:01 -0000	2.297
+++ scummvm.cpp	28 Jul 2003 01:36:16 -0000	2.298
@@ -232,6 +232,7 @@
 	_pauseDialog = NULL;
 	_optionsDialog = NULL;
 	_saveLoadDialog = NULL;
+	_confirmExitDialog = NULL;
 	_debuggerDialog = NULL;
 	_fastMode = 0;
 	memset(&_rnd, 0, sizeof(RandomSource));
@@ -394,6 +395,7 @@
 	_charsetBufPos = 0;
 	memset(_charsetBuffer, 0, sizeof(_charsetBuffer));
 	_noSubtitles = false;
+	_confirmExit = false;
 	_numInMsgStack = 0;
 	_msgPtrToAdd = NULL;
 	_messagePtr = NULL;
@@ -545,6 +547,7 @@
 	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 @@
 	delete _pauseDialog;
 	delete _optionsDialog;
 	delete _saveLoadDialog;
+	delete _confirmExitDialog;
 
 	delete _sound;
 	delete _imuse;
@@ -1459,6 +1463,9 @@
 			break;
 	
 		case OSystem::EVENT_QUIT:
+			if(_confirmExit)
+				confirmexitDialog();
+			else
 			_quit = true;
 			break;
 	
@@ -2299,6 +2306,15 @@
 	if (!_optionsDialog)
 		_optionsDialog = new OptionsDialog(_newgui, this);
 	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, ...) {





More information about the Scummvm-git-logs mailing list