diff --git a/BotWSaveManager.Conversion/Save.cs b/BotWSaveManager.Conversion/Save.cs index 4ee61b7..8bbd6db 100644 --- a/BotWSaveManager.Conversion/Save.cs +++ b/BotWSaveManager.Conversion/Save.cs @@ -76,7 +76,7 @@ public enum SaveType "0E9D0E75", "750E9D0E" }; - public Save(string folder, bool skipSwitchVersionCheck = false) + public Save(string folder, bool skipVersionCheck = false) { this.SaveFolder = folder; @@ -119,7 +119,11 @@ public Save(string folder, bool skipSwitchVersionCheck = false) catch (Exception e) { Console.WriteLine(e); - throw new UnsupportedSaveException("The version of a numbered save folder you selected cannot be retrieved."); + if (!skipVersionCheck) + { + throw new UnsupportedSaveException( + "The version of a numbered save folder you selected cannot be retrieved."); + } } } else @@ -147,7 +151,7 @@ public Save(string folder, bool skipSwitchVersionCheck = false) catch (Exception e) { Console.WriteLine(e); - if (!skipSwitchVersionCheck) + if (!skipVersionCheck) { throw new UnsupportedSaveException("The version of a numbered save folder you selected cannot be retrieved.") {IsSwitch = true}; } diff --git a/BotWSaveManager.UI/MainForm.cs b/BotWSaveManager.UI/MainForm.cs index e3e1b34..435c01e 100644 --- a/BotWSaveManager.UI/MainForm.cs +++ b/BotWSaveManager.UI/MainForm.cs @@ -84,31 +84,39 @@ private void OpenSaveToolStripMenuItem_Click(object sender, EventArgs e) } else { - Logger.Fatal("Aborting save loading as per user request."); + Logger.Fatal(exception, "Aborting save loading as per user request."); MessageBox.Show(exception.Message); - this.btnConvert.Hide(); - this.tbSaveLocation.Hide(); - this.btnBrowse.Hide(); - this.btnSaveToFiles.Hide(); - this.pbConsole.Image = null; - this.lblConsoleName.Text = ""; + this.ResetControls(); return; } } else { - Logger.Fatal("Aborting save loading due to unexpected version error."); - MessageBox.Show(exception.Message); - this.btnConvert.Hide(); - this.tbSaveLocation.Hide(); - this.btnBrowse.Hide(); - this.btnSaveToFiles.Hide(); - this.pbConsole.Image = null; - this.lblConsoleName.Text = ""; - return; + Logger.Error("The version of a numbered Wii U save folder selected could not be retrieved. Prompting user to ignore error."); + + if (MessageBox.Show("The version of a numbered save folder you selected cannot be retrieved. If you would like to attempt to use this file anyways, select Yes.", "Possibly unsupported save.", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + Logger.Info("User chose to ignore error. Initializing save with Wii U version checking disabled."); + this.SelectedSave = new Save(dia.SelectedPath, true); + } + else + { + Logger.Fatal(exception, "Aborting save loading as per user request."); + MessageBox.Show(exception.Message); + this.ResetControls(); + return; + } } } + if (this.SelectedSave?.SaveFolder == null) + { + Logger.Fatal("The save folder selected by the user is null. Resetting controls and notifying user."); + MessageBox.Show("The selected folder is null or invalid. Try running this app as administrator."); + this.ResetControls(); + return; + } + this.SaveFilesDictionary = new Dictionary(); foreach (string file in Directory.GetFiles(this.SelectedSave.SaveFolder, "*.sav", SearchOption.AllDirectories)) @@ -141,6 +149,16 @@ private void OpenSaveToolStripMenuItem_Click(object sender, EventArgs e) } } + private void ResetControls() + { + this.btnConvert.Hide(); + this.tbSaveLocation.Hide(); + this.btnBrowse.Hide(); + this.btnSaveToFiles.Hide(); + this.pbConsole.Image = null; + this.lblConsoleName.Text = ""; + } + private void AboutToolStripMenuItem_Click(object sender, EventArgs e) { Logger.Trace("User opened about dialog.");