diff options
| author | Jason <[email protected]> | 2017-07-22 23:43:39 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-07-22 23:43:39 +0200 |
| commit | 5afd2ec6c6d7c458c1caffc55566d4365602c122 (patch) | |
| tree | b9e2c5f7861799b7b5f209046f97052493565734 /TimeHACK.Engine | |
| parent | 7b12feef44adfcafd46d651adcd3e8fe11cb8523 (diff) | |
| parent | c97b5bddf841573e92c67fd2d325ca44825351f0 (diff) | |
| download | histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.tar.gz histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.tar.bz2 histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.zip | |
Merge pull request #133 from Alex-TIMEHACK/master
Done a lot of work on the Windows ExplorerS
Diffstat (limited to 'TimeHACK.Engine')
| -rw-r--r-- | TimeHACK.Engine/FileAssociation.cs | 50 | ||||
| -rw-r--r-- | TimeHACK.Engine/SaveSystem.cs | 90 | ||||
| -rw-r--r-- | TimeHACK.Engine/Theme.cs | 17 | ||||
| -rw-r--r-- | TimeHACK.Engine/TimeHACK.Engine.csproj | 3 |
4 files changed, 82 insertions, 78 deletions
diff --git a/TimeHACK.Engine/FileAssociation.cs b/TimeHACK.Engine/FileAssociation.cs deleted file mode 100644 index 25fe895..0000000 --- a/TimeHACK.Engine/FileAssociation.cs +++ /dev/null @@ -1,50 +0,0 @@ -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/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs index 41bb9d0..81aa322 100644 --- a/TimeHACK.Engine/SaveSystem.cs +++ b/TimeHACK.Engine/SaveSystem.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using System.Diagnostics; +using System.Windows.Forms; namespace TimeHACK.Engine { @@ -14,8 +15,7 @@ namespace TimeHACK.Engine public static Save CurrentSave { get; set; } public static FileSystemFolderInfo filesystemflinfo { get; set; } public static bool DevMode = false; - - public static FileAssociation IconChanger = new FileAssociation(); + public static Form troubleshooter; public static Theme currentTheme { get; set; } @@ -66,7 +66,7 @@ namespace TimeHACK.Engine { get { - return Path.Combine(ProfileFileSystemDirectory, "Computer"); + return Path.Combine(ProfileFileSystemDirectory, "CDrive"); } } @@ -104,28 +104,36 @@ namespace TimeHACK.Engine 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<Save>(json); + try + { + // 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<Save>(json); + + } catch + { + MessageBox.Show("WARNING! It looks like this save is corrupt!"); + MessageBox.Show("We will now open the Save troubleshooter"); + + troubleshooter.ShowDialog(); + } return true; } public static void NewGame() - { - //TODO: User must set a username....somehow - + { var save = new Save(); save.ExperiencedStories = new List<string>(); if (DevMode == true) @@ -134,6 +142,7 @@ namespace TimeHACK.Engine { save.CurrentOS = "98"; save.ThemeName = "default98"; + currentTheme = new Default98Theme(); } else { @@ -169,12 +178,14 @@ namespace TimeHACK.Engine Directory.CreateDirectory(ProfileFileSystemDirectory); SaveDirectoryInfo(ProfileFileSystemDirectory, false, "My Computer", false); - SaveDirectoryInfo(ProfileMyComputerDirectory, false, "Win95", true); - if (CurrentSave.CurrentOS == "95") SaveDirectoryInfo(ProfileDocumentsDirectory, false, "My Documents", true); - if (CurrentSave.CurrentOS != "95") SaveDirectoryInfo(ProfileSettingsDirectory, false, "Documents and Settings", true); + SaveDirectoryInfo(ProfileMyComputerDirectory, false, "Win95 (C:)", true); + if (CurrentSave.CurrentOS == "95" || CurrentSave.CurrentOS == "98") SaveDirectoryInfo(ProfileDocumentsDirectory, false, "My Documents", true); + if (CurrentSave.CurrentOS == "2000" || CurrentSave.CurrentOS == "ME") SaveDirectoryInfo(ProfileSettingsDirectory, false, "Documents and Settings", true); + SaveDirectoryInfo(Path.Combine(ProfileProgramsDirectory, "Accessories"), false, "Accessories", true); SaveDirectoryInfo(ProfileProgramsDirectory, true, "Program Files", true); SaveDirectoryInfo(ProfileWindowsDirectory, true, "Windows", true); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Accessories", "wordpad.exe"), "wordpad"); CreateWindowsDirectory(); } @@ -187,8 +198,8 @@ namespace TimeHACK.Engine 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"); + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "calc.exe"), "calc"); + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "explorer.exe"), "explorer"); } public static void CreateWindowsFile(string filepath, string contents) @@ -196,6 +207,30 @@ namespace TimeHACK.Engine File.WriteAllText(filepath, contents); } + public static void UpgradeFileSystem(string oldOS, string newOS) + { + switch (oldOS) + { + case "95": + if (newOS == "98" || newOS == "2000" || newOS == "ME") + { + // We are upgrading from the old WinClassic file System to the new WinClassic filesystem! + // All the above OSes share basically the same file layout! + // (Excluding Documents And Settings) which is 2000 and ME only + + // Rename the C Drive to Win98 + + SaveDirectoryInfo(ProfileMyComputerDirectory, false, "Win98 (C:)", true); + + // Add Address Book into existance! + + SaveDirectoryInfo(Path.Combine(ProfileProgramsDirectory, "Outlook Express"), false, "Outlook Express", true); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Outlook Express", "WAB.exe"), "addressbook"); + } + break; + } + } + public static void SaveDirectoryInfo(string directory, bool isProtected, string label, bool allowback) { if (!Directory.Exists(directory)) @@ -247,6 +282,9 @@ namespace TimeHACK.Engine case "default95": currentTheme = new Default95Theme(); break; + case "default98": + currentTheme = new Default98Theme(); + break; case "dangeranimals": currentTheme = new DangerousCreaturesTheme(); break; diff --git a/TimeHACK.Engine/Theme.cs b/TimeHACK.Engine/Theme.cs index 89c913d..2b22072 100644 --- a/TimeHACK.Engine/Theme.cs +++ b/TimeHACK.Engine/Theme.cs @@ -40,6 +40,23 @@ namespace TimeHACK.Engine } } + public class Default98Theme : Theme + { + public Default98Theme() + { + startSound = Properties.Resources.Win95Start; + stopSound = Properties.Resources.Win95Stop; + + asteriskSound = Properties.Resources.CHORD; + critStopSound = Properties.Resources.CHORD; + progErrorSound = Properties.Resources.CHORD; + questionSound = Properties.Resources.CHORD; + + defaultWallpaper = null; + themeName = "default98"; + } + } + public class DangerousCreaturesTheme: Theme { public DangerousCreaturesTheme() diff --git a/TimeHACK.Engine/TimeHACK.Engine.csproj b/TimeHACK.Engine/TimeHACK.Engine.csproj index f58b7cc..2f4073d 100644 --- a/TimeHACK.Engine/TimeHACK.Engine.csproj +++ b/TimeHACK.Engine/TimeHACK.Engine.csproj @@ -15,7 +15,7 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> - <Optimize>false</Optimize> + <Optimize>true</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> @@ -48,7 +48,6 @@ <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" /> |
