Always confirm restart

svn-id: r11635
This commit is contained in:
Travis Howell 2003-12-14 15:04:05 +00:00
parent cbcca65d06
commit 2556f9b77a
4 changed files with 35 additions and 1 deletions

View File

@ -621,6 +621,21 @@ void ConfirmExitDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
ScummDialog::handleKeyDown(ascii, keycode, modifiers);
}
ConfirmRestartDialog::ConfirmRestartDialog(ScummEngine *scumm)
: InfoDialog(scumm, "Do you really want to quit (y/n)?") {
}
void ConfirmRestartDialog::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 -

View File

@ -157,6 +157,12 @@ public:
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
};
class ConfirmRestartDialog : public InfoDialog {
public:
ConfirmRestartDialog(ScummEngine *scumm);
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
};
#ifdef _WIN32_WCE
class KeysDialog : public ScummDialog {

View File

@ -352,10 +352,12 @@ protected:
Dialog *_optionsDialog;
Dialog *_mainMenuDialog;
Dialog *_confirmExitDialog;
Dialog *_confirmRestartDialog;
protected:
int runDialog(Dialog &dialog);
void confirmexitDialog();
void confirmrestartDialog();
void pauseDialog();
void mainMenuDialog();
public:

View File

@ -327,6 +327,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
_optionsDialog = NULL;
_mainMenuDialog = NULL;
_confirmExitDialog = NULL;
_confirmRestartDialog = NULL;
_fastMode = 0;
_actors = NULL;
_inventory = NULL;
@ -862,6 +863,7 @@ ScummEngine::~ScummEngine() {
delete _optionsDialog;
delete _mainMenuDialog;
delete _confirmExitDialog;
delete _confirmRestartDialog;
delete _sound;
if (_musicEngine) {
@ -1844,7 +1846,7 @@ void ScummEngine::processKbd() {
#endif
if (VAR_RESTART_KEY != 0xFF && _lastKeyHit == VAR(VAR_RESTART_KEY)) {
restart();
confirmrestartDialog();
return;
}
@ -2583,6 +2585,15 @@ void ScummEngine::confirmexitDialog() {
}
}
void ScummEngine::confirmrestartDialog() {
if (!_confirmRestartDialog)
_confirmRestartDialog = new ConfirmRestartDialog(this);
if (runDialog(*_confirmRestartDialog)) {
restart();
}
}
char ScummEngine::displayError(bool showCancel, const char *message, ...) {
#ifdef __PALM_OS__
char buf[256]; // 1024 is too big overflow the stack