Skip to content

Commit

Permalink
Added the ability to skip version checking for the Wii U.
Browse files Browse the repository at this point in the history
Added more logging to trace errors better.
Added a check for if the save folder is null.
  • Loading branch information
Jordan Marine committed Oct 8, 2020
1 parent fd06dcf commit 1431ec2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
10 changes: 7 additions & 3 deletions BotWSaveManager.Conversion/Save.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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};
}
Expand Down
50 changes: 34 additions & 16 deletions BotWSaveManager.UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, byte[]>();

foreach (string file in Directory.GetFiles(this.SelectedSave.SaveFolder, "*.sav", SearchOption.AllDirectories))
Expand Down Expand Up @@ -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.");
Expand Down

0 comments on commit 1431ec2

Please sign in to comment.