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 | |
| 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')
| -rw-r--r-- | TimeHACK.Main/OS/Win95/Win95.cs | 8 | ||||
| -rw-r--r-- | TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs | 23 | ||||
| -rw-r--r-- | TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWordPad.Designer.cs | 3 | ||||
| -rw-r--r-- | TimeHACK.Main/Program.cs | 3 | ||||
| -rw-r--r-- | TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs | 4 | ||||
| -rw-r--r-- | TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs | 27 |
6 files changed, 52 insertions, 16 deletions
diff --git a/TimeHACK.Main/OS/Win95/Win95.cs b/TimeHACK.Main/OS/Win95/Win95.cs index d968dd4..4e61bb7 100644 --- a/TimeHACK.Main/OS/Win95/Win95.cs +++ b/TimeHACK.Main/OS/Win95/Win95.cs @@ -103,7 +103,10 @@ namespace TimeHACK.OS.Win95 this.SendToBack(); // Update the taskbar - UpdateTaskbar(); + UpdateTaskbar(); + + // Bring to this the front + this.BringToFront(); //Check if it is the first time if (CurrentSave.FTime95 == false) @@ -118,8 +121,7 @@ namespace TimeHACK.OS.Win95 nonimportantapps[nonimportantapps.Count - 1].BringToFront(); nonimportantapps[nonimportantapps.Count - 1].FormClosing += new FormClosingEventHandler(NonImportantApp_Closing); - // Bring to this the front - this.BringToFront(); + app.BringToFront(); diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs index 8a57563..f7748fe 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs @@ -25,7 +25,7 @@ namespace TimeHACK.OS.Win95.Win95Apps string currentDirectory = Path.Combine(ProfileDirectory, "folders", "Computer"); string oldLabelText; int fileType = 6; - string attemptedDirectory = ""; + //string attemptedDirectory = ""; WindowManager wm = new WindowManager(); public WinClassicWindowsExplorer() @@ -169,11 +169,14 @@ namespace TimeHACK.OS.Win95.Win95Apps case "explorer": Engine.Template.WinClassic app = wm.StartWin95(new WinClassicWindowsExplorer(), "Windows Explorer", Properties.Resources.WinClassicFileExplorer, true, true); Program.AddTaskbarItem(app, app.Tag.ToString(), "Windows Explorer", Properties.Resources.WinClassicFileExplorer); - break; case "calc": - Engine.Template.WinClassic appCalc = wm.StartWin95(new WinClassicCalculator(), "Windows Explorer", Properties.Resources.WinClassicCalc, true, true); - Program.AddTaskbarItem(appCalc, appCalc.Tag.ToString(), "Windows Explorer", Properties.Resources.WinClassicCalc); + Engine.Template.WinClassic appCalc = wm.StartWin95(new WinClassicCalculator(), "Calculator", Properties.Resources.WinClassicCalc, true, true); + Program.AddTaskbarItem(appCalc, appCalc.Tag.ToString(), "Calculator", Properties.Resources.WinClassicCalc); + break; + case "wordpad": + Engine.Template.WinClassic appWP = wm.StartWin95(new WinClassicWordPad(), "Wordpad", Properties.Resources.WinClassicWordpad, true, true); + Program.AddTaskbarItem(appWP, appWP.Tag.ToString(), "Wordpad", Properties.Resources.WinClassicWordpad); break; } } @@ -679,23 +682,29 @@ namespace TimeHACK.OS.Win95.Win95Apps { try { - if (!File.Exists(Path.Combine(currentDirectory, mainView.FocusedItem.Text))) + if (!FileOrDirectoryExists(Path.Combine(currentDirectory, mainView.FocusedItem.Text))) { wm.StartInfobox95("Windows Explorer", "This directory doesn't exist", Properties.Resources.Win95Info); } else { - Directory.Delete(currentDirectory + mainView.FocusedItem.Text, true); + if (Directory.Exists(Path.Combine(currentDirectory, mainView.FocusedItem.Text))) Directory.Delete(Path.Combine(currentDirectory, mainView.FocusedItem.Text), true); + else File.Delete(Path.Combine(currentDirectory, mainView.FocusedItem.Text)); RefreshAll(); } } catch { - + RefreshAll(); } } + internal static bool FileOrDirectoryExists(string path) + { + return (Directory.Exists(path) || File.Exists(path)); + } + private void CloseToolStripMenuItem_Click(object sender, EventArgs e) { ((Form)this.TopLevelControl).Close(); diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWordPad.Designer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWordPad.Designer.cs index 465e375..710c51c 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWordPad.Designer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWordPad.Designer.cs @@ -508,9 +508,6 @@ } #endregion - - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem helloToolStripMenuItem; private System.Windows.Forms.MenuStrip topmenu; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; diff --git a/TimeHACK.Main/Program.cs b/TimeHACK.Main/Program.cs index 086c084..9534c6d 100644 --- a/TimeHACK.Main/Program.cs +++ b/TimeHACK.Main/Program.cs @@ -13,6 +13,7 @@ using TimeHACK.OS.Win95.Win95Apps; using TimeHACK.Engine; using TimeHACK.Engine.Template; using System.Drawing; +using TimeHACK.SaveDialogs; namespace TimeHACK { @@ -58,6 +59,8 @@ namespace TimeHACK //MySaveData = (TimeHACK.Engine.GameSave.SaveData)JsonConvert.DeserializeObject(TheJSON, MySaveData.GetType()); //MessageBox.Show(MySaveData.OS.ToString()); + + Engine.SaveSystem.troubleshooter = new SaveFileTroubleShooter(); Application.EnableVisualStyles(); Application.Run(title); } 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 { |
