aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Engine
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-07-02 16:55:35 -0400
committerlempamo <[email protected]>2017-07-02 16:55:35 -0400
commit776adbafcbcccb4661589794a73933d518bbf4be (patch)
tree855e94fb60bbdaf1fbd3427ef8f46193fd22a4d7 /TimeHACK.Engine
parent66eec928d5867d00e57ceed0b211e8c8681b5430 (diff)
parentddbca5032ce763c43894088a5b5c0fba8f035daa (diff)
downloadhistacom2-776adbafcbcccb4661589794a73933d518bbf4be.tar.gz
histacom2-776adbafcbcccb4661589794a73933d518bbf4be.tar.bz2
histacom2-776adbafcbcccb4661589794a73933d518bbf4be.zip
Merge remote-tracking branch 'refs/remotes/TimeHACKDevs/master'
Diffstat (limited to 'TimeHACK.Engine')
-rw-r--r--TimeHACK.Engine/BSODCreator.cs2
-rw-r--r--TimeHACK.Engine/FileAssociation.cs50
-rw-r--r--TimeHACK.Engine/Paintbrush.cs2
-rw-r--r--TimeHACK.Engine/SaveSystem.cs24
-rw-r--r--TimeHACK.Engine/TimeHACK.Engine.csproj1
-rw-r--r--TimeHACK.Engine/WindowManager.cs11
6 files changed, 82 insertions, 8 deletions
diff --git a/TimeHACK.Engine/BSODCreator.cs b/TimeHACK.Engine/BSODCreator.cs
index 4e25fea..6c49b7b 100644
--- a/TimeHACK.Engine/BSODCreator.cs
+++ b/TimeHACK.Engine/BSODCreator.cs
@@ -21,7 +21,7 @@ namespace TimeHACK.Engine
public Win9XBSOD throw9XBSOD(bool except, BSODCauses type)
{
- pfc.AddFontFile(SaveSystem.GameDirectory + "\\Data\\windows_command_prompt.ttf");
+ pfc.AddFontFile($@"{SaveSystem.GameDirectory}\Data\windows_command_prompt.ttf");
Win9XBSOD bsod = new Win9XBSOD();
foreach (Control ctrl in bsod.Controls) {
ctrl.Font = new System.Drawing.Font(pfc.Families[0], 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((0)));
diff --git a/TimeHACK.Engine/FileAssociation.cs b/TimeHACK.Engine/FileAssociation.cs
new file mode 100644
index 0000000..25fe895
--- /dev/null
+++ b/TimeHACK.Engine/FileAssociation.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+using Microsoft.Win32;
+
+namespace TimeHACK.Engine
+{
+ public class FileAssociation
+ {
+ // Associate file extension with progID, description, icon and application
+ public static void Associate(string extension,
+ string progID, string description, string icon, string application)
+ {
+ Registry.ClassesRoot.CreateSubKey(extension).SetValue("", progID);
+ if (progID != null && progID.Length > 0)
+ using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(progID))
+ {
+ if (description != null)
+ key.SetValue("", description);
+ if (icon != null)
+ key.CreateSubKey("DefaultIcon").SetValue("", ToShortPathName(icon));
+ if (application != null)
+ key.CreateSubKey(@"Shell\Open\Command").SetValue("",
+ ToShortPathName(application) + " \"%1\"");
+ }
+ }
+
+ // Return true if extension already associated in registry
+ public static bool IsAssociated(string extension)
+ {
+ return (Registry.ClassesRoot.OpenSubKey(extension, false) != null);
+ }
+
+ [DllImport("Kernel32.dll")]
+ private static extern uint GetShortPathName(string lpszLongPath,
+ [Out] StringBuilder lpszShortPath, uint cchBuffer);
+
+ // Return short path format of a file name
+ private static string ToShortPathName(string longName)
+ {
+ StringBuilder s = new StringBuilder(1000);
+ uint iSize = (uint)s.Capacity;
+ uint iRet = GetShortPathName(longName, s, iSize);
+ return s.ToString();
+ }
+ }
+}
diff --git a/TimeHACK.Engine/Paintbrush.cs b/TimeHACK.Engine/Paintbrush.cs
index b343100..1b442bc 100644
--- a/TimeHACK.Engine/Paintbrush.cs
+++ b/TimeHACK.Engine/Paintbrush.cs
@@ -11,7 +11,7 @@ namespace TimeHACK.Engine
public class Paintbrush
{
- public static void paintClassicBorders(object sender, PaintEventArgs e, int borderwidth)
+ public static void PaintClassicBorders(object sender, PaintEventArgs e, int borderwidth)
{
ControlPaint.DrawBorder(e.Graphics, ((Control)sender).ClientRectangle,
SystemColors.ControlLightLight, borderwidth, ButtonBorderStyle.Outset,
diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs
index e217bf4..7a6eed0 100644
--- a/TimeHACK.Engine/SaveSystem.cs
+++ b/TimeHACK.Engine/SaveSystem.cs
@@ -14,6 +14,8 @@ namespace TimeHACK.Engine
public static FileSystemFolderInfo filesystemflinfo { get; set; }
public static Boolean DevMode = false;
+ public static FileAssociation IconChanger = new FileAssociation();
+
public static string GameDirectory
{
get
@@ -118,7 +120,7 @@ namespace TimeHACK.Engine
save.ExperiencedStories = new List<string>();
save.CurrentOS = "95";
CurrentSave = save;
-
+
CheckFiles();
SaveGame();
}
@@ -143,6 +145,26 @@ namespace TimeHACK.Engine
if (CurrentSave.CurrentOS != "95") SaveDirectoryInfo(ProfileSettingsDirectory, false, "Documents and Settings", true);
SaveDirectoryInfo(ProfileProgramsDirectory, true, "Program Files", true);
SaveDirectoryInfo(ProfileWindowsDirectory, true, "Windows", true);
+
+ CreateWindowsDirectory();
+ }
+
+ public static void CreateWindowsDirectory()
+ {
+ SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "System"), true, "System", true);
+ SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Config"), true, "Config", true);
+ SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Cursors"), true, "Cursors", true);
+ SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Fonts"), true, "Fonts", true);
+ SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Help"), true, "Help", true);
+ SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Temp"), true, "Temp", true);
+
+ CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "Calc.exe"), "Calculator");
+ CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "explorer.exe"), "windowsexplorer");
+ }
+
+ public static void CreateWindowsFile(String filepath, String contents)
+ {
+ File.WriteAllText(filepath, contents);
}
public static void SaveDirectoryInfo(String directory, Boolean isProtected, String label, Boolean allowback)
diff --git a/TimeHACK.Engine/TimeHACK.Engine.csproj b/TimeHACK.Engine/TimeHACK.Engine.csproj
index 6a2dba4..3043220 100644
--- a/TimeHACK.Engine/TimeHACK.Engine.csproj
+++ b/TimeHACK.Engine/TimeHACK.Engine.csproj
@@ -48,6 +48,7 @@
<Compile Include="BSODCreator.cs" />
<None Include="packages.config" />
<None Include="Resources\WinClassic\Window\pjBg6mKP.bin" />
+ <Compile Include="FileAssociation.cs" />
<Compile Include="FileDialogBoxManager.cs" />
<Compile Include="Paintbrush.cs" />
<Compile Include="SaveSystem.cs" />
diff --git a/TimeHACK.Engine/WindowManager.cs b/TimeHACK.Engine/WindowManager.cs
index aa9d941..9e96673 100644
--- a/TimeHACK.Engine/WindowManager.cs
+++ b/TimeHACK.Engine/WindowManager.cs
@@ -10,7 +10,7 @@ namespace TimeHACK.Engine
{
public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
- public WinClassic startWin95(UserControl content, String title, Image icon, Boolean MaxButton, Boolean MinButton, Boolean ShowApplicationAsDialog = false)
+ public WinClassic StartWin95(UserControl content, String title, Image icon, Boolean MaxButton, Boolean MinButton, Boolean ShowApplicationAsDialog = false)
{
// Setup Window
WinClassic app = new WinClassic();
@@ -72,23 +72,24 @@ namespace TimeHACK.Engine
return app;
}
- public WinClassic startInfobox95(String title, String text, Image erroricon)
+ public WinClassic StartInfobox95(String title, String text, Image erroricon)
{
Infobox95 app = new Infobox95();
app.infoText.Text = text;
+
SoundPlayer sp = new SoundPlayer(Properties.Resources.CHORD);
sp.Play();
- return startWin95(app, title, null, false, false);
+ return StartWin95(app, title, null, false, false);
}
- public WinClassic startAboutBox95(String shortname, String longname, Image appicon)
+ public WinClassic StartAboutBox95(String shortname, String longname, Image appicon)
{
AboutBox95 uc = new AboutBox95();
uc.pictureBox1.Image = appicon;
uc.textBox1.Text = longname + "\r\nWindows 95\r\nCopyright © 1981-1995 Microsoft Corp.";
uc.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
- return startWin95(uc, "About " + shortname, null, false, false);
+ return StartWin95(uc, "About " + shortname, null, false, false);
}
}
}