From 9e2582cd3f5b2bf6f3e8c2d6434ab06ea97832a7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 7 May 2017 20:04:31 -0400 Subject: Implement a proper save system --- TimeHACK.Engine/SaveSystem.cs | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 TimeHACK.Engine/SaveSystem.cs (limited to 'TimeHACK.Engine/SaveSystem.cs') diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs new file mode 100644 index 0000000..c6e19a2 --- /dev/null +++ b/TimeHACK.Engine/SaveSystem.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace TimeHACK.Engine +{ + public static class SaveSystem + { + public static Save CurrentSave { get; private set; } + + public static string GameDirectory + { + get + { + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "TimeHACK"); + } + } + + public static string ProfileDirectory + { + get + { + return Path.Combine(GameDirectory, "Profiles"); + } + } + + public static bool LoadSave() + { + if(File.Exists(Path.Combine(ProfileDirectory, "user.save"))) + { + //Read base64 string from file + string b64 = File.ReadAllText(Path.Combine(ProfileDirectory, "user.save")); + //Get Unicode byte array + byte[] bytes = Convert.FromBase64String(b64); + //Decode the Unicode + string json = Encoding.UTF8.GetString(bytes); + //Deserialize save object. + CurrentSave = JsonConvert.DeserializeObject(json); + return true; + } + else + { + NewGame(); + return false; + } + } + + public static void NewGame() + { + //TODO: User must set a username....somehow + if (!Directory.Exists(GameDirectory)) + Directory.CreateDirectory(GameDirectory); + + if (!Directory.Exists(ProfileDirectory)) + Directory.CreateDirectory(ProfileDirectory); + + var save = new Save(); + save.ExperiencedStories = new List(); + save.InstalledPrograms = new Dictionary(); + CurrentSave = save; + SaveGame(); + } + + public static void SaveGame() + { + //Serialize the save to JSON. + string json = JsonConvert.SerializeObject(CurrentSave); + //Get JSON bytes (Unicode format). + var bytes = Encoding.UTF8.GetBytes(json); + //Encode the array into Base64. + string b64 = Convert.ToBase64String(bytes); + //Write to disk. + File.WriteAllText(Path.Combine(ProfileDirectory, "user.save"), b64); + } + } + + public class Save + { + public string Username { get; set; } + public Dictionary InstalledPrograms { get; set; } + public List ExperiencedStories { get; set; } + } +} -- cgit v1.2.3 From b9841ccabcc577dec863a0a8979a3415e7c385a0 Mon Sep 17 00:00:00 2001 From: Aren Date: Sat, 20 May 2017 12:49:25 +0200 Subject: Store saves in AppData instead of My Documents Required for Windows Store support. --- TimeHACK.Engine/SaveSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'TimeHACK.Engine/SaveSystem.cs') diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs index c6e19a2..2016110 100644 --- a/TimeHACK.Engine/SaveSystem.cs +++ b/TimeHACK.Engine/SaveSystem.cs @@ -16,7 +16,7 @@ namespace TimeHACK.Engine { get { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "TimeHACK"); + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TimeHACK"); } } -- cgit v1.2.3 From 9328abe3848262d9d52e847f0029ed1144399f7b Mon Sep 17 00:00:00 2001 From: Alex-TIMEHACK Date: Sat, 20 May 2017 13:33:32 +0100 Subject: Added my SaveSystem! --- .vs/TimeHACK/v15/.suo | Bin 166912 -> 156672 bytes TimeHACK.Engine/SaveSystem.cs | 61 ++++--- TimeHACK.Engine/bin/Release/TimeHACK.Engine.dll | Bin 187392 -> 187392 bytes TimeHACK.Engine/bin/Release/TimeHACK.Engine.pdb | Bin 54784 -> 54784 bytes .../TimeHACK.Engine.csproj.FileListAbsolute.txt | 1 - .../TimeHACK.Engine.csproj.GenerateResource.Cache | Bin 2245 -> 2531 bytes ...ACK.Engine.csprojResolveAssemblyReference.cache | Bin 10673 -> 0 bytes TimeHACK.Engine/obj/Release/TimeHACK.Engine.dll | Bin 187392 -> 187392 bytes TimeHACK.Engine/obj/Release/TimeHACK.Engine.pdb | Bin 54784 -> 54784 bytes TimeHACK.Main/NewGameDialog.Designer.cs | 125 -------------- TimeHACK.Main/NewGameDialog.cs | 42 ----- TimeHACK.Main/NewGameDialog.resx | 120 ------------- .../SaveDialogs/LoadGameDialog.Designer.cs | 101 +++++++++++ TimeHACK.Main/SaveDialogs/LoadGameDialog.cs | 57 +++++++ TimeHACK.Main/SaveDialogs/LoadGameDialog.resx | 120 +++++++++++++ .../SaveDialogs/LoadGameProfileItem.Designer.cs | 190 +++++++++++++++++++++ TimeHACK.Main/SaveDialogs/LoadGameProfileItem.cs | 152 +++++++++++++++++ TimeHACK.Main/SaveDialogs/LoadGameProfileItem.resx | 120 +++++++++++++ .../SaveDialogs/NewGameDialog.Designer.cs | 141 +++++++++++++++ TimeHACK.Main/SaveDialogs/NewGameDialog.cs | 97 +++++++++++ TimeHACK.Main/SaveDialogs/NewGameDialog.resx | 120 +++++++++++++ TimeHACK.Main/TimeHACK.Main.csproj | 24 ++- TimeHACK.Main/TitleScreen.Designer.cs | 3 +- TimeHACK.Main/TitleScreen.cs | 49 ++++-- TimeHACK.Main/bin/Release/TimeHACK.Engine.dll | Bin 187392 -> 187392 bytes TimeHACK.Main/bin/Release/TimeHACK.Engine.pdb | Bin 54784 -> 54784 bytes TimeHACK.Main/bin/Release/TimeHACK.application | 2 +- TimeHACK.Main/bin/Release/TimeHACK.exe | Bin 4804608 -> 4812288 bytes TimeHACK.Main/bin/Release/TimeHACK.exe.manifest | 6 +- TimeHACK.Main/bin/Release/TimeHACK.pdb | Bin 235008 -> 249344 bytes TimeHACK.Main/bin/Release/app.publish/TimeHACK.exe | Bin 4804608 -> 4812288 bytes TimeHACK.Main/obj/Release/CoreCompileInputs.cache | 2 +- .../DesignTimeResolveAssemblyReferences.cache | Bin 1464 -> 35211 bytes .../obj/Release/TimeHACK.LoadGameDialog.resources | Bin 0 -> 180 bytes .../Release/TimeHACK.LoadGameProfileItem.resources | Bin 0 -> 180 bytes .../TimeHACK.Main.csproj.FileListAbsolute.txt | 2 + .../TimeHACK.Main.csproj.GenerateResource.Cache | Bin 6278 -> 6453 bytes ...eHACK.Main.csprojResolveAssemblyReference.cache | Bin 15071 -> 15081 bytes ...K.WinClassicForms.WinClassicInstaller.resources | Bin 1385 -> 1383 bytes TimeHACK.Main/obj/Release/TimeHACK.application | 2 +- TimeHACK.Main/obj/Release/TimeHACK.exe | Bin 4804608 -> 4812288 bytes TimeHACK.Main/obj/Release/TimeHACK.exe.manifest | 6 +- TimeHACK.Main/obj/Release/TimeHACK.pdb | Bin 235008 -> 249344 bytes 43 files changed, 1210 insertions(+), 333 deletions(-) delete mode 100644 TimeHACK.Engine/obj/Release/TimeHACK.Engine.csprojResolveAssemblyReference.cache delete mode 100644 TimeHACK.Main/NewGameDialog.Designer.cs delete mode 100644 TimeHACK.Main/NewGameDialog.cs delete mode 100644 TimeHACK.Main/NewGameDialog.resx create mode 100644 TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs create mode 100644 TimeHACK.Main/SaveDialogs/LoadGameDialog.cs create mode 100644 TimeHACK.Main/SaveDialogs/LoadGameDialog.resx create mode 100644 TimeHACK.Main/SaveDialogs/LoadGameProfileItem.Designer.cs create mode 100644 TimeHACK.Main/SaveDialogs/LoadGameProfileItem.cs create mode 100644 TimeHACK.Main/SaveDialogs/LoadGameProfileItem.resx create mode 100644 TimeHACK.Main/SaveDialogs/NewGameDialog.Designer.cs create mode 100644 TimeHACK.Main/SaveDialogs/NewGameDialog.cs create mode 100644 TimeHACK.Main/SaveDialogs/NewGameDialog.resx create mode 100644 TimeHACK.Main/obj/Release/TimeHACK.LoadGameDialog.resources create mode 100644 TimeHACK.Main/obj/Release/TimeHACK.LoadGameProfileItem.resources (limited to 'TimeHACK.Engine/SaveSystem.cs') diff --git a/.vs/TimeHACK/v15/.suo b/.vs/TimeHACK/v15/.suo index 6f8653c..af9fd08 100644 Binary files a/.vs/TimeHACK/v15/.suo and b/.vs/TimeHACK/v15/.suo differ diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs index c6e19a2..e043b69 100644 --- a/TimeHACK.Engine/SaveSystem.cs +++ b/TimeHACK.Engine/SaveSystem.cs @@ -11,6 +11,7 @@ namespace TimeHACK.Engine public static class SaveSystem { public static Save CurrentSave { get; private set; } + public static Boolean DevMode = false; public static string GameDirectory { @@ -20,7 +21,7 @@ namespace TimeHACK.Engine } } - public static string ProfileDirectory + public static string AllProfilesDirectory { get { @@ -28,33 +29,47 @@ namespace TimeHACK.Engine } } - public static bool LoadSave() + public static string ProfileName = ""; + public static string ProfileFile = "main.save"; + + public static string ProfileDirectory { - if(File.Exists(Path.Combine(ProfileDirectory, "user.save"))) - { - //Read base64 string from file - string b64 = File.ReadAllText(Path.Combine(ProfileDirectory, "user.save")); - //Get Unicode byte array - byte[] bytes = Convert.FromBase64String(b64); - //Decode the Unicode - string json = Encoding.UTF8.GetString(bytes); - //Deserialize save object. - CurrentSave = JsonConvert.DeserializeObject(json); - return true; - } - else + get { - NewGame(); - return false; + return Path.Combine(GameDirectory, Path.Combine("Profiles", ProfileName)); } } + public static bool LoadSave() + { + // ON A FINAL RELEASE USE THE "FINAL RELEASE THINGS" + #region Final Release Things + //Read base64 string from file + //string b64 = File.ReadAllText(Path.Combine(ProfileDirectory, ProfileFile)); + //Get Unicode byte array + //byte[] bytes = Convert.FromBase64String(b64); + //Decode the Unicode + //string json = Encoding.UTF8.GetString(bytes); + //Deserialize save object. + #endregion + // USE THE THINGS IN THE "DEVELOPER THINGS" FOR A DEVELOPMENT RELEASE + #region Developer Things + string json = File.ReadAllText(Path.Combine(ProfileDirectory, ProfileFile)); + #endregion + CurrentSave = JsonConvert.DeserializeObject(json); + return true; + } + public static void NewGame() { + //TODO: User must set a username....somehow if (!Directory.Exists(GameDirectory)) Directory.CreateDirectory(GameDirectory); + if (!Directory.Exists(AllProfilesDirectory)) + Directory.CreateDirectory(AllProfilesDirectory); + if (!Directory.Exists(ProfileDirectory)) Directory.CreateDirectory(ProfileDirectory); @@ -68,13 +83,17 @@ namespace TimeHACK.Engine public static void SaveGame() { //Serialize the save to JSON. - string json = JsonConvert.SerializeObject(CurrentSave); + string json = JsonConvert.SerializeObject(CurrentSave, Formatting.Indented); + + // ADD THE TWO LINES OF CODE BELOW ON A FINAL RELEASE //Get JSON bytes (Unicode format). - var bytes = Encoding.UTF8.GetBytes(json); + //var bytes = Encoding.UTF8.GetBytes(json); //Encode the array into Base64. - string b64 = Convert.ToBase64String(bytes); + //string b64 = Convert.ToBase64String(bytes); //Write to disk. - File.WriteAllText(Path.Combine(ProfileDirectory, "user.save"), b64); + + // CHANGE THE "JSON" TO "B64" ON A FINAL RELEASE! + File.WriteAllText(Path.Combine(ProfileDirectory, ProfileFile), json); } } diff --git a/TimeHACK.Engine/bin/Release/TimeHACK.Engine.dll b/TimeHACK.Engine/bin/Release/TimeHACK.Engine.dll index 86d9598..062eb83 100644 Binary files a/TimeHACK.Engine/bin/Release/TimeHACK.Engine.dll and b/TimeHACK.Engine/bin/Release/TimeHACK.Engine.dll differ diff --git a/TimeHACK.Engine/bin/Release/TimeHACK.Engine.pdb b/TimeHACK.Engine/bin/Release/TimeHACK.Engine.pdb index 10716d1..57383ef 100644 Binary files a/TimeHACK.Engine/bin/Release/TimeHACK.Engine.pdb and b/TimeHACK.Engine/bin/Release/TimeHACK.Engine.pdb differ diff --git a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.FileListAbsolute.txt b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.FileListAbsolute.txt index 7fd9d9e..f9bcb5d 100644 --- a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.FileListAbsolute.txt +++ b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.FileListAbsolute.txt @@ -28,7 +28,6 @@ I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Engine\obj\Release\TimeHACK I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Engine\obj\Release\TimeHACK.Engine.csproj.GenerateResource.Cache I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Engine\obj\Release\TimeHACK.Engine.dll I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Engine\obj\Release\TimeHACK.Engine.pdb -I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Engine\obj\Release\TimeHACK.Engine.csprojResolveAssemblyReference.cache C:\Users\lempamo\Documents\GitHub\TimeHACK-fork\TimeHACK.Engine\bin\Release\TimeHACK.Engine.dll C:\Users\lempamo\Documents\GitHub\TimeHACK-fork\TimeHACK.Engine\bin\Release\TimeHACK.Engine.pdb C:\Users\lempamo\Documents\GitHub\TimeHACK-fork\TimeHACK.Engine\bin\Release\Newtonsoft.Json.dll diff --git a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.GenerateResource.Cache b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.GenerateResource.Cache index c63151a..5860591 100644 Binary files a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.GenerateResource.Cache and b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csproj.GenerateResource.Cache differ diff --git a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csprojResolveAssemblyReference.cache b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csprojResolveAssemblyReference.cache deleted file mode 100644 index 138bee0..0000000 Binary files a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.csprojResolveAssemblyReference.cache and /dev/null differ diff --git a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.dll b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.dll index 86d9598..062eb83 100644 Binary files a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.dll and b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.dll differ diff --git a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.pdb b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.pdb index 10716d1..57383ef 100644 Binary files a/TimeHACK.Engine/obj/Release/TimeHACK.Engine.pdb and b/TimeHACK.Engine/obj/Release/TimeHACK.Engine.pdb differ diff --git a/TimeHACK.Main/NewGameDialog.Designer.cs b/TimeHACK.Main/NewGameDialog.Designer.cs deleted file mode 100644 index 9aee1e0..0000000 --- a/TimeHACK.Main/NewGameDialog.Designer.cs +++ /dev/null @@ -1,125 +0,0 @@ -namespace TimeHACK -{ - partial class NewGameDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.txtProfName = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.btnOk = new System.Windows.Forms.Button(); - this.btnHelp = new System.Windows.Forms.Button(); - this.btnCancl = new System.Windows.Forms.Button(); - this.btnInfo = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // txtProfName - // - this.txtProfName.Location = new System.Drawing.Point(87, 12); - this.txtProfName.Name = "txtProfName"; - this.txtProfName.Size = new System.Drawing.Size(370, 20); - this.txtProfName.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 15); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(70, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Profile Name:"; - // - // btnOk - // - this.btnOk.Location = new System.Drawing.Point(382, 70); - this.btnOk.Name = "btnOk"; - this.btnOk.Size = new System.Drawing.Size(75, 23); - this.btnOk.TabIndex = 2; - this.btnOk.Text = "OK"; - this.btnOk.UseVisualStyleBackColor = true; - this.btnOk.Click += new System.EventHandler(this.btnOk_Click); - // - // btnHelp - // - this.btnHelp.Location = new System.Drawing.Point(301, 70); - this.btnHelp.Name = "btnHelp"; - this.btnHelp.Size = new System.Drawing.Size(75, 23); - this.btnHelp.TabIndex = 2; - this.btnHelp.Text = "Help"; - this.btnHelp.UseVisualStyleBackColor = true; - this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click); - // - // btnCancl - // - this.btnCancl.Location = new System.Drawing.Point(220, 70); - this.btnCancl.Name = "btnCancl"; - this.btnCancl.Size = new System.Drawing.Size(75, 23); - this.btnCancl.TabIndex = 2; - this.btnCancl.Text = "Cancel"; - this.btnCancl.UseVisualStyleBackColor = true; - this.btnCancl.Click += new System.EventHandler(this.btnCancl_Click); - // - // btnInfo - // - this.btnInfo.Location = new System.Drawing.Point(7, 70); - this.btnInfo.Name = "btnInfo"; - this.btnInfo.Size = new System.Drawing.Size(121, 23); - this.btnInfo.TabIndex = 2; - this.btnInfo.Text = "Technical Info"; - this.btnInfo.UseVisualStyleBackColor = true; - this.btnInfo.Click += new System.EventHandler(this.btnInfo_Click); - // - // NewGameDialog - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(469, 96); - this.Controls.Add(this.btnInfo); - this.Controls.Add(this.btnCancl); - this.Controls.Add(this.btnHelp); - this.Controls.Add(this.btnOk); - this.Controls.Add(this.label1); - this.Controls.Add(this.txtProfName); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "NewGameDialog"; - this.Text = "New Game"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox txtProfName; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button btnOk; - private System.Windows.Forms.Button btnHelp; - private System.Windows.Forms.Button btnCancl; - private System.Windows.Forms.Button btnInfo; - } -} \ No newline at end of file diff --git a/TimeHACK.Main/NewGameDialog.cs b/TimeHACK.Main/NewGameDialog.cs deleted file mode 100644 index 0d95aff..0000000 --- a/TimeHACK.Main/NewGameDialog.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using TimeHACK.Engine; -using Newtonsoft.Json; - -namespace TimeHACK -{ - public partial class NewGameDialog : Form - { - public NewGameDialog() - { - InitializeComponent(); - } - - private void btnHelp_Click(object sender, EventArgs e) - { - MessageBox.Show("You can choose a profile name - this will create a new profile! Whenever you want to Load a game, click 'Load Game' and then choose a profile (You can have as many prfiles as you want)"); - } - - private void btnCancl_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void btnInfo_Click(object sender, EventArgs e) - { - MessageBox.Show("The game's profiles are stored in C:/TimeHACK/Profiles - the rest is for you to figure out!"); - } - - private void btnOk_Click(object sender, EventArgs e) - { - - } - } -} diff --git a/TimeHACK.Main/NewGameDialog.resx b/TimeHACK.Main/NewGameDialog.resx deleted file mode 100644 index 1af7de1..0000000 --- a/TimeHACK.Main/NewGameDialog.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs b/TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs new file mode 100644 index 0000000..4d8691d --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/LoadGameDialog.Designer.cs @@ -0,0 +1,101 @@ +namespace TimeHACK +{ + partial class LoadGameDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.button3 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.Profiles = new System.Windows.Forms.Panel(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.BackColor = System.Drawing.Color.Silver; + this.panel1.Controls.Add(this.button3); + this.panel1.Controls.Add(this.button1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 340); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(516, 25); + this.panel1.TabIndex = 0; + // + // button3 + // + this.button3.Location = new System.Drawing.Point(360, -1); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(75, 23); + this.button3.TabIndex = 0; + this.button3.Text = "Help"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(441, 0); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 0; + this.button1.Text = "OK"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // Profiles + // + this.Profiles.AutoScroll = true; + this.Profiles.Dock = System.Windows.Forms.DockStyle.Fill; + this.Profiles.Location = new System.Drawing.Point(0, 0); + this.Profiles.Name = "Profiles"; + this.Profiles.Size = new System.Drawing.Size(516, 340); + this.Profiles.TabIndex = 2; + // + // LoadGameDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + this.ClientSize = new System.Drawing.Size(516, 365); + this.Controls.Add(this.Profiles); + this.Controls.Add(this.panel1); + this.Name = "LoadGameDialog"; + this.Text = "Profiles"; + this.Load += new System.EventHandler(this.LoadGameDialog_Load); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Panel Profiles; + } +} \ No newline at end of file diff --git a/TimeHACK.Main/SaveDialogs/LoadGameDialog.cs b/TimeHACK.Main/SaveDialogs/LoadGameDialog.cs new file mode 100644 index 0000000..b31bc50 --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/LoadGameDialog.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.IO; +using static TimeHACK.Engine.SaveSystem; + +namespace TimeHACK +{ + public partial class LoadGameDialog : Form + { + public Boolean successful = false; + public LoadGameDialog() + { + InitializeComponent(); + } + + public void ChooseProfile(string SelectedProfile) + { + ProfileName = SelectedProfile; + successful = true; + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void button1_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void button3_Click(object sender, EventArgs e) + { + MessageBox.Show("Here you can control all your profiles! Use can open a profile by hovering over it and clicking 'Load Profile!'"); + } + + private void LoadGameDialog_Load(object sender, EventArgs e) + { + foreach (string dir in Directory.GetDirectories(AllProfilesDirectory)) + { + LoadGameProfileItem newItem = new LoadGameProfileItem(); + newItem.Tag = Path.GetFileName(dir); + newItem.Dock = DockStyle.Top; + Profiles.Controls.Add(newItem); + newItem.Show(); + } + } + } +} diff --git a/TimeHACK.Main/SaveDialogs/LoadGameDialog.resx b/TimeHACK.Main/SaveDialogs/LoadGameDialog.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/LoadGameDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.Designer.cs b/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.Designer.cs new file mode 100644 index 0000000..61a0976 --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.Designer.cs @@ -0,0 +1,190 @@ +namespace TimeHACK +{ + partial class LoadGameProfileItem + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.sidebar = new System.Windows.Forms.Panel(); + this.exampleLoadProfile = new System.Windows.Forms.Button(); + this.exampleDelete = new System.Windows.Forms.Button(); + this.exampleNameBtn = new System.Windows.Forms.Button(); + this.profileName = new System.Windows.Forms.Label(); + this.pnlConfirm = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.sidebar.SuspendLayout(); + this.pnlConfirm.SuspendLayout(); + this.SuspendLayout(); + // + // sidebar + // + this.sidebar.BackColor = System.Drawing.Color.Gray; + this.sidebar.Controls.Add(this.exampleLoadProfile); + this.sidebar.Controls.Add(this.exampleDelete); + this.sidebar.Controls.Add(this.exampleNameBtn); + this.sidebar.Dock = System.Windows.Forms.DockStyle.Right; + this.sidebar.Location = new System.Drawing.Point(245, 0); + this.sidebar.Name = "sidebar"; + this.sidebar.Size = new System.Drawing.Size(102, 82); + this.sidebar.TabIndex = 2; + this.sidebar.Visible = false; + // + // exampleLoadProfile + // + this.exampleLoadProfile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); + this.exampleLoadProfile.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.exampleLoadProfile.Location = new System.Drawing.Point(3, 1); + this.exampleLoadProfile.Name = "exampleLoadProfile"; + this.exampleLoadProfile.Size = new System.Drawing.Size(94, 23); + this.exampleLoadProfile.TabIndex = 0; + this.exampleLoadProfile.Text = "Load Profile!"; + this.exampleLoadProfile.UseVisualStyleBackColor = false; + this.exampleLoadProfile.Click += new System.EventHandler(this.exampleLoadProfile_Click); + // + // exampleDelete + // + this.exampleDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.exampleDelete.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.exampleDelete.Location = new System.Drawing.Point(3, 54); + this.exampleDelete.Name = "exampleDelete"; + this.exampleDelete.Size = new System.Drawing.Size(93, 23); + this.exampleDelete.TabIndex = 0; + this.exampleDelete.Text = "Delete"; + this.exampleDelete.UseVisualStyleBackColor = false; + this.exampleDelete.Click += new System.EventHandler(this.exampleDelete_Click); + // + // exampleNameBtn + // + this.exampleNameBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); + this.exampleNameBtn.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.exampleNameBtn.Location = new System.Drawing.Point(3, 27); + this.exampleNameBtn.Name = "exampleNameBtn"; + this.exampleNameBtn.Size = new System.Drawing.Size(93, 23); + this.exampleNameBtn.TabIndex = 0; + this.exampleNameBtn.Text = "Change Name"; + this.exampleNameBtn.UseVisualStyleBackColor = false; + this.exampleNameBtn.Click += new System.EventHandler(this.exampleNameBtn_Click); + // + // profileName + // + this.profileName.BackColor = System.Drawing.Color.Gray; + this.profileName.Dock = System.Windows.Forms.DockStyle.Fill; + this.profileName.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.profileName.Location = new System.Drawing.Point(0, 0); + this.profileName.Name = "profileName"; + this.profileName.Size = new System.Drawing.Size(245, 82); + this.profileName.TabIndex = 1; + this.profileName.Text = "Profile Name"; + // + // pnlConfirm + // + this.pnlConfirm.BackColor = System.Drawing.Color.Gray; + this.pnlConfirm.Controls.Add(this.button2); + this.pnlConfirm.Controls.Add(this.button1); + this.pnlConfirm.Controls.Add(this.label1); + this.pnlConfirm.Controls.Add(this.textBox1); + this.pnlConfirm.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlConfirm.Location = new System.Drawing.Point(0, 32); + this.pnlConfirm.Name = "pnlConfirm"; + this.pnlConfirm.Size = new System.Drawing.Size(245, 50); + this.pnlConfirm.TabIndex = 1; + this.pnlConfirm.Visible = false; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 5); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(240, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Are you really sure you want to delete this Profile?"; + // + // button1 + // + this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.button1.Location = new System.Drawing.Point(10, 20); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(109, 22); + this.button1.TabIndex = 1; + this.button1.Text = "Yes"; + this.button1.UseVisualStyleBackColor = false; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); + this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.button2.Location = new System.Drawing.Point(136, 20); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(109, 23); + this.button2.TabIndex = 1; + this.button2.Text = "No"; + this.button2.UseVisualStyleBackColor = false; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(3, 22); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(130, 20); + this.textBox1.TabIndex = 1; + this.textBox1.Visible = false; + // + // LoadGameProfileItem + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.pnlConfirm); + this.Controls.Add(this.profileName); + this.Controls.Add(this.sidebar); + this.Name = "LoadGameProfileItem"; + this.Size = new System.Drawing.Size(347, 82); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.LoadGameProfileItem_Paint); + this.sidebar.ResumeLayout(false); + this.pnlConfirm.ResumeLayout(false); + this.pnlConfirm.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel sidebar; + private System.Windows.Forms.Button exampleLoadProfile; + private System.Windows.Forms.Button exampleDelete; + private System.Windows.Forms.Button exampleNameBtn; + private System.Windows.Forms.Label profileName; + private System.Windows.Forms.Panel pnlConfirm; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.TextBox textBox1; + } +} diff --git a/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.cs b/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.cs new file mode 100644 index 0000000..0087fb0 --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static TimeHACK.Engine.SaveSystem; +using System.IO; + +namespace TimeHACK +{ + public partial class LoadGameProfileItem : UserControl, IMessageFilter + { + public Boolean OnceRemoveHeight = false; + public Boolean OnceAddHeight = false; + public Boolean RequestingNewName = false; + public LoadGameProfileItem() + { + InitializeComponent(); + Application.AddMessageFilter(this); + } + + //private void LoadGameProfileItem_MouseHover(object sender, EventArgs e) + //{ + // exampleTop.Show(); + // this.Height += 28; + // OnceRemoveHeight = false; + //} + + public bool PreFilterMessage(ref Message m) + { + var mouseLocation = Cursor.Position; + + if (!ClientRectangle.Contains(PointToClient(Control.MousePosition))) + { + sidebar.Hide(); + if (OnceRemoveHeight == false) + { + this.Height -= 28; + OnceRemoveHeight = true; + profileName.BackColor = Color.Gray; + sidebar.BackColor = Color.Gray; + pnlConfirm.BackColor = Color.Gray; + } + OnceAddHeight = false; + } else + { + sidebar.Show(); + if (OnceAddHeight == false) + { + this.Height += 28; + OnceAddHeight = true; + profileName.BackColor = Color.LightGray; + sidebar.BackColor = Color.LightGray; + pnlConfirm.BackColor = Color.LightGray; + } + OnceRemoveHeight = false; + } + + if (m.Msg != 0x20a) // Scrolling Message + { + return false;//ignore message + } + return false; + } + + private void LoadGameProfileItem_Paint(object sender, PaintEventArgs e) + { + profileName.Text = this.Tag.ToString(); + } + + private void exampleLoadProfile_Click(object sender, EventArgs e) + { + ((LoadGameDialog)this.TopLevelControl).ChooseProfile(this.Tag.ToString()); + } + + private void button1_Click(object sender, EventArgs e) + { + DeleteProfile(); + } + + void DeleteProfile() + { + if (Directory.Exists(Path.Combine(AllProfilesDirectory, this.Tag.ToString()))) + { + Directory.Delete(Path.Combine(AllProfilesDirectory, this.Tag.ToString()), true); + this.Hide(); + } + } + + private void button2_Click(object sender, EventArgs e) + { + try + { + if (!RequestingNewName == false) + { + if (textBox1.Text == "") + { + MessageBox.Show("New profile name cannot be empty!"); + } + else + { + if (textBox1.Text.Length > 20) + { + MessageBox.Show("The profile name cannot be longer than 20 characters"); + } + else + { + if (Directory.Exists(Path.Combine(AllProfilesDirectory, textBox1.Text))) + { + MessageBox.Show("That profile already exists"); + } + else + { + Directory.Move(Path.Combine(AllProfilesDirectory, this.Tag.ToString()), Path.Combine(AllProfilesDirectory, textBox1.Text)); + this.Tag = textBox1.Text; + this.Invalidate(); + } + } + } + } + pnlConfirm.Hide(); + } catch (Exception ex) + { + + } + } + + private void exampleDelete_Click(object sender, EventArgs e) + { + label1.Text = "Are you really sure you want to delete this Profile?"; + button1.Show(); + textBox1.Hide(); + button2.Text = "No"; + RequestingNewName = false; + pnlConfirm.Show(); + } + + private void exampleNameBtn_Click(object sender, EventArgs e) + { + label1.Text = "Enter a new profile name: "; + button1.Hide(); + textBox1.Show(); + button2.Text = "OK"; + RequestingNewName = true; + pnlConfirm.Show(); + } + } +} diff --git a/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.resx b/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/LoadGameProfileItem.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeHACK.Main/SaveDialogs/NewGameDialog.Designer.cs b/TimeHACK.Main/SaveDialogs/NewGameDialog.Designer.cs new file mode 100644 index 0000000..e58e0a7 --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/NewGameDialog.Designer.cs @@ -0,0 +1,141 @@ +namespace TimeHACK +{ + partial class NewGameDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.txtProfName = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnHelp = new System.Windows.Forms.Button(); + this.btnCancl = new System.Windows.Forms.Button(); + this.btnInfo = new System.Windows.Forms.Button(); + this.btnDevMode = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // txtProfName + // + this.txtProfName.Location = new System.Drawing.Point(87, 12); + this.txtProfName.Name = "txtProfName"; + this.txtProfName.Size = new System.Drawing.Size(370, 20); + this.txtProfName.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(70, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Profile Name:"; + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(382, 70); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 23); + this.btnOk.TabIndex = 2; + this.btnOk.Text = "OK"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // btnHelp + // + this.btnHelp.Location = new System.Drawing.Point(301, 70); + this.btnHelp.Name = "btnHelp"; + this.btnHelp.Size = new System.Drawing.Size(75, 23); + this.btnHelp.TabIndex = 2; + this.btnHelp.Text = "Help"; + this.btnHelp.UseVisualStyleBackColor = true; + this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click); + // + // btnCancl + // + this.btnCancl.Location = new System.Drawing.Point(220, 70); + this.btnCancl.Name = "btnCancl"; + this.btnCancl.Size = new System.Drawing.Size(75, 23); + this.btnCancl.TabIndex = 2; + this.btnCancl.Text = "Cancel"; + this.btnCancl.UseVisualStyleBackColor = true; + this.btnCancl.Click += new System.EventHandler(this.btnCancl_Click); + // + // btnInfo + // + this.btnInfo.Location = new System.Drawing.Point(7, 70); + this.btnInfo.Name = "btnInfo"; + this.btnInfo.Size = new System.Drawing.Size(121, 23); + this.btnInfo.TabIndex = 2; + this.btnInfo.Text = "Technical Info"; + this.btnInfo.UseVisualStyleBackColor = true; + this.btnInfo.Click += new System.EventHandler(this.btnInfo_Click); + // + // btnDevMode + // + this.btnDevMode.Location = new System.Drawing.Point(7, 41); + this.btnDevMode.Name = "btnDevMode"; + this.btnDevMode.Size = new System.Drawing.Size(121, 23); + this.btnDevMode.TabIndex = 3; + this.btnDevMode.Text = "What is DevMode?"; + this.btnDevMode.UseVisualStyleBackColor = true; + this.btnDevMode.Visible = false; + this.btnDevMode.Click += new System.EventHandler(this.btnDevMode_Click); + // + // NewGameDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(469, 96); + this.Controls.Add(this.btnDevMode); + this.Controls.Add(this.btnInfo); + this.Controls.Add(this.btnCancl); + this.Controls.Add(this.btnHelp); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.label1); + this.Controls.Add(this.txtProfName); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "NewGameDialog"; + this.Tag = "ignoreFormOnTaskbar"; + this.Text = "New Game"; + this.Load += new System.EventHandler(this.NewGameDialog_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtProfName; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnHelp; + private System.Windows.Forms.Button btnCancl; + private System.Windows.Forms.Button btnInfo; + private System.Windows.Forms.Button btnDevMode; + } +} \ No newline at end of file diff --git a/TimeHACK.Main/SaveDialogs/NewGameDialog.cs b/TimeHACK.Main/SaveDialogs/NewGameDialog.cs new file mode 100644 index 0000000..227edfd --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/NewGameDialog.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using TimeHACK.Engine; +using Newtonsoft.Json; +using static TimeHACK.Engine.SaveSystem; +using System.IO; + +namespace TimeHACK +{ + public partial class NewGameDialog : Form + { + public Boolean Successful = false; + public NewGameDialog() + { + InitializeComponent(); + } + + private void btnHelp_Click(object sender, EventArgs e) + { + MessageBox.Show("You can choose a profile name - this will create a new profile! Whenever you want to Load a game, click 'Load Game' and then choose a profile (You can have as many profiles as you want)"); + } + + private void btnCancl_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnInfo_Click(object sender, EventArgs e) + { + MessageBox.Show("The game's profiles are stored in your Documents /TimeHACK/Profiles - the rest is for you to figure out!"); + } + + private void btnOk_Click(object sender, EventArgs e) + { + try + { + if (txtProfName.Text != "") + { + if (!(txtProfName.Text.Length > 20)) + { + ProfileName = txtProfName.Text; + if (DevMode == true) + if (Directory.Exists(ProfileDirectory)) + { + Directory.Delete(ProfileDirectory, true); + Successful = true; + this.Close(); + } + + if (!Directory.Exists(ProfileDirectory)) + { + Successful = true; + this.Close(); + } + else + { + MessageBox.Show("That profile already exists! \n USEFUL INFO: Use 'Load Game' to manage your profiles - from there you can delete the profile!"); + } + } + else + { + MessageBox.Show("The profile name cannot be longer than 20 characters"); + } + + } + else + { + MessageBox.Show("You must enter a profile name!"); + } + } catch (Exception ex) + { + + } + } + + private void NewGameDialog_Load(object sender, EventArgs e) + { + if (DevMode == true) + { + btnDevMode.Show(); + } + } + + private void btnDevMode_Click(object sender, EventArgs e) + { + MessageBox.Show("DevMode is a mode Designed for Development of the game, if you are seeing this that means it is activated! All DevMode does is if a Profile already exists then rather than asking you to choose a different name it just " + + "deletes the old one! This means that you won't have 1 million profiles everytime you want to test something in the game!"); + } + } +} diff --git a/TimeHACK.Main/SaveDialogs/NewGameDialog.resx b/TimeHACK.Main/SaveDialogs/NewGameDialog.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TimeHACK.Main/SaveDialogs/NewGameDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeHACK.Main/TimeHACK.Main.csproj b/TimeHACK.Main/TimeHACK.Main.csproj index 4956405..a8ccbff 100644 --- a/TimeHACK.Main/TimeHACK.Main.csproj +++ b/TimeHACK.Main/TimeHACK.Main.csproj @@ -122,10 +122,22 @@ - + Form - + + LoadGameDialog.cs + + + UserControl + + + LoadGameProfileItem.cs + + + Form + + NewGameDialog.cs @@ -231,7 +243,13 @@ TitleScreen.cs - + + LoadGameDialog.cs + + + LoadGameProfileItem.cs + + NewGameDialog.cs diff --git a/TimeHACK.Main/TitleScreen.Designer.cs b/TimeHACK.Main/TitleScreen.Designer.cs index 0437c60..6ecbda3 100644 --- a/TimeHACK.Main/TitleScreen.Designer.cs +++ b/TimeHACK.Main/TitleScreen.Designer.cs @@ -61,7 +61,7 @@ this.gameversion.Text = "gameversion"; this.gameversion.MouseLeave += new System.EventHandler(this.gameversion_MouseLeave); this.gameversion.MouseHover += new System.EventHandler(this.gameversion_MouseHover); - // + this.gameversion.Click += new System.EventHandler(this.startbutton_Click); // vm_mode // this.vm_mode.AutoSize = true; @@ -214,6 +214,7 @@ this.startbutton.Size = new System.Drawing.Size(279, 22); this.startbutton.TabIndex = 12; this.startbutton.TabStop = false; + this.startbutton.Click += new System.EventHandler(this.startbutton_Click); // // TitleScreen // diff --git a/TimeHACK.Main/TitleScreen.cs b/TimeHACK.Main/TitleScreen.cs index c883a95..05fb7cf 100644 --- a/TimeHACK.Main/TitleScreen.cs +++ b/TimeHACK.Main/TitleScreen.cs @@ -19,17 +19,19 @@ namespace TimeHACK public static DirectoryInfo thfolder; public static DirectoryInfo datafolder; public static DirectoryInfo profilefolder; + public static NewGameDialog newGameBox; + public static LoadGameDialog loadGameBox; public void StartGame() - { + { //TODO: You may want to handle story stuff to decide what OS to boot here. if (Convert.ToInt32(VM_Width.Text) == 1337 && Convert.ToInt32(VM_Height.Text) == 1337) { leet(); } else -// If VM Mode is not enabled -if (vm_mode.Checked != true) + // If VM Mode is not enabled + if (vm_mode.Checked != true) { // Generate fullscreen desktop frm95 = new Windows95(); @@ -50,7 +52,6 @@ if (vm_mode.Checked != true) frm95.Show(); Hide(); } - } @@ -144,8 +145,14 @@ if (vm_mode.Checked != true) // When NewGame is Clicked private void NewGame_Click(object sender, EventArgs e) { - NewGame(); - StartGame(); + newGameBox = new NewGameDialog(); + newGameBox.ShowDialog(); + + if (newGameBox.Successful == true) + { + NewGame(); + StartGame(); + } } public void BSODRewind(object sender, EventArgs e) @@ -193,12 +200,19 @@ if (vm_mode.Checked != true) #region LoadGame private void LoadGame_Click(object sender, EventArgs e) { - var result = LoadSave(); - if(result == false) + loadGameBox = new LoadGameDialog(); + loadGameBox.ShowDialog(); + + //var result = LoadSave(); + //if(result == false) + //{ + // MessageBox.Show(caption: "No save found.", text: "No save was found on your system. However, we have created a new one, and we will start it up for you."); + //} + if (loadGameBox.successful == true) { - MessageBox.Show(caption: "No save found.", text: "No save was found on your system. However, we have created a new one, and we will start it up for you."); - } - StartGame(); + LoadSave(); + StartGame(); + } } private void LoadGame_Enter(object sender, EventArgs e) { @@ -236,5 +250,18 @@ if (vm_mode.Checked != true) { gameversion.Text = "TimeHACK " + Program.gameID; } + + private void startbutton_Click(object sender, EventArgs e) + { + if (DevMode == true) + { + DevMode = false; + gameversion.Text = "Developer Mode Deactivated"; + } else { + DevMode = true; + gameversion.Text = "Developer Mode Activated"; + } + + } } } diff --git a/TimeHACK.Main/bin/Release/TimeHACK.Engine.dll b/TimeHACK.Main/bin/Release/TimeHACK.Engine.dll index 86d9598..062eb83 100644 Binary files a/TimeHACK.Main/bin/Release/TimeHACK.Engine.dll and b/TimeHACK.Main/bin/Release/TimeHACK.Engine.dll differ diff --git a/TimeHACK.Main/bin/Release/TimeHACK.Engine.pdb b/TimeHACK.Main/bin/Release/TimeHACK.Engine.pdb index 10716d1..57383ef 100644 Binary files a/TimeHACK.Main/bin/Release/TimeHACK.Engine.pdb and b/TimeHACK.Main/bin/Release/TimeHACK.Engine.pdb differ diff --git a/TimeHACK.Main/bin/Release/TimeHACK.application b/TimeHACK.Main/bin/Release/TimeHACK.application index 0330353..055a7f3 100644 --- a/TimeHACK.Main/bin/Release/TimeHACK.application +++ b/TimeHACK.Main/bin/Release/TimeHACK.application @@ -14,7 +14,7 @@ - XMTyg5Kg3uvVV2ZvfkI43b0wiH20oJy+kuosu8ml90M= + btyohAVc+4Sb51EUMC2WPcUaog+43R54sTs+wcGFXps= diff --git a/TimeHACK.Main/bin/Release/TimeHACK.exe b/TimeHACK.Main/bin/Release/TimeHACK.exe index 65f8e05..a0ec537 100644 Binary files a/TimeHACK.Main/bin/Release/TimeHACK.exe and b/TimeHACK.Main/bin/Release/TimeHACK.exe differ diff --git a/TimeHACK.Main/bin/Release/TimeHACK.exe.manifest b/TimeHACK.Main/bin/Release/TimeHACK.exe.manifest index 6059ec2..5aabcc3 100644 --- a/TimeHACK.Main/bin/Release/TimeHACK.exe.manifest +++ b/TimeHACK.Main/bin/Release/TimeHACK.exe.manifest @@ -56,14 +56,14 @@ - + - u03DD/pHUph61RloaEJSWDxvuKIJlTZGJIAld/bJir8= + ZM+Y7lQ8FJWiXzXVRe9IyUX7OOiMMpcs9z5UaYLK604= @@ -75,7 +75,7 @@ - 4Bmiv+Bv5HnrACFrxYEZWLpxwAHN9AGwSRIgpeHajHM= + EffWUA6LIrqzxasZmwNPhJDRDde+8cUqYyPVn9gesvQ= diff --git a/TimeHACK.Main/bin/Release/TimeHACK.pdb b/TimeHACK.Main/bin/Release/TimeHACK.pdb index 85b4249..2a84a2c 100644 Binary files a/TimeHACK.Main/bin/Release/TimeHACK.pdb and b/TimeHACK.Main/bin/Release/TimeHACK.pdb differ diff --git a/TimeHACK.Main/bin/Release/app.publish/TimeHACK.exe b/TimeHACK.Main/bin/Release/app.publish/TimeHACK.exe index 65f8e05..a0ec537 100644 Binary files a/TimeHACK.Main/bin/Release/app.publish/TimeHACK.exe and b/TimeHACK.Main/bin/Release/app.publish/TimeHACK.exe differ diff --git a/TimeHACK.Main/obj/Release/CoreCompileInputs.cache b/TimeHACK.Main/obj/Release/CoreCompileInputs.cache index 0769fb6..7c551b4 100644 --- a/TimeHACK.Main/obj/Release/CoreCompileInputs.cache +++ b/TimeHACK.Main/obj/Release/CoreCompileInputs.cache @@ -1 +1 @@ -1b9c46aa867d802039fc56e435e48b2dd2dc4952 +55e5267912f35225509997d29deb1d005ac19e4a diff --git a/TimeHACK.Main/obj/Release/DesignTimeResolveAssemblyReferences.cache b/TimeHACK.Main/obj/Release/DesignTimeResolveAssemblyReferences.cache index 8ab60bb..3502978 100644 Binary files a/TimeHACK.Main/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/TimeHACK.Main/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/TimeHACK.Main/obj/Release/TimeHACK.LoadGameDialog.resources b/TimeHACK.Main/obj/Release/TimeHACK.LoadGameDialog.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/TimeHACK.Main/obj/Release/TimeHACK.LoadGameDialog.resources differ diff --git a/TimeHACK.Main/obj/Release/TimeHACK.LoadGameProfileItem.resources b/TimeHACK.Main/obj/Release/TimeHACK.LoadGameProfileItem.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/TimeHACK.Main/obj/Release/TimeHACK.LoadGameProfileItem.resources differ diff --git a/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.FileListAbsolute.txt b/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.FileListAbsolute.txt index a0a93a1..2377ecd 100644 --- a/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.FileListAbsolute.txt +++ b/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.FileListAbsolute.txt @@ -27,3 +27,5 @@ I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Main\obj\Release\TimeHACK.e I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Main\obj\Release\TimeHACK.application I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Main\obj\Release\TimeHACK.exe I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Main\obj\Release\TimeHACK.pdb +I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Main\obj\Release\TimeHACK.LoadGameDialog.resources +I:\Desktop\HistamcomVB\My-TimeHACK\TimeHACK\TimeHACK.Main\obj\Release\TimeHACK.LoadGameProfileItem.resources diff --git a/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.GenerateResource.Cache b/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.GenerateResource.Cache index 52c2d62..1364508 100644 Binary files a/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.GenerateResource.Cache and b/TimeHACK.Main/obj/Release/TimeHACK.Main.csproj.GenerateResource.Cache differ diff --git a/TimeHACK.Main/obj/Release/TimeHACK.Main.csprojResolveAssemblyReference.cache b/TimeHACK.Main/obj/Release/TimeHACK.Main.csprojResolveAssemblyReference.cache index 567e21d..f689b80 100644 Binary files a/TimeHACK.Main/obj/Release/TimeHACK.Main.csprojResolveAssemblyReference.cache and b/TimeHACK.Main/obj/Release/TimeHACK.Main.csprojResolveAssemblyReference.cache differ diff --git a/TimeHACK.Main/obj/Release/TimeHACK.WinClassicForms.WinClassicInstaller.resources b/TimeHACK.Main/obj/Release/TimeHACK.WinClassicForms.WinClassicInstaller.resources index 3dc6527..efaafcd 100644 Binary files a/TimeHACK.Main/obj/Release/TimeHACK.WinClassicForms.WinClassicInstaller.resources and b/TimeHACK.Main/obj/Release/TimeHACK.WinClassicForms.WinClassicInstaller.resources differ diff --git a/TimeHACK.Main/obj/Release/TimeHACK.application b/TimeHACK.Main/obj/Release/TimeHACK.application index 0330353..055a7f3 100644 --- a/TimeHACK.Main/obj/Release/TimeHACK.application +++ b/TimeHACK.Main/obj/Release/TimeHACK.application @@ -14,7 +14,7 @@ - XMTyg5Kg3uvVV2ZvfkI43b0wiH20oJy+kuosu8ml90M= + btyohAVc+4Sb51EUMC2WPcUaog+43R54sTs+wcGFXps= diff --git a/TimeHACK.Main/obj/Release/TimeHACK.exe b/TimeHACK.Main/obj/Release/TimeHACK.exe index 65f8e05..a0ec537 100644 Binary files a/TimeHACK.Main/obj/Release/TimeHACK.exe and b/TimeHACK.Main/obj/Release/TimeHACK.exe differ diff --git a/TimeHACK.Main/obj/Release/TimeHACK.exe.manifest b/TimeHACK.Main/obj/Release/TimeHACK.exe.manifest index 6059ec2..5aabcc3 100644 --- a/TimeHACK.Main/obj/Release/TimeHACK.exe.manifest +++ b/TimeHACK.Main/obj/Release/TimeHACK.exe.manifest @@ -56,14 +56,14 @@ - + - u03DD/pHUph61RloaEJSWDxvuKIJlTZGJIAld/bJir8= + ZM+Y7lQ8FJWiXzXVRe9IyUX7OOiMMpcs9z5UaYLK604= @@ -75,7 +75,7 @@ - 4Bmiv+Bv5HnrACFrxYEZWLpxwAHN9AGwSRIgpeHajHM= + EffWUA6LIrqzxasZmwNPhJDRDde+8cUqYyPVn9gesvQ= diff --git a/TimeHACK.Main/obj/Release/TimeHACK.pdb b/TimeHACK.Main/obj/Release/TimeHACK.pdb index 85b4249..2a84a2c 100644 Binary files a/TimeHACK.Main/obj/Release/TimeHACK.pdb and b/TimeHACK.Main/obj/Release/TimeHACK.pdb differ -- cgit v1.2.3