aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Main/SaveDialogs
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-06-10 12:22:50 +0100
committerAlex-TIMEHACK <[email protected]>2017-06-10 12:22:50 +0100
commit316b7739bd1f2e19ba67d7fd6302b8ec0c8fa75a (patch)
tree4ed1f7005fb5a9149078f4a0d9953cffce058b2c /TimeHACK.Main/SaveDialogs
parenta15d2c212ad88efa571c2421bb67629a884eee89 (diff)
downloadhistacom2-316b7739bd1f2e19ba67d7fd6302b8ec0c8fa75a.tar.gz
histacom2-316b7739bd1f2e19ba67d7fd6302b8ec0c8fa75a.tar.bz2
histacom2-316b7739bd1f2e19ba67d7fd6302b8ec0c8fa75a.zip
Done ALOT of tweaks and Save troubleshooter
There is now a save troubleshooter that checks your save files if they can't load! Also, it checks what OS to load on startup of the game!
Diffstat (limited to 'TimeHACK.Main/SaveDialogs')
-rw-r--r--TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.Designer.cs147
-rw-r--r--TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs119
-rw-r--r--TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.resx120
3 files changed, 386 insertions, 0 deletions
diff --git a/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.Designer.cs b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.Designer.cs
new file mode 100644
index 0000000..a242366
--- /dev/null
+++ b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.Designer.cs
@@ -0,0 +1,147 @@
+namespace TimeHACK.SaveDialogs
+{
+ partial class SaveFileTroubleShooter
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.pnlResolved = new System.Windows.Forms.Panel();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.panel2 = new System.Windows.Forms.Panel();
+ this.btnClose = new System.Windows.Forms.Button();
+ this.pnlResolved.SuspendLayout();
+ this.panel2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(12, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(393, 20);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Please wait while we check the state of your Save file...";
+ //
+ // pnlResolved
+ //
+ this.pnlResolved.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pnlResolved.Controls.Add(this.textBox1);
+ this.pnlResolved.Controls.Add(this.label3);
+ this.pnlResolved.Controls.Add(this.label2);
+ this.pnlResolved.Location = new System.Drawing.Point(12, 38);
+ this.pnlResolved.Name = "pnlResolved";
+ this.pnlResolved.Size = new System.Drawing.Size(589, 146);
+ this.pnlResolved.TabIndex = 1;
+ this.pnlResolved.Visible = false;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label2.Location = new System.Drawing.Point(8, 11);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(210, 20);
+ this.label2.TabIndex = 0;
+ this.label2.Text = "The issue has been resolved";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(9, 31);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(24, 13);
+ this.label3.TabIndex = 2;
+ this.label3.Text = "log:";
+ //
+ // textBox1
+ //
+ this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBox1.Location = new System.Drawing.Point(10, 55);
+ this.textBox1.Multiline = true;
+ this.textBox1.Name = "textBox1";
+ this.textBox1.ReadOnly = true;
+ this.textBox1.Size = new System.Drawing.Size(567, 79);
+ this.textBox1.TabIndex = 3;
+ //
+ // panel2
+ //
+ this.panel2.BackColor = System.Drawing.SystemColors.ControlDark;
+ this.panel2.Controls.Add(this.btnClose);
+ this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.panel2.Location = new System.Drawing.Point(0, 217);
+ this.panel2.Name = "panel2";
+ this.panel2.Size = new System.Drawing.Size(612, 30);
+ this.panel2.TabIndex = 2;
+ //
+ // btnClose
+ //
+ this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnClose.Location = new System.Drawing.Point(526, 4);
+ this.btnClose.Name = "btnClose";
+ this.btnClose.Size = new System.Drawing.Size(75, 23);
+ this.btnClose.TabIndex = 0;
+ this.btnClose.Text = "Close";
+ this.btnClose.UseVisualStyleBackColor = true;
+ this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
+ //
+ // SaveFileTroubleShooter
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(612, 247);
+ this.Controls.Add(this.panel2);
+ this.Controls.Add(this.pnlResolved);
+ this.Controls.Add(this.label1);
+ this.Name = "SaveFileTroubleShooter";
+ this.Text = "Save File Troubleshooter";
+ this.Load += new System.EventHandler(this.SaveFileTroubleShooter_Load);
+ this.pnlResolved.ResumeLayout(false);
+ this.pnlResolved.PerformLayout();
+ this.panel2.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Panel pnlResolved;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Panel panel2;
+ private System.Windows.Forms.Button btnClose;
+ }
+} \ No newline at end of file
diff --git a/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
new file mode 100644
index 0000000..eb79543
--- /dev/null
+++ b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
@@ -0,0 +1,119 @@
+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 System.IO;
+
+namespace TimeHACK.SaveDialogs
+{
+ public partial class SaveFileTroubleShooter : Form
+ {
+ public String log;
+ Save savedata = new Save();
+ String json;
+ public SaveFileTroubleShooter()
+ {
+ InitializeComponent();
+ }
+
+ private void btnClose_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void SaveFileTroubleShooter_Load(object sender, EventArgs e)
+ {
+ BeginScan();
+ }
+
+ void WriteToLog(String toWrite)
+ {
+ log += toWrite + Environment.NewLine;
+ }
+
+ void BeginScan()
+ {
+ WriteToLog("Started scanning profile: " + SaveSystem.ProfileName);
+
+ // Check if the main.save file exists
+
+ if (!File.Exists(Path.Combine(SaveSystem.ProfileDirectory, "main.save")))
+ {
+ WriteToLog("ISSUE FOUND! File main.save doesn't exist");
+
+ WriteToLog("Creating one...");
+
+ SaveSystem.NewGame();
+
+ WriteToLog("Created one!");
+
+ EndScan(true);
+ return;
+ } else {
+ WriteToLog("File main.save does exist - checking contents");
+
+ // Read the main.save file
+ json = File.ReadAllText(Path.Combine(SaveSystem.ProfileDirectory, "main.save"));
+
+ savedata = Newtonsoft.Json.JsonConvert.DeserializeObject<Save>(json);
+
+ // Check the values
+
+ if (savedata.CurrentOS == null || savedata.CurrentOS == "")
+ {
+ WriteToLog("ISSUE FOUND! Data for CurrentOS is null! Giving default value...");
+ savedata.CurrentOS = "95";
+ EndScan(true);
+ }
+
+ if (savedata.ExperiencedStories == null)
+ {
+ WriteToLog("ISSUE FOUND! Data for ExperiencedStories is null! Giving default value...");
+ savedata.ExperiencedStories = new List<string>();
+ }
+
+ if (savedata.ExperiencedStories == null)
+ {
+ WriteToLog("ISSUE FOUND! Data for ExperiencedStories is null! Giving default value...");
+ savedata.ExperiencedStories = new List<string>();
+ }
+ }
+
+ if (!Directory.Exists(Path.Combine(SaveSystem.ProfileDirectory, "folders")))
+ {
+ WriteToLog("ISSUE FOUND! Directory 'folders' doesn't exist! Creating one...");
+ Directory.CreateDirectory(Path.Combine(SaveSystem.ProfileDirectory, "folders"));
+ SaveSystem.CheckFiles();
+ }
+
+
+ }
+
+ void EndScan(Boolean successful)
+ {
+ pnlResolved.Visible = true;
+ if (successful == true)
+ {
+ label2.Text = "The issue has been resolved.";
+ // Set CurrentSave to the resolved one
+
+ SaveSystem.CurrentSave = savedata;
+
+ // Set the main.save file to the resolved one
+
+ File.WriteAllText(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), Newtonsoft.Json.JsonConvert.SerializeObject(savedata));
+
+ textBox1.Text = log;
+ } else {
+ label2.Text = "The issue has not been resolved, sorry";
+ textBox1.Text = log;
+ }
+ }
+ }
+}
diff --git a/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.resx b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.resx
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file