aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-08-29 14:32:19 -0400
committerGitHub <[email protected]>2017-08-29 14:32:19 -0400
commitd4d94f85a6424e4d21cecccec21b0e78860431d6 (patch)
tree3644ac63218378082e0afa90d4c42d73d6d3980c
parent7e54d42ed67bf8417a4a479dedce65217adc8309 (diff)
parent213861a59ee7cb42816172c38994d93484d129e8 (diff)
downloadhistacom2-d4d94f85a6424e4d21cecccec21b0e78860431d6.tar.gz
histacom2-d4d94f85a6424e4d21cecccec21b0e78860431d6.tar.bz2
histacom2-d4d94f85a6424e4d21cecccec21b0e78860431d6.zip
Merge pull request #154 from Alex-TIMEHACK/master
New resizing system + Save troubleshooter fix
-rw-r--r--Histacom2.Engine/Histacom2.Engine.csproj9
-rw-r--r--Histacom2.Engine/SaveSystem.cs7
-rw-r--r--Histacom2.Engine/Template/ResizeOverlay.Designer.cs78
-rw-r--r--Histacom2.Engine/Template/ResizeOverlay.cs35
-rw-r--r--Histacom2.Engine/Template/ResizeOverlay.resx123
-rw-r--r--Histacom2.Engine/Template/WinClassic.Designer.cs10
-rw-r--r--Histacom2.Engine/Template/WinClassic.cs115
-rw-r--r--Histacom2.Engine/Template/WinClassic.resx48
-rw-r--r--Histacom2/OS/Win95/Win95Apps/Win95WindowsExplorer.Designer.cs27
-rw-r--r--Histacom2/OS/Win98/Win98Apps/WinClassicWindowsExplorer.Designer.cs2
-rw-r--r--Histacom2/SaveDialogs/SaveFileTroubleShooter.Designer.cs49
-rw-r--r--Histacom2/SaveDialogs/SaveFileTroubleShooter.cs135
-rw-r--r--Histacom2/TitleScreen.Designer.cs2
-rw-r--r--Histacom2/TitleScreen.cs2
14 files changed, 505 insertions, 137 deletions
diff --git a/Histacom2.Engine/Histacom2.Engine.csproj b/Histacom2.Engine/Histacom2.Engine.csproj
index 37c4489..361672e 100644
--- a/Histacom2.Engine/Histacom2.Engine.csproj
+++ b/Histacom2.Engine/Histacom2.Engine.csproj
@@ -54,6 +54,12 @@
<Compile Include="Paintbrush.cs" />
<Compile Include="SaveSystem.cs" />
<Compile Include="TaskBarController.cs" />
+ <Compile Include="Template\ResizeOverlay.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Template\ResizeOverlay.Designer.cs">
+ <DependentUpon>ResizeOverlay.cs</DependentUpon>
+ </Compile>
<Compile Include="Template\Win9XBSOD.cs">
<SubType>Form</SubType>
</Compile>
@@ -102,6 +108,9 @@
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
+ <EmbeddedResource Include="Template\ResizeOverlay.resx">
+ <DependentUpon>ResizeOverlay.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Template\Win9XBSOD.resx">
<DependentUpon>Win9XBSOD.cs</DependentUpon>
</EmbeddedResource>
diff --git a/Histacom2.Engine/SaveSystem.cs b/Histacom2.Engine/SaveSystem.cs
index 7da916b..b8c619e 100644
--- a/Histacom2.Engine/SaveSystem.cs
+++ b/Histacom2.Engine/SaveSystem.cs
@@ -28,6 +28,13 @@ namespace Histacom2.Engine
public static Theme currentTheme { get; set; }
+ public static bool IsBinarySave =
+#if BINARY_SAVE
+ true;
+#else
+ false;
+#endif
+
#if BINARY_SAVE
private static readonly byte[] magic = Encoding.UTF8.GetBytes("THSv");
private static readonly IOrderedEnumerable<System.Reflection.PropertyInfo> properties = typeof(Save).GetProperties().OrderBy(p => (p.GetCustomAttributes(typeof(OrderAttribute), false).SingleOrDefault() as OrderAttribute).Order);
diff --git a/Histacom2.Engine/Template/ResizeOverlay.Designer.cs b/Histacom2.Engine/Template/ResizeOverlay.Designer.cs
new file mode 100644
index 0000000..8d76c26
--- /dev/null
+++ b/Histacom2.Engine/Template/ResizeOverlay.Designer.cs
@@ -0,0 +1,78 @@
+namespace Histacom2.Engine.Template
+{
+ partial class ResizeOverlay
+ {
+ /// <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.components = new System.ComponentModel.Container();
+ this.outline = new System.Windows.Forms.PictureBox();
+ this.tmrMove = new System.Windows.Forms.Timer(this.components);
+ ((System.ComponentModel.ISupportInitialize)(this.outline)).BeginInit();
+ this.SuspendLayout();
+ //
+ // outline
+ //
+ this.outline.BackColor = System.Drawing.Color.Transparent;
+ this.outline.Location = new System.Drawing.Point(194, 158);
+ this.outline.Name = "outline";
+ this.outline.Size = new System.Drawing.Size(300, 158);
+ this.outline.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
+ this.outline.TabIndex = 0;
+ this.outline.TabStop = false;
+ this.outline.Paint += new System.Windows.Forms.PaintEventHandler(this.outline_Paint);
+ //
+ // tmrMove
+ //
+ this.tmrMove.Interval = 20;
+ this.tmrMove.Tick += new System.EventHandler(this.tmrMove_Tick);
+ //
+ // ResizeOverlay
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(0)))), ((int)(((byte)(1)))));
+ this.ClientSize = new System.Drawing.Size(800, 600);
+ this.Controls.Add(this.outline);
+ this.DoubleBuffered = true;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.Name = "ResizeOverlay";
+ this.Tag = "ignoreFormOnTaskbar";
+ this.Text = "ResizeOverlay";
+ this.TopMost = true;
+ this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(0)))), ((int)(((byte)(1)))));
+ this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
+ ((System.ComponentModel.ISupportInitialize)(this.outline)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PictureBox outline;
+ public System.Windows.Forms.Timer tmrMove;
+ }
+} \ No newline at end of file
diff --git a/Histacom2.Engine/Template/ResizeOverlay.cs b/Histacom2.Engine/Template/ResizeOverlay.cs
new file mode 100644
index 0000000..ca8a5e4
--- /dev/null
+++ b/Histacom2.Engine/Template/ResizeOverlay.cs
@@ -0,0 +1,35 @@
+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;
+
+namespace Histacom2.Engine.Template
+{
+ public partial class ResizeOverlay : Form
+ {
+ public Rectangle ToDraw = new Rectangle();
+
+ public ResizeOverlay()
+ {
+ InitializeComponent();
+ }
+
+ private void tmrMove_Tick(object sender, EventArgs e)
+ {
+ outline.Bounds = ToDraw; // Pens.Gray, ToDraw);
+ }
+
+ private void outline_Paint(object sender, PaintEventArgs e)
+ {
+ e.Graphics.FillRectangle(Brushes.Gray, 0, 0, outline.Width, 4); // Top border
+ e.Graphics.FillRectangle(Brushes.Gray, 0, outline.Height - 4, outline.Width, 4); // Bottom border
+ e.Graphics.FillRectangle(Brushes.Gray, 0, 0, 4, outline.Height); // Left border
+ e.Graphics.FillRectangle(Brushes.Gray, outline.Width - 4, 0, 4, outline.Height); // Right border
+ }
+ }
+}
diff --git a/Histacom2.Engine/Template/ResizeOverlay.resx b/Histacom2.Engine/Template/ResizeOverlay.resx
new file mode 100644
index 0000000..10340d0
--- /dev/null
+++ b/Histacom2.Engine/Template/ResizeOverlay.resx
@@ -0,0 +1,123 @@
+<?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>
+ <metadata name="tmrMove.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+</root> \ No newline at end of file
diff --git a/Histacom2.Engine/Template/WinClassic.Designer.cs b/Histacom2.Engine/Template/WinClassic.Designer.cs
index be76be6..593cfd6 100644
--- a/Histacom2.Engine/Template/WinClassic.Designer.cs
+++ b/Histacom2.Engine/Template/WinClassic.Designer.cs
@@ -162,6 +162,7 @@
this.toprightcorner.TabIndex = 6;
this.toprightcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.toprightcorner.MouseMove += new System.Windows.Forms.MouseEventHandler(this.toprightcorner_MouseMove);
+ this.toprightcorner.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// bottomrightcorner
//
@@ -174,6 +175,7 @@
this.bottomrightcorner.TabIndex = 4;
this.bottomrightcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.bottomrightcorner.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bottomrightcorner_MouseMove);
+ this.bottomrightcorner.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// bottomleftcorner
//
@@ -186,6 +188,7 @@
this.bottomleftcorner.TabIndex = 2;
this.bottomleftcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.bottomleftcorner.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bottomleftcorner_MouseMove);
+ this.bottomleftcorner.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// topleftcorner
//
@@ -197,6 +200,7 @@
this.topleftcorner.TabIndex = 1;
this.topleftcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.topleftcorner.MouseMove += new System.Windows.Forms.MouseEventHandler(this.topleftcorner_MouseMove);
+ this.topleftcorner.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// left
//
@@ -209,6 +213,7 @@
this.left.TabIndex = 3;
this.left.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.left.MouseMove += new System.Windows.Forms.MouseEventHandler(this.left_MouseMove);
+ this.left.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// bottom
//
@@ -222,6 +227,7 @@
this.bottom.TabIndex = 5;
this.bottom.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.bottom.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bottom_MouseMove);
+ this.bottom.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// right
//
@@ -234,6 +240,7 @@
this.right.TabIndex = 7;
this.right.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.right.MouseMove += new System.Windows.Forms.MouseEventHandler(this.right_MouseMove);
+ this.right.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// top
//
@@ -247,6 +254,7 @@
this.top.TabIndex = 8;
this.top.MouseDown += new System.Windows.Forms.MouseEventHandler(this.border_MouseDown);
this.top.MouseMove += new System.Windows.Forms.MouseEventHandler(this.top_MouseMove);
+ this.top.MouseUp += new System.Windows.Forms.MouseEventHandler(this.border_MouseUp);
//
// WinClassic
//
@@ -254,11 +262,13 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 300);
this.Controls.Add(this.program);
+ this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "WinClassic";
this.Text = "WinClassic";
this.Activated += new System.EventHandler(this.WinClassic_Activated);
this.Deactivate += new System.EventHandler(this.WinClassic_Deactivate);
+ this.Paint += new System.Windows.Forms.PaintEventHandler(this.WinClassic_Paint);
this.program.ResumeLayout(false);
this.programtopbar.ResumeLayout(false);
this.programtopbar.PerformLayout();
diff --git a/Histacom2.Engine/Template/WinClassic.cs b/Histacom2.Engine/Template/WinClassic.cs
index 4c495bc..23ea562 100644
--- a/Histacom2.Engine/Template/WinClassic.cs
+++ b/Histacom2.Engine/Template/WinClassic.cs
@@ -14,11 +14,13 @@ namespace Histacom2.Engine.Template
}
public Font fnt;
+ public ResizeOverlay resizer = new ResizeOverlay();
public bool resizable = true;
public bool closeDisabled = false;
public bool isActive = true;
-
+ public bool Resizing = false;
+ public Bitmap ResizingBmp = null;
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int WM_SYSCOMMAND = 0x0112;
public const int HT_CAPTION = 0x2;
@@ -72,7 +74,9 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Size = new Size(MousePosition.X - this.Location.X, this.Size.Height);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = MousePosition.X - this.Location.X;
+ resizer.ToDraw = toDraw;
}
}
@@ -80,8 +84,10 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
- if (resizable)this.Location = new Point(Cursor.Position.X, this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
+ if (resizable) toDraw.X = Cursor.Position.X;
+ resizer.ToDraw = toDraw;
}
}
@@ -89,7 +95,10 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Size = new Size(this.Size.Width, MousePosition.Y - this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Y = this.Location.Y;
+ if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -97,7 +106,10 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Size = new Size(MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = MousePosition.X - this.Location.X;
+ if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -105,9 +117,11 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
- if (resizable) this.Height = (Cursor.Position.Y - this.Location.Y);
- if (resizable) this.Location = new Point(Cursor.Position.X, this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = ((toDraw.Width + toDraw.Location.X) - Cursor.Position.X);
+ if (resizable) toDraw.Height = Cursor.Position.Y - this.Location.Y;
+ if (resizable) toDraw.X = Cursor.Position.X;
+ resizer.ToDraw = toDraw;
}
}
@@ -115,10 +129,12 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
- if (resizable) this.Location = new Point(Cursor.Position.X, this.Location.Y);
- if (resizable) this.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
- if (resizable) this.Location = new Point(this.Location.X, Cursor.Position.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
+ if (resizable) toDraw.X = Cursor.Position.X;
+ if (resizable) toDraw.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
+ if (resizable) toDraw.Y = Cursor.Position.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -126,8 +142,10 @@ namespace Histacom2.Engine.Template
{
if(e.Button == MouseButtons.Left)
{
- if(resizable) this.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
- if(resizable) this.Location = new Point(this.Location.X, Cursor.Position.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
+ if (resizable) toDraw.Y = Cursor.Position.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -135,12 +153,58 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = (Cursor.Position.X - this.Location.X);
- if (resizable) this.Height = ((this.Location.Y - Cursor.Position.Y) + this.Height);
- if (resizable) this.Location = new Point(this.Location.X, Cursor.Position.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = MousePosition.X - this.Location.X;
+ if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
+ if (resizable) toDraw.Y = Cursor.Position.Y;
+ resizer.ToDraw = toDraw;
+ }
+ }
+
+ private void WinClassic_Paint(object sender, PaintEventArgs e)
+ {
+ if (Resizing)
+ {
+ MessageBox.Show("HIT IT");
+ e.Graphics.DrawImage(ResizingBmp, 0, 0, this.Width, this.Height);
}
}
+ private void border_MouseUp(object sender, MouseEventArgs e)
+ {
+ this.Bounds = resizer.ToDraw;
+ resizer.tmrMove.Stop();
+ resizer.Close();
+
+ resizer = new ResizeOverlay();
+ }
+
+ private void border_MouseDown(object sender, MouseEventArgs e)
+ {
+ var cursor = this.PointToClient(Cursor.Position);
+
+ if (topleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF004, 0);
+ else if (toprightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF005, 0);
+ else if (bottomleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF007, 0);
+ else if (bottomrightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF008, 0);
+
+ else if (top.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF003, 0);
+ else if (left.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF001, 0);
+ else if (right.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF002, 0);
+ else if (bottom.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF006, 0);
+
+ // Now we need to fix this weird artificating!
+
+ resizer.tmrMove.Start();
+ resizer.Show();
+
+ resizer.ToDraw = this.Bounds;
+
+ // However this defocuses the window which we don't want
+
+ WinClassic_Activated(null, null);
+ }
+
public bool max = false;
private void maximizebutton_Click(object sender, EventArgs e)
@@ -216,20 +280,5 @@ namespace Histacom2.Engine.Template
var c = (Button)sender;
c.UseVisualStyleBackColor = true;
}
-
- private void border_MouseDown(object sender, EventArgs e)
- {
- var cursor = this.PointToClient(Cursor.Position);
-
- if (topleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF004, 0);
- else if (toprightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF005, 0);
- else if (bottomleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF007, 0);
- else if (bottomrightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF008, 0);
-
- else if (top.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF003, 0);
- else if (left.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF001, 0);
- else if (right.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF002, 0);
- else if (bottom.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF006, 0);
- }
}
}
diff --git a/Histacom2.Engine/Template/WinClassic.resx b/Histacom2.Engine/Template/WinClassic.resx
index 394031d..6876b17 100644
--- a/Histacom2.Engine/Template/WinClassic.resx
+++ b/Histacom2.Engine/Template/WinClassic.resx
@@ -118,30 +118,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <data name="maximizebutton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>
- iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAIAAACpTQvdAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
- wwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMzQDW3oAAAA+SURBVChTY/hP
- CmAAAiB1nzjQ0NCA0HDgwAEQBwcAygIBNTRAJNDAqAY0DbgAdg0EAUIDkEUkAGkgDTAwAACYPGiagsMD
- PwAAAABJRU5ErkJggg==
-</value>
- </data>
- <data name="minimizebutton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>
- iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAIAAACpTQvdAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
- wwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMzQDW3oAAAA5SURBVChTY/hP
- CmAAAiB1nzjQ0NCA0HCACDCqASqGF2DRAOKjAog4BFBDA36A0ABkEQlAGkgDDAwAKPmlWmNluNoAAAAA
- SUVORK5CYII=
-</value>
- </data>
- <data name="closebutton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>
- iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAIAAACpTQvdAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
- wwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMzQDW3oAAABcSURBVChTrY/R
- DcAgCERvdEbrJh2lPU+SYkINRt+PSN6J4FkBhMddw8y+wFUgCbQ70OtO7OQTJLgRa/L7JWmOt8RsB8mD
- TQ5NkFbeQcLwauzMdkjZCLAq0gJrAC8niIXaIK89FAAAAABJRU5ErkJggg==
-</value>
- </data>
<data name="toprightcorner.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
@@ -198,4 +174,28 @@
/DTD////wfTh46cBUSgJ/bC/izUAAAAASUVORK5CYII=
</value>
</data>
+ <data name="maximizebutton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAIAAACpTQvdAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
+ wwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMzQDW3oAAAA+SURBVChTY/hP
+ CmAAAiB1nzjQ0NCA0HDgwAEQBwcAygIBNTRAJNDAqAY0DbgAdg0EAUIDkEUkAGkgDTAwAACYPGiagsMD
+ PwAAAABJRU5ErkJggg==
+</value>
+ </data>
+ <data name="minimizebutton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAIAAACpTQvdAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
+ wwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMzQDW3oAAAA5SURBVChTY/hP
+ CmAAAiB1nzjQ0NCA0HCACDCqASqGF2DRAOKjAog4BFBDA36A0ABkEQlAGkgDDAwAKPmlWmNluNoAAAAA
+ SUVORK5CYII=
+</value>
+ </data>
+ <data name="closebutton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAIAAACpTQvdAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
+ wwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMzQDW3oAAABcSURBVChTrY/R
+ DcAgCERvdEbrJh2lPU+SYkINRt+PSN6J4FkBhMddw8y+wFUgCbQ70OtO7OQTJLgRa/L7JWmOt8RsB8mD
+ TQ5NkFbeQcLwauzMdkjZCLAq0gJrAC8niIXaIK89FAAAAABJRU5ErkJggg==
+</value>
+ </data>
</root> \ No newline at end of file
diff --git a/Histacom2/OS/Win95/Win95Apps/Win95WindowsExplorer.Designer.cs b/Histacom2/OS/Win95/Win95Apps/Win95WindowsExplorer.Designer.cs
index e16d79b..8939b84 100644
--- a/Histacom2/OS/Win95/Win95Apps/Win95WindowsExplorer.Designer.cs
+++ b/Histacom2/OS/Win95/Win95Apps/Win95WindowsExplorer.Designer.cs
@@ -67,7 +67,6 @@
// program
//
this.program.BackColor = System.Drawing.Color.Silver;
- this.program.Controls.Add(this.pnlSave);
this.program.Controls.Add(this.mainView);
this.program.Controls.Add(this.diskView);
this.program.Controls.Add(this.MenuStrip1);
@@ -75,6 +74,7 @@
this.program.Controls.Add(this.bottomrightcorner);
this.program.Controls.Add(this.bottomleftcorner);
this.program.Controls.Add(this.topleftcorner);
+ this.program.Controls.Add(this.pnlSave);
this.program.Dock = System.Windows.Forms.DockStyle.Fill;
this.program.Location = new System.Drawing.Point(0, 0);
this.program.Name = "program";
@@ -86,9 +86,10 @@
this.pnlSave.Controls.Add(this.Button1);
this.pnlSave.Controls.Add(this.Label1);
this.pnlSave.Controls.Add(this.txtSave);
- this.pnlSave.Location = new System.Drawing.Point(3, 474);
+ this.pnlSave.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.pnlSave.Location = new System.Drawing.Point(0, 482);
this.pnlSave.Name = "pnlSave";
- this.pnlSave.Size = new System.Drawing.Size(850, 35);
+ this.pnlSave.Size = new System.Drawing.Size(704, 35);
this.pnlSave.TabIndex = 18;
this.pnlSave.Visible = false;
//
@@ -96,7 +97,7 @@
//
this.Button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.Button1.Location = new System.Drawing.Point(608, 1);
+ this.Button1.Location = new System.Drawing.Point(629, 1);
this.Button1.Name = "Button1";
this.Button1.Size = new System.Drawing.Size(75, 23);
this.Button1.TabIndex = 17;
@@ -119,17 +120,15 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSave.Location = new System.Drawing.Point(60, 3);
this.txtSave.Name = "txtSave";
- this.txtSave.Size = new System.Drawing.Size(542, 20);
+ this.txtSave.Size = new System.Drawing.Size(563, 20);
this.txtSave.TabIndex = 15;
//
// mainView
//
- this.mainView.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.mainView.Location = new System.Drawing.Point(215, 27);
+ this.mainView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.mainView.Location = new System.Drawing.Point(213, 24);
this.mainView.Name = "mainView";
- this.mainView.Size = new System.Drawing.Size(486, 444);
+ this.mainView.Size = new System.Drawing.Size(491, 458);
this.mainView.TabIndex = 10;
this.mainView.UseCompatibleStateImageBehavior = false;
this.mainView.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.mainView_AfterLabelEdit);
@@ -137,12 +136,10 @@
//
// diskView
//
- this.diskView.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.diskView.Location = new System.Drawing.Point(3, 27);
+ this.diskView.Dock = System.Windows.Forms.DockStyle.Left;
+ this.diskView.Location = new System.Drawing.Point(0, 24);
this.diskView.Name = "diskView";
- this.diskView.Size = new System.Drawing.Size(213, 444);
+ this.diskView.Size = new System.Drawing.Size(213, 458);
this.diskView.TabIndex = 13;
this.diskView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.diskView_AfterSelect);
//
diff --git a/Histacom2/OS/Win98/Win98Apps/WinClassicWindowsExplorer.Designer.cs b/Histacom2/OS/Win98/Win98Apps/WinClassicWindowsExplorer.Designer.cs
index 25d29fd..af2570c 100644
--- a/Histacom2/OS/Win98/Win98Apps/WinClassicWindowsExplorer.Designer.cs
+++ b/Histacom2/OS/Win98/Win98Apps/WinClassicWindowsExplorer.Designer.cs
@@ -337,7 +337,7 @@
//
// Button1
//
- this.Button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.Button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Button1.Location = new System.Drawing.Point(626, 3);
this.Button1.Name = "Button1";
diff --git a/Histacom2/SaveDialogs/SaveFileTroubleShooter.Designer.cs b/Histacom2/SaveDialogs/SaveFileTroubleShooter.Designer.cs
index 4c11576..85c04fb 100644
--- a/Histacom2/SaveDialogs/SaveFileTroubleShooter.Designer.cs
+++ b/Histacom2/SaveDialogs/SaveFileTroubleShooter.Designer.cs
@@ -30,9 +30,9 @@
{
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.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.btnClose = new System.Windows.Forms.Button();
this.pnlResolved.SuspendLayout();
@@ -59,19 +59,22 @@
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.Size = new System.Drawing.Size(589, 275);
this.pnlResolved.TabIndex = 1;
this.pnlResolved.Visible = false;
//
- // label2
+ // textBox1
//
- 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";
+ 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.ScrollBars = System.Windows.Forms.ScrollBars.Both;
+ this.textBox1.Size = new System.Drawing.Size(567, 208);
+ this.textBox1.TabIndex = 3;
//
// label3
//
@@ -82,24 +85,22 @@
this.label3.TabIndex = 2;
this.label3.Text = "log:";
//
- // textBox1
+ // label2
//
- 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;
+ 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";
//
// panel2
//
- this.panel2.BackColor = System.Drawing.SystemColors.ControlDark;
+ this.panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
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.Location = new System.Drawing.Point(0, 315);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(612, 30);
this.panel2.TabIndex = 2;
@@ -119,7 +120,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(612, 247);
+ this.ClientSize = new System.Drawing.Size(612, 345);
this.Controls.Add(this.panel2);
this.Controls.Add(this.pnlResolved);
this.Controls.Add(this.label1);
diff --git a/Histacom2/SaveDialogs/SaveFileTroubleShooter.cs b/Histacom2/SaveDialogs/SaveFileTroubleShooter.cs
index 9d26762..af105f0 100644
--- a/Histacom2/SaveDialogs/SaveFileTroubleShooter.cs
+++ b/Histacom2/SaveDialogs/SaveFileTroubleShooter.cs
@@ -43,6 +43,7 @@ namespace Histacom2.SaveDialogs
// Check if the main.save file exists
string savefile = Path.Combine(SaveSystem.ProfileDirectory, "main.save");
+ string oldsavefile = Path.Combine(SaveSystem.ProfileDirectory, "oldmain.save");
if (!File.Exists(savefile))
{
@@ -58,54 +59,111 @@ namespace Histacom2.SaveDialogs
return;
} else {
WriteToLog("File main.save does exist - checking contents");
+ bool readable = false;
try
{
savedata = SaveSystem.ReadSave(savefile);
-
+ readable = true;
} catch
{
- WriteToLog("ISSUE FOUND! File main.save is unreadable");
+ WriteToLog("Save file cannot be read - scanning each line and examining them...");
+ // Take a little look at the file?
- WriteToLog("Sorry, there is no repairing it easily, your data will be lost");
+ // But first let's just create a measure of how the JSON SHOULD look
+ if (!SaveSystem.IsBinarySave)
+ {
+ if (File.Exists(oldsavefile)) File.Delete(oldsavefile);
+ File.Copy(savefile, oldsavefile);
- string backupfile = Path.Combine(SaveSystem.ProfileDirectory, "main.backup");
+ SaveSystem.NewGame();
+ string[] fileLines = File.ReadAllText(oldsavefile).Split('\n');
+ string[] shouldBeLines = File.ReadAllText(savefile).Split('\n');
+ int i = 0;
- if (Directory.Exists(backupfile)) Directory.Delete(backupfile);
+ string newJson = "";
- File.Copy(savefile, backupfile);
- SaveSystem.NewGame();
+ foreach (string element in fileLines)
+ {
+ element.Replace("\n", "").Replace("\r", "");
+ }
- // Make sure the username is set
+ foreach (string line in fileLines)
+ {
+ if (!line.StartsWith("{"))
+ {
+ if (!line.StartsWith("}"))
+ {
+ try {
+ // We will attempt to deserialize this line
- SaveSystem.CurrentSave.Username = SaveSystem.ProfileName;
+ Newtonsoft.Json.JsonConvert.DeserializeObject("{" + $"{Environment.NewLine}{line}{Environment.NewLine}" + "}");
- WriteToLog($"The corrupt file has been stored in {backupfile}");
+ // It worked! This line is not the problem!
- EndScan(true);
- }
-
+ newJson += $"{Environment.NewLine}{fileLines[i]}";
- // Check the values
+ WriteToLog($"The line {fileLines[i]} is fine!");
+ } catch {
+ // If it failed to read this line the this is the line that's causing problems!
- if (savedata.CurrentOS == null || savedata.CurrentOS == "")
- {
- WriteToLog("ISSUE FOUND! Data for CurrentOS is null! Giving default value...");
- savedata.CurrentOS = "95";
- EndScan(true);
- }
+ try { newJson += $"{Environment.NewLine}{shouldBeLines[i]}";
+ WriteToLog($"ISSUE FOUND! The line {fileLines[i]} was corrupt - it has been reset to default settings!");
+ } catch { WriteToLog($"ISSUE FOUND! A line was unneeded - it has been removed as it should!"); } // The reason I'm catching that is in case someone adds a line at the end of the file or something
+ }
+ }
+ }
+ i++;
+ }
- if (savedata.ExperiencedStories == null)
- {
- WriteToLog("ISSUE FOUND! Data for ExperiencedStories is null! Giving default value...");
- savedata.ExperiencedStories = new List<string>();
- }
+ // After all that let's see if we fixed the file - but first, add the "{" and "}" in!
- if (savedata.ThemeName == null || savedata.ThemeName == "")
- {
- WriteToLog("ISSUE FOUND! Data for ThemeName is null! Giving default value...");
- savedata.ThemeName = "95normal";
+ newJson = "{" + $"{Environment.NewLine}{newJson}{Environment.NewLine}" + "}";
+
+ // Now let's test it
+
+ try
+ {
+ savedata = Newtonsoft.Json.JsonConvert.DeserializeObject<Save>(newJson);
+
+ WriteToLog("Save file successfully recovered!");
+
+ File.WriteAllText(savefile, newJson);
+ readable = true;
+
+ if (File.Exists(oldsavefile)) File.Delete(oldsavefile);
+ EndScan(true);
+ } catch {
+ // It's unusable...
+
+ WriteToLog("ISSUE FOUND! File main.save is unreadable");
+
+ WriteToLog("Sorry, there is no repairing it easily, your data will be lost");
+
+ string backupfile = Path.Combine(SaveSystem.ProfileDirectory, "main.backup");
+
+ if (Directory.Exists(backupfile)) Directory.Delete(backupfile);
+
+ File.Copy(savefile, backupfile);
+ SaveSystem.NewGame();
+
+ // Make sure the username is set
+
+ SaveSystem.CurrentSave.Username = SaveSystem.ProfileName;
+ SaveSystem.SaveGame();
+
+ WriteToLog($"The corrupt file has been stored in {backupfile}");
+
+ EndScan(true);
+ }
+ }
}
+
+
+ // Check the values if it was readable
+
+ if (readable) CheckValues();
+
}
string folderspath = Path.Combine(SaveSystem.ProfileDirectory, "folders");
@@ -117,26 +175,29 @@ namespace Histacom2.SaveDialogs
SaveSystem.CheckFiles();
}
+ }
+ private void CheckValues()
+ {
+ foreach (var field in typeof(Save).GetFields())
+ {
+ if (field.GetValue(savedata) is string) if (field.GetValue(savedata).ToString() == null) { field.SetValue(savedata, ""); continue; }
+ if (field.GetValue(savedata) is Theme) if (field.GetValue(savedata) == null) { field.SetValue(savedata, new Default95Theme()); continue; }
+ if (field.GetValue(savedata) is List<string>) if (field.GetValue(savedata) == null) { field.SetValue(savedata, new List<string>()); }
+ }
}
void EndScan(bool successful)
{
pnlResolved.Visible = true;
+ label1.Hide();
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
-
- SaveSystem.WriteSave(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), savedata);
textBox1.Text = log;
} else {
- label2.Text = "The issue has not been resolved, sorry";
+ label2.Text = "The issue has not been resolved, sorry.";
textBox1.Text = log;
}
}
diff --git a/Histacom2/TitleScreen.Designer.cs b/Histacom2/TitleScreen.Designer.cs
index 07bbc54..e29c283 100644
--- a/Histacom2/TitleScreen.Designer.cs
+++ b/Histacom2/TitleScreen.Designer.cs
@@ -244,7 +244,7 @@
this.startmenuitems.Name = "startmenuitems";
this.startmenuitems.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0);
this.startmenuitems.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
- this.startmenuitems.Size = new System.Drawing.Size(140, 220);
+ this.startmenuitems.Size = new System.Drawing.Size(140, 239);
this.startmenuitems.TabIndex = 0;
this.startmenuitems.Text = "StartMenu";
//
diff --git a/Histacom2/TitleScreen.cs b/Histacom2/TitleScreen.cs
index 851bd19..e29c67c 100644
--- a/Histacom2/TitleScreen.cs
+++ b/Histacom2/TitleScreen.cs
@@ -207,8 +207,6 @@ namespace Histacom2
} catch {
}
-
-
// If VM Mode is not enabled
if (vm_mode.Checked != true)