From b56050694f6473b13807a10d39881591e0f0f469 Mon Sep 17 00:00:00 2001 From: lempamo Date: Thu, 27 Jul 2017 00:25:37 -0400 Subject: the files thing, will fix in morning --- TimeHACK.Engine/DesktopController.cs | 21 ++++--- TimeHACK.Engine/SaveSystem.cs | 66 ++++++++++++++++----- .../GlobalPrograms/WinClassicDownloader.cs | 4 +- TimeHACK.Main/OS/Win95/Win95.Designer.cs | 8 +-- TimeHACK.Main/OS/Win95/Win95.cs | 2 +- .../OS/Win95/Win95Apps/Win95WindowsExplorer.cs | 4 +- .../Win98/Win98Apps/WinClassicWindowsExplorer.cs | 4 +- TimeHACK.Main/Properties/Resources.Designer.cs | 42 +++++++++---- TimeHACK.Main/Properties/Resources.resx | 12 +++- TimeHACK.Main/Resources/WinClassic/Win95File.png | Bin 0 -> 236 bytes .../Resources/WinClassic/WinClassicApp.png | Bin 0 -> 148 bytes .../Resources/WinClassic/WinClassicMinesweeper.png | Bin 0 -> 309 bytes TimeHACK.Main/TimeHACK.Main.csproj | 3 + 13 files changed, 118 insertions(+), 48 deletions(-) create mode 100644 TimeHACK.Main/Resources/WinClassic/Win95File.png create mode 100644 TimeHACK.Main/Resources/WinClassic/WinClassicApp.png create mode 100644 TimeHACK.Main/Resources/WinClassic/WinClassicMinesweeper.png diff --git a/TimeHACK.Engine/DesktopController.cs b/TimeHACK.Engine/DesktopController.cs index f507ab8..83fcc98 100644 --- a/TimeHACK.Engine/DesktopController.cs +++ b/TimeHACK.Engine/DesktopController.cs @@ -14,21 +14,20 @@ namespace TimeHACK.Engine public static string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) { string Val = ""; - string directoryFileInfo; - directoryFileInfo = File.ReadAllText(Path.Combine(reqDirectory, "_data.info")); + string directoryFileInfo = File.ReadAllText(Path.Combine(reqDirectory, "_data.info")); FileSystemFolderInfo toRead = new FileSystemFolderInfo(); toRead = JsonConvert.DeserializeObject(directoryFileInfo); if (returnYesIfProtected == true) { - if (toRead.Isprotected == true) + if (toRead.IsProtected == true) { return "yes"; } } else { - return toRead.label; + return toRead.Label; } return Val; } @@ -49,11 +48,19 @@ namespace TimeHACK.Engine { if (Path.GetFileName(dir) != "_data.info") { - int appIcon = 12; + THFileInfo file = new THFileInfo(); + FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(theDirectory, "_data.info"))); + foreach (THFileInfo f in fsfi.Files) + { + if (f.Name.ToLower() == Path.GetFileName(dir).ToLower()) + { + file = f; break; + } + } - if (new FileInfo(dir).Extension == ".exe") appIcon = 8; + if (new FileInfo(dir).Extension == ".exe" && file.FileIcon == 8) file.FileIcon = 10; - theView.Items.Add(Path.GetFileName(dir), appIcon); + theView.Items.Add(Path.GetFileName(dir), file.FileIcon); theView.FindItemWithText(Path.GetFileName(dir)).Tag = dir; } } diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs index 2745738..5886d41 100644 --- a/TimeHACK.Engine/SaveSystem.cs +++ b/TimeHACK.Engine/SaveSystem.cs @@ -14,6 +14,9 @@ using Newtonsoft.Json; using System.Diagnostics; using System.Windows.Forms; using System.Runtime.CompilerServices; +using System.Drawing; +using System.Text.RegularExpressions; +using System.Runtime.InteropServices; namespace TimeHACK.Engine { @@ -102,7 +105,7 @@ namespace TimeHACK.Engine { get { - return Path.Combine(ProfileMyComputerDirectory, "Prog"); + return Path.Combine(ProfileMyComputerDirectory, "Program Files"); } } @@ -169,10 +172,10 @@ namespace TimeHACK.Engine SaveDirectoryInfo(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"), true, "The Microsoft Network", true); SaveDirectoryInfo(ProfileWindowsDirectory, true, "Windows", true); - CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Accessories", "wordpad.exe"), "wordpad"); - CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Internet Explorer", "ie20.exe"), "ie"); - CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Internet Explorer", "lnfinst.exe"), "iebrokeninstaller"); - CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network", "msnver.txt"), "5900"); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Accessories"), "wordpad.exe", "wordpad"); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Internet Explorer"), "ie20.exe", "ie"); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Internet Explorer"), "lnfinst.exe", "iebrokeninstaller"); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"), "msnver.txt", "5900"); CreateWindowsDirectory(); } @@ -187,13 +190,35 @@ namespace TimeHACK.Engine SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Temp"), true, "Temp", true); SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Desktop"), true, "Desktop", true); - CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "calc.exe"), "calc"); - CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "explorer.exe"), "explorer"); + CreateWindowsFile(ProfileWindowsDirectory, "calc.exe", "calc"); + CreateWindowsFile(ProfileWindowsDirectory, "explorer.exe", "explorer"); } - public static void CreateWindowsFile(string filepath, string contents) + public static void CreateWindowsFile(string filepath, string filename, string contents, int fileicon = 8) { - File.WriteAllText(filepath, contents); + File.WriteAllText(Path.Combine(filepath, filename), contents); + THFileInfo info = new THFileInfo(); + info.Name = filename; + info.FileIcon = fileicon; + UpdateDirectoryInfo(filepath, info); + } + + [DllImport("kernel32.dll", SetLastError = true)] + private static extern int GetShortPathName(String pathName, StringBuilder shortName, int cbShortName); + + public static void UpdateDirectoryInfo(string path, THFileInfo newfile) + { + StringBuilder sb = new StringBuilder(300); + GetShortPathName(newfile.Name, sb, 300); + Regex rgx = new Regex(".{8}\\.[A-Z]{3}"); + newfile.DOSName = Regex.Match(sb.ToString(), rgx.ToString(), RegexOptions.RightToLeft).ToString(); + if (File.ReadAllText(Path.Combine(path, "_data.info")).Contains(newfile.DOSName)) return; + FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(path, "_data.info"))); + fsfi.Files[fsfi.Files.Count()] = newfile; + + string toWrite = JsonConvert.SerializeObject(fsfi, Formatting.Indented); + + File.WriteAllText(Path.Combine(path, "_data.info"), toWrite); } public static void UpgradeFileSystem(string oldOS, string newOS) @@ -214,7 +239,7 @@ namespace TimeHACK.Engine // Add Address Book into existance! SaveDirectoryInfo(Path.Combine(ProfileProgramsDirectory, "Outlook Express"), false, "Outlook Express", true); - CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Outlook Express", "WAB.exe"), "addressbook"); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Outlook Express"), "WAB.exe", "addressbook"); // There is no "The Microsoft Network" folder! @@ -231,9 +256,10 @@ namespace TimeHACK.Engine FileSystemFolderInfo info = new FileSystemFolderInfo(); - info.Isprotected = isProtected; - info.label = label; - info.allowback = allowback; + info.IsProtected = isProtected; + info.Label = label; + info.AllowBack = allowback; + info.Files = new THFileInfo[200]; string toWrite = JsonConvert.SerializeObject(info, Formatting.Indented); @@ -603,8 +629,16 @@ namespace TimeHACK.Engine public class FileSystemFolderInfo { - public bool Isprotected { get; set; } - public string label { get; set; } - public bool allowback { get; set; } + public bool IsProtected { get; set; } + public string Label { get; set; } + public bool AllowBack { get; set; } + public THFileInfo[] Files { get; set; } + } + + public class THFileInfo + { + public string Name { get; set; } + public string DOSName { get; set; } + public int FileIcon { get; set; } } } diff --git a/TimeHACK.Main/GlobalPrograms/WinClassicDownloader.cs b/TimeHACK.Main/GlobalPrograms/WinClassicDownloader.cs index ce71b40..0237fac 100644 --- a/TimeHACK.Main/GlobalPrograms/WinClassicDownloader.cs +++ b/TimeHACK.Main/GlobalPrograms/WinClassicDownloader.cs @@ -38,10 +38,10 @@ namespace TimeHACK.OS.Win95.Win95Apps switch (appName.Text) { case "Downloading: FTP Client": - CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "Desktop", "FTP Client setup.exe"), "ftp client setup"); + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "Desktop"), "FTP Client Setup.exe", "ftp client setup"); break; case "Downloading: Web Chat 1998": - CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "Desktop", "Web Chat Setup.exe"), "web chat setup"); + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "Desktop"), "Web Chat Setup.exe", "web chat setup"); break; } /* if (appName.Text == "Downloading: Guess The Number") diff --git a/TimeHACK.Main/OS/Win95/Win95.Designer.cs b/TimeHACK.Main/OS/Win95/Win95.Designer.cs index df05e65..49bfba6 100644 --- a/TimeHACK.Main/OS/Win95/Win95.Designer.cs +++ b/TimeHACK.Main/OS/Win95/Win95.Designer.cs @@ -434,7 +434,7 @@ namespace TimeHACK.OS.Win95 this.MinsweeperToolStripMenuItem.BackColor = System.Drawing.Color.Silver; this.MinsweeperToolStripMenuItem.BackgroundImage = global::TimeHACK.Properties.Resources.sliversilver; this.MinsweeperToolStripMenuItem.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.MinsweeperToolStripMenuItem.Image = global::TimeHACK.Properties.Resources.minsweeper_logo; + this.MinsweeperToolStripMenuItem.Image = global::TimeHACK.Properties.Resources.WinClassicMinesweeper; this.MinsweeperToolStripMenuItem.Name = "MinsweeperToolStripMenuItem"; this.MinsweeperToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.MinsweeperToolStripMenuItem.Text = "Minesweeper"; @@ -963,9 +963,9 @@ namespace TimeHACK.OS.Win95 this.desktopImages.Images.SetKeyName(5, "WinClassicNetworking.png"); this.desktopImages.Images.SetKeyName(6, "WinClassicOutlook.png"); this.desktopImages.Images.SetKeyName(7, "WinClassicRecycle.png"); - this.desktopImages.Images.SetKeyName(8, "WinClassicSetup.png"); - this.desktopImages.Images.SetKeyName(9, "WinClassicSetup.png"); - this.desktopImages.Images.SetKeyName(10, "WinClassicSetup.png"); + this.desktopImages.Images.SetKeyName(8, "Win95File.png"); + this.desktopImages.Images.SetKeyName(9, "WinClassicFolder.png"); + this.desktopImages.Images.SetKeyName(10, "WinClassicApp.png"); this.desktopImages.Images.SetKeyName(11, "WinClassicSetup.png"); this.desktopImages.Images.SetKeyName(12, "blank-file-Windows95Icon.gif"); // diff --git a/TimeHACK.Main/OS/Win95/Win95.cs b/TimeHACK.Main/OS/Win95/Win95.cs index caef618..3279967 100644 --- a/TimeHACK.Main/OS/Win95/Win95.cs +++ b/TimeHACK.Main/OS/Win95/Win95.cs @@ -574,7 +574,7 @@ namespace TimeHACK.OS.Win95 private void MinsweeperToolStripMenuItem_Click(object sender, EventArgs e) { - WinClassic app = wm.StartWin95(new WinClassicMinesweeper(), "Minesweeper", Properties.Resources.minsweeper_logo, false, false); + WinClassic app = wm.StartWin95(new WinClassicMinesweeper(), "Minesweeper", Properties.Resources.WinClassicMinesweeper, false, false); AddTaskBarItem(app, app.Tag.ToString(), "Calculator", Properties.Resources.WinClassicCalc); nonimportantapps.Add(app); diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs index 4b0157e..7c999c8 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs @@ -93,14 +93,14 @@ namespace TimeHACK.OS.Win95.Win95Apps if (returnYesIfProtected == true) { - if (toRead.Isprotected == true) + if (toRead.IsProtected == true) { return "yes"; } } else { - return toRead.label; + return toRead.Label; } return Val; } diff --git a/TimeHACK.Main/OS/Win98/Win98Apps/WinClassicWindowsExplorer.cs b/TimeHACK.Main/OS/Win98/Win98Apps/WinClassicWindowsExplorer.cs index ef28bca..290d2f2 100644 --- a/TimeHACK.Main/OS/Win98/Win98Apps/WinClassicWindowsExplorer.cs +++ b/TimeHACK.Main/OS/Win98/Win98Apps/WinClassicWindowsExplorer.cs @@ -110,14 +110,14 @@ namespace TimeHACK.OS.Win95.Win95Apps if (returnYesIfProtected == true) { - if (toRead.Isprotected == true) + if (toRead.IsProtected == true) { return "yes"; } } else { - return toRead.label; + return toRead.Label; } return Val; } diff --git a/TimeHACK.Main/Properties/Resources.Designer.cs b/TimeHACK.Main/Properties/Resources.Designer.cs index c4e9524..4abab30 100644 --- a/TimeHACK.Main/Properties/Resources.Designer.cs +++ b/TimeHACK.Main/Properties/Resources.Designer.cs @@ -375,16 +375,6 @@ namespace TimeHACK.Properties { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap minsweeper_logo { - get { - object obj = ResourceManager.GetObject("minsweeper logo", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -400,7 +390,7 @@ namespace TimeHACK.Properties { /// internal static System.Drawing.Bitmap minsweeper_smile { get { - object obj = ResourceManager.GetObject("minsweeper smile", resourceCulture); + object obj = ResourceManager.GetObject("minsweeper_smile", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -784,6 +774,16 @@ namespace TimeHACK.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Win95File { + get { + object obj = ResourceManager.GetObject("Win95File", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1021,6 +1021,16 @@ namespace TimeHACK.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap WinClassicApp { + get { + object obj = ResourceManager.GetObject("WinClassicApp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1201,6 +1211,16 @@ namespace TimeHACK.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap WinClassicMinesweeper { + get { + object obj = ResourceManager.GetObject("WinClassicMinesweeper", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/TimeHACK.Main/Properties/Resources.resx b/TimeHACK.Main/Properties/Resources.resx index 779be5c..7a96a19 100644 --- a/TimeHACK.Main/Properties/Resources.resx +++ b/TimeHACK.Main/Properties/Resources.resx @@ -148,7 +148,7 @@ ..\Resources\WinClassic\WinClassicNew.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\minsweeper smile.PNG;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -681,7 +681,13 @@ ..\Resources\ie4_mail.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\minsweeper logo.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\WinClassic\Win95File.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\WinClassic\WinClassicApp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\WinClassic\WinClassicMinesweeper.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/TimeHACK.Main/Resources/WinClassic/Win95File.png b/TimeHACK.Main/Resources/WinClassic/Win95File.png new file mode 100644 index 0000000..ada2ccd Binary files /dev/null and b/TimeHACK.Main/Resources/WinClassic/Win95File.png differ diff --git a/TimeHACK.Main/Resources/WinClassic/WinClassicApp.png b/TimeHACK.Main/Resources/WinClassic/WinClassicApp.png new file mode 100644 index 0000000..5d954ac Binary files /dev/null and b/TimeHACK.Main/Resources/WinClassic/WinClassicApp.png differ diff --git a/TimeHACK.Main/Resources/WinClassic/WinClassicMinesweeper.png b/TimeHACK.Main/Resources/WinClassic/WinClassicMinesweeper.png new file mode 100644 index 0000000..c528175 Binary files /dev/null and b/TimeHACK.Main/Resources/WinClassic/WinClassicMinesweeper.png differ diff --git a/TimeHACK.Main/TimeHACK.Main.csproj b/TimeHACK.Main/TimeHACK.Main.csproj index 77192ec..c6433e0 100644 --- a/TimeHACK.Main/TimeHACK.Main.csproj +++ b/TimeHACK.Main/TimeHACK.Main.csproj @@ -572,6 +572,7 @@ + @@ -582,6 +583,7 @@ + @@ -599,6 +601,7 @@ + -- cgit v1.2.3