aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Main/SaveDialogs
diff options
context:
space:
mode:
authorJason <[email protected]>2017-07-22 23:43:39 +0200
committerGitHub <[email protected]>2017-07-22 23:43:39 +0200
commit5afd2ec6c6d7c458c1caffc55566d4365602c122 (patch)
treeb9e2c5f7861799b7b5f209046f97052493565734 /TimeHACK.Main/SaveDialogs
parent7b12feef44adfcafd46d651adcd3e8fe11cb8523 (diff)
parentc97b5bddf841573e92c67fd2d325ca44825351f0 (diff)
downloadhistacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.tar.gz
histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.tar.bz2
histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.zip
Merge pull request #133 from Alex-TIMEHACK/master
Done a lot of work on the Windows ExplorerS
Diffstat (limited to 'TimeHACK.Main/SaveDialogs')
-rw-r--r--TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs4
-rw-r--r--TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs27
2 files changed, 28 insertions, 3 deletions
diff --git a/TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs b/TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs
index 4d8691d..cacfe9e 100644
--- a/TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs
+++ b/TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs
@@ -48,7 +48,8 @@
//
// button3
//
- this.button3.Location = new System.Drawing.Point(360, -1);
+ this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.button3.Location = new System.Drawing.Point(364, 0);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 0;
@@ -58,6 +59,7 @@
//
// button1
//
+ this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(441, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
diff --git a/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
index bcd60d1..5ec84be 100644
--- a/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
+++ b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
@@ -61,7 +61,30 @@ namespace TimeHACK.SaveDialogs
// Read the main.save file
json = File.ReadAllText(Path.Combine(SaveSystem.ProfileDirectory, "main.save"));
- savedata = Newtonsoft.Json.JsonConvert.DeserializeObject<Save>(json);
+ try
+ {
+ savedata = Newtonsoft.Json.JsonConvert.DeserializeObject<Save>(json);
+
+ } catch
+ {
+ WriteToLog("ISSUE FOUND! File main.save is unreadable");
+
+ WriteToLog("Sorry, there is no repairing it easily, your data will be lost");
+
+ if (Directory.Exists(Path.Combine(SaveSystem.ProfileDirectory, "main.backup"))) Directory.Delete(Path.Combine(SaveSystem.ProfileDirectory, "main.backup"));
+
+ File.Copy(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), Path.Combine(SaveSystem.ProfileDirectory, "main.backup"));
+ SaveSystem.NewGame();
+
+ // Make sure the username is set
+
+ SaveSystem.CurrentSave.Username = SaveSystem.ProfileName;
+
+ WriteToLog($"The corrupt file has been stored in {Path.Combine(SaveSystem.ProfileDirectory, "main.backup")}");
+
+ EndScan(true);
+ }
+
// Check the values
@@ -107,7 +130,7 @@ namespace TimeHACK.SaveDialogs
// Set the main.save file to the resolved one
- File.WriteAllText(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), Newtonsoft.Json.JsonConvert.SerializeObject(savedata));
+ File.WriteAllText(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), Newtonsoft.Json.JsonConvert.SerializeObject(savedata, Newtonsoft.Json.Formatting.Indented));
textBox1.Text = log;
} else {