aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-07-27 23:58:39 -0400
committerlempamo <[email protected]>2017-07-27 23:58:39 -0400
commit6b6369ba73c60d1b9472365ad96e5cd986e4c4f6 (patch)
tree201c6ba49d6d1cebc22c1ba04859766a3eb1157a
parent7d3d306a8c0116273f45c1e1a08efc5347776b4f (diff)
downloadhistacom2-6b6369ba73c60d1b9472365ad96e5cd986e4c4f6.tar.gz
histacom2-6b6369ba73c60d1b9472365ad96e5cd986e4c4f6.tar.bz2
histacom2-6b6369ba73c60d1b9472365ad96e5cd986e4c4f6.zip
sweet new dos command (dir)
-rw-r--r--TimeHACK.Engine/SaveSystem.cs18
-rw-r--r--TimeHACK.Main/OS/Win95/Win95Apps/WinClassicTerminal.cs71
2 files changed, 64 insertions, 25 deletions
diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs
index 226a68f..eaf3a5a 100644
--- a/TimeHACK.Engine/SaveSystem.cs
+++ b/TimeHACK.Engine/SaveSystem.cs
@@ -163,7 +163,7 @@ namespace TimeHACK.Engine
Directory.CreateDirectory(ProfileFileSystemDirectory);
SaveDirectoryInfo(ProfileDirectory, "folders", false, "My Computer", false);
- SaveDirectoryInfo(ProfileFileSystemDirectory, "CDrive", false, "Win95 (C:)", true);
+ SaveDirectoryInfo(ProfileFileSystemDirectory, "CDrive", false, "C:", true);
if (CurrentSave.CurrentOS == "95" || CurrentSave.CurrentOS == "98") SaveDirectoryInfo(ProfileMyComputerDirectory, "Doc", false, "My Documents", true);
if (CurrentSave.CurrentOS == "2000" || CurrentSave.CurrentOS == "ME") SaveDirectoryInfo(ProfileMyComputerDirectory, "Settings", false, "Documents and Settings", true);
SaveDirectoryInfo(ProfileMyComputerDirectory, "Prog", true, "Program Files", true);
@@ -194,12 +194,13 @@ namespace TimeHACK.Engine
CreateWindowsFile(ProfileWindowsDirectory, "explorer.exe", "explorer");
}
- public static void CreateWindowsFile(string filepath, string filename, string contents, int fileicon = 8)
+ public static void CreateWindowsFile(string filepath, string filename, string contents, int fileicon = 8, int bytes = 512)
{
File.WriteAllText(Path.Combine(filepath, filename), contents);
THFileInfo info = new THFileInfo();
info.Name = filename;
info.FileIcon = fileicon;
+ info.ByteSize = bytes;
UpdateDirectoryInfo(filepath, info);
}
@@ -222,6 +223,7 @@ namespace TimeHACK.Engine
if (File.ReadAllText(Path.Combine(path, "_data.info")).Contains(newfile.DOSName)) return;
FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(path, "_data.info")));
fsfi.Files.Add(newfile);
+ fsfi.ByteSize += newfile.ByteSize;
string toWrite = JsonConvert.SerializeObject(fsfi, Formatting.Indented);
@@ -239,10 +241,6 @@ namespace TimeHACK.Engine
// 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(ProfileFileSystemDirectory, "CDrive", false, "Win98 (C:)", true);
-
// Add Address Book into existance!
SaveDirectoryInfo(ProfileProgramsDirectory, "Outlook Express", false, "Outlook Express", true);
@@ -258,8 +256,8 @@ namespace TimeHACK.Engine
public static void SaveDirectoryInfo(string parent, string dirname, bool isProtected, string label, bool allowback)
{
- if (!Directory.Exists(Path.Combine(parent, dirname)))
- Directory.CreateDirectory(Path.Combine(parent, dirname));
+ if (Directory.Exists(Path.Combine(parent, dirname)) && Path.Combine(parent, dirname) != ProfileFileSystemDirectory) return;
+ Directory.CreateDirectory(Path.Combine(parent, dirname));
FileSystemFolderInfo info = new FileSystemFolderInfo();
@@ -268,9 +266,11 @@ namespace TimeHACK.Engine
info.DOSLabel = info.Label.ToUpper().Replace("*", "").Replace("+", "").Replace(":", "").Replace(";", "").Replace(".", "").Replace(" ", "");
if (info.DOSLabel.Length > 8) info.DOSLabel = info.DOSLabel.Substring(0, 6) + "~1";
+ if (dirname == "C:") info.DOSLabel = "C:";
info.AllowBack = allowback;
info.Files = new List<THFileInfo>(256);
info.SubDirs = new List<THDirInfo>(256);
+ info.ByteSize = 0;
if (parent != ProfileDirectory)
{
@@ -655,6 +655,7 @@ namespace TimeHACK.Engine
public string Label { get; set; }
public string DOSLabel { get; set; }
public bool AllowBack { get; set; }
+ public int ByteSize { get; set; }
public List<THFileInfo> Files { get; set; }
public List<THDirInfo> SubDirs { get; set; }
}
@@ -664,6 +665,7 @@ namespace TimeHACK.Engine
public string Name { get; set; }
public string DOSName { get; set; }
public int FileIcon { get; set; }
+ public int ByteSize { get; set; }
}
public class THDirInfo
diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicTerminal.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicTerminal.cs
index a754ed0..0b414a4 100644
--- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicTerminal.cs
+++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicTerminal.cs
@@ -14,6 +14,9 @@ using System.Reflection;
using System.Linq.Expressions;
using System.Diagnostics;
using System.Text.RegularExpressions;
+using Newtonsoft.Json;
+using TimeHACK.Engine;
+using System.Globalization;
namespace TimeHACK.OS.Win95.Win95Apps
{
@@ -21,9 +24,9 @@ namespace TimeHACK.OS.Win95.Win95Apps
{
public Engine.WindowManager wm = new Engine.WindowManager();
- public int currentLine = 0;
- public static string prefix = @"C:\>";
- public static string startupDir = $"{Engine.SaveSystem.ProfileMyComputerDirectory}";
+ public int currentLine = 4;
+ public static string prefix = @"C:\WINDOWS>";
+ public static string workingDir = $"{Engine.SaveSystem.ProfileWindowsDirectory}";
public string output = "";
public WinClassicTerminal(bool readOnly)
@@ -43,7 +46,7 @@ namespace TimeHACK.OS.Win95.Win95Apps
sizeSel.SelectedIndex = 0;
// Set the font and append the prefix text
- cmdPrompt.Font = new Font(TitleScreen.pfc.Families[1], 10F, FontStyle.Regular);
+ cmdPrompt.Font = new Font(TitleScreen.pfc.Families[1], 12F, FontStyle.Regular);
cmdPrompt.BringToFront();
@@ -54,6 +57,7 @@ namespace TimeHACK.OS.Win95.Win95Apps
}
else
{
+ cmdPrompt.AppendText("\nMicrosoft<R> Windows 95\n <C>Copyright Microsoft Corp 1981-1995.\n\n");
cmdPrompt.AppendText(prefix);
}
}
@@ -108,18 +112,51 @@ namespace TimeHACK.OS.Win95.Win95Apps
{
if (e.KeyData == Keys.Return)
{
- // Temporary CMD redirect
- Process p = new Process();
-
- p.StartInfo.UseShellExecute = false;
- p.StartInfo.RedirectStandardOutput = true;
- p.StartInfo.CreateNoWindow = true;
- p.StartInfo.WorkingDirectory = startupDir;
- p.StartInfo.FileName = "cmd.exe";
- p.StartInfo.Arguments = $"/C {cmdPrompt.Lines[currentLine].Substring(prefix.Length)}";
- p.Start();
-
- output = p.StandardOutput.ReadToEnd();
+ string[] cmd = cmdPrompt.Lines[currentLine].Substring(prefix.Length).Split(' ');
+
+ switch (cmd[0])
+ {
+ case "dir":
+ NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
+ nfi.NumberDecimalDigits = 0;
+ output = $" Volume in drive C has no label\n Volume Serial Number is 0000-0000\n Directory of {prefix.Replace(">", "")}\n\n";
+ foreach (THDirInfo thd in JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(workingDir, "_data.info"))).SubDirs)
+ {
+ string dirline = new string(' ', 50);
+ dirline = dirline.Insert(0, thd.DOSName);
+ dirline = dirline.Insert(15, "<DIR>");
+ output += dirline + Environment.NewLine;
+ }
+ foreach (THFileInfo thfi in JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(workingDir, "_data.info"))).Files)
+ {
+ string[] dosname = thfi.DOSName.Split('.');
+ string dirline = new string(' ', 50);
+ dirline = dirline.Insert(0, dosname[0]);
+ dirline = dirline.Insert(9, dosname[1]);
+ dirline = dirline.Insert(26 - thfi.ByteSize.ToString("N", nfi).Length, thfi.ByteSize.ToString("N", nfi));
+ output += dirline + Environment.NewLine;
+ }
+
+ break;
+ default:
+ // Temporary CMD redirect
+ /*
+ Process p = new Process();
+
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.RedirectStandardOutput = true;
+ p.StartInfo.CreateNoWindow = true;
+ p.StartInfo.WorkingDirectory = startupDir;
+ p.StartInfo.FileName = "cmd.exe";
+ p.StartInfo.Arguments = $"/C {cmdPrompt.Lines[currentLine].Substring(prefix.Length)}";
+ p.Start();
+
+ output = p.StandardOutput.ReadToEnd();
+ */
+ output = "Bad command or file name";
+
+ break;
+ }
cmdPrompt.Focus();
cmdPrompt.AppendText($"\n{output}"); // Append the command output
@@ -127,7 +164,7 @@ namespace TimeHACK.OS.Win95.Win95Apps
int numLines = output.Split('\n').Length; // Get the number of lines from the command output
currentLine = currentLine + 2 + numLines; // Set the current line to equals the previous line plus 2 plus the number of lines from the command
- cmdPrompt.AppendText($"\n{prefix}"); // Append the text to the RichTextBox
+ cmdPrompt.AppendText($"\n\n{prefix}"); // Append the text to the RichTextBox
}
}
}