Ticket #8194: quitdialog.2.diff

File quitdialog.2.diff, 4.5 KB (added by Deledrius, 21 years ago)

Patch against 2003-07-21 CVS Snapshot to add Exit Confirmation

  • common/gameDetector.cpp

    Only in ./scummvmdiff/backends/PalmOS: Obj
    Only in ./scummvmdiff/backends/gp32: h
    Only in ./scummvmdiff/backends: mac
    diff -rub ./scummvm/common/gameDetector.cpp ./scummvmdiff/common/gameDetector.cpp
    old new  
    192192        _save_slot = 0;
    193193       
    194194        _saveconfig = false;
     195        _confirmExit = false;
    195196       
    196197#ifndef _WIN32_WCE
    197198        _gfx_mode = GFX_DOUBLESIZE;
     
    300301                _gameTempo = strtol(val, NULL, 0);
    301302
    302303        _talkSpeed = g_config->getInt("talkspeed", _talkSpeed);
     304
     305        _confirmExit = g_config->getBool("confirmExit", _confirmExit ? true : false);
    303306
    304307        _multi_midi = g_config->getBool ("multi_midi", _multi_midi);
    305308        _native_mt32 = g_config->getBool ("native_mt32", _native_mt32);
  • common/gameDetector.h

    diff -rub ./scummvm/common/gameDetector.h ./scummvmdiff/common/gameDetector.h
    old new  
    148148        int _save_slot;
    149149       
    150150        bool _saveconfig;
     151        bool _confirmExit;
    151152
    152153public:
    153154        OSystem *createSystem();
  • scumm/dialogs.cpp

    diff -rub ./scummvm/scumm/dialogs.cpp ./scummvmdiff/scumm/dialogs.cpp
    old new  
    695695        : InfoDialog(gui, scumm, 10) {
    696696}
    697697
     698ConfirmExitDialog::ConfirmExitDialog(NewGui *gui, Scumm *scumm)
     699        : InfoDialog(gui, scumm, "Are you sure you want to quit (y/n)?") {
     700}
     701
    698702#ifdef _WIN32_WCE
    699703
    700704#pragma mark -
  • scumm/dialogs.h

    diff -rub ./scummvm/scumm/dialogs.h ./scummvmdiff/scumm/dialogs.h
    old new  
    171171                }
    172172};
    173173
     174class ConfirmExitDialog : public InfoDialog {
     175public:
     176        ConfirmExitDialog(NewGui *gui, Scumm *scumm);
     177        virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers) {
     178                if (tolower(ascii) == 'n') { // Close exit dialog if n key is pressed
     179                        setResult(ascii);
     180                        close();
     181                }
     182                if (tolower(ascii) == 'y') { // Quit engine if y key is pressed
     183                        setResult(ascii);
     184                        close();
     185                }
     186                else
     187                        ScummDialog::handleKeyDown(ascii, keycode, modifiers);
     188        }
     189};
     190
    174191#ifdef _WIN32_WCE
    175192
    176193class KeysDialog : public ScummDialog {
  • scumm/scumm.h

    diff -rub ./scummvm/scumm/scumm.h ./scummvmdiff/scumm/scumm.h
    old new  
    390390        Dialog *_pauseDialog;
    391391        Dialog *_optionsDialog;
    392392        Dialog *_saveLoadDialog;
     393        Dialog *_confirmExitDialog;
    393394        // Debugger access this one, too...
    394395        ConsoleDialog *_debuggerDialog;
    395396
     
    397398        void pauseDialog();
    398399        void saveloadDialog();
    399400        void optionsDialog();
     401        void confirmexitDialog();
    400402        char displayError(bool showCancel, const char *message, ...);
    401403
    402404protected:
     
    10591061
    10601062public:
    10611063        bool _noSubtitles;      // Whether to skip all subtitles
     1064        bool _confirmExit;
    10621065protected:
    10631066
    10641067        void initCharset(int charset);
  • scumm/scummvm.cpp

    diff -rub ./scummvm/scumm/scummvm.cpp ./scummvmdiff/scumm/scummvm.cpp
    old new  
    232232        _pauseDialog = NULL;
    233233        _optionsDialog = NULL;
    234234        _saveLoadDialog = NULL;
     235        _confirmExitDialog = NULL;
    235236        _debuggerDialog = NULL;
    236237        _fastMode = 0;
    237238        memset(&_rnd, 0, sizeof(RandomSource));
     
    394395        _charsetBufPos = 0;
    395396        memset(_charsetBuffer, 0, sizeof(_charsetBuffer));
    396397        _noSubtitles = false;
     398        _confirmExit = false;
    397399        _numInMsgStack = 0;
    398400        _msgPtrToAdd = NULL;
    399401        _messagePtr = NULL;
     
    545547        setFeatures(detector->_game.features);
    546548
    547549        _noSubtitles = detector->_noSubtitles;
     550        _confirmExit = detector->_confirmExit;
    548551        _defaultTalkDelay = detector->_talkSpeed;
    549552        _use_adlib = detector->_use_adlib;
    550553        _language = detector->_language;
     
    709712        delete _pauseDialog;
    710713        delete _optionsDialog;
    711714        delete _saveLoadDialog;
     715        delete _confirmExitDialog;
    712716
    713717        delete _sound;
    714718        delete _imuse;
     
    14611465                        break;
    14621466       
    14631467                case OSystem::EVENT_QUIT:
     1468                        if(_confirmExit)
     1469                                confirmexitDialog();
     1470                        else
    14641471                        _quit = true;
    14651472                        break;
    14661473       
     
    22952302        if (!_optionsDialog)
    22962303                _optionsDialog = new OptionsDialog(_newgui, this);
    22972304        runDialog(_optionsDialog);
     2305}
     2306
     2307void Scumm::confirmexitDialog() {
     2308        if (!_confirmExitDialog)
     2309                _confirmExitDialog = new ConfirmExitDialog(_newgui, this);
     2310
     2311        if (tolower(runDialog(_confirmExitDialog)) == 'y') {
     2312                _quit = true;
     2313        }
    22982314}
    22992315
    23002316char Scumm::displayError(bool showCancel, const char *message, ...) {