From 7b8f25f7e5b342108ac976e610579ded036d76ba Mon Sep 17 00:00:00 2001 From: Zoey Zolotova Date: Thu, 9 May 2019 23:56:51 +1000 Subject: [PATCH] Fix outputted files to all be in the same user-selected directory. --- Build.cs | 2 +- Majora's Mask Randomiser.csproj | 10 ---------- Models/Settings.cs | 21 +++------------------ Shuffle.cs | 4 +++- fMain.cs | 28 ++++++++++------------------ packages.config | 5 ----- 6 files changed, 17 insertions(+), 53 deletions(-) delete mode 100644 packages.config diff --git a/Build.cs b/Build.cs index 167530067..89c94064f 100644 --- a/Build.cs +++ b/Build.cs @@ -468,7 +468,7 @@ private void MakeROM(string InFile, string FileName, BackgroundWorker worker) if (_outputVC) { worker.ReportProgress(98, "Building VC..."); - ROMFuncs.BuildVC(ROM, VCDirectory, Settings.OutputWADFilename); + ROMFuncs.BuildVC(ROM, VCDirectory, Path.ChangeExtension(FileName, "wad")); } worker.ReportProgress(100, "Done!"); diff --git a/Majora's Mask Randomiser.csproj b/Majora's Mask Randomiser.csproj index 0d9dcbe09..02f444031 100644 --- a/Majora's Mask Randomiser.csproj +++ b/Majora's Mask Randomiser.csproj @@ -52,15 +52,6 @@ 200px_majoramask_rtw_icon.ico - - packages\Microsoft.WindowsAPICodePack-Core.1.1.0.2\lib\Microsoft.WindowsAPICodePack.dll - - - packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll - - - packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll - @@ -725,7 +716,6 @@ Always - SettingsSingleFileGenerator Settings.Designer.cs diff --git a/Models/Settings.cs b/Models/Settings.cs index f49935090..608e5bf0d 100644 --- a/Models/Settings.cs +++ b/Models/Settings.cs @@ -11,41 +11,26 @@ public class Settings // General - /// - /// Indicates a N64 Rom to be randomized. Default true. - /// - public bool IsN64Rom { get; private set; } = true; - /// /// Filepath to the input ROM /// - public string InputRomFilename { get; set; } + public string InputROMFilename { get; set; } /// - /// Path to the output directory where rom/vc are saved + /// Default Filename for the output ROM /// - public string OutputDirectory { get; internal set; } + public string DefaultOutputROMFilename { get; set; } /// /// Filepath to the output ROM /// public string OutputROMFilename { get; set; } - /// - /// Filepath to the output ROM - /// - public string OutputWADFilename { get; set; } - /// /// Generate spoiler log on randomizing /// public bool GenerateSpoilerLog { get; set; } - /// - /// - /// - public bool WiiVirtualConsoleChannel { get; set; } - /// /// Use Custom Item list for the logic. /// diff --git a/Shuffle.cs b/Shuffle.cs index fe1913172..36627565c 100644 --- a/Shuffle.cs +++ b/Shuffle.cs @@ -479,8 +479,10 @@ private void MakeSpoilerLog() { var settingsString = EncodeSettings(); + var directory = Path.GetDirectoryName(Settings.OutputROMFilename); + var filename = $"{Path.GetFileNameWithoutExtension(Settings.OutputROMFilename)}_SpoilerLog.txt"; - StreamWriter LogFile = new StreamWriter($"{Settings.OutputDirectory}\\SpoilerLog_{Settings.Seed}_{settingsString}.txt"); + StreamWriter LogFile = new StreamWriter(Path.Combine(directory, filename)); if (Settings.RandomizeDungeonEntrances) diff --git a/fMain.cs b/fMain.cs index 6a77e3f93..d582ba86e 100644 --- a/fMain.cs +++ b/fMain.cs @@ -5,7 +5,6 @@ using System.IO; using System.Reflection; using System.Windows.Forms; -using Microsoft.WindowsAPICodePack.Dialogs; namespace MMRando { @@ -102,27 +101,23 @@ private void bopen_Click(object sender, EventArgs e) { openROM.ShowDialog(); - Settings.InputRomFilename = openROM.FileName; - tROMName.Text = Settings.InputRomFilename; + Settings.InputROMFilename = openROM.FileName; + tROMName.Text = Settings.InputROMFilename; } private void bRandomise_Click(object sender, EventArgs e) { if (!ValidateInputFile()) return; - - var outputFolderDialog = new CommonOpenFileDialog - { - IsFolderPicker = true - }; - - if ((_outputROM || _outputVC) && outputFolderDialog.ShowDialog() != CommonFileDialogResult.Ok) + + saveROM.FileName = Settings.DefaultOutputROMFilename; + if ((_outputROM || _outputVC) && saveROM.ShowDialog() != DialogResult.OK) { MessageBox.Show("No output directory selected; Nothing will be saved.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } - Settings.OutputDirectory = outputFolderDialog.FileName; + Settings.OutputROMFilename = saveROM.FileName; EnableAllControls(false); bgWorker.RunWorkerAsync(); @@ -564,8 +559,7 @@ private void UpdateOutputFilenames(string settings) string appendSeed = Settings.GenerateSpoilerLog ? $"{Settings.Seed}_" : ""; string filename = $"MMR_{appendSeed}{settings}"; - Settings.OutputROMFilename = filename + ".z64"; - Settings.OutputWADFilename = filename + ".wad"; + Settings.DefaultOutputROMFilename = filename + ".z64"; } private string EncodeSettings() @@ -677,16 +671,14 @@ private void TryRandomize(BackgroundWorker worker, DoWorkEventArgs e) // Additional validation of preconditions if (!ValidateInputFile()) return; - if (!ValidateROM(Settings.InputRomFilename)) + if (!ValidateROM(Settings.InputROMFilename)) { MessageBox.Show("Cannot verify input ROM is Majora's Mask (U).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - MakeROM(Settings.InputRomFilename, - Path.Combine(Settings.OutputDirectory, Settings.OutputROMFilename), - worker); + MakeROM(Settings.InputROMFilename, Settings.OutputROMFilename, worker); MessageBox.Show("Successfully built output ROM!", "Success", MessageBoxButtons.OK, MessageBoxIcon.None); @@ -698,7 +690,7 @@ private void TryRandomize(BackgroundWorker worker, DoWorkEventArgs e) /// private bool ValidateInputFile() { - if (!File.Exists(Settings.InputRomFilename)) + if (!File.Exists(Settings.InputROMFilename)) { MessageBox.Show("Input ROM not selected or doesn't exist, cannot generate output.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); diff --git a/packages.config b/packages.config deleted file mode 100644 index 7a500e778..000000000 --- a/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file