diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-07-21 22:14:23 +0100 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-07-21 22:14:23 +0100 |
| commit | 2c87ba5fdef12cb62d40c5a9d2513ce097ac0aa9 (patch) | |
| tree | e3733218d0d4633cd11790c222c6a9366f40b1ae /TimeHACK.Main/SaveDialogs | |
| parent | 5bfa0d8184b94d22c8bd0cff404acae0ef210a3c (diff) | |
| download | histacom2-2c87ba5fdef12cb62d40c5a9d2513ce097ac0aa9.tar.gz histacom2-2c87ba5fdef12cb62d40c5a9d2513ce097ac0aa9.tar.bz2 histacom2-2c87ba5fdef12cb62d40c5a9d2513ce097ac0aa9.zip | |
A lot of backend work!
Diffstat (limited to 'TimeHACK.Main/SaveDialogs')
| -rw-r--r-- | TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs | 4 | ||||
| -rw-r--r-- | TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs | 27 |
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 { |
