/// <summary> Builds the argument line in order to start DOSBox. </summary> /// <param name="forSetupExe"> /// Whether or not we are starting the game's setup utility or the game itself. /// </param> /// <returns> The list of command line arguments to pass to DOSBox. </returns> private string BuildArgs(bool forSetupExe) { if (this._game.IsDOSBoxUsed(_userData) == false) { return(string.Empty); } var configFile = new DOSBoxConfigFile(this._game.DBConfPath); var dosboxArgs = new StringBuilder(); string dosBoxExePath = this._game.GetDOSBoxPath(_userData); if (StringExt.IsNullOrWhiteSpace(dosBoxExePath) == true || dosBoxExePath == "dosbox.exe isn't in the same directory as AmpShell.exe!" || File.Exists(dosBoxExePath) == false) { throw new FileNotFoundException("DOSBox not found!"); } dosboxArgs.Append(this.AddCustomConfigFile()); if (StringExt.IsNullOrWhiteSpace(_userData.DBDefaultLangFilePath) == false && _userData.DBDefaultLangFilePath != "No language file (*.lng) found in AmpShell's directory.") { dosboxArgs.Append($" -lang \"{_userData.DBDefaultLangFilePath}\""); } dosboxArgs.Append(this.AddAdditionalCommands(forSetupExe, configFile)); //corresponds to the Fullscreen checkbox in GameForm if (this._game.InFullScreen == true) { dosboxArgs.Append(" -fullscreen"); } //corresponds to the "no console" checkbox in the GameForm if (this._game.NoConsole == true) { dosboxArgs.Append(" -noconsole"); } //corresponds to the "quit on exit (only for .exe)" checkbox in the GameForm if (this._game.QuitOnExit == true) { dosboxArgs.Append(" -exit"); } return(dosboxArgs.ToString()); }
private string AddAdditionalCommands(bool forSetupExe, DOSBoxConfigFile configFile) { if (configFile.IsAutoExecSectionUsed() == true) { return(string.Empty); } var commands = new StringBuilder(); if (StringExt.IsNullOrWhiteSpace(this._game.DOSEXEPath) == false) { if (!forSetupExe) { commands.Append($" \"{Path.GetFullPath(this._game.DOSEXEPath)}\""); } else { commands.Append($" \"{Path.GetFullPath(this._game.SetupEXEPath)}\""); } } //the game directory mounted as C if (StringExt.IsNullOrWhiteSpace(this._game.Directory) == false) { commands.Append($" -c \"mount c '{this._game.Directory}'\""); } //Path for the game's CD image (.bin, .cue, or .iso) mounted as D: if (StringExt.IsNullOrWhiteSpace(this._game.CDPath) == false) { //put ' and not " after imgmount (or else the path will be misunderstood by DOSBox). if (this._game.CDIsAnImage == true) { commands.Append(" -c \"imgmount"); if (this._game.MountAsFloppy == true) { commands.Append($" a '{this._game.CDPath}' -t floppy\""); } else { commands.Append($" d '{this._game.CDPath}' -t iso\""); } } else { bool addedMountOptions; if (this._game.UseIOCTL == true) { addedMountOptions = true; commands.Append($" -c \"mount d '{this._game.CDPath}' -t cdrom -usecd 0 -ioctl"); } else if (this._game.MountAsFloppy == true) { addedMountOptions = true; commands.Append($" -c \"mount a '{this._game.CDPath}' -t floppy"); } else { addedMountOptions = true; commands.Append($" -c \"mount d '{this._game.CDPath}'"); } if (StringExt.IsNullOrWhiteSpace(this._game.CDLabel) == false && addedMountOptions) { commands.Append($" -label '{this._game.CDLabel}'"); } commands.Append('"'); } } var gameAdditionnalCommands = this._game.GetAdditionnalCommandsInASingleLine(); if (StringExt.IsNullOrWhiteSpace(gameAdditionnalCommands) == false) { commands.Append(gameAdditionnalCommands); } return(commands.ToString()); }