diff --git a/ShiftOS.MFSProfiler/FileCreator.Designer.cs b/ShiftOS.MFSProfiler/FileCreator.Designer.cs new file mode 100644 index 0000000..09761c6 --- /dev/null +++ b/ShiftOS.MFSProfiler/FileCreator.Designer.cs @@ -0,0 +1,108 @@ +namespace ShiftOS.MFSProfiler +{ + partial class FileCreator + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.txtfname = new System.Windows.Forms.TextBox(); + this.txtcontents = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(55, 13); + this.label1.TabIndex = 0; + this.label1.Text = "File name:"; + // + // txtfname + // + this.txtfname.Location = new System.Drawing.Point(16, 30); + this.txtfname.Name = "txtfname"; + this.txtfname.Size = new System.Drawing.Size(416, 20); + this.txtfname.TabIndex = 1; + // + // txtcontents + // + this.txtcontents.Location = new System.Drawing.Point(16, 78); + this.txtcontents.Multiline = true; + this.txtcontents.Name = "txtcontents"; + this.txtcontents.Size = new System.Drawing.Size(416, 200); + this.txtcontents.TabIndex = 3; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(13, 61); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(52, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Contents:"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(357, 284); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 4; + this.button1.Text = "OK"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // FileCreator + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(444, 312); + this.Controls.Add(this.button1); + this.Controls.Add(this.txtcontents); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtfname); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "FileCreator"; + this.Text = "FileCreator"; + this.Load += new System.EventHandler(this.FileCreator_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtfname; + private System.Windows.Forms.TextBox txtcontents; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + } +} \ No newline at end of file diff --git a/ShiftOS.MFSProfiler/FileCreator.cs b/ShiftOS.MFSProfiler/FileCreator.cs new file mode 100644 index 0000000..4ff01b2 --- /dev/null +++ b/ShiftOS.MFSProfiler/FileCreator.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 ShiftOS.MFSProfiler +{ + public partial class FileCreator : Form + { + public FileCreator(string fileToCreate) + { + InitializeComponent(); + FileToCreate = fileToCreate; + } + + public string FileToCreate { get; private set; } + + private void FileCreator_Load(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + } + + private void button1_Click(object sender, EventArgs e) + { + ShiftOS.Objects.ShiftFS.Utils.WriteAllText(FileToCreate + "/" + txtfname.Text, txtcontents.Text); + this.DialogResult = DialogResult.OK; + this.Close(); + } + } +} diff --git a/ShiftOS.MFSProfiler/FileCreator.resx b/ShiftOS.MFSProfiler/FileCreator.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.MFSProfiler/FileCreator.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.MFSProfiler/Main.Designer.cs b/ShiftOS.MFSProfiler/Main.Designer.cs index 85f1310..83e9b72 100644 --- a/ShiftOS.MFSProfiler/Main.Designer.cs +++ b/ShiftOS.MFSProfiler/Main.Designer.cs @@ -52,31 +52,37 @@ namespace ShiftOS.MFSProfiler /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.tvfiles = new System.Windows.Forms.TreeView(); - this.pnlfileinfo = new System.Windows.Forms.Panel(); - this.pnldirectorylisting = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel(); this.button1 = new System.Windows.Forms.Button(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.pnlfileinfo = new System.Windows.Forms.Panel(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.txtascii = new System.Windows.Forms.TextBox(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.txtbinary = new System.Windows.Forms.TextBox(); - this.txtascii = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); this.lbfileinfo = new System.Windows.Forms.Label(); + this.pnldirectorylisting = new System.Windows.Forms.Panel(); + this.ctxfileoptions = new System.Windows.Forms.ContextMenuStrip(this.components); + this.newFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.newDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); - this.pnlfileinfo.SuspendLayout(); this.panel1.SuspendLayout(); - this.groupBox1.SuspendLayout(); + this.pnlfileinfo.SuspendLayout(); this.groupBox2.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage1.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.ctxfileoptions.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 @@ -107,24 +113,6 @@ namespace ShiftOS.MFSProfiler this.tvfiles.TabIndex = 0; this.tvfiles.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvfiles_AfterSelect); // - // pnlfileinfo - // - this.pnlfileinfo.Controls.Add(this.groupBox2); - this.pnlfileinfo.Controls.Add(this.groupBox1); - this.pnlfileinfo.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlfileinfo.Location = new System.Drawing.Point(0, 0); - this.pnlfileinfo.Name = "pnlfileinfo"; - this.pnlfileinfo.Size = new System.Drawing.Size(489, 466); - this.pnlfileinfo.TabIndex = 0; - // - // pnldirectorylisting - // - this.pnldirectorylisting.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnldirectorylisting.Location = new System.Drawing.Point(0, 0); - this.pnldirectorylisting.Name = "pnldirectorylisting"; - this.pnldirectorylisting.Size = new System.Drawing.Size(489, 466); - this.pnldirectorylisting.TabIndex = 1; - // // panel1 // this.panel1.Controls.Add(this.button1); @@ -144,16 +132,15 @@ namespace ShiftOS.MFSProfiler this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // - // groupBox1 + // pnlfileinfo // - this.groupBox1.Controls.Add(this.lbfileinfo); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(489, 164); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "File record information"; + this.pnlfileinfo.Controls.Add(this.groupBox2); + this.pnlfileinfo.Controls.Add(this.groupBox1); + this.pnlfileinfo.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlfileinfo.Location = new System.Drawing.Point(0, 0); + this.pnlfileinfo.Name = "pnlfileinfo"; + this.pnlfileinfo.Size = new System.Drawing.Size(489, 466); + this.pnlfileinfo.TabIndex = 0; // // groupBox2 // @@ -188,6 +175,15 @@ namespace ShiftOS.MFSProfiler this.tabPage2.Text = "ASCII"; this.tabPage2.UseVisualStyleBackColor = true; // + // txtascii + // + this.txtascii.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtascii.Location = new System.Drawing.Point(3, 3); + this.txtascii.Multiline = true; + this.txtascii.Name = "txtascii"; + this.txtascii.Size = new System.Drawing.Size(469, 251); + this.txtascii.TabIndex = 0; + // // tabPage1 // this.tabPage1.Controls.Add(this.txtbinary); @@ -208,14 +204,16 @@ namespace ShiftOS.MFSProfiler this.txtbinary.Size = new System.Drawing.Size(469, 251); this.txtbinary.TabIndex = 0; // - // txtascii + // groupBox1 // - this.txtascii.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtascii.Location = new System.Drawing.Point(3, 3); - this.txtascii.Multiline = true; - this.txtascii.Name = "txtascii"; - this.txtascii.Size = new System.Drawing.Size(469, 251); - this.txtascii.TabIndex = 0; + this.groupBox1.Controls.Add(this.lbfileinfo); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox1.Location = new System.Drawing.Point(0, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(489, 164); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "File record information"; // // lbfileinfo // @@ -226,27 +224,64 @@ namespace ShiftOS.MFSProfiler this.lbfileinfo.TabIndex = 0; this.lbfileinfo.Text = "label1"; // - // Form1 + // pnldirectorylisting + // + this.pnldirectorylisting.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnldirectorylisting.Location = new System.Drawing.Point(0, 0); + this.pnldirectorylisting.Name = "pnldirectorylisting"; + this.pnldirectorylisting.Size = new System.Drawing.Size(489, 466); + this.pnldirectorylisting.TabIndex = 1; + // + // ctxfileoptions + // + this.ctxfileoptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.newFileToolStripMenuItem, + this.newDirectoryToolStripMenuItem, + this.deleteToolStripMenuItem}); + this.ctxfileoptions.Name = "ctxfileoptions"; + this.ctxfileoptions.Size = new System.Drawing.Size(153, 92); + // + // newFileToolStripMenuItem + // + this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem"; + this.newFileToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.newFileToolStripMenuItem.Text = "New file"; + this.newFileToolStripMenuItem.Click += new System.EventHandler(this.newFileToolStripMenuItem_Click); + // + // newDirectoryToolStripMenuItem + // + this.newDirectoryToolStripMenuItem.Name = "newDirectoryToolStripMenuItem"; + this.newDirectoryToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.newDirectoryToolStripMenuItem.Text = "New directory"; + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.deleteToolStripMenuItem.Text = "Delete"; + // + // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(739, 466); this.Controls.Add(this.splitContainer1); - this.Name = "Form1"; + this.Name = "Main"; this.Text = "Form1"; this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); - this.pnlfileinfo.ResumeLayout(false); this.panel1.ResumeLayout(false); - this.groupBox1.ResumeLayout(false); + this.pnlfileinfo.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.tabControl1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); this.tabPage1.ResumeLayout(false); this.tabPage1.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.ctxfileoptions.ResumeLayout(false); this.ResumeLayout(false); } @@ -267,6 +302,10 @@ namespace ShiftOS.MFSProfiler private System.Windows.Forms.TextBox txtbinary; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Label lbfileinfo; + private System.Windows.Forms.ContextMenuStrip ctxfileoptions; + private System.Windows.Forms.ToolStripMenuItem newFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem newDirectoryToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; } } diff --git a/ShiftOS.MFSProfiler/Main.cs b/ShiftOS.MFSProfiler/Main.cs index dbfe276..39f087c 100644 --- a/ShiftOS.MFSProfiler/Main.cs +++ b/ShiftOS.MFSProfiler/Main.cs @@ -65,6 +65,7 @@ namespace ShiftOS.MFSProfiler public void RecursiveDirectoryAdd(TreeNode node) { + node.ContextMenuStrip = ctxfileoptions; foreach (var dir in GetDirectories(node.Tag.ToString())) { var dirInf = GetDirectoryInfo(dir); @@ -131,5 +132,14 @@ System path: {tvfiles.SelectedNode.Tag.ToString()}"; } } catch { } } + + private void newFileToolStripMenuItem_Click(object sender, EventArgs e) + { + var fCreator = new FileCreator(tvfiles.SelectedNode.Tag.ToString()); + if(fCreator.ShowDialog() == DialogResult.OK) + { + SetupTree(); + } + } } } diff --git a/ShiftOS.MFSProfiler/Main.resx b/ShiftOS.MFSProfiler/Main.resx index 1af7de1..107e277 100644 --- a/ShiftOS.MFSProfiler/Main.resx +++ b/ShiftOS.MFSProfiler/Main.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj b/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj index f20926b..f1f944b 100644 --- a/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj +++ b/ShiftOS.MFSProfiler/ShiftOS.MFSProfiler.csproj @@ -46,6 +46,12 @@ + + Form + + + FileCreator.cs + Form @@ -54,6 +60,9 @@ + + FileCreator.cs + Main.cs diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 92d672d..192b497 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -220,6 +220,16 @@ namespace ShiftOS.Server } + public static string ReadEncFile(string fPath) + { + return Encryption.Decrypt(File.ReadAllText(fPath)); + } + + public static void WriteEncFile(string fPath, string contents) + { + File.WriteAllText(fPath, Encryption.Encrypt(contents)); + } + /// /// Interpret the specified msg. /// @@ -268,11 +278,11 @@ Contents: { foreach (var saveFile in Directory.GetFiles("saves")) { - var saveFileContents = JsonConvert.DeserializeObject(File.ReadAllText(saveFile)); + var saveFileContents = JsonConvert.DeserializeObject(ReadEncFile(saveFile)); if (saveFileContents.Username == userName && saveFileContents.Password == passw) { saveFileContents.Codepoints += amount; - File.WriteAllText(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented)); + WriteEncFile(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented)); server.DispatchAll(new NetObject("stop_being_drunk_michael", new ServerMessage { Name = "update_your_cp", @@ -372,11 +382,11 @@ Contents: { foreach(var saveFile in Directory.GetFiles("saves")) { - var saveFileContents = JsonConvert.DeserializeObject(File.ReadAllText(saveFile)); + var saveFileContents = JsonConvert.DeserializeObject(ReadEncFile(saveFile)); if(saveFileContents.Username == userName) { saveFileContents.Codepoints += amount; - File.WriteAllText(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented)); + WriteEncFile(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented)); server.DispatchAll(new NetObject("pikachu_use_thunderbolt_oh_yeah_and_if_you_happen_to_be_doing_backend_and_see_this_post_a_picture_of_ash_ketchum_from_the_unova_series_in_the_discord_dev_room_holy_crap_this_is_a_long_snake_case_thing_about_ash_ketchum_and_pikachu", new ServerMessage { Name = "update_your_cp", @@ -399,14 +409,11 @@ Contents: { try { - var save = JsonConvert.DeserializeObject(File.ReadAllText(savefile)); + var save = JsonConvert.DeserializeObject(ReadEncFile(savefile)); - string hashedPass = Encryption.Encrypt(args["password"].ToString()); - if(save.Username == args["username"].ToString() && save.Password == hashedPass) + if(save.Username == args["username"].ToString() && save.Password == args["password"].ToString()) { - if(save.PasswordHashed == true) - save.Password = Encryption.Decrypt(save.Password); server.DispatchTo(new Guid(msg.GUID), new NetObject("mud_savefile", new ServerMessage { @@ -537,13 +544,8 @@ Contents: break; case "mud_save": var sav = JsonConvert.DeserializeObject(msg.Contents); - if (!sav.PasswordHashed) - { - sav.Password = Encryption.Encrypt(sav.Password.ToString()); - sav.PasswordHashed = true; - } - - File.WriteAllText("saves/" + sav.Username + ".save", JsonConvert.SerializeObject(sav, Formatting.Indented)); + + WriteEncFile("saves/" + sav.Username + ".save", JsonConvert.SerializeObject(sav, Formatting.Indented)); server.DispatchTo(new Guid(msg.GUID), new NetObject("auth_failed", new ServerMessage { @@ -559,11 +561,10 @@ Contents: { try { - var save = JsonConvert.DeserializeObject(File.ReadAllText(savefile)); + var save = JsonConvert.DeserializeObject(ReadEncFile(savefile)); - string hashed = Encryption.Encrypt(args["password"].ToString()); - if (save.Username == args["username"].ToString() && save.Password == hashed) + if (save.Username == args["username"].ToString() && save.Password == args["password"].ToString()) { server.DispatchTo(new Guid(msg.GUID), new NetObject("mud_savefile", new ServerMessage { diff --git a/ShiftOS.WinForms/FakeSetupScreen.cs b/ShiftOS.WinForms/FakeSetupScreen.cs index b7b8612..8a6aa95 100644 --- a/ShiftOS.WinForms/FakeSetupScreen.cs +++ b/ShiftOS.WinForms/FakeSetupScreen.cs @@ -347,7 +347,7 @@ So make sure your password is secure enough that it can't be guessed, but easy f { ShiftOS.Objects.ShiftFS.Utils.Delete(Paths.GetPath("user.dat")); System.IO.File.WriteAllText(Paths.SaveFile, ShiftOS.Objects.ShiftFS.Utils.ExportMount(0)); - Application.Restart(); + SaveSystem.Restart(); } } } diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 32a1fed..14125dc 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -190,11 +190,14 @@ namespace ShiftOS.WinForms TextType("I will reboot your system in Tutorial Mode now. Complete the tutorial, and you shall be on your way."); SaveSystem.CurrentSave = MySave; SaveSystem.CurrentSave.StoryPosition = 1; - SaveSystem.SaveGame(); - this.Invoke(new Action(() => + Utils.WriteAllText(Paths.GetPath("user.dat"), JsonConvert.SerializeObject(new { - this.Close(); + username = MySave.Username, + password = MySave.Password })); + SaveSystem.SaveGame(); + Thread.Sleep(5000); + SaveSystem.Restart(); })); this.Show(); this.BringToFront(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index d2cc521..284c8d6 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -216,6 +216,12 @@ namespace ShiftOS.Engine Console.WriteLine($"{{SHIFTORIUM_TRANSFERRED_TO}}: {amount} -> sys"); } + public static void Restart() + { + TerminalBackend.InvokeCommand("sos.shutdown"); + System.Windows.Forms.Application.Restart(); + } + public static void ReadSave() { //Migrate old saves.