|
|
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" ! 18: #include "paths.h" ! 19: #include "file.h" ! 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(¤t, &ConfigureParams) ! 58: && ConfigureParams.Log.nAlertDlgLogLevel > LOG_FATAL) { ! 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(¤t, &ConfigureParams, bForceReset); ! 68: } else { ! 69: ConfigureParams = current; ! 70: } ! 71: ! 72: Main_UnPauseEmulation(); ! 73: ! 74: if (bQuitProgram) ! 75: Main_RequestQuit(); ! 76: ! 77: return bOKDialog; ! 78: } ! 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) { ! 86: int i; ! 87: ! 88: char *szMissingFile = strdup(""); ! 89: char szDefault[FILENAME_MAX]; ! 90: char szMachine[64]; ! 91: bool bEnable = false; ! 92: ! 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: ! 96: szMissingFile = ConfigureParams.Rom.szRom030FileName; ! 97: sprintf(szMachine, "NeXT Computer"); ! 98: sprintf(szDefault, "%s%cRev_1.0_v41.BIN", Paths_GetWorkingDir(), PATHSEP); ! 99: break; ! 100: case NEXT_CUBE040: ! 101: case NEXT_STATION: ! 102: if (ConfigureParams.System.bTurbo) { ! 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); ! 108: } else { ! 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); ! 114: } ! 115: break; ! 116: ! 117: default: ! 118: break; ! 119: } ! 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: for (i = 0; i < ND_MAX_BOARDS; i++) { ! 129: while (ConfigureParams.Dimension.board[i].bEnabled && !File_Exists(ConfigureParams.Dimension.board[i].szRomFileName)) { ! 130: sprintf(szMachine, "NeXTdimension at slot %i", i*2+2); ! 131: sprintf(szDefault, "%s%cdimension_eeprom.bin", Paths_GetWorkingDir(), PATHSEP); ! 132: DlgMissing_Rom(szMachine, ConfigureParams.Dimension.board[i].szRomFileName, ! 133: szDefault, &ConfigureParams.Dimension.board[i].bEnabled); ! 134: if (bQuitProgram) { ! 135: Main_RequestQuit(); ! 136: if (bQuitProgram) ! 137: return; ! 138: } ! 139: } ! 140: } ! 141: ! 142: /* Check if SCSI disk images exist. Present a dialog to select missing files. */ ! 143: for (i = 0; i < ESP_MAX_DEVS; i++) { ! 144: while ((ConfigureParams.SCSI.target[i].nDeviceType!=DEVTYPE_NONE) && ! 145: ConfigureParams.SCSI.target[i].bDiskInserted && ! 146: !File_Exists(ConfigureParams.SCSI.target[i].szImageName)) { ! 147: DlgMissing_Disk("SCSI disk", i, ! 148: ConfigureParams.SCSI.target[i].szImageName, ! 149: &ConfigureParams.SCSI.target[i].bDiskInserted, ! 150: &ConfigureParams.SCSI.target[i].bWriteProtected); ! 151: if (ConfigureParams.SCSI.target[i].nDeviceType==DEVTYPE_HARDDISK && ! 152: !ConfigureParams.SCSI.target[i].bDiskInserted) { ! 153: ConfigureParams.SCSI.target[i].nDeviceType=DEVTYPE_NONE; ! 154: } ! 155: if (bQuitProgram) { ! 156: Main_RequestQuit(); ! 157: if (bQuitProgram) ! 158: return; ! 159: } ! 160: } ! 161: } ! 162: ! 163: /* Check if MO disk images exist. Present a dialog to select missing files. */ ! 164: for (i = 0; i < MO_MAX_DRIVES; i++) { ! 165: while (ConfigureParams.MO.drive[i].bDriveConnected && ! 166: ConfigureParams.MO.drive[i].bDiskInserted && ! 167: !File_Exists(ConfigureParams.MO.drive[i].szImageName)) { ! 168: DlgMissing_Disk("MO disk", i, ! 169: ConfigureParams.MO.drive[i].szImageName, ! 170: &ConfigureParams.MO.drive[i].bDiskInserted, ! 171: &ConfigureParams.MO.drive[i].bWriteProtected); ! 172: if (bQuitProgram) { ! 173: Main_RequestQuit(); ! 174: if (bQuitProgram) ! 175: return; ! 176: } ! 177: } ! 178: } ! 179: ! 180: /* Check if Floppy disk images exist. Present a dialog to select missing files. */ ! 181: for (i = 0; i < FLP_MAX_DRIVES; i++) { ! 182: while (ConfigureParams.Floppy.drive[i].bDriveConnected && ! 183: ConfigureParams.Floppy.drive[i].bDiskInserted && ! 184: !File_Exists(ConfigureParams.Floppy.drive[i].szImageName)) { ! 185: DlgMissing_Disk("Floppy", i, ! 186: ConfigureParams.Floppy.drive[i].szImageName, ! 187: &ConfigureParams.Floppy.drive[i].bDiskInserted, ! 188: &ConfigureParams.Floppy.drive[i].bWriteProtected); ! 189: if (bQuitProgram) { ! 190: Main_RequestQuit(); ! 191: if (bQuitProgram) ! 192: return; ! 193: } ! 194: } ! 195: } ! 196: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.