Annotation of previous/src/dialog.c, revision 1.1.1.4

1.1       root        1: /*
                      2:   Hatari - dialog.c
                      3: 
                      4:   This file is distributed under the GNU Public License, version 2 or at
                      5:   your option any later version. Read the file gpl.txt for details.
                      6: 
                      7:   Code to handle our options dialog.
                      8: */
                      9: const char Dialog_fileid[] = "Hatari dialog.c : " __DATE__ " " __TIME__;
                     10: 
                     11: #include "main.h"
                     12: #include "configuration.h"
                     13: #include "change.h"
                     14: #include "dialog.h"
                     15: #include "log.h"
                     16: #include "sdlgui.h"
                     17: #include "screen.h"
1.1.1.4 ! root       18: #include "paths.h"
1.1.1.3   root       19: #include "file.h"
1.1       root       20: 
                     21: 
                     22: /*-----------------------------------------------------------------------*/
                     23: /**
                     24:  * Open Property sheet Options dialog.
                     25:  * 
                     26:  * We keep all our configuration details in a structure called
                     27:  * 'ConfigureParams'. When we open our dialog we make a backup
                     28:  * of this structure. When the user finally clicks on 'OK',
                     29:  * we can compare and makes the necessary changes.
                     30:  * 
                     31:  * Return true if user chooses OK, or false if cancel!
                     32:  */
                     33: bool Dialog_DoProperty(void)
                     34: {
                     35:        bool bOKDialog;  /* Did user 'OK' dialog? */
                     36:        bool bForceReset;
                     37:        bool bLoadedSnapshot;
                     38:        CNF_PARAMS current;
                     39: 
                     40:        Main_PauseEmulation(true);
                     41:        bForceReset = false;
                     42: 
                     43:        /* Copy details (this is so can restore if 'Cancel' dialog) */
                     44:        current = ConfigureParams;
                     45:        ConfigureParams.Screen.bFullScreen = bInFullScreen;
                     46:        bOKDialog = Dialog_MainDlg(&bForceReset, &bLoadedSnapshot);
                     47: 
                     48:        /* If a memory snapshot has been loaded, no further changes are required */
                     49:        if (bLoadedSnapshot)
                     50:        {
                     51:                Main_UnPauseEmulation();
                     52:                return true;
                     53:        }
                     54: 
                     55:        /* Check if reset is required and ask user if he really wants to continue then */
                     56:        if (bOKDialog && !bForceReset
                     57:            && Change_DoNeedReset(&current, &ConfigureParams)
1.1.1.2   root       58:            && ConfigureParams.Log.nAlertDlgLogLevel > LOG_FATAL) {
1.1       root       59:                bOKDialog = DlgAlert_Query("The emulated system must be "
                     60:                                           "reset to apply these changes. "
                     61:                                           "Apply changes now and reset "
                     62:                                           "the emulator?");
                     63:        }
                     64: 
                     65:        /* Copy details to configuration */
                     66:        if (bOKDialog) {
                     67:                Change_CopyChangedParamsToConfiguration(&current, &ConfigureParams, bForceReset);
                     68:        } else {
                     69:                ConfigureParams = current;
                     70:        }
                     71: 
                     72:        Main_UnPauseEmulation();
1.1.1.3   root       73:     
1.1       root       74:        if (bQuitProgram)
                     75:                Main_RequestQuit();
1.1.1.3   root       76:  
1.1       root       77:        return bOKDialog;
                     78: }
1.1.1.3   root       79: 
                     80: 
                     81: /* Function to check if all necessary files exist. If loading of a file fails, we bring up a dialog to let the
                     82:  * user choose another file. This is repeated for each missing file.
                     83:  */
                     84: 
                     85: void Dialog_CheckFiles(void) {
1.1.1.4 ! root       86:     int i;
        !            87:     
        !            88:     char *szMissingFile = "\0";
        !            89:     char szDefault[FILENAME_MAX];
        !            90:     char szMachine[64];
        !            91:     bool bEnable = false;
        !            92:     
1.1.1.3   root       93:     /* Check if ROM file exists. If it is missing present a dialog to select a new ROM file. */
                     94:     switch (ConfigureParams.System.nMachineType) {
                     95:         case NEXT_CUBE030:
1.1.1.4 ! root       96:             szMissingFile = ConfigureParams.Rom.szRom030FileName;
        !            97:             sprintf(szMachine, "NeXT Computer");
        !            98:             sprintf(szDefault, "%s%cRev_1.0_v41.BIN", Paths_GetWorkingDir(), PATHSEP);
1.1.1.3   root       99:             break;
                    100:         case NEXT_CUBE040:
                    101:         case NEXT_STATION:
                    102:             if (ConfigureParams.System.bTurbo) {
1.1.1.4 ! root      103:                 szMissingFile = ConfigureParams.Rom.szRomTurboFileName;
        !           104:                 sprintf(szMachine, "%s Turbo %s",
        !           105:                         (ConfigureParams.System.nMachineType==NEXT_CUBE040)?"NeXTcube":"NeXTstation",
        !           106:                         (ConfigureParams.System.bColor)?"Color":"");
        !           107:                 sprintf(szDefault, "%s%cRev_3.3_v74.BIN", Paths_GetWorkingDir(), PATHSEP);
1.1.1.3   root      108:             } else {
1.1.1.4 ! root      109:                 szMissingFile = ConfigureParams.Rom.szRom040FileName;
        !           110:                 sprintf(szMachine, "%s %s",
        !           111:                         (ConfigureParams.System.nMachineType==NEXT_CUBE040)?"NeXTcube":"NeXTstation",
        !           112:                         (ConfigureParams.System.bColor)?"Color":"");
        !           113:                 sprintf(szDefault, "%s%cRev_2.5_v66.BIN", Paths_GetWorkingDir(), PATHSEP);
1.1.1.3   root      114:             }
                    115:             break;
                    116:             
                    117:         default:
                    118:             break;
                    119:     }
1.1.1.4 ! root      120:     while (!File_Exists(szMissingFile)) {
        !           121:         DlgMissing_Rom(szMachine, szMissingFile, szDefault, &bEnable);
        !           122:         if (bQuitProgram) {
        !           123:             Main_RequestQuit();
        !           124:             if (bQuitProgram)
        !           125:                 return;
        !           126:         }
        !           127:     }
        !           128:     while (ConfigureParams.Dimension.bEnabled && !File_Exists(ConfigureParams.Dimension.szRomFileName)) {
        !           129:         sprintf(szDefault, "%s%cdimension_eeprom.bin", Paths_GetWorkingDir(), PATHSEP);
        !           130:         DlgMissing_Rom("NeXTdimension", ConfigureParams.Dimension.szRomFileName,
        !           131:                        szDefault, &ConfigureParams.Dimension.bEnabled);
        !           132:         if (bQuitProgram) {
        !           133:             Main_RequestQuit();
        !           134:             if (bQuitProgram)
        !           135:                 return;
        !           136:         }
        !           137:     }
1.1.1.3   root      138:     
                    139:     /* Check if SCSI disk images exist. Present a dialog to select missing files. */
1.1.1.4 ! root      140:     for (i = 0; i < ESP_MAX_DEVS; i++) {
        !           141:         while ((ConfigureParams.SCSI.target[i].nDeviceType!=DEVTYPE_NONE) &&
        !           142:                ConfigureParams.SCSI.target[i].bDiskInserted &&
        !           143:                !File_Exists(ConfigureParams.SCSI.target[i].szImageName)) {
        !           144:             DlgMissing_Disk("SCSI disk", i,
        !           145:                             ConfigureParams.SCSI.target[i].szImageName,
        !           146:                             &ConfigureParams.SCSI.target[i].bDiskInserted,
        !           147:                             &ConfigureParams.SCSI.target[i].bWriteProtected);
        !           148:             if (ConfigureParams.SCSI.target[i].nDeviceType==DEVTYPE_HARDDISK &&
        !           149:                 !ConfigureParams.SCSI.target[i].bDiskInserted) {
        !           150:                 ConfigureParams.SCSI.target[i].nDeviceType=DEVTYPE_NONE;
        !           151:             }
1.1.1.3   root      152:             if (bQuitProgram) {
                    153:                 Main_RequestQuit();
                    154:                 if (bQuitProgram)
1.1.1.4 ! root      155:                     return;
1.1.1.3   root      156:             }
                    157:         }
                    158:     }
                    159:     
1.1.1.4 ! root      160:     /* Check if MO disk images exist. Present a dialog to select missing files. */
        !           161:     for (i = 0; i < MO_MAX_DRIVES; i++) {
        !           162:         while (ConfigureParams.MO.drive[i].bDriveConnected &&
        !           163:                ConfigureParams.MO.drive[i].bDiskInserted &&
        !           164:                !File_Exists(ConfigureParams.MO.drive[i].szImageName)) {
        !           165:             DlgMissing_Disk("MO disk", i,
        !           166:                             ConfigureParams.MO.drive[i].szImageName,
        !           167:                             &ConfigureParams.MO.drive[i].bDiskInserted,
        !           168:                             &ConfigureParams.MO.drive[i].bWriteProtected);
        !           169:             if (bQuitProgram) {
        !           170:                 Main_RequestQuit();
        !           171:                 if (bQuitProgram)
        !           172:                     return;
        !           173:             }
        !           174:         }
        !           175:     }
        !           176: 
        !           177:     /* Check if Floppy disk images exist. Present a dialog to select missing files. */
        !           178:     for (i = 0; i < FLP_MAX_DRIVES; i++) {
        !           179:         while (ConfigureParams.Floppy.drive[i].bDriveConnected &&
        !           180:                ConfigureParams.Floppy.drive[i].bDiskInserted &&
        !           181:                !File_Exists(ConfigureParams.Floppy.drive[i].szImageName)) {
        !           182:             DlgMissing_Disk("Floppy", i,
        !           183:                             ConfigureParams.Floppy.drive[i].szImageName,
        !           184:                             &ConfigureParams.Floppy.drive[i].bDiskInserted,
        !           185:                             &ConfigureParams.Floppy.drive[i].bWriteProtected);
        !           186:             if (bQuitProgram) {
        !           187:                 Main_RequestQuit();
        !           188:                 if (bQuitProgram)
        !           189:                     return;
        !           190:             }
        !           191:         }
        !           192:     }
1.1.1.3   root      193: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.