From 0ea74f3088d2b302ab796ae02fffb5dfd4bc8a4f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 7 Mar 2017 09:18:40 -0500 Subject: story stuff --- ShiftOS_TheReturn/SaveSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 9ae18a9..9f0b9b7 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -110,7 +110,7 @@ namespace ShiftOS.Engine ServerManager.GUIDReceived += (str) => { guidReceived = true; - Console.WriteLine("{CONNECTION_SUCCESSFUL}"); + Console.WriteLine("Connection successful."); }; try -- cgit v1.2.3 From 17957f9bb8b3c7fd06cf39a01cd172343cd98a9a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 7 Mar 2017 10:06:20 -0500 Subject: Fix bootstrapper bug. --- ShiftOS.WinForms/Controls/TerminalBox.cs | 4 +- ShiftOS_TheReturn/SaveSystem.cs | 104 ++++++++++++++++++------------- 2 files changed, 61 insertions(+), 47 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index ffc3f86..200c1d7 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -52,12 +52,12 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { - this.Text += Localization.Parse(text); + this.AppendText(Localization.Parse(text)); } public void WriteLine(string text) { - this.Text += Localization.Parse(text) + Environment.NewLine; + this.AppendText(Localization.Parse(text) + Environment.NewLine); } } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 9f0b9b7..b9633e5 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -109,6 +109,7 @@ namespace ShiftOS.Engine bool guidReceived = false; ServerManager.GUIDReceived += (str) => { + //Connection successful! Stop waiting! guidReceived = true; Console.WriteLine("Connection successful."); }; @@ -117,20 +118,26 @@ namespace ShiftOS.Engine { ServerManager.Initiate("secondary4162.cloudapp.net", 13370); - while(guidReceived == false) + //This haults the client until the connection is successful. + while (ServerManager.thisGuid == new Guid()) { } + Console.WriteLine("GUID received - bootstrapping complete."); + FinishBootstrap(); } catch (Exception ex) { + //No errors, this never gets called. Console.WriteLine("{ERROR}: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); - while (guidReceived == false) + while (ServerManager.thisGuid == new Guid()) { } + Console.WriteLine("GUID received - bootstrapping complete."); + FinishBootstrap(); } } else @@ -138,62 +145,69 @@ namespace ShiftOS.Engine ServerManager.StartLANServer(); } - ServerManager.MessageReceived += (msg) => - { - if(msg.Name == "mud_savefile") - { - CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - } - else if(msg.Name == "mud_login_denied") - { - oobe.PromptForLogin(); - } - }; + //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. - ReadSave(); + + })); + thread.IsBackground = true; + thread.Start(); + } - while(CurrentSave == null) + public static void FinishBootstrap() + { + ServerManager.MessageReceived += (msg) => + { + if (msg.Name == "mud_savefile") { - + CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + } + else if (msg.Name == "mud_login_denied") + { + oobe.PromptForLogin(); } + }; - Shiftorium.Init(); + ReadSave(); - while (CurrentSave.StoryPosition < 1) - { + while (CurrentSave == null) + { - } + } + + Shiftorium.Init(); - Thread.Sleep(75); + while (CurrentSave.StoryPosition < 1) + { + + } - Thread.Sleep(50); - Console.WriteLine("{SYSTEM_INITIATED}"); + Thread.Sleep(75); - TerminalBackend.InStory = false; - TerminalBackend.PrefixEnabled = true; - Shiftorium.LogOrphanedUpgrades = true; + Thread.Sleep(50); + Console.WriteLine("{SYSTEM_INITIATED}"); + + TerminalBackend.InStory = false; + TerminalBackend.PrefixEnabled = true; + Shiftorium.LogOrphanedUpgrades = true; + Desktop.InvokeOnWorkerThread(new Action(() => + { + ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); + })); + Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); + if (CurrentSave.StoryPosition == 1) + { Desktop.InvokeOnWorkerThread(new Action(() => { - ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); + TutorialManager.StartTutorial(); + })); - Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); - if (CurrentSave.StoryPosition == 1) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - TutorialManager.StartTutorial(); - - })); - while(TutorialManager.IsInTutorial == true) { } - GameReady?.Invoke(); - } - else - { - GameReady?.Invoke(); - } - })); - thread.IsBackground = true; - thread.Start(); + while (TutorialManager.IsInTutorial == true) { } + GameReady?.Invoke(); + } + else + { + GameReady?.Invoke(); + } } public delegate void EmptyEventHandler(); -- cgit v1.2.3 From 2a747334bd926d79537b9e8d4f38c79a815752e5 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 7 Mar 2017 14:56:48 -0500 Subject: WHOA HACKING --- .../Applications/TutorialBox.Designer.cs | 57 +++ ShiftOS.WinForms/Applications/TutorialBox.cs | 73 ++++ ShiftOS.WinForms/Applications/TutorialBox.resx | 120 +++++ ShiftOS.WinForms/Controls/TerminalBox.cs | 2 + ShiftOS.WinForms/HackerCommands.cs | 484 ++++++++++++++++++++- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 + ShiftOS_TheReturn/Command.cs | 6 + ShiftOS_TheReturn/Commands.cs | 28 ++ ShiftOS_TheReturn/KernelWatchdog.cs | 70 +++ ShiftOS_TheReturn/SaveSystem.cs | 4 +- ShiftOS_TheReturn/ServerManager.cs | 7 + ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/Shiftorium.cs | 7 +- ShiftOS_TheReturn/TerminalBackend.cs | 156 +++---- 14 files changed, 939 insertions(+), 85 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/TutorialBox.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/TutorialBox.cs create mode 100644 ShiftOS.WinForms/Applications/TutorialBox.resx create mode 100644 ShiftOS_TheReturn/KernelWatchdog.cs (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Applications/TutorialBox.Designer.cs b/ShiftOS.WinForms/Applications/TutorialBox.Designer.cs new file mode 100644 index 0000000..6e74023 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TutorialBox.Designer.cs @@ -0,0 +1,57 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class TutorialBox + { + /// + /// 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 Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lbltuttext = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbltuttext + // + this.lbltuttext.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbltuttext.Location = new System.Drawing.Point(0, 0); + this.lbltuttext.Name = "lbltuttext"; + this.lbltuttext.Size = new System.Drawing.Size(401, 134); + this.lbltuttext.TabIndex = 0; + // + // TutorialBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbltuttext); + this.Name = "TutorialBox"; + this.Size = new System.Drawing.Size(401, 134); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label lbltuttext; + } +} diff --git a/ShiftOS.WinForms/Applications/TutorialBox.cs b/ShiftOS.WinForms/Applications/TutorialBox.cs new file mode 100644 index 0000000..25921e1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TutorialBox.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using System.Threading; + +namespace ShiftOS.WinForms.Applications +{ + + [DefaultTitle("Tutorial objective")] + public partial class TutorialBox : UserControl, IShiftOSWindow + { + public TutorialBox() + { + InitializeComponent(); + IsComplete = false; + lbltuttext.Text = ""; + } + + bool stillTyping = false; + + public void SetObjective(string text) + { + while (stillTyping == true) + { + + } + + new Thread(() => + { + stillTyping = true; + this.Invoke(new Action(() => + { + lbltuttext.Text = ""; + })); + foreach(var c in text.ToCharArray()) + { + this.Invoke(new Action(() => + { + lbltuttext.Text += c; + })); + Thread.Sleep(75); + } + stillTyping = false; + }).Start(); + } + + public void OnLoad() + { + } + + public void OnSkinLoad() + { + } + + public bool IsComplete { get; set; } + + public bool OnUnload() + { + return IsComplete; + } + + public void OnUpgrade() + { + } + } +} diff --git a/ShiftOS.WinForms/Applications/TutorialBox.resx b/ShiftOS.WinForms/Applications/TutorialBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TutorialBox.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.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 200c1d7..4fcb429 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -52,7 +52,9 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { + this.HideSelection = true; this.AppendText(Localization.Parse(text)); + this.HideSelection = false; } public void WriteLine(string text) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index ebe25a2..7938fd0 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -1,27 +1,67 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using Newtonsoft.Json; using ShiftOS.Engine; +using ShiftOS.Objects; using ShiftOS.WinForms.Applications; +using static ShiftOS.Objects.ShiftFS.Utils; namespace ShiftOS.WinForms { - [Namespace("l337")] + [Namespace("puppy")] + [RequiresUpgrade("hacker101_deadaccts")] + [KernelMode] + public static class KernelPuppyCommands + { + [Command("clear", true)] + public static bool ClearLogs() + { + WriteAllText("0:/system/data/kernel.log", ""); + Console.WriteLine(" logs cleared successfully."); + return true; + } + } + + [Namespace("krnl")] + public static class KernelCommands + { + [Command("control", true)] + [RequiresArgument("pass")] + public static bool Control(Dictionary args) + { + if(args["pass"].ToString() == ServerManager.thisGuid.ToString()) + { + KernelWatchdog.Log("warn", "User has breached the kernel."); + KernelWatchdog.EnterKernelMode(); + } + return true; + } + + [Command("lock_session")] + [KernelMode] + public static bool LeaveControl() + { + KernelWatchdog.Log("inf", "User has left the kernel-mode session."); + KernelWatchdog.LeaveKernelMode(); + KernelWatchdog.MudConnected = true; + return true; + } + } + + [Namespace("hacker101")] [RequiresUpgrade("hacker101_deadaccts")] public static class HackerCommands { private static void writeSlow(string text) { Console.Write("[hacker101@undisclosed]: "); - foreach(var c in text.ToCharArray()) - { - Console.Write(c); - Thread.Sleep(125); - } - Console.WriteLine(); + Thread.Sleep(200); + Console.WriteLine(text); Thread.Sleep(1000); } @@ -88,9 +128,217 @@ namespace ShiftOS.WinForms internal static void StartHackerTutorial() { - //nyi + Desktop.InvokeOnWorkerThread(() => + { + var tut = new TutorialBox(); + AppearanceManager.SetupWindow(tut); + + new Thread(() => + { + + + int tutPos = 0; + Action ondec = () => + { + if (tutPos == 2) + tutPos++; + }; + TerminalBackend.CommandProcessed += (o, a) => + { + switch (tutPos) + { + + case 0: + case 10: + if (o.ToLower().StartsWith("mud.disconnect")) + { + tutPos++; + } + break; + case 11: + if (o.ToLower().StartsWith("krnl.lock_session")) + tutPos++; + break; + case 1: + if (o.ToLower().StartsWith("hacker101.brute_decrypt")) + { + if (a.Contains("0:/system/data/kernel.log")) + { + tutPos++; + } + } + break; + case 3: + if (o.ToLower().StartsWith("krnl.control")) + { + tutPos++; + } + break; + case 4: + if (o.ToLower().StartsWith("puppy.clear")) + tutPos++; + break; + case 5: + if (o.ToLower().StartsWith("mud.reconnect")) + tutPos++; + break; + case 6: + if (o.ToLower().StartsWith("mud.sendmsg")) + { + var msg = JsonConvert.DeserializeObject(a); + try + { + if (msg.header == "getusers" && msg.body == "dead") + tutPos++; + } + catch + { + + } + } + break; + case 7: + if (o.ToLower().StartsWith("hacker101.breach_user_password")) + tutPos++; + break; + case 8: + if (o.ToLower().StartsWith("hacker101.print_user_info")) + tutPos++; + break; + case 9: + if (o.ToLower().StartsWith("hacker101.steal_codepoints")) + tutPos++; + break; + } + }; + tut.SetObjective("Welcome to the dead account exploitation tutorial. In this tutorial you will learn the basics of hacking within the multi-user domain."); + Thread.Sleep(1000); + tut.SetObjective("We will start with a simple system exploit - gaining kernel-level access to ShiftOS. This can help you perform actions not ever possible in the user level."); + Thread.Sleep(1000); + tut.SetObjective("To gain root access, you will first need to breach the system watchdog to keep it from dialing home to DevX."); + Thread.Sleep(1000); + tut.SetObjective("The watchdog can only function when it has a successful connection to the multi-user domain. You will need to use the MUD Control Centre to disconnect yourself from the MUD. This will lock you out of most features. To disconnect from the multi-user domain, simply run the 'mud.disconnect' command."); + while(tutPos == 0) + { + + } + tut.SetObjective("As you can see, the kernel watchdog has shut down temporarily, however before the disconnect it was able to tell DevX that it has gone offline."); + Thread.Sleep(1000); + tut.SetObjective("You'll also notice that commands like the shiftorium, MUD control centre and various applications that utilize these system components no longer function."); + Thread.Sleep(1000); + tut.SetObjective("The watchdog, however, is still watching. DevX was smart and programmed the kernel to log all events to a local file in 0:/system/data/kernel.log."); + Thread.Sleep(1000); + tut.SetObjective("You will need to empty out this file before you can connect to the multi-user domain, as the watchdog will send the contents of this file straight to DevX."); + Thread.Sleep(1000); + tut.SetObjective("Or, you can do what we're about to do and attempt to decrypt the log and sniff out the kernel-mode access password."); + Thread.Sleep(1000); + tut.SetObjective("This will allow us to gain kernel-level access to our system using the krnl.control{pass:} command."); + Thread.Sleep(1000); + tut.SetObjective("Let's start decrypting the log file using the hacker101.brute_decrypt{file:} script. The file: argument is a string and should point to a .log file. When the script succeeds, you will see a TextPad open with the decrypted contents."); + while(tutPos == 1) + { + + } + onCompleteDecrypt += ondec; + tut.SetObjective("This script isn't the most agile script ever, but it'll get the job done."); + while(tutPos == 2) + { + + } + onCompleteDecrypt -= ondec; + tut.SetObjective("Alright - it's done. Here's how it's laid out. In each log entry, you have the timestamp, then the event name, then the event description."); + Thread.Sleep(1000); + tut.SetObjective("Look for the most recent 'mudhandshake' event. This contains the kernel access code."); + Thread.Sleep(1000); + tut.SetObjective("Once you have it, run 'krnl.control{pass:\"the-kernel-code-here\"}. This will allow you to gain access to the kernel."); + while(tutPos == 3) + { + + } + tut.SetObjective("You are now in kernel mode. Every command you enter will run on the kernel. Now, let's clear the watchdog's logfile and reconnect to the multi-user domain."); + Thread.Sleep(1000); + tut.SetObjective("To clear the log, simply run 'puppy.clear'."); + while(tutPos == 4) + { + + } + tut.SetObjective("Who's a good dog... You are, ShiftOS. Now, we can connect back to the MUD using 'mud.reconnect'."); + Thread.Sleep(1000); + while(tutPos == 5) + { + + } + tut.SetObjective("We have now snuck by the watchdog and DevX has no idea. With kernel-level access, everything you do is not logged, however if you perform too much in one shot, you'll get kicked off and locked out of the multi-user domain temporarily."); + Thread.Sleep(1000); + tut.SetObjective("So, let's focus on the job. You want to get into one of those fancy dead accounts, don't ya? Well, first, we need to talk with the MUD to get a list of these accounts."); + Thread.Sleep(1000); + tut.SetObjective("Simply run the `mud.sendmsg` command, specifying a 'header' of \"getusers\", and a body of \"dead\"."); + while(tutPos == 6) + { + + } + tut.SetObjective("Great. We now have the usernames and sysnames of all dead accounts on the MUD. Now let's use the hacker101.breach_user_password{user:,sys:} command to breach one of these accounts' passwords."); + while(tutPos == 7) + { + + } + tut.SetObjective("There - you now have access to that account. Use its password, username and sysname and run the hacker101.print_user_info{user:,pass:,sys:} command to print the entirety of this user's information."); + while(tutPos == 8) + { + + } + tut.SetObjective("Now you can see a list of the user's Codepoints among other things. Now you can steal their codepoints by using the hacker101.steal_codepoints{user:,pass:,sys;,amount:} command. Be careful. This may alert DevX."); + while(tutPos == 9) + { + + } + if(devx_alerted == true) + { + tut.SetObjective("Alright... enough fun and games. DevX just found out we were doing this."); + Thread.Sleep(500); + tut.SetObjective("Quick! Disconnect from the MUD!!"); + while(tutPos == 10) + { + + } + tut.SetObjective("Now, get out of kernel mode! To do that, run krnl.lock_session."); + while(tutPos == 11) + { + + } + + } + else + { + tut.SetObjective("OK, that was risky, but we pulled it off. Treat yourself! But first, let's get you out of kernel mode."); + Thread.Sleep(500); + tut.SetObjective("First we need to get you off the MUD. Simply run mud.disconnect again."); + while (tutPos == 10) + { + + } + tut.SetObjective("Now, let's run krnl.lock_session. This will lock you back into the user mode, and reconnect you to the MUD."); + while (tutPos == 11) + { + + } + tut.SetObjective("If, for some reason, DevX DOES find out, you have to be QUICK to get off of kernel mode. You don't want to make him mad."); + } + + Thread.Sleep(1000); + tut.SetObjective("So that's all for now. Whenever you're in kernel mode again, and you have access to a user account, try breaching their filesystem next time. You can use sos.help{ns:} to show commands from a specific namespace to help you find more commands easily."); + Thread.Sleep(1000); + tut.SetObjective("You can now close this window."); + tut.IsComplete = true; + + }).Start(); + }); } + private static bool devx_alerted = false; + + private static event Action onCompleteDecrypt; + private static bool terminalIsOpen() { foreach(var win in AppearanceManager.OpenForms) @@ -100,6 +348,226 @@ namespace ShiftOS.WinForms } return false; } + + const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_"; + + [Command("breach_user_password")] + [KernelMode] + [RequiresArgument("user")] + [RequiresArgument("sys")] + [RequiresUpgrade("hacker101_deadaccts")] + public static bool BreachUserPassword(Dictionary args) + { + string usr = args["user"].ToString(); + string sys = args["sys"].ToString(); + + ServerMessageReceived msgReceived = null; + + Console.WriteLine("--hooking system thread..."); + + msgReceived = (msg) => + { + if(msg.Name == "user_data") + { + var sve = JsonConvert.DeserializeObject(msg.Contents); + var rnd = new Random(); + var sw = new Stopwatch(); + sw.Start(); + string pass = ""; + for(int i = 0; i < sve.Password.Length; i++) + { + char c = '\0'; + while (c != sve.Password[i]) + c = chars[rnd.Next(0, chars.Length)]; + pass += c; + Thread.Sleep(rnd.Next(25,75)); + } + sw.Stop(); + Console.WriteLine(pass); + Console.WriteLine(); + Console.WriteLine("--password breached. Operation took " + sw.ElapsedMilliseconds + " milliseconds."); + } + else if(msg.Name == "user_data_not_found") + { + Console.WriteLine("--access denied."); + } + ServerManager.MessageReceived -= msgReceived; + }; + + Console.WriteLine("--beginning brute-force attack on " + usr + "@" + sys + "..."); + Thread.Sleep(500); + ServerManager.MessageReceived += msgReceived; + + ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new + { + user = usr, + sysname = sys + })); + return true; + } + + [Command("print_user_info")] + [KernelMode] + [RequiresArgument("pass")] + [RequiresArgument("user")] + [RequiresArgument("sys")] + [RequiresUpgrade("hacker101_deadaccts")] + public static bool PrintUserInfo(Dictionary args) + { + string usr = args["user"].ToString(); + string sys = args["sys"].ToString(); + string pass = args["pass"].ToString(); + + ServerMessageReceived msgReceived = null; + + Console.WriteLine("--hooking multi-user domain response call..."); + + msgReceived = (msg) => + { + if (msg.Name == "user_data") + { + var sve = JsonConvert.DeserializeObject(msg.Contents); + if(sve.Password == pass) + { + Console.WriteLine("Username: " + sve.Username); + Console.WriteLine("Password: " + sve.Password); + Console.WriteLine("System name: " + sve.SystemName); + Console.WriteLine(); + Console.WriteLine("Codepoints: " + sve.Codepoints.ToString()); + + } + else + { + Console.WriteLine("--access denied."); + } + + } + else if (msg.Name == "user_data_not_found") + { + Console.WriteLine("--access denied."); + } + ServerManager.MessageReceived -= msgReceived; + }; + + Console.WriteLine("--contacting multi-user domain..."); + Thread.Sleep(500); + ServerManager.MessageReceived += msgReceived; + + ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new + { + user = usr, + sysname = sys + })); + return true; + } + + [Command("steal_codepoints")] + [KernelMode] + [RequiresArgument("amount")] + [RequiresArgument("pass")] + [RequiresArgument("user")] + [RequiresArgument("sys")] + [RequiresUpgrade("hacker101_deadaccts")] + public static bool StealCodepoints(Dictionary args) + { + string usr = args["user"].ToString(); + string sys = args["sys"].ToString(); + string pass = args["pass"].ToString(); + long amount = (long)args["amount"]; + + if(amount < 0) + { + Console.WriteLine("--invalid codepoint amount - halting..."); + return true; + } + + ServerMessageReceived msgReceived = null; + + Console.WriteLine("--hooking multi-user domain response call..."); + + msgReceived = (msg) => + { + if (msg.Name == "user_data") + { + var sve = JsonConvert.DeserializeObject(msg.Contents); + if (sve.Password == pass) + { + if(amount > sve.Codepoints) + { + Console.WriteLine("--can't steal this many codepoints from user."); + return; + } + + sve.Codepoints -= amount; + SaveSystem.TransferCodepointsFrom(sve.Username, amount); + ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); + SaveSystem.SaveGame(); + } + else + { + Console.WriteLine("--access denied."); + } + + } + else if (msg.Name == "user_data_not_found") + { + Console.WriteLine("--access denied."); + } + ServerManager.MessageReceived -= msgReceived; + }; + + Console.WriteLine("--contacting multi-user domain..."); + Thread.Sleep(500); + ServerManager.MessageReceived += msgReceived; + + ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new + { + user = usr, + sysname = sys + })); + return true; + } + + + + [Command("brute_decrypt", true)] + [RequiresArgument("file")] + public static bool BruteDecrypt(Dictionary args) + { + if (FileExists(args["file"].ToString())) + { + string pass = new Random().Next(1000, 10000).ToString(); + string fake = ""; + Console.WriteLine("Beginning brute-force attack on password."); + var s = new Stopwatch(); + s.Start(); + for(int i = 0; i < pass.Length; i++) + { + for(int num = 0; num < 10; num++) + { + if(pass[i].ToString() == num.ToString()) + { + fake += num.ToString(); + Console.Write(num); + } + } + } + s.Stop(); + + Console.WriteLine("...password cracked - operation took " + s.ElapsedMilliseconds + " milliseconds."); + var tp = new TextPad(); + AppearanceManager.SetupWindow(tp); + WriteAllText("0:/temp.txt", ReadAllText(args["file"].ToString())); + tp.LoadFile("0:/temp.txt"); + Delete("0:/temp.txt"); + onCompleteDecrypt?.Invoke(); + } + else + { + Console.WriteLine("brute_decrypt: file not found"); + } + return true; + } } [Namespace("storydev")] diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 4bc79a0..7f728d5 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -208,6 +208,12 @@ Terminal.cs + + UserControl + + + TutorialBox.cs + @@ -350,6 +356,9 @@ Terminal.cs + + TutorialBox.cs + DownloadControl.cs diff --git a/ShiftOS_TheReturn/Command.cs b/ShiftOS_TheReturn/Command.cs index 85da6ca..a5924ed 100644 --- a/ShiftOS_TheReturn/Command.cs +++ b/ShiftOS_TheReturn/Command.cs @@ -30,6 +30,12 @@ using System.Threading.Tasks; namespace ShiftOS.Engine { + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] + public class KernelModeAttribute : Attribute + { + + } + public class Command : Attribute { public string name; diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 76aa42f..0ea00e5 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -164,7 +164,35 @@ namespace ShiftOS.Engine } } + [Command("reconnect")] + [RequiresUpgrade("hacker101_deadaccts")] + public static bool Reconnect() + { + Console.WriteLine("--reconnecting to multi-user domain..."); + KernelWatchdog.MudConnected = true; + Console.WriteLine("--done."); + return true; + } + + [Command("disconnect")] + [RequiresUpgrade("hacker101_deadaccts")] + public static bool Disconnect() + { + Console.WriteLine("--connection to multi-user domain severed..."); + KernelWatchdog.MudConnected = false; + return true; + } + [Command("sendmsg")] + [KernelMode] + [RequiresUpgrade("hacker101_deadaccts")] + [RequiresArgument("header")] + [RequiresArgument("body")] + public static bool SendMessage(Dictionary args) + { + ServerManager.SendMessage(args["header"].ToString(), args["body"].ToString()); + return true; + } } [RequiresUpgrade("mud_fundamentals")] diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs new file mode 100644 index 0000000..1b59b25 --- /dev/null +++ b/ShiftOS_TheReturn/KernelWatchdog.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using static ShiftOS.Objects.ShiftFS.Utils; + +namespace ShiftOS.Engine +{ + public static class KernelWatchdog + { + public static void Log(string e, string desc) + { + string line = $"[{DateTime.Now}] <{e}> {desc}"; + if (FileExists("0:/system/data/kernel.log")) + { + string contents = ReadAllText("0:/system/data/kernel.log"); + contents += Environment.NewLine + line; + WriteAllText("0:/system/data/kernel.log", contents); + } + else + { + WriteAllText("0:/system/data/kernel.log", line); + } + } + + public static bool InKernelMode { get; private set; } + public static bool MudConnected { get; set; } + + public static bool IsSafe(Type type) + { + if (InKernelMode == true) + return true; + + foreach (var attrib in type.GetCustomAttributes(false)) + { + if (attrib is KernelModeAttribute) + return false; + } + return true; + } + + public static bool IsSafe(MethodInfo type) + { + if (InKernelMode == true) + return true; + + foreach (var attrib in type.GetCustomAttributes(false)) + { + if (attrib is KernelModeAttribute) + return false; + } + return true; + } + + + public static void EnterKernelMode() + { + InKernelMode = true; + Console.WriteLine(" Watchdog deactivated, system-level access granted."); + } + + public static void LeaveKernelMode() + { + InKernelMode = false; + Console.WriteLine(" Kernel mode disabled."); + } + } +} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index b9633e5..df4c6d6 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -155,6 +155,8 @@ namespace ShiftOS.Engine public static void FinishBootstrap() { + KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); + ServerManager.MessageReceived += (msg) => { if (msg.Name == "mud_savefile") @@ -313,7 +315,7 @@ namespace ShiftOS.Engine System.IO.File.WriteAllText(Paths.SaveFile, Utils.ExportMount(0)); } - public static void TransferCodepointsFrom(string who, int amount) + public static void TransferCodepointsFrom(string who, long amount) { NotificationDaemon.AddNotification(NotificationType.CodepointsReceived, amount); CurrentSave.Codepoints += amount; diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 3059391..a121ab6 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -126,6 +126,13 @@ namespace ShiftOS.Engine thisGuid = new Guid(msg.Contents); GUIDReceived?.Invoke(msg.Contents); } + else if(msg.Name == "allusers") + { + foreach(var acc in JsonConvert.DeserializeObject(msg.Contents)) + { + Console.WriteLine(acc); + } + } else if(msg.Name == "update_your_cp") { var args = JsonConvert.DeserializeObject>(msg.Contents); diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 3702b18..20ca879 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -107,6 +107,7 @@ + diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 198dcc7..0bdd9f4 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -210,9 +210,12 @@ namespace ShiftOS.Engine if (SaveSystem.CurrentSave.StoriesExperienced == null) SaveSystem.CurrentSave.StoriesExperienced = new List(); - if (!SaveSystem.CurrentSave.StoriesExperienced.Contains(id)) - return SaveSystem.CurrentSave.Upgrades[id]; + bool upgInstalled = false; + if(SaveSystem.CurrentSave.Upgrades.ContainsKey(id)) + upgInstalled = SaveSystem.CurrentSave.Upgrades[id]; + if(upgInstalled == false) + return SaveSystem.CurrentSave.StoriesExperienced.Contains(id); return true; } catch diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 3c8e62a..8be54d0 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -139,121 +139,129 @@ namespace ShiftOS.Engine { if (Shiftorium.UpgradeAttributesUnlocked(type)) { - foreach (var a in type.GetCustomAttributes(false)) + if (KernelWatchdog.IsSafe(type)) { - if (a is Namespace) + foreach (var a in type.GetCustomAttributes(false)) { - var ns = a as Namespace; - if (text.Split('.')[0] == ns.name) + if (a is Namespace) { - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + var ns = a as Namespace; + if (text.Split('.')[0] == ns.name) { - if (Shiftorium.UpgradeAttributesUnlocked(method)) + foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - if (CanRunRemotely(method, isRemote)) + if (Shiftorium.UpgradeAttributesUnlocked(method)) { - foreach (var ma in method.GetCustomAttributes(false)) + if (KernelWatchdog.IsSafe(method)) { - if (ma is Command) + if (CanRunRemotely(method, isRemote)) { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) + foreach (var ma in method.GetCustomAttributes(false)) { - - var attr = method.GetCustomAttribute(); - - if (attr != null) + if (ma is Command) { - string newcommand = attr.newcommand; - if (attr.warn) + var cmd = ma as Command; + if (text.Split('.')[1] == cmd.name) { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { + + var attr = method.GetCustomAttribute(); + + if (attr != null) + { + string newcommand = attr.newcommand; + if (attr.warn) + { + Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { {"%newcommand", newcommand} })); - } - if (newcommand != "") - { - // redo the entire process running newcommand - - return RunClient(newcommand, args); - } - } + } + if (newcommand != "") + { + // redo the entire process running newcommand - var requiresArgs = method.GetCustomAttributes(); + return RunClient(newcommand, args); + } + } - bool error = false; - bool providedusage = false; + var requiresArgs = method.GetCustomAttributes(); - foreach (RequiresArgument argument in requiresArgs) - { - if (!args.ContainsKey(argument.argument)) - { + bool error = false; + bool providedusage = false; - if (!providedusage) + foreach (RequiresArgument argument in requiresArgs) { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { + if (!args.ContainsKey(argument.argument)) + { + + if (!providedusage) + { + string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; + if (usageparse == Localization.Parse(usageparse)) + usageparse = ""; + else + usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { {"%ns", ns.name}, {"%cmd", cmd.name} }) : ""; - Console.WriteLine(usageparse); + Console.WriteLine(usageparse); - providedusage = true; - } + providedusage = true; + } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { + if (Shiftorium.UpgradeInstalled("help_usage")) + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { {"%argument", argument.argument} })); + } + else + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + } + + error = true; + } } - else + + if (error) { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + throw new Exception("{ERROR_COMMAND_WRONG}"); } - error = true; + try + { + return (bool)method.Invoke(null, new[] { args }); + } + catch (TargetInvocationException e) + { + Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); + Console.WriteLine(e.InnerException.Message); + Console.WriteLine(e.InnerException.StackTrace); + return true; + } + catch + { + return (bool)method.Invoke(null, new object[] { }); + } } } - - if (error) - { - throw new Exception("{ERROR_COMMAND_WRONG}"); - } - - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); - return true; - } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } } } + else + { + Console.WriteLine(text + " cannot be ran in a remote session"); + return true; + } } - } - else - { - Console.WriteLine(text + " cannot be ran in a remote session"); - return true; + } } } } } } + } } } -- cgit v1.2.3 From 07376e9ecd6687b2c4278661d0eaf3795d5124c3 Mon Sep 17 00:00:00 2001 From: lempamo Date: Wed, 5 Apr 2017 21:57:09 -0400 Subject: language selection screen! --- ShiftOS.WinForms/LanguageSelector.Designer.cs | 94 ++++++++++++++++++++ ShiftOS.WinForms/LanguageSelector.cs | 44 ++++++++++ ShiftOS.WinForms/LanguageSelector.resx | 120 ++++++++++++++++++++++++++ ShiftOS.WinForms/Program.cs | 9 +- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ ShiftOS.WinForms/WFLanguageProvider.cs | 17 ++++ ShiftOS_TheReturn.sln | 14 +-- ShiftOS_TheReturn/Localization.cs | 14 ++- ShiftOS_TheReturn/SaveSystem.cs | 2 +- 9 files changed, 307 insertions(+), 16 deletions(-) create mode 100644 ShiftOS.WinForms/LanguageSelector.Designer.cs create mode 100644 ShiftOS.WinForms/LanguageSelector.cs create mode 100644 ShiftOS.WinForms/LanguageSelector.resx (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/LanguageSelector.Designer.cs b/ShiftOS.WinForms/LanguageSelector.Designer.cs new file mode 100644 index 0000000..508b5df --- /dev/null +++ b/ShiftOS.WinForms/LanguageSelector.Designer.cs @@ -0,0 +1,94 @@ +using ShiftOS.Engine; + +namespace ShiftOS.WinForms +{ + partial class LanguageSelector + { + /// + /// 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.comboBox1 = new System.Windows.Forms.ComboBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBox1 + // + this.comboBox1.Cursor = System.Windows.Forms.Cursors.Default; + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(Localization.GetAllLanguages()); + this.comboBox1.Location = new System.Drawing.Point(13, 13); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(167, 21); + this.comboBox1.TabIndex = 0; + this.comboBox1.SelectedItem = this.comboBox1.Items[0]; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(12, 40); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Run"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(105, 40); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 2; + this.button2.Text = "Quit"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // LanguageSelector + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(192, 74); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.comboBox1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "LanguageSelector"; + this.ShowIcon = false; + this.Text = "Choose A Language"; + this.ResumeLayout(false); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.closing); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/LanguageSelector.cs b/ShiftOS.WinForms/LanguageSelector.cs new file mode 100644 index 0000000..c9a5ac1 --- /dev/null +++ b/ShiftOS.WinForms/LanguageSelector.cs @@ -0,0 +1,44 @@ +using ShiftOS.Engine; +using ShiftOS.WinForms.Applications; +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.WinForms +{ + public partial class LanguageSelector : Form + { + public string languageID; + public bool rdy = false; + + public LanguageSelector() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + Localization.SetLanguageID((string)comboBox1.SelectedItem); + + rdy = true; + + this.Close(); + } + + private void button2_Click(object sender, EventArgs e) + { + Environment.Exit(0); + } + + private void closing(object sender, FormClosingEventArgs e) + { + if (!rdy) Environment.Exit(0); + } + } +} diff --git a/ShiftOS.WinForms/LanguageSelector.resx b/ShiftOS.WinForms/LanguageSelector.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/LanguageSelector.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.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 0578389..b5f371e 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -58,6 +58,14 @@ namespace ShiftOS.WinForms Environment.Exit(0); }; + var langselect = new LanguageSelector(); + langselect.ShowDialog(); + + while (!langselect.rdy) + { + + }; + TutorialManager.RegisterTutorial(new Oobe()); TerminalBackend.TerminalRequested += () => @@ -102,7 +110,6 @@ namespace ShiftOS.WinForms } } - public class WinformsFSFrontend : IFileSkimmer { diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index d865c62..d7b3478 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -258,6 +258,12 @@ + + Form + + + LanguageSelector.cs + Form @@ -383,6 +389,9 @@ FakeSetupScreen.cs + + LanguageSelector.cs + Oobe.cs diff --git a/ShiftOS.WinForms/WFLanguageProvider.cs b/ShiftOS.WinForms/WFLanguageProvider.cs index e762e7e..b6b652b 100644 --- a/ShiftOS.WinForms/WFLanguageProvider.cs +++ b/ShiftOS.WinForms/WFLanguageProvider.cs @@ -52,6 +52,18 @@ namespace ShiftOS.WinForms } } + public string GetLanguagePath() + { + switch (SaveSystem.CurrentSave.Language) + { + case "deutsch - in beta": + return Paths.GetPath("deutsch.local"); + default: + return Paths.GetPath("english.local"); + + } + } + public List GetJSONTranscripts() { var strings = new List(); @@ -65,6 +77,11 @@ namespace ShiftOS.WinForms Utils.WriteAllText(Paths.GetPath("english.local"), getDefault()); } + public void WriteTranscript() + { + Utils.WriteAllText(GetLanguagePath(), GetCurrentTranscript()); + } + private string getDefault() { return Properties.Resources.strings_en; diff --git a/ShiftOS_TheReturn.sln b/ShiftOS_TheReturn.sln index e56ebaa..8bb8ef4 100644 --- a/ShiftOS_TheReturn.sln +++ b/ShiftOS_TheReturn.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftOS.Engine", "ShiftOS_TheReturn\ShiftOS.Engine.csproj", "{7C979B07-0585-4033-A110-E5555B9D6651}" EndProject @@ -19,10 +19,6 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ShiftOS.Modding.VB.LegacySk EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModLauncher", "ModLauncher\ModLauncher.csproj", "{AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gwen", "Gwen\Gwen.csproj", "{ADDA2F43-96C0-497F-8216-29C67ABC9806}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gwen.Renderer.OpenTK", "Gwen.Renderer.OpenTK\Gwen.Renderer.OpenTK.csproj", "{41650C82-D630-4E5C-845A-F1513C8FDC99}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -61,14 +57,6 @@ Global {AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {AEACB7B5-E8FC-4569-BBD3-5053A694D6EC}.Release|Any CPU.Build.0 = Release|Any CPU - {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ADDA2F43-96C0-497F-8216-29C67ABC9806}.Release|Any CPU.Build.0 = Release|Any CPU - {41650C82-D630-4E5C-845A-F1513C8FDC99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {41650C82-D630-4E5C-845A-F1513C8FDC99}.Debug|Any CPU.Build.0 = Debug|Any CPU - {41650C82-D630-4E5C-845A-F1513C8FDC99}.Release|Any CPU.ActiveCfg = Release|Any CPU - {41650C82-D630-4E5C-845A-F1513C8FDC99}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index de5e158..a9d24b8 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -37,6 +37,7 @@ namespace ShiftOS.Engine { List GetJSONTranscripts(); void WriteDefaultTranscript(); + void WriteTranscript(); string GetCurrentTranscript(); string[] GetAllLanguages(); } @@ -44,6 +45,7 @@ namespace ShiftOS.Engine public static class Localization { private static ILanguageProvider _provider = null; + private static string _languageid = null; public static string[] GetAllLanguages() { @@ -67,7 +69,7 @@ namespace ShiftOS.Engine } else { - _provider.WriteDefaultTranscript(); + _provider.WriteTranscript(); } } @@ -197,5 +199,15 @@ namespace ShiftOS.Engine { _provider = p; } + + public static void SetLanguageID(string id) + { + _languageid = id; + } + + public static string GetLanguageID() + { + return _languageid; + } } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index df4c6d6..5188bf1 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,7 @@ namespace ShiftOS.Engine root.permissions = Permissions.All; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } - + CurrentSave.Language = Localization.GetLanguageID(); if (Utils.Mounts.Count == 0) Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); -- cgit v1.2.3 From 9a8949cffcd454f6297923c7001cfb036604e02f Mon Sep 17 00:00:00 2001 From: lempamo Date: Thu, 6 Apr 2017 10:17:19 -0400 Subject: language changing actually works --- ShiftOS.WinForms/LanguageSelector.Designer.cs | 94 -------------------- ShiftOS.WinForms/LanguageSelector.cs | 44 ---------- ShiftOS.WinForms/LanguageSelector.resx | 120 -------------------------- ShiftOS.WinForms/Program.cs | 8 -- ShiftOS.WinForms/Resources/languages.txt | 2 +- ShiftOS.WinForms/Resources/strings_de.txt | 3 + ShiftOS.WinForms/Resources/strings_en.txt | 5 +- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 -- ShiftOS.WinForms/WFLanguageProvider.cs | 21 +++-- ShiftOS_TheReturn/Commands.cs | 29 +++++++ ShiftOS_TheReturn/Localization.cs | 6 ++ ShiftOS_TheReturn/SaveSystem.cs | 3 +- 12 files changed, 59 insertions(+), 285 deletions(-) delete mode 100644 ShiftOS.WinForms/LanguageSelector.Designer.cs delete mode 100644 ShiftOS.WinForms/LanguageSelector.cs delete mode 100644 ShiftOS.WinForms/LanguageSelector.resx (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/LanguageSelector.Designer.cs b/ShiftOS.WinForms/LanguageSelector.Designer.cs deleted file mode 100644 index 508b5df..0000000 --- a/ShiftOS.WinForms/LanguageSelector.Designer.cs +++ /dev/null @@ -1,94 +0,0 @@ -using ShiftOS.Engine; - -namespace ShiftOS.WinForms -{ - partial class LanguageSelector - { - /// - /// 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.comboBox1 = new System.Windows.Forms.ComboBox(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // comboBox1 - // - this.comboBox1.Cursor = System.Windows.Forms.Cursors.Default; - this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(Localization.GetAllLanguages()); - this.comboBox1.Location = new System.Drawing.Point(13, 13); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(167, 21); - this.comboBox1.TabIndex = 0; - this.comboBox1.SelectedItem = this.comboBox1.Items[0]; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(12, 40); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 1; - this.button1.Text = "Run"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // button2 - // - this.button2.Location = new System.Drawing.Point(105, 40); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 2; - this.button2.Text = "Quit"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // LanguageSelector - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(192, 74); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); - this.Controls.Add(this.comboBox1); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "LanguageSelector"; - this.ShowIcon = false; - this.Text = "Choose A Language"; - this.ResumeLayout(false); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.closing); - - } - - #endregion - - private System.Windows.Forms.ComboBox comboBox1; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/LanguageSelector.cs b/ShiftOS.WinForms/LanguageSelector.cs deleted file mode 100644 index c9a5ac1..0000000 --- a/ShiftOS.WinForms/LanguageSelector.cs +++ /dev/null @@ -1,44 +0,0 @@ -using ShiftOS.Engine; -using ShiftOS.WinForms.Applications; -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.WinForms -{ - public partial class LanguageSelector : Form - { - public string languageID; - public bool rdy = false; - - public LanguageSelector() - { - InitializeComponent(); - } - - private void button1_Click(object sender, EventArgs e) - { - Localization.SetLanguageID((string)comboBox1.SelectedItem); - - rdy = true; - - this.Close(); - } - - private void button2_Click(object sender, EventArgs e) - { - Environment.Exit(0); - } - - private void closing(object sender, FormClosingEventArgs e) - { - if (!rdy) Environment.Exit(0); - } - } -} diff --git a/ShiftOS.WinForms/LanguageSelector.resx b/ShiftOS.WinForms/LanguageSelector.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ShiftOS.WinForms/LanguageSelector.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index b5f371e..348360f 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -58,14 +58,6 @@ namespace ShiftOS.WinForms Environment.Exit(0); }; - var langselect = new LanguageSelector(); - langselect.ShowDialog(); - - while (!langselect.rdy) - { - - }; - TutorialManager.RegisterTutorial(new Oobe()); TerminalBackend.TerminalRequested += () => diff --git a/ShiftOS.WinForms/Resources/languages.txt b/ShiftOS.WinForms/Resources/languages.txt index ca34308..a452137 100644 --- a/ShiftOS.WinForms/Resources/languages.txt +++ b/ShiftOS.WinForms/Resources/languages.txt @@ -1,4 +1,4 @@ [ "english" - "deutsch - in beta" + "deutsch" ] \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/strings_de.txt b/ShiftOS.WinForms/Resources/strings_de.txt index 5abfd32..59631de 100644 --- a/ShiftOS.WinForms/Resources/strings_de.txt +++ b/ShiftOS.WinForms/Resources/strings_de.txt @@ -159,6 +159,8 @@ Wenn eine Systemdatei von dem Virenscanner erkannt wird, wird sie ersetzt.", "{COMMAND_SOS_SHUTDOWN_DESCRIPTION}":"Saves and shuts down ShiftOS", "{COMMAND_SOS_STATUS_USAGE}":"%ns.%cmd", "{COMMAND_SOS_STATUS_DESCRIPTION}":"Displays how many codepoints you have", + "{COMMAND_SOS_LANG_USAGE}":"%ns.%cmd{[language:\"english\"]}", + "{COMMAND_SOS_LANG_DESCRIPTION}":"Sprache ändern.", "{COMMAND_DEV_CRASH_USAGE}":"%ns.%cmd", "{COMMAND_DEV_CRASH_DESCRIPTION}":"Shuts down ShiftOS forcefully", "{COMMAND_DEV_UNLOCKEVERYTHING_USAGE}":"%ns.%cmd", @@ -217,6 +219,7 @@ Wenn eine Systemdatei von dem Virenscanner erkannt wird, wird sie ersetzt.", "{OBSOLETE_SYS_SHUTDOWN}":"sys.shutdown is obsolete", "{PY_EXCEPTION}":"There was an error running python code.", "{LUA_ERROR}":"There was an error running lua code.", + "{LANGUAGE_CHANGED}":"The language has been changed. Please restart ShiftOS for changes to take full effect.", "{TERMINAL_NAME}":"Terminal", "{ARTPAD_NAME}":"Artpad", diff --git a/ShiftOS.WinForms/Resources/strings_en.txt b/ShiftOS.WinForms/Resources/strings_en.txt index 54c9b54..34d034a 100644 --- a/ShiftOS.WinForms/Resources/strings_en.txt +++ b/ShiftOS.WinForms/Resources/strings_en.txt @@ -158,12 +158,14 @@ If a system file is deleted by the virus scanner, it will be replaced.", "{COMMAND_SOS_SHUTDOWN_DESCRIPTION}":"Saves and shuts down ShiftOS", "{COMMAND_SOS_STATUS_USAGE}":"%ns.%cmd", "{COMMAND_SOS_STATUS_DESCRIPTION}":"Displays how many codepoints you have", + "{COMMAND_SOS_LANG_USAGE}":"%ns.%cmd{[language:\"deutsch\"]}", + "{COMMAND_SOS_LANG_DESCRIPTION}":"Change the language.", "{COMMAND_DEV_CRASH_USAGE}":"%ns.%cmd", "{COMMAND_DEV_CRASH_DESCRIPTION}":"Shuts down ShiftOS forcefully", "{COMMAND_DEV_UNLOCKEVERYTHING_USAGE}":"%ns.%cmd", "{COMMAND_DEV_UNLOCKEVERYTHING_DESCRIPTION}":"Unlocks all shiftorium upgrades", "{COMMAND_DEV_FREECP_USAGE}":"%ns.%cmd{[amount:1000]}", - "{COMMAND_DEV_FREECP_DESCRIPTION}":"Gives [ammount] codepoints", + "{COMMAND_DEV_FREECP_DESCRIPTION}":"Gives [amount] codepoints", "{COMMAND_TRM_CLEAR_USAGE}":"%ns.%cmd", "{COMMAND_TRM_CLEAR_DESCRIPTION}":"Clears the terminal", "{COMMAND_SHIFTORIUM_BUY_USAGE}":"%ns.%cmd{upgrade:}", @@ -217,6 +219,7 @@ If a system file is deleted by the virus scanner, it will be replaced.", "{OBSOLETE_SYS_SHUTDOWN}":"sys.shutdown is obsolete", "{PY_EXCEPTION}":"There was an error running python code.", "{LUA_ERROR}":"There was an error running lua code.", + "{LANGUAGE_CHANGED}":"The language has been changed. Please restart ShiftOS for changes to take full effect.", "{TERMINAL_NAME}":"Terminal", "{ARTPAD_NAME}":"Artpad", diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index d7b3478..d865c62 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -258,12 +258,6 @@ - - Form - - - LanguageSelector.cs - Form @@ -389,9 +383,6 @@ FakeSetupScreen.cs - - LanguageSelector.cs - Oobe.cs diff --git a/ShiftOS.WinForms/WFLanguageProvider.cs b/ShiftOS.WinForms/WFLanguageProvider.cs index b6b652b..c11b6dc 100644 --- a/ShiftOS.WinForms/WFLanguageProvider.cs +++ b/ShiftOS.WinForms/WFLanguageProvider.cs @@ -42,13 +42,20 @@ namespace ShiftOS.WinForms public string GetCurrentTranscript() { - switch (SaveSystem.CurrentSave.Language) + try { - case "deutsch - in beta": - return Properties.Resources.strings_de; - default: - return getDefault(); - + switch (SaveSystem.CurrentSave.Language) + { + case "deutsch": + return Properties.Resources.strings_de; + default: + return getDefault(); + + } + } + catch (NullReferenceException) + { + return getDefault(); } } @@ -56,7 +63,7 @@ namespace ShiftOS.WinForms { switch (SaveSystem.CurrentSave.Language) { - case "deutsch - in beta": + case "deutsch": return Paths.GetPath("deutsch.local"); default: return Paths.GetPath("english.local"); diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 9f85a25..fedff19 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -357,6 +357,35 @@ namespace ShiftOS.Engine return true; } + [Command("lang", usage = "{{COMMAND_SOS_LANG_USAGE}}", description = "{{COMMAND_SOS_LANG_DESCRIPTION}}")] + [RequiresArgument("language")] + public static bool SetLanguage(Dictionary userArgs) + { + try + { + string lang = ""; + + if (userArgs.ContainsKey("language")) + lang = (string)userArgs["language"]; + else + throw new Exception("You must specify a valid 'language' value."); + + if (Localization.GetAllLanguages().Contains(lang)) + { + SaveSystem.CurrentSave.Language = lang; + SaveSystem.SaveGame(); + Console.WriteLine("{LANGUAGE_CHANGED}"); + return true; + } + + throw new Exception($"Couldn't find language with ID: {lang}"); + } + catch + { + return false; + } + } + [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] public static bool Help() { diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index a9d24b8..c1a6bd6 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -67,6 +67,12 @@ namespace ShiftOS.Engine var path = "english.local"; Utils.WriteAllText(Paths.GetPath(path), lines); } + else if (SaveSystem.CurrentSave == null) + { + var lines = Properties.Resources.strings_en; + var path = "english.local"; + Utils.WriteAllText(Paths.GetPath(path), lines); + } else { _provider.WriteTranscript(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 5188bf1..9ff3111 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,6 @@ namespace ShiftOS.Engine root.permissions = Permissions.All; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } - CurrentSave.Language = Localization.GetLanguageID(); if (Utils.Mounts.Count == 0) Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); @@ -176,6 +175,8 @@ namespace ShiftOS.Engine } + Localization.SetupTHETRUEDefaultLocals(); + Shiftorium.Init(); while (CurrentSave.StoryPosition < 1) -- cgit v1.2.3 From 32fc6ed13d8334a6af66b43cf84324a123670620 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 17 Apr 2017 15:10:34 -0400 Subject: Basically finish new OOBE --- ShiftOS.Server/SaveManager.cs | 4 +- ShiftOS.WinForms/Applications/Terminal.cs | 5 +- ShiftOS.WinForms/Oobe.Designer.cs | 4 +- ShiftOS.WinForms/Oobe.cs | 134 ++++---------- ShiftOS.WinForms/OobeStory.cs | 284 ++++++++++++++++++++++++++++++ ShiftOS.WinForms/Program.cs | 4 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 7 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS_TheReturn/SaveSystem.cs | 8 +- ShiftOS_TheReturn/Story.cs | 2 +- 10 files changed, 334 insertions(+), 119 deletions(-) create mode 100644 ShiftOS.WinForms/OobeStory.cs (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index a277b6d..56e8d50 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -121,7 +121,7 @@ namespace ShiftOS.Server public static void CheckUserExists(string guid, object contents) { var args = contents as Dictionary; - if (args["username"] != null && args["password"] != null) + if (args["username"] != null) { args["username"] = args["username"].ToString().ToLower(); foreach (var savefile in Directory.GetFiles("saves")) @@ -131,7 +131,7 @@ namespace ShiftOS.Server var save = JsonConvert.DeserializeObject(ReadEncFile(savefile)); - if (save.Username == args["username"].ToString() && save.Password == args["password"].ToString()) + if (save.Username == args["username"].ToString()) { server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage { diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 8d29cba..30dbd82 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -56,7 +56,6 @@ namespace ShiftOS.WinForms.Applications { public static string latestCommmand = ""; - public static bool IsInRemoteSystem = false; public static string RemoteGuid = ""; @@ -371,5 +370,9 @@ namespace ShiftOS.WinForms.Applications { } + internal void ClearText() + { + rtbterm.Text = ""; + } } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Oobe.Designer.cs b/ShiftOS.WinForms/Oobe.Designer.cs index 587f50a..d3a0f38 100644 --- a/ShiftOS.WinForms/Oobe.Designer.cs +++ b/ShiftOS.WinForms/Oobe.Designer.cs @@ -82,14 +82,14 @@ namespace ShiftOS.WinForms // // lblhackwords // - this.lblhackwords.AutoSize = true; this.lblhackwords.Dock = System.Windows.Forms.DockStyle.Fill; this.lblhackwords.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblhackwords.ForeColor = System.Drawing.SystemColors.ButtonFace; this.lblhackwords.Location = new System.Drawing.Point(0, 0); this.lblhackwords.Name = "lblhackwords"; - this.lblhackwords.Size = new System.Drawing.Size(127, 18); + this.lblhackwords.Size = new System.Drawing.Size(653, 457); this.lblhackwords.TabIndex = 1; + this.lblhackwords.Tag = "header2"; this.lblhackwords.Text = "Hijack in progress"; // // hackeffecttimer diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index d6d3b92..5b767e0 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -36,6 +36,7 @@ using Newtonsoft.Json; using ShiftOS.Engine; using ShiftOS.Objects; using ShiftOS.Objects.ShiftFS; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms { @@ -47,7 +48,10 @@ namespace ShiftOS.WinForms this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; this.BackColor = Color.Black; - + this.Load += (o, a) => + { + ControlManager.SetupControls(this); + }; } @@ -62,6 +66,7 @@ namespace ShiftOS.WinForms public void TextType(string texttotype) { + textgeninput.TextAlign = ContentAlignment.MiddleCenter; while(typing == true) { //JESUS CHRIST PAST MICHAEL. @@ -116,114 +121,43 @@ namespace ShiftOS.WinForms { try { - textgeninput = this.lblHijack; - TextType("Your system is now being hijacked."); - rtext = ""; - Thread.Sleep(1000); textgeninput = this.lblhackwords; this.Invoke(new Action(() => { lblHijack.Hide(); })); - TextType("Hello, and welcome to ShiftOS."); - Thread.Sleep(500); - TextType("You have been cordially and involuntarily selected to participate in the development and testing of this operating system."); - Thread.Sleep(500); - TextType("My identity shall remain secret, but if you've been through this before, you'll know exactly who I am."); - Thread.Sleep(500); - TextType("But that doesn't matter."); - Thread.Sleep(500); - TextType("I will now begin to prepare your system for the installation of ShiftOS."); - Thread.Sleep(1000); - FakeSetupScreen fakeForm = null; - this.Invoke(new Action(() => - { - fakeForm = new FakeSetupScreen(this); - fakeForm.Show(); - MySave = save; - lblhackwords.GotFocus += (o, a) => - { - try - { - fakeForm.Invoke(new Action(() => - { - fakeForm.Focus(); - fakeForm.BringToFront(); - })); - } - catch { } - }; - fakeForm.TextSent += (txt) => - { - TextType(txt); - }; - })); - while (fakeForm?.Visible == true) - { - Thread.Sleep(10); - } - if (fakeForm.CreateNewSave == true) + + TextType(@"Throughout many years, man has tried to develop +a digital environment usable by anyone that never goes +offline, full of AIs and humans alike, thinking, interacting, +innovating. + +No one has ever come close to a digital society of such +properties yet, except for one sentient being. It does not +have a life, a gender, an age or a body, but simply one name. + +They call it ""DevX"". + +If anyone sees this message, my identity is anonymous, but I +need your help. I am trapped within ""DevX""'s digital society +with no way out, constantly under attack. + +You must join the digital society, rise up the ranks, and save us. + + - undisclosed_0x1DDFB5977."); + + Thread.Sleep(5000); + while(this.Opacity > 0f) { - TextType("That's all the information I need for now."); - Thread.Sleep(2000); - TextType("Beginning installation of ShiftOS on " + MySave.SystemName + "."); - Thread.Sleep(500); - TextType("Creating new user: " + MySave.Username); - TextType("...with 0 Codepoints, 0 installed upgrades, no legion, and no user shops..."); - MySave.Codepoints = 0; - MySave.CurrentLegions = new List(); - MySave.MyShop = ""; - TextType("User created successfully."); - Thread.Sleep(450); - TextType("You may be wondering what all that meant... You see, in ShiftOS, your user account holds everything I need to know about you."); - Thread.Sleep(640); - TextType("It holds the amount of Codepoints you have - Codepoints are a special currency you can get by doing various tasks in ShiftOS."); - Thread.Sleep(500); - TextType("It also holds all the upgrades you've installed onto ShiftOS - features, applications, enhancements, patches, all that stuff."); - Thread.Sleep(500); - TextType("As for the legions and the shop thing, I'll reveal that to you when it becomes necessary."); - Thread.Sleep(500); - TextType("Your user account is stored on a server of mine called the multi-user domain. It holds every single user account, every script, every application, every thing within ShiftOS."); - Thread.Sleep(600); - TextType("Every time you boot ShiftOS, if you are connected to the Internet, you will immediately connect to the multi-user domain and ShiftOS will attempt to authenticate using the last "); - TextType("successful username and password pair."); - Thread.Sleep(500); - TextType("When you are in the MUD, you are in the middle of a free-for-all. I don't want it to be this way, it just is. I've employed you to help me develop and test the MUD and ShiftOS, "); - TextType("but you have a secondary task if you choose to accept it."); - Thread.Sleep(500); - TextType("There have been a few rebelious groups in the MUD - who have cracked ShiftOS's security barriers - and they're using these exploits to steal others' Codepoints, upgrades, "); - TextType("and even spread damaging viruses."); - Thread.Sleep(500); - TextType("I want you to stop them."); - Thread.Sleep(500); - TextType("Whoever can stop these hackers will gain eternal control over the multi-user domain. They will be given the ability to do as they please, so long as it doesn't interfere with my experiments."); - Thread.Sleep(500); - TextType("I have been installing ShiftOS on your system in the background as I was talking with you. Before I can set you free, I need to give you a tutorial on how to use the system."); - Thread.Sleep(500); - TextType("I will reboot your system in Tutorial Mode now. Complete the tutorial, and you shall be on your way."); - - Thread.Sleep(3000); - SaveSystem.CurrentSave = MySave; - SaveSystem.CurrentSave.StoryPosition = 1; - Utils.WriteAllText(Paths.GetPath("user.dat"), JsonConvert.SerializeObject(new + this.Invoke(new Action(() => { - username = MySave.Username, - password = MySave.Password + this.Opacity -= 0.01f; })); - Shiftorium.Silent = true; - SaveSystem.SaveGame(); //Yknow, just incase it crashes. - } - else - { - TextType("Your login attempt was successful, " + SaveSystem.CurrentSave.Username + "."); - Thread.Sleep(500); - TextType($"According to my data on you, you have earned {SaveSystem.CurrentSave.Codepoints} Codepoints so far."); - Thread.Sleep(500); - TextType($"You have also acquired {SaveSystem.CurrentSave.CountUpgrades()} Shiftorium upgrades out of the {SaveSystem.CurrentSave.Upgrades.Count} available."); - Thread.Sleep(500); - TextType("I will now let you proceed to your system."); - Thread.Sleep(1000); + Thread.Sleep(25); } + + Story.Start("mud_fundamentals"); + this.Invoke(new Action(this.Close)); } catch (Exception e) diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs new file mode 100644 index 0000000..68e2a7b --- /dev/null +++ b/ShiftOS.WinForms/OobeStory.cs @@ -0,0 +1,284 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using Newtonsoft.Json; +using ShiftOS.Engine; +using ShiftOS.Objects; + +namespace ShiftOS.WinForms +{ + public class OobeStory + { + [Story("mud_fundamentals")] + public static void DoStory() + { + Applications.Terminal term = null; + TerminalBackend.PrefixEnabled = false; + Desktop.InvokeOnWorkerThread(() => + { + term = new Applications.Terminal(); + AppearanceManager.SetupWindow(term); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Welcome to ShiftOS."); + Console.WriteLine(); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.WriteLine("Before we can bring you to your new system, we must perform some system tasks."); + Console.WriteLine(); + Console.WriteLine("Here's the installation outline."); + Console.WriteLine(); + Console.Write(" - "); + ConsoleEx.Bold = true; + Console.Write("Storage preparation"); + ConsoleEx.Bold = false; + Console.Write(" First, we have to prepare your computer's storage device for ShiftOS. This \r\nincludes formatting your drive with the ShiftFS file \r\nsystem, creating system directories, and generating system files."); + Console.WriteLine(); + Console.Write(" - "); + ConsoleEx.Bold = true; + Console.Write("User configuration"); + ConsoleEx.Bold = false; + Console.Write(" Next it's up to you to set up a system hostname, create a user account, and personalize it."); + Console.WriteLine(); + Console.Write(" - "); + ConsoleEx.Bold = true; + Console.Write("System tutorial"); + ConsoleEx.Bold = false; + Console.WriteLine("Finally, we'll teach you how to use ShiftOS."); + + Console.WriteLine(); + + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("Let's get started!"); + }); + int position = 0; + + Thread.Sleep(5000); + + ConsoleEx.Bold = true; + Console.WriteLine("System preparation"); + + + Console.WriteLine(); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.WriteLine(@"We'll now begin formatting your drive. Please be patient."); + Console.WriteLine(); + var dinf = new DriveInfo("C:\\"); + decimal bytesFree = ((dinf.AvailableFreeSpace / 1024) / 1024) / 1024; + decimal totalBytes = ((dinf.TotalSize / 1024) / 1024) / 1024; + string type = dinf.DriveType.ToString(); + string name = dinf.Name; + ConsoleEx.Bold = true; + Console.Write("Drive name: "); + ConsoleEx.Bold = false; + Console.WriteLine(name); + ConsoleEx.Bold = true; + Console.Write("Drive type: "); + ConsoleEx.Bold = false; + Console.WriteLine(type); + ConsoleEx.Bold = true; + Console.Write("Total space: "); + ConsoleEx.Bold = false; + Console.WriteLine(totalBytes.ToString() + " GB"); + ConsoleEx.Bold = true; + Console.Write("Free space: "); + Console.WriteLine(bytesFree.ToString() + " GB"); + Console.WriteLine(); + + + ConsoleEx.Bold = false; + ConsoleEx.BackgroundColor = ConsoleColor.Black; + Console.Write("Formatting: ["); + int formatProgress = 0; + while (formatProgress <= 100) + { + if (formatProgress % 3 == 0) + { + ConsoleEx.BackgroundColor = ConsoleColor.White; + Console.Write(" "); + ConsoleEx.BackgroundColor = ConsoleColor.Black; + } + Engine.AudioManager.PlayStream(Properties.Resources.typesound); + formatProgress++; + Thread.Sleep(175); + } + Console.WriteLine("] ..done."); + Thread.Sleep(1000); + ConsoleEx.Bold = true; + Console.WriteLine("Creating directories..."); + ConsoleEx.Bold = false; + foreach (var dir in Paths.GetAllWithoutKey()) + { + if (!dir.Contains(".") && dir.StartsWith("0:/")) + { + Console.WriteLine("Creating: " + dir); + Thread.Sleep(125); + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + } + } + Console.WriteLine(); + Console.WriteLine("Next, let's get user information."); + Console.WriteLine(); + Console.WriteLine("Please enter a system hostname."); + string allowed_chars = "abcdefghijklmnopqrstuvwxyz1234567890_"; + bool userExists = false; + Applications.Terminal.TextSent += (text) => + { + if(position == 0) + { + if(text.Length < 5) + { + Console.WriteLine("Your hostname must be at least 5 characters long."); + return; + } + + if(!isValid(text, allowed_chars)) + { + Console.WriteLine("Your hostname contains illegal characters. You can only use these characters: " + allowed_chars); + return; + } + SaveSystem.CurrentSave.SystemName = text; + position = 1; + } + else if(position == 1) + { + if (text.Length < 5) + { + Console.WriteLine("Your username must be at least 5 characters long."); + return; + } + if (!isValid(text, allowed_chars)) + { + Console.WriteLine("Your username contains illegal characters. You can only use these characters: " + allowed_chars); + return; + } + SaveSystem.CurrentSave.Username = text; + position = 2; + } + else if(position == 3) + { + if (!userExists) + { + if (text.Length < 5) + { + Console.WriteLine("Your password must be at least 5 characters long."); + return; + } + SaveSystem.CurrentSave.Password = text; + position = 4; + } + else + { + ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new + { + username = SaveSystem.CurrentSave.Username, + password = text + })); + } + } + }; + + TerminalBackend.InStory = false; + + while (position == 0) + Thread.Sleep(10); + Console.WriteLine("Connecting to the multi-user domain as " + SaveSystem.CurrentSave.SystemName + "..."); + Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02); + Console.WriteLine("Connection successful, system spinning up..."); + Thread.Sleep(200); + Console.WriteLine("No users associated with this system. Please enter a username."); + Console.WriteLine(" - If the username is registered as a digital being, you will be prompted for your password. Else, you will be prompted to create a new account."); + while(position == 1) + { + Thread.Sleep(10); + } + int incorrectChances = 2; + Console.WriteLine("Checking sentience records..."); + ServerManager.MessageReceived += (msg) => + { + if (position == 2) + { + if (msg.Name == "mud_found") + { + Console.WriteLine("Your username has been taken by another sentient being within the digital society."); + Console.WriteLine("If you are that sentience, you have two chances to type the correct password."); + userExists = true; + } + else if (msg.Name == "mud_notfound") + { + Console.WriteLine("Please enter a password for this new user."); + userExists = false; + } + position = 3; + } + else if (position == 3) + { + if(userExists == true) + { + if(msg.Name == "mud_savefile") + { + Console.WriteLine("Your sentience profile has been assigned to your system successfully. We will bring you to your system shortly."); + SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + position = 4; + } + else if(msg.Name == "mud_login_denied") + { + if (incorrectChances > 0) + { + incorrectChances--; + Console.WriteLine("Access denied. Chances: " + incorrectChances); + } + else + { + Console.WriteLine("Access denied."); + position = 2; + } + } + } + } + }; + ServerManager.SendMessage("mud_checkuserexists", JsonConvert.SerializeObject(new { username = SaveSystem.CurrentSave.Username })); + while(position == 2) + { + Thread.Sleep(10); + } + while (position == 3) + { + Thread.Sleep(10); + } + Console.WriteLine("Sentience linkup successful."); + Console.WriteLine("We will bring you to your system in 5 seconds."); + Thread.Sleep(5000); + Desktop.InvokeOnWorkerThread(() => + { + var lst = new List
(); + foreach (Form frm in Application.OpenForms) + lst.Add(frm); + lst.ForEach((frm) => + { + if (!(frm is WinformsDesktop)) + frm.Close(); + }); + TerminalBackend.PrefixEnabled = true; + + AppearanceManager.SetupWindow(new Applications.Terminal()); + }); + } + private static bool isValid(string text, string chars) + { + foreach(var c in text) + { + if (!chars.Contains(c)) + return false; + } + return true; + } + } +} diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 348360f..36c9338 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -64,12 +64,12 @@ namespace ShiftOS.WinForms { AppearanceManager.SetupWindow(new Applications.Terminal()); }; - AppearanceManager.Initiate(new WinformsWindowManager()); - OutOfBoxExperience.Init(new Oobe()); Infobox.Init(new Dialog()); FileSkimmerBackend.Init(new WinformsFSFrontend()); var desk = new WinformsDesktop(); Desktop.Init(desk); + OutOfBoxExperience.Init(new Oobe()); + AppearanceManager.Initiate(new WinformsWindowManager()); Application.Run(desk); } } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index c18f456..c70f849 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -98,13 +98,6 @@ Category: "Enhancements", Description: "Wanna start all over with a new equation? With this CE (Clear Everything) button, you get rid of not only the numbers in the number field, but also the equation!" }, - { - Name: "MUD Fundamentals", - Cost: 50, - Description: "Some basic commands for the terminal that'll help you out in the multi-user domain.", - Category: "Kernel & System", - Dependencies: null - }, { Name: "AL Notifications", Cost: 150, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index a223f47..b9e6910 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -286,6 +286,7 @@ Oobe.cs + True True diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 9ff3111..998c60d 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -120,7 +120,7 @@ namespace ShiftOS.Engine //This haults the client until the connection is successful. while (ServerManager.thisGuid == new Guid()) { - + Thread.Sleep(10); } Console.WriteLine("GUID received - bootstrapping complete."); FinishBootstrap(); @@ -133,7 +133,7 @@ namespace ShiftOS.Engine ServerManager.StartLANServer(); while (ServerManager.thisGuid == new Guid()) { - + Thread.Sleep(10); } Console.WriteLine("GUID received - bootstrapping complete."); FinishBootstrap(); @@ -172,7 +172,7 @@ namespace ShiftOS.Engine while (CurrentSave == null) { - + Thread.Sleep(10); } Localization.SetupTHETRUEDefaultLocals(); @@ -181,7 +181,7 @@ namespace ShiftOS.Engine while (CurrentSave.StoryPosition < 1) { - + Thread.Sleep(10); } Thread.Sleep(75); diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index ecd04f4..8c726ed 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -68,7 +68,7 @@ namespace ShiftOS.Engine } } } - catch { } + catch (Exception ex) { throw ex; } } } #if DEBUG -- cgit v1.2.3 From e833a9bf2751f16d8614af9aa20f5b9bec3d81a8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 Apr 2017 14:53:10 -0400 Subject: FUCKTONS OF SHIFTORIUM WORK --- ShiftOS.WinForms/Applications/FormatEditor.cs | 3 +- ShiftOS.WinForms/Applications/Shiftnet.Designer.cs | 30 +- ShiftOS.WinForms/Applications/Shiftnet.cs | 301 +++++++-------------- .../Applications/ShiftoriumFrontend.cs | 2 +- ShiftOS.WinForms/Program.cs | 33 ++- ShiftOS.WinForms/Resources/Shiftorium.txt | 7 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 18 ++ .../ShiftnetSites/AppscapeMain.Designer.cs | 113 ++++++++ ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 208 ++++++++++++++ ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx | 120 ++++++++ .../ShiftnetSites/MainHomepage.Designer.cs | 153 +++++++++++ ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs | 89 ++++++ ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx | 128 +++++++++ ShiftOS.WinForms/WindowBorder.cs | 15 +- ShiftOS_TheReturn/Command.cs | 2 +- ShiftOS_TheReturn/Commands.cs | 2 +- ShiftOS_TheReturn/SaveSystem.cs | 2 +- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/ShiftnetSite.cs | 46 ++++ ShiftOS_TheReturn/Shiftorium.cs | 6 +- 20 files changed, 1040 insertions(+), 239 deletions(-) create mode 100644 ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx create mode 100644 ShiftOS.WinForms/ShiftnetSites/MainHomepage.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx create mode 100644 ShiftOS_TheReturn/ShiftnetSite.cs (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Applications/FormatEditor.cs b/ShiftOS.WinForms/Applications/FormatEditor.cs index 7491e36..db52d85 100644 --- a/ShiftOS.WinForms/Applications/FormatEditor.cs +++ b/ShiftOS.WinForms/Applications/FormatEditor.cs @@ -36,11 +36,10 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] [Launcher("Format Editor", true, "al_format_editor", "Customization")] - [RequiresUpgrade("format_editor")] + [AppscapeEntry("Format Editor", "Edit the syntax of your Terminal to be however you like.", 750, "file_skimmer", "Customization")] [WinOpen("formateditor")] [DefaultTitle("Format Editor")] [DefaultIcon("iconFormatEditor")] - public partial class FormatEditor : UserControl, IShiftOSWindow { IList parts = new List(); diff --git a/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs index eca44ae..a7fe700 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs @@ -57,13 +57,12 @@ namespace ShiftOS.WinForms.Applications this.btnforward = new System.Windows.Forms.Button(); this.txturl = new System.Windows.Forms.TextBox(); this.btngo = new System.Windows.Forms.Button(); - this.wbcanvas = new System.Windows.Forms.WebBrowser(); + this.pnlcanvas = new System.Windows.Forms.Panel(); this.flcontrols.SuspendLayout(); this.SuspendLayout(); // // flcontrols // - this.flcontrols.AutoSize = true; this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.flcontrols.Controls.Add(this.btnback); this.flcontrols.Controls.Add(this.btnforward); @@ -123,42 +122,35 @@ namespace ShiftOS.WinForms.Applications this.btngo.UseVisualStyleBackColor = true; this.btngo.Click += new System.EventHandler(this.btngo_Click); // - // wbcanvas + // pnlcanvas // - this.wbcanvas.Dock = System.Windows.Forms.DockStyle.Fill; - this.wbcanvas.IsWebBrowserContextMenuEnabled = false; - this.wbcanvas.Location = new System.Drawing.Point(0, 29); - this.wbcanvas.MinimumSize = new System.Drawing.Size(20, 20); - this.wbcanvas.Name = "wbcanvas"; - this.wbcanvas.ScriptErrorsSuppressed = true; - this.wbcanvas.Size = new System.Drawing.Size(805, 510); - this.wbcanvas.TabIndex = 1; - this.wbcanvas.WebBrowserShortcutsEnabled = false; - this.wbcanvas.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbcanvas_Navigated); - this.wbcanvas.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.wbcanvas_Navigating); + this.pnlcanvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlcanvas.Location = new System.Drawing.Point(0, 29); + this.pnlcanvas.Name = "pnlcanvas"; + this.pnlcanvas.Size = new System.Drawing.Size(805, 510); + this.pnlcanvas.TabIndex = 1; // // Shiftnet // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.wbcanvas); + this.Controls.Add(this.pnlcanvas); this.Controls.Add(this.flcontrols); this.Name = "Shiftnet"; this.Size = new System.Drawing.Size(805, 539); this.flcontrols.ResumeLayout(false); this.flcontrols.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion - - private System.Windows.Forms.FlowLayoutPanel flcontrols; private System.Windows.Forms.Button btnback; private System.Windows.Forms.Button btnforward; private System.Windows.Forms.TextBox txturl; private System.Windows.Forms.Button btngo; - private System.Windows.Forms.WebBrowser wbcanvas; + private System.Windows.Forms.Panel pnlcanvas; + private System.Windows.Forms.FlowLayoutPanel flcontrols; } } diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 54a8aa6..7f5d3c1 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -35,6 +35,8 @@ using ShiftOS.Engine; using Newtonsoft.Json; using static ShiftOS.Engine.SkinEngine; using ShiftOS.WinForms.Tools; +using System.IO; +using System.Reflection; namespace ShiftOS.WinForms.Applications { @@ -50,216 +52,34 @@ namespace ShiftOS.WinForms.Applications [WinOpen("shiftnet")] [RequiresUpgrade("victortran_shiftnet")] [DefaultIcon("iconShiftnet")] - public partial class Shiftnet : UserControl, IShiftOSWindow + public partial class Shiftnet : UserControl, IShiftOSWindow, IShiftnetClient { public Shiftnet() { InitializeComponent(); - ServerManager.MessageReceived += (msg) => - { - try - { - if (msg.Name == "shiftnet_file") - { - if (Objects.ShiftFS.Utils.FileExists("0:/md.txt")) - { - this.Invoke(new Action(() => - { - wbcanvas.DocumentText = ConstructHtml(Objects.ShiftFS.Utils.ReadAllText("0:/md.txt")); - })); - } - else - { - this.Invoke(new Action(() => - { - wbcanvas.DocumentText = ConstructHtml(msg.Contents); - })); - } - } - } - catch - { - - } - }; - } - - public string ConstructHtml(string markdown) - { - var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC); - var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC); - string html = $@" - - - - - - -"; - - string body = CommonMark.CommonMarkConverter.Convert(markdown); - for (int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed()) - { - //halt the page load until 'download' finishes. - } - html = html.Replace("", body); - return html; } public string CurrentUrl { get; set; } - private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e) - { - string Url = e.Url.ToString().Replace("http://", ""); - if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:")) - { - e.Cancel = true; - Future.Clear(); - if (Url.StartsWith("runsyscmd/")) - { - ProcessShiftnetCmd(Url.Replace("runsyscmd/", "")); - } - - ShiftnetNavigate(Url.ToString()); - } - } - - public void ProcessShiftnetCmd(string cmd) - { - var args = cmd.Split('/'); - switch (args[0]) - { - case "setsnsub": - for (int i = 0; i < DownloadManager.GetAllSubscriptions().Length; i++) - { - if (DownloadManager.GetAllSubscriptions()[i].Name == args[1]) - { - var sub = DownloadManager.GetAllSubscriptions()[i]; - Infobox.PromptYesNo("Shiftnet", $"Are you sure you want to switch your system's Shiftnet subscription to {sub.Name} by {sub.Company}?{Environment.NewLine}{Environment.NewLine}Cost per month: {sub.CostPerMonth} CP{Environment.NewLine}Download speed: {sub.DownloadSpeed} bytes per second", new Action((answer) => - { - if (answer == true) - { - if (SaveSystem.CurrentSave.Codepoints >= sub.CostPerMonth) - { - //Initial fee gets deducted. - SaveSystem.CurrentSave.Codepoints -= sub.CostPerMonth; - //Then we set the subscription. - SaveSystem.CurrentSave.ShiftnetSubscription = i; - //Then we say that we have paid this month. - SaveSystem.CurrentSave.LastMonthPaid = DateTime.Now.Month; - //Then we send our save to the MUD. - SaveSystem.SaveGame(); - - } - else - { - //User can't afford this subscription. - Infobox.Show("Shiftnet - Not enough Codepoints", $"You cannot afford to pay for this subscription at this time. You need {sub.CostPerMonth - SaveSystem.CurrentSave.Codepoints} more Codepoints."); - } - } - })); - } - } - return; - } - } - public Stack History = new Stack(); public Stack Future = new Stack(); - public void ShiftnetNavigate(string Url, bool pushHistory = true) - { - if (Url.EndsWith(".rnp") || !Url.Contains(".")) - { - if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory) - History.Push(CurrentUrl); - CurrentUrl = Url; - ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new - { - url = Url - })); - txturl.Text = Url; - - } - else - { - ServerMessageReceived smr = null; - smr = (msg) => - { - if (msg.Name == "download_meta") - { - var bytes = JsonConvert.DeserializeObject(msg.Contents); - string destPath = null; - string ext = Url.Split('.')[Url.Split('.').Length - 1]; - this.Invoke(new Action(() => - { - FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action((file) => - { - destPath = file; - })); - })); - while (string.IsNullOrEmpty(destPath)) - { - - } - var d = new Download - { - ShiftnetUrl = Url, - Destination = destPath, - Bytes = bytes, - Progress = 0, - }; - DownloadManager.StartDownload(d); - this.Invoke(new Action(() => - { - AppearanceManager.SetupWindow(new Downloader()); - })); - ServerManager.MessageReceived -= smr; - } - }; - ServerManager.MessageReceived += smr; - ServerManager.SendMessage("download_start", Url); - } - } + public IShiftnetSite CurrentPage = null; public void OnLoad() { - ShiftnetNavigate("shiftnet/main"); + NavigateToUrl("shiftnet/main"); } public void OnSkinLoad() { - ShiftnetNavigate(CurrentUrl); + CurrentPage?.OnSkinLoad(); + btnback.Location = new Point(2, 2); + btnforward.Location = new Point(btnback.Left + btnback.Width + 2, 2); + txturl.Location = new Point(btnforward.Left + btnforward.Width + 2, 2); + txturl.Width = flcontrols.Width - btnback.Width - 2 - btnforward.Width - 2 - (btngo.Width*2) - 2; + btngo.Location = new Point(flcontrols.Width - btngo.Width - 2, 2); } public bool OnUnload() @@ -269,6 +89,7 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + CurrentPage?.OnUpgrade(); } private void btnback_Click(object sender, EventArgs e) @@ -279,7 +100,7 @@ namespace ShiftOS.WinForms.Applications if (!string.IsNullOrEmpty(hist)) { Future.Push(hist); - ShiftnetNavigate(hist, false); + NavigateToUrl(hist); } } catch @@ -295,7 +116,8 @@ namespace ShiftOS.WinForms.Applications string fut = Future.Pop(); if (!string.IsNullOrEmpty(fut)) { - ShiftnetNavigate(fut); + History.Push(CurrentUrl); + NavigateToUrl(fut); } } catch @@ -309,8 +131,8 @@ namespace ShiftOS.WinForms.Applications if (!string.IsNullOrWhiteSpace(txturl.Text)) { Future.Clear(); - - ShiftnetNavigate(txturl.Text); + History.Push(CurrentUrl); + NavigateToUrl(txturl.Text); } } @@ -323,8 +145,95 @@ namespace ShiftOS.WinForms.Applications } } - private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e) + public void NavigateToUrl(string url) + { + txturl.Text = url; + foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach (var type in asm.GetTypes()) + { + if (type.GetInterfaces().Contains(typeof(IShiftnetSite))) + { + if (type.BaseType == typeof(UserControl)) + { + var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; + if (attribute != null) + { + if (attribute.Url == url) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + var obj = (IShiftnetSite)Activator.CreateInstance(type, null); + obj.GoToUrl += (u) => + { + History.Push(u); + NavigateToUrl(u); + }; + obj.GoBack += () => + { + string u = History.Pop(); + Future.Push(u); + NavigateToUrl(u); + }; + CurrentPage = obj; + this.pnlcanvas.Controls.Clear(); + this.pnlcanvas.Controls.Add((UserControl)obj); + ((UserControl)obj).Show(); + ((UserControl)obj).Dock = DockStyle.Fill; + obj.OnUpgrade(); + obj.OnSkinLoad(); + obj.Setup(); + return; + } + } + } + } + } + } + } + catch (Exception ex) + { + pnlcanvas.Controls.Clear(); + var tlbl = new Label(); + tlbl.Text = "Server error in \"" + url + "\" application."; + tlbl.Tag = "header1"; + tlbl.AutoSize = true; + tlbl.Location = new Point(10, 10); + tlbl.Dock = DockStyle.Top; + pnlcanvas.Controls.Add(tlbl); + tlbl.Show(); + + var crash = new Label(); + crash.Dock = DockStyle.Fill; + crash.AutoSize = false; + crash.Text = ex.ToString(); + pnlcanvas.Controls.Add(crash); + crash.Show(); + crash.BringToFront(); + ControlManager.SetupControls(pnlcanvas); + return; + } + } + } + pnlcanvas.Controls.Clear(); + var lbl = new Label(); + lbl.Text = "Page not found!"; + lbl.Tag = "header1"; + lbl.AutoSize = true; + lbl.Location = new Point(10, 10); + pnlcanvas.Controls.Add(lbl); + lbl.Show(); + + } + + public void RefreshSite() { + NavigateToUrl(CurrentUrl); } } } diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index 0762897..66b0448 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -185,7 +185,7 @@ namespace ShiftOS.WinForms.Applications { long cpCost = 0; backend.Silent = true; - Dictionary UpgradesToBuy = new Dictionary(); + Dictionary UpgradesToBuy = new Dictionary(); foreach (var itm in lbupgrades.SelectedItems) { cpCost += upgrades[itm.ToString()].Cost; diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 36c9338..3343cb0 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -34,6 +34,7 @@ using static ShiftOS.Objects.ShiftFS.Utils; using ShiftOS.WinForms.Applications; using ShiftOS.WinForms.Tools; using System.Reflection; +using System.IO; namespace ShiftOS.WinForms { @@ -98,7 +99,37 @@ namespace ShiftOS.WinForms { public List GetDefaults() { - return JsonConvert.DeserializeObject>(Properties.Resources.Shiftorium); + var defaultList = JsonConvert.DeserializeObject>(Properties.Resources.Shiftorium); + + foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach(var type in asm.GetTypes()) + { + var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute; + if(attrib != null) + { + var upgrade = new ShiftoriumUpgrade + { + Id = attrib.Name.ToLower().Replace(" ", "_"), + Name = attrib.Name, + Description = attrib.Description, + Cost = attrib.Cost, + Category = attrib.Category, + Dependencies = (string.IsNullOrWhiteSpace(attrib.DependencyString)) ? "appscape_handled_nodisplay" : "appscape_handled_nodisplay;" + attrib.DependencyString + }; + defaultList.Add(upgrade); + } + } + } + catch { } + } + } + return defaultList; } } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index ca555d4..e68277c 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -368,13 +368,6 @@ Category: "GUI", Dependencies:"desktop;wm_unlimited_windows" }, - { - Name: "Format Editor", - Cost: 6000, - Description: "Allows you to change the format of commands.", - Category: "Applications", - Dependencies: "shifter;name_changer" - }, { Name: "Format Editor Optional Text", Cost: 150, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index bd8fd65..3edfd38 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -317,6 +317,18 @@ Resources.resx + + UserControl + + + AppscapeMain.cs + + + UserControl + + + MainHomepage.cs + @@ -463,6 +475,12 @@ Designer Resources.Designer.cs + + AppscapeMain.cs + + + MainHomepage.cs + WindowBorder.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs new file mode 100644 index 0000000..6698e5a --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs @@ -0,0 +1,113 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class AppscapeMain + { + /// + /// 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 Component 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.flcategories = new System.Windows.Forms.FlowLayoutPanel(); + this.pnlappslist = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.lbtitle = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(17, 17); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(55, 13); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "Appscape"; + // + // flcategories + // + this.flcategories.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.flcategories.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flcategories.Location = new System.Drawing.Point(20, 120); + this.flcategories.Margin = new System.Windows.Forms.Padding(0); + this.flcategories.Name = "flcategories"; + this.flcategories.Size = new System.Drawing.Size(187, 310); + this.flcategories.TabIndex = 1; + // + // pnlappslist + // + this.pnlappslist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlappslist.Location = new System.Drawing.Point(221, 120); + this.pnlappslist.Name = "pnlappslist"; + this.pnlappslist.Size = new System.Drawing.Size(459, 310); + this.pnlappslist.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(20, 76); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(57, 13); + this.label2.TabIndex = 3; + this.label2.Tag = "header2"; + this.label2.Text = "Categories"; + // + // lbtitle + // + this.lbtitle.AutoSize = true; + this.lbtitle.Location = new System.Drawing.Point(218, 76); + this.lbtitle.Name = "lbtitle"; + this.lbtitle.Size = new System.Drawing.Size(57, 13); + this.lbtitle.TabIndex = 4; + this.lbtitle.Tag = "header2"; + this.lbtitle.Text = "Categories"; + // + // AppscapeMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbtitle); + this.Controls.Add(this.label2); + this.Controls.Add(this.pnlappslist); + this.Controls.Add(this.flcategories); + this.Controls.Add(this.label1); + this.Name = "AppscapeMain"; + this.Size = new System.Drawing.Size(709, 457); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.FlowLayoutPanel flcategories; + private System.Windows.Forms.Panel pnlappslist; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label lbtitle; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs new file mode 100644 index 0000000..88db07b --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -0,0 +1,208 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms.ShiftnetSites +{ + [ShiftnetSite("shiftnet/appscape", "Appscape", "Bringing ShiftOS to life")] + [ShiftnetFundamental] + public partial class AppscapeMain : UserControl, IShiftnetSite + { + public AppscapeMain() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + public string Category = "All"; + + public string[] GetCategories() + { + var upgrades = Shiftorium.GetDefaults().Where(x => x.Dependencies.Contains("appscape_")); + List cats = new List(); + cats.Add("All"); + try + { + if (upgrades.Count() > 0) + foreach (var upg in upgrades) + { + if (!cats.Contains(upg.Category)) + cats.Add(upg.Category); + } + } + catch { } + return cats.ToArray(); + } + + public ShiftoriumUpgrade CurrentUpgrade = null; + + public void SetupCategory(string cat) + { + pnlappslist.Controls.Clear(); + pnlappslist.Show(); + pnlappslist.BringToFront(); + Category = cat; + var upgrades = GetAllInCategory(); + lbtitle.Text = cat; + if(upgrades.Length == 0) + { + var err = new Label(); + err.AutoSize = true; + err.Text = "There are no apps in this list! Come back later for more."; + pnlappslist.Controls.Add(err); + err.Show(); + } + else + { + var fl = new FlowLayoutPanel(); + fl.Dock = DockStyle.Fill; + pnlappslist.Controls.Add(fl); + fl.Show(); + foreach(var upg in upgrades) + { + var pnl = new Panel(); + pnl.Height = 250; + pnl.Width = 200; + fl.Controls.Add(pnl); + pnl.Show(); + var upgTitle = new Label(); + upgTitle.Text = upg.Name; + upgTitle.Dock = DockStyle.Top; + upgTitle.AutoSize = true; + upgTitle.MaximumSize = new Size(pnl.Width, 0); + upgTitle.Tag = "header3"; + pnl.Controls.Add(upgTitle); + upgTitle.Show(); + + var cp_display = new Panel(); + cp_display.Height = 30; + cp_display.Dock = DockStyle.Bottom; + pnl.Controls.Add(cp_display); + cp_display.Show(); + + var cp_value = new Label(); + if (Shiftorium.UpgradeInstalled(upg.ID)) + { + cp_value.Text = "Out of stock."; + } + else + { + cp_value.Text = $"{upg.Cost} CP"; + } + cp_value.AutoSize = true; + cp_value.Top = (cp_display.Height - cp_value.Height) / 2; + cp_value.Left = 5; + cp_display.Controls.Add(cp_value); + cp_value.Show(); + + + if(cp_value.Text != "Out of stock.") + { + var more_info = new Button(); + more_info.Text = "More info"; + more_info.Click += (o, a) => + { + ViewMoreInfo(upg); + }; + more_info.AutoSize = false; + more_info.AutoSizeMode = AutoSizeMode.GrowAndShrink; + more_info.Top = (cp_display.Height - more_info.Height) / 2; + more_info.Left = cp_display.Width - more_info.Width - 5; + cp_display.Controls.Add(more_info); + more_info.Show(); + } + + var desc = new Label(); + desc.Text = upg.Description; + desc.AutoSize = false; + desc.Dock = DockStyle.Fill; + pnl.Controls.Add(desc); + desc.Show(); + desc.BringToFront(); + + + ControlManager.SetupControls(pnl); + } + } + } + + public void ViewMoreInfo(ShiftoriumUpgrade upg) + { + + } + + public ShiftoriumUpgrade[] GetAllInCategory() + { + var upgrades = Shiftorium.GetDefaults().Where(x => (x.Dependencies == null) ? false : x.Dependencies.Contains("appscape_")); + if (upgrades.Count() == 0) + return new ShiftoriumUpgrade[0]; + + if (Category == "All") + return upgrades.ToArray(); + else + return upgrades.Where(x => x.Category == Category).ToArray(); + } + + public void Setup() + { + flcategories.Controls.Clear(); + foreach(var cat in this.GetCategories()) + { + var btn = new Button(); + btn.Text = cat; + btn.Click += (o, a) => + { + SetupCategory(cat); + }; + ControlManager.SetupControl(btn); + btn.Width = flcategories.Width - 2; + flcategories.Controls.Add(btn); + btn.Show(); + } + SetupCategory("All"); + } + } +} + +namespace ShiftOS.WinForms +{ + /// + /// Special version of for specifying Appscape applications as Shiftorium upgrades. + /// + public class AppscapeEntryAttribute : RequiresUpgradeAttribute + { + public AppscapeEntryAttribute(string name, string description, long cost, string dependencies = "", string category = "Misc") : base((string.IsNullOrWhiteSpace(dependencies)) ? name.ToLower().Replace(" ","_") : name.ToLower().Replace(" ", "_") + dependencies) + { + Name = name; + Description = description; + Category = category; + Cost = cost; + DependencyString = dependencies; + } + + public string Name { get; private set; } + public string Description { get; private set; } + public string Category { get; private set; } + public long Cost { get; private set; } + public string DependencyString { get; private set; } + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.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.WinForms/ShiftnetSites/MainHomepage.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.Designer.cs new file mode 100644 index 0000000..bebc8bd --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.Designer.cs @@ -0,0 +1,153 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class MainHomepage + { + /// + /// 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 Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainHomepage)); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.lbspecheader = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.panel2 = new System.Windows.Forms.Panel(); + this.label4 = new System.Windows.Forms.Label(); + this.flfundamentals = new System.Windows.Forms.FlowLayoutPanel(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(710, 65); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "Welcome to the Shiftnet!"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 65); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(710, 22); + this.label2.TabIndex = 1; + this.label2.Text = "The Shiftnet is a vast network of services, websites, software and so much more f" + + "or ShiftOS. Have a look around!"; + this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.lbspecheader); + this.panel1.Location = new System.Drawing.Point(27, 140); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(389, 281); + this.panel1.TabIndex = 2; + // + // lbspecheader + // + this.lbspecheader.Dock = System.Windows.Forms.DockStyle.Top; + this.lbspecheader.Location = new System.Drawing.Point(0, 0); + this.lbspecheader.Name = "lbspecheader"; + this.lbspecheader.Size = new System.Drawing.Size(389, 42); + this.lbspecheader.TabIndex = 0; + this.lbspecheader.Tag = "header3"; + this.lbspecheader.Text = "How to use the Shiftnet"; + // + // label3 + // + this.label3.Dock = System.Windows.Forms.DockStyle.Fill; + this.label3.Location = new System.Drawing.Point(0, 42); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(389, 239); + this.label3.TabIndex = 1; + this.label3.Text = resources.GetString("label3.Text"); + // + // panel2 + // + this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel2.Controls.Add(this.flfundamentals); + this.panel2.Controls.Add(this.label4); + this.panel2.Location = new System.Drawing.Point(439, 140); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(247, 281); + this.panel2.TabIndex = 3; + // + // label4 + // + this.label4.Dock = System.Windows.Forms.DockStyle.Top; + this.label4.Location = new System.Drawing.Point(0, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(247, 42); + this.label4.TabIndex = 1; + this.label4.Tag = "header3"; + this.label4.Text = "The Fundamentals"; + // + // flfundamentals + // + this.flfundamentals.Dock = System.Windows.Forms.DockStyle.Fill; + this.flfundamentals.Location = new System.Drawing.Point(0, 42); + this.flfundamentals.Name = "flfundamentals"; + this.flfundamentals.Size = new System.Drawing.Size(247, 239); + this.flfundamentals.TabIndex = 2; + // + // MainHomepage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.panel2); + this.Controls.Add(this.panel1); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "MainHomepage"; + this.Size = new System.Drawing.Size(710, 437); + this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label lbspecheader; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.FlowLayoutPanel flfundamentals; + private System.Windows.Forms.Label label4; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs new file mode 100644 index 0000000..cb39cd6 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; +using System.Reflection; +using System.IO; + +namespace ShiftOS.WinForms.ShiftnetSites +{ + [ShiftnetSite("shiftnet/main", "Main Site", "The main Shiftnet hub.")] + public partial class MainHomepage : UserControl, IShiftnetSite + { + public MainHomepage() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + + } + + public void Setup() + { + //Get the Fundamentals List + flfundamentals.Controls.Clear(); + foreach (var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if (exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach (var type in asm.GetTypes()) + { + if (type.GetInterfaces().Contains(typeof(IShiftnetSite))) + { + if (type.BaseType == typeof(UserControl)) + { + var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; + if (attribute != null) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + if (type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetFundamentalAttribute) != null) + { + var dash = new Label(); + dash.Text = " - "; + dash.AutoSize = true; + flfundamentals.Controls.Add(dash); + dash.Show(); + var link = new LinkLabel(); + link.Text = attribute.Name; + link.Click += (o, a) => + { + GoToUrl?.Invoke(attribute.Url); + }; + flfundamentals.Controls.Add(link); + flfundamentals.SetFlowBreak(link, true); + link.Show(); + } + } + } + } + } + } + } + catch { } + } + } + + } + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx new file mode 100644 index 0000000..e9a0c8f --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + The Shiftnet works a lot like a regular web browser. To browse to a website, you can either click links or you can type a Shiftnet URL into your Address Bar at the top and click "Go". + +An example of a Shiftnet URL would be "shiftnet/main", which you are at right now. This is the main Shiftnet hub. You can also browse to files and folder listings, if you have access to them. + + +There are lots of Shiftnet websites for you to visit - so go ahead and explore, but first, check out some of the fundamental sites and services to the right! + + \ No newline at end of file diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 64f2da4..2829a3e 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -134,18 +134,16 @@ namespace ShiftOS.WinForms } }; - this.Width = LoadedSkin.LeftBorderWidth + _parentWindow.Width + LoadedSkin.RightBorderWidth; - this.Height = LoadedSkin.TitlebarHeight + _parentWindow.Height + LoadedSkin.BottomBorderWidth; - - SetupControls(this); - + + this.pnlcontents.Controls.Add(this._parentWindow); this._parentWindow.Dock = DockStyle.Fill; this._parentWindow.Show(); + SetupControls(this); + this.Width = LoadedSkin.LeftBorderWidth + this.Width + LoadedSkin.RightBorderWidth; + this.Height = LoadedSkin.TitlebarHeight + this.Height + LoadedSkin.BottomBorderWidth; ControlManager.SetupControls(this._parentWindow); - ParentWindow.OnSkinLoad(); - ParentWindow.OnUpgrade(); Shiftorium.Installed += () => { Setup(); @@ -221,6 +219,9 @@ namespace ShiftOS.WinForms this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; ParentWindow.OnLoad(); + ParentWindow.OnSkinLoad(); + ParentWindow.OnUpgrade(); + } /// diff --git a/ShiftOS_TheReturn/Command.cs b/ShiftOS_TheReturn/Command.cs index c6d58e1..09cf206 100644 --- a/ShiftOS_TheReturn/Command.cs +++ b/ShiftOS_TheReturn/Command.cs @@ -104,7 +104,7 @@ namespace ShiftOS.Engine /// /// Gets whether the dependent upgrade(s) are installed. /// - public bool Installed + public virtual bool Installed { get { diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 0257f11..ce94030 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -612,7 +612,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); cat = args["cat"].ToString(); } - Dictionary upgrades = new Dictionary(); + Dictionary upgrades = new Dictionary(); int maxLength = 5; IEnumerable upglist = Shiftorium.GetAvailable(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 998c60d..3e68a70 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -223,7 +223,7 @@ namespace ShiftOS.Engine public static event EmptyEventHandler GameReady; - public static void TransferCodepointsToVoid(int amount) + public static void TransferCodepointsToVoid(long amount) { CurrentSave.Codepoints -= amount; NotificationDaemon.AddNotification(NotificationType.CodepointsSent, amount); diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index b6ff903..f7b730f 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -124,6 +124,7 @@ + diff --git a/ShiftOS_TheReturn/ShiftnetSite.cs b/ShiftOS_TheReturn/ShiftnetSite.cs new file mode 100644 index 0000000..5460171 --- /dev/null +++ b/ShiftOS_TheReturn/ShiftnetSite.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public interface IShiftnetSite + { + void Setup(); + void OnSkinLoad(); + void OnUpgrade(); + + event Action GoToUrl; + event Action GoBack; + } + + /// + /// Marks a shiftnet site as a fundamental, and will make it display on the homepage. + /// + public class ShiftnetFundamentalAttribute : Attribute + { + + } + + public interface IShiftnetClient + { + void NavigateToUrl(string url); + void RefreshSite(); + } + + public class ShiftnetSiteAttribute : Attribute + { + public ShiftnetSiteAttribute(string url, string name, string description) + { + Url = url; + Name = name; + Description = description; + } + + public string Url { get; private set; } + public string Name { get; private set; } + public string Description { get; private set; } + } +} diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 43ea13a..c46aed0 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -85,7 +85,7 @@ namespace ShiftOS.Engine return GetDefaults().Where(x => x.Category == cat).FirstOrDefault(x => x.Installed == false) == null; } - public static bool Buy(string id, int cost) + public static bool Buy(string id, long cost) { if(SaveSystem.CurrentSave.Codepoints >= cost) { @@ -188,7 +188,7 @@ namespace ShiftOS.Engine } - public static int GetCPValue(string id) + public static long GetCPValue(string id) { foreach(var upg in GetDefaults()) { @@ -316,7 +316,7 @@ namespace ShiftOS.Engine { public string Name { get; set; } public string Description { get; set; } - public int Cost { get; set; } + public long Cost { get; set; } public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } public string Id { get; set; } public string Category { get; set; } -- cgit v1.2.3 From cdfba45faaa9202c69bdfe1a2f9e92140e0ecdae Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Apr 2017 17:50:50 -0400 Subject: unite stuffs --- ShiftOS.Unite/Properties/AssemblyInfo.cs | 36 ++++++++ ShiftOS.Unite/ShiftOS.Unite.csproj | 54 +++++++++++ ShiftOS.WinForms/Applications/Dialog.cs | 7 +- ShiftOS.WinForms/Oobe.cs | 115 ++++++++++++++++-------- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ ShiftOS.WinForms/UniteLoginDialog.Designer.cs | 123 ++++++++++++++++++++++++++ ShiftOS.WinForms/UniteLoginDialog.cs | 90 +++++++++++++++++++ ShiftOS.WinForms/UniteLoginDialog.resx | 120 +++++++++++++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 7 +- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 2 + ShiftOS_TheReturn/UniteClient.cs | 68 ++++++++++++++ ShiftOS_TheReturn/UniteTestCommands.cs | 64 ++++++++++++++ 12 files changed, 648 insertions(+), 47 deletions(-) create mode 100644 ShiftOS.Unite/Properties/AssemblyInfo.cs create mode 100644 ShiftOS.Unite/ShiftOS.Unite.csproj create mode 100644 ShiftOS.WinForms/UniteLoginDialog.Designer.cs create mode 100644 ShiftOS.WinForms/UniteLoginDialog.cs create mode 100644 ShiftOS.WinForms/UniteLoginDialog.resx create mode 100644 ShiftOS_TheReturn/UniteClient.cs create mode 100644 ShiftOS_TheReturn/UniteTestCommands.cs (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.Unite/Properties/AssemblyInfo.cs b/ShiftOS.Unite/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..837b88a --- /dev/null +++ b/ShiftOS.Unite/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ShiftOS.Unite")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ShiftOS.Unite")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e57ff1e6-3780-4510-b7ef-64731ec81bb8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ShiftOS.Unite/ShiftOS.Unite.csproj b/ShiftOS.Unite/ShiftOS.Unite.csproj new file mode 100644 index 0000000..ed03ccc --- /dev/null +++ b/ShiftOS.Unite/ShiftOS.Unite.csproj @@ -0,0 +1,54 @@ + + + + + Debug + AnyCPU + {E57FF1E6-3780-4510-B7EF-64731EC81BB8} + Library + Properties + ShiftOS.Unite + ShiftOS.Unite + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/Dialog.cs b/ShiftOS.WinForms/Applications/Dialog.cs index 6e358e6..2abc705 100644 --- a/ShiftOS.WinForms/Applications/Dialog.cs +++ b/ShiftOS.WinForms/Applications/Dialog.cs @@ -69,7 +69,7 @@ namespace ShiftOS.WinForms.Applications { } - internal void OpenInternal(string title, string msg) + internal void OpenInternal(string title, string msg, Action c) { Title = title; AppearanceManager.SetupDialog(this); @@ -80,7 +80,7 @@ namespace ShiftOS.WinForms.Applications btnok.Click += (o, a) => { AppearanceManager.Close(this); - OpenCallback?.Invoke(); + c?.Invoke(); }; } @@ -89,8 +89,7 @@ namespace ShiftOS.WinForms.Applications public void Open(string title, string msg, Action c = null) { - OpenCallback = c; - new Dialog().OpenInternal(title, msg); + new Dialog().OpenInternal(title, msg, c); } public void PromptTextInternal(string title, string message, Action callback, bool isPassword) diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 309495d..6339588 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -36,6 +36,7 @@ using Newtonsoft.Json; using ShiftOS.Engine; using ShiftOS.Objects; using ShiftOS.Objects.ShiftFS; +using ShiftOS.Unite; using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms @@ -219,55 +220,93 @@ You must join the digital society, rise up the ranks, and save us. t.Start(); } + public void PerformUniteLogin() + { + + } + public void PromptForLogin() { - ServerMessageReceived MessageReceived = null; - MessageReceived = (msg) => + Infobox.Show("Login", "Since the last time you've played ShiftOS, some changes have been made to the login system. You must now login using your website credentials.", () => { - if(msg.Name == "mud_savefile") + Infobox.PromptYesNo("Website account", "Do you have an account at http://getshiftos.ml?", (hasAccount) => { - SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - SaveSystem.SaveGame(); - Application.Restart(); - } - else if(msg.Name == "mud_notfound") - { - ServerManager.MessageReceived -= MessageReceived; - - PromptForLogin(); - } - }; - ServerManager.MessageReceived += MessageReceived; - Infobox.PromptYesNo("Login", "You are missing a digital society authentication link. Would you like to generate a new link with an existing account? Choosing \"No\" will restart the session in the out-of-box experience.", (result)=> + if(hasAccount == true) + { + var loginDialog = new UniteLoginDialog((success)=> + { + string token = success; + var uClient = new UniteClient("http://getshiftos.ml", token); + Infobox.Show("Welcome to ShiftOS.", $"Hello, {uClient.GetDisplayName()}! We've signed you into your account. We'll now try to link your ShiftOS account with your save file.", () => + { + ServerMessageReceived smr = null; + smr = (msg) => + { + ServerManager.MessageReceived -= smr; + if (msg.Name == "mud_savefile") + { + SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + SaveSystem.SaveGame(); + } + else + { + LinkSaveFile(token); + } + }; + ServerManager.MessageReceived += smr; + ServerManager.SendMessage("mud_token_login", token); + }); + }); + AppearanceManager.SetupDialog(loginDialog); + } + }); + }); + } + + public void LinkSaveFile(string token) + { + Infobox.PromptText("Enter username", "Please enter the username you used for your save file before these changes.", (cuname) => { - if (result == true) + Infobox.PromptText("Enter password", "Now, please enter the corresponding password.", (cpass) => { - Infobox.PromptText("Login", "Please enter your digital society username.", (uname) => + ServerMessageReceived nsmr = null; + nsmr = (nmsg) => { - Infobox.PromptText("Login", "Please enter your password.", (pword) => + ServerManager.MessageReceived -= nsmr; + if (nmsg.Name == "mud_savefile") { - ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new + var save = JsonConvert.DeserializeObject(nmsg.Contents); + save.UniteAuthToken = token; + Infobox.Show("That'll do it.", "Your save has been linked up! Next time you log into the ShiftOS site, your Codepoints should show on your profile. There's just a few more things we have to do.", () => { - username = uname, - password = pword - })); - }, true); - }); - } - else - { - //restart in OOBE - if (Objects.ShiftFS.Utils.FileExists(Paths.GetPath("user.dat"))) + SaveSystem.CurrentSave = save; + SaveSystem.SaveGame(); + }); + } + else + { + Infobox.Show("Uh oh.", "We couldn't find a save file with those values. Please try again", () => + { + LinkSaveFile(token); + }); + } + }; + ServerManager.MessageReceived += nsmr; + ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new { - Utils.Delete(Paths.GetPath("user.dat")); - } - string json = Utils.ExportMount(0); - System.IO.File.WriteAllText(Paths.SaveFile, json); - System.Diagnostics.Process.Start(Application.ExecutablePath); - Environment.Exit(0); - } + username = cuname, + password = cpass + })); + }, true); }); - + } + + public void ForceReboot() + { + string json = Utils.ExportMount(0); + System.IO.File.WriteAllText(Paths.SaveFile, json); + System.Diagnostics.Process.Start(Application.ExecutablePath); + Environment.Exit(0); } public void StartTrailer() diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index cf104fe..97ba8ef 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -367,6 +367,12 @@ + + UserControl + + + UniteLoginDialog.cs + @@ -525,6 +531,9 @@ MainHomepage.cs + + UniteLoginDialog.cs + WindowBorder.cs diff --git a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs new file mode 100644 index 0000000..daf385b --- /dev/null +++ b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs @@ -0,0 +1,123 @@ +namespace ShiftOS.WinForms +{ + partial class UniteLoginDialog + { + /// + /// 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 Component 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.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.txtusername = new System.Windows.Forms.TextBox(); + this.txtpassword = new System.Windows.Forms.TextBox(); + this.btnlogin = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(16, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(84, 13); + this.label1.TabIndex = 0; + this.label1.Tag = "header2"; + this.label1.Text = "Login to ShiftOS"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(16, 82); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(58, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Username:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(16, 115); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(56, 13); + this.label3.TabIndex = 2; + this.label3.Text = "Password:"; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(112, 79); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(424, 20); + this.txtusername.TabIndex = 3; + // + // txtpassword + // + this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtpassword.Location = new System.Drawing.Point(112, 112); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(424, 20); + this.txtpassword.TabIndex = 4; + this.txtpassword.UseSystemPasswordChar = true; + // + // btnlogin + // + this.btnlogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnlogin.Location = new System.Drawing.Point(460, 148); + this.btnlogin.Name = "btnlogin"; + this.btnlogin.Size = new System.Drawing.Size(75, 23); + this.btnlogin.TabIndex = 5; + this.btnlogin.Text = "Login"; + this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); + // + // UniteLoginDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.btnlogin); + this.Controls.Add(this.txtpassword); + this.Controls.Add(this.txtusername); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "UniteLoginDialog"; + this.Size = new System.Drawing.Size(573, 192); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtusername; + private System.Windows.Forms.TextBox txtpassword; + private System.Windows.Forms.Button btnlogin; + } +} diff --git a/ShiftOS.WinForms/UniteLoginDialog.cs b/ShiftOS.WinForms/UniteLoginDialog.cs new file mode 100644 index 0000000..4c85005 --- /dev/null +++ b/ShiftOS.WinForms/UniteLoginDialog.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using System.Net; + +namespace ShiftOS.WinForms +{ + public partial class UniteLoginDialog : UserControl, IShiftOSWindow + { + public UniteLoginDialog(Action callback) + { + InitializeComponent(); + Callback = callback; + } + + private Action Callback { get; set; } + + public void OnLoad() + { + this.ParentForm.AcceptButton = btnlogin; + } + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + } + + private void btnlogin_Click(object sender, EventArgs e) + { + string u = txtusername.Text; + string p = txtpassword.Text; + + if (string.IsNullOrWhiteSpace(u)) + { + Infobox.Show("Please enter a username.", "You must enter a proper email address."); + return; + } + + if (string.IsNullOrWhiteSpace(p)) + { + Infobox.Show("Please enter a password.", "You must enter a valid password."); + return; + } + + try + { + var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); + webrequest.Headers.Add("Authentication: Basic " + base64); + var response = webrequest.GetResponse(); + var str = response.GetResponseStream(); + var reader = new System.IO.StreamReader(str); + string result = reader.ReadToEnd(); + reader.Close(); + str.Close(); + str.Dispose(); + response.Dispose(); + Callback?.Invoke(result); + AppearanceManager.Close(this); + } +#if DEBUG + catch(Exception ex) + { + Infobox.Show("Error", ex.ToString()); + } +#else + catch + { + Infobox.Show("Login failed.", "The login attempt failed due to an incorrect username and password pair."); + } +#endif + + } + } +} diff --git a/ShiftOS.WinForms/UniteLoginDialog.resx b/ShiftOS.WinForms/UniteLoginDialog.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/UniteLoginDialog.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_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 3e68a70..4f4e9f5 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -266,12 +266,9 @@ namespace ShiftOS.Engine { if (Utils.FileExists(Paths.GetPath("user.dat"))) { - var userdat = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("user.dat"))); + string token = Utils.ReadAllText(Paths.GetPath("user.dat")); - ServerManager.SendMessage("mud_login", $@"{{ - username: ""{userdat.Username}"", - password: ""{userdat.Password}"" -}}"); + ServerManager.SendMessage("mud_token_login", token); } else { diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index f7b730f..5cd6c68 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -131,6 +131,8 @@ + + diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs new file mode 100644 index 0000000..8d9eef2 --- /dev/null +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Unite +{ + public class UniteClient + { + public string Token { get; private set; } + public string BaseURL { get; private set; } + + public UniteClient(string baseurl, string usertoken) + { + BaseURL = baseurl; + Token = Token; + } + + internal string MakeCall(string url) + { + var webrequest = WebRequest.Create(BaseURL + url); + webrequest.Headers.Add("Authentication: Token " + Token); + using (var response = webrequest.GetResponse()) + { + using (var stream = response.GetResponseStream()) + { + using (var reader = new System.IO.StreamReader(stream)) + { + return reader.ReadToEnd(); + } + } + } + } + + public string GetDisplayName() + { + return MakeCall("/API/GetDisplayName"); + } + + public void SetDisplayName(string value) + { + MakeCall("/API/SetDisplayName/" + value.ToString()); + } + + public string GetFullName() + { + return MakeCall("/API/GetFullName"); + } + + public void SetFullName(string value) + { + MakeCall("/API/SetFullName/" + value.ToString()); + } + + + public long GetCodepoints() + { + return Convert.ToInt64(MakeCall("/API/GetCodepoints")); + } + + public void SetCodepoints(long value) + { + MakeCall("/API/SetCodepoints/" + value.ToString()); + } + } +} diff --git a/ShiftOS_TheReturn/UniteTestCommands.cs b/ShiftOS_TheReturn/UniteTestCommands.cs new file mode 100644 index 0000000..37ab1ee --- /dev/null +++ b/ShiftOS_TheReturn/UniteTestCommands.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + [Namespace("unite")] + public static class UniteTestCommands + { + [Command("login")] + [RequiresArgument("username")] + [RequiresArgument("password")] + public static bool LoginTest(Dictionary args) + { + string u = args["username"].ToString(); + string p = args["password"].ToString(); + var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); + webrequest.Headers.Add("Authentication: Basic " + base64); + var response = webrequest.GetResponse(); + var str = response.GetResponseStream(); + var reader = new System.IO.StreamReader(str); + string result = reader.ReadToEnd(); + Console.WriteLine("Server returned: " + result); + reader.Close(); + str.Close(); + str.Dispose(); + response.Dispose(); + + return true; + } + + [Command("linklogin")] + [RequiresArgument("username")] + [RequiresArgument("password")] + public static bool LinkLogin(Dictionary args) + { + string u = args["username"].ToString(); + string p = args["password"].ToString(); + var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); + webrequest.Headers.Add("Authentication: Basic " + base64); + var response = webrequest.GetResponse(); + var str = response.GetResponseStream(); + var reader = new System.IO.StreamReader(str); + string result = reader.ReadToEnd(); + //If we get this far, the token is OURS. :D + SaveSystem.CurrentSave.UniteAuthToken = result; + Console.WriteLine("Unite says \"Access Granted!\""); + SaveSystem.SaveGame(); + reader.Close(); + str.Close(); + str.Dispose(); + response.Dispose(); + + return true; + } + + + } +} -- cgit v1.2.3 From aec0eff8187fadb7418892c076a88c9bd03b8ff0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Apr 2017 19:26:00 -0400 Subject: unite registration --- ShiftOS.WinForms/Oobe.cs | 16 +++++ ShiftOS.WinForms/UniteSignupDialog.Designer.cs | 37 ++++++++-- ShiftOS.WinForms/UniteSignupDialog.cs | 93 ++++++++++++++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 9 +-- 4 files changed, 141 insertions(+), 14 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 35efca4..245d13e 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -263,6 +263,22 @@ You must join the digital society, rise up the ranks, and save us. { var signupDialog = new UniteSignupDialog((token) => { + ServerMessageReceived smr = null; + smr = (msg) => + { + ServerManager.MessageReceived -= smr; + if (msg.Name == "mud_savefile") + { + SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + SaveSystem.SaveGame(); + } + else + { + LinkSaveFile(token); + } + }; + ServerManager.MessageReceived += smr; + ServerManager.SendMessage("mud_token_login", token); }); AppearanceManager.SetupDialog(signupDialog); diff --git a/ShiftOS.WinForms/UniteSignupDialog.Designer.cs b/ShiftOS.WinForms/UniteSignupDialog.Designer.cs index 752f5c0..a1509d7 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.Designer.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.Designer.cs @@ -40,17 +40,20 @@ this.txtdisplay = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); + this.txtsysname = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // btnlogin // this.btnlogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnlogin.Location = new System.Drawing.Point(462, 407); + this.btnlogin.Location = new System.Drawing.Point(462, 479); this.btnlogin.Name = "btnlogin"; this.btnlogin.Size = new System.Drawing.Size(75, 23); this.btnlogin.TabIndex = 11; this.btnlogin.Text = "Submit"; this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); // // txtpassword // @@ -94,10 +97,10 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(17, 36); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(84, 13); + this.label1.Size = new System.Drawing.Size(120, 13); this.label1.TabIndex = 6; this.label1.Tag = "header2"; - this.label1.Text = "Login to ShiftOS"; + this.label1.Text = "Create ShiftOS Account"; // // txtconfirm // @@ -141,16 +144,36 @@ this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label6.Location = new System.Drawing.Point(20, 251); + this.label6.Location = new System.Drawing.Point(20, 267); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(517, 153); + this.label6.Size = new System.Drawing.Size(517, 209); this.label6.TabIndex = 16; this.label6.Text = resources.GetString("label6.Text"); // + // txtsysname + // + this.txtsysname.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtsysname.Location = new System.Drawing.Point(113, 223); + this.txtsysname.Name = "txtsysname"; + this.txtsysname.Size = new System.Drawing.Size(424, 20); + this.txtsysname.TabIndex = 18; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(17, 226); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(73, 13); + this.label7.TabIndex = 17; + this.label7.Text = "System name:"; + // // UniteSignupDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.txtsysname); + this.Controls.Add(this.label7); this.Controls.Add(this.label6); this.Controls.Add(this.txtdisplay); this.Controls.Add(this.label5); @@ -163,7 +186,7 @@ this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Name = "UniteSignupDialog"; - this.Size = new System.Drawing.Size(555, 447); + this.Size = new System.Drawing.Size(555, 519); this.ResumeLayout(false); this.PerformLayout(); @@ -182,5 +205,7 @@ private System.Windows.Forms.TextBox txtdisplay; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtsysname; + private System.Windows.Forms.Label label7; } } diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs index 2f20d9f..a46a9b0 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -8,6 +8,8 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using Newtonsoft.Json; +using System.Net; namespace ShiftOS.WinForms { @@ -39,5 +41,96 @@ namespace ShiftOS.WinForms public void OnUpgrade() { } + + private void btnlogin_Click(object sender, EventArgs e) + { + string u = txtusername.Text; + string p = txtpassword.Text; + + if (string.IsNullOrWhiteSpace(u)) + { + Infobox.Show("Please enter a username.", "You must enter a proper email address."); + return; + } + + if (string.IsNullOrWhiteSpace(p)) + { + Infobox.Show("Please enter a password.", "You must enter a valid password."); + return; + } + + if(p != txtconfirm.Text) + { + Infobox.Show("Passwords don't match.", "The \"Password\" and \"Confirm\" boxes must match."); + return; + } + + if (string.IsNullOrWhiteSpace(txtdisplay.Text)) + { + Infobox.Show("Empty display name", "Please choose a proper display name."); + return; + } + + if (string.IsNullOrWhiteSpace(txtsysname.Text)) + { + Infobox.Show("Empty system name", "Please name your computer!"); + return; + } + + if(p.Length < 7) + { + Infobox.Show("Password error", "Your password must have at least 7 characters."); + return; + } + + if (!(p.Any(char.IsUpper) && + p.Any(char.IsLower) && + p.Any(char.IsDigit))) + { + Infobox.Show("Password error", "Your password must contain at least one uppercase, lowercase, digit and symbol character."); + return; + } + + if (!u.Contains("@")) + { + Infobox.Show("Valid email required.", "You must specify a valid email address."); + return; + } + + try + { + var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); + string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); + webrequest.Headers.Add("Authentication: Basic " + base64); + var response = webrequest.GetResponse(); + var str = response.GetResponseStream(); + var reader = new System.IO.StreamReader(str); + string result = reader.ReadToEnd(); + if (result.StartsWith("{")) + { + var exc = JsonConvert.DeserializeObject(result); + Infobox.Show("Error", exc.Message); + return; + } + reader.Close(); + str.Close(); + str.Dispose(); + response.Dispose(); + Callback?.Invoke(result); + AppearanceManager.Close(this); + } +#if DEBUG + catch (Exception ex) + { + Infobox.Show("Error", ex.ToString()); + } +#else + catch + { + Infobox.Show("Login failed.", "The login attempt failed due to an incorrect username and password pair."); + } +#endif + + } } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 4f4e9f5..bd9a14f 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -298,14 +298,7 @@ namespace ShiftOS.Engine Console.Write("{SE_SAVING}... "); if (SaveSystem.CurrentSave != null) { - string username = CurrentSave.Username; - string password = CurrentSave.Password; - - Utils.WriteAllText(Paths.GetPath("user.dat"), $@"{{ - username: ""{username}"", - password: ""{password}"" -}}"); - + Utils.WriteAllText(Paths.GetPath("user.dat"), CurrentSave.UniteAuthToken); ServerManager.SendMessage("mud_save", JsonConvert.SerializeObject(CurrentSave, Formatting.Indented)); } if (!Shiftorium.Silent) -- cgit v1.2.3 From a99711507970055e02dd678e613e9d8546e6742e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Apr 2017 20:28:31 -0400 Subject: fix unite login and add multiuser support --- ShiftOS.Objects/ClientSave.cs | 9 +++ ShiftOS.Objects/Save.cs | 2 + ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/UniteLoginDialog.Designer.cs | 4 +- ShiftOS_TheReturn/SaveSystem.cs | 99 +++++++++++++++++++---- ShiftOS_TheReturn/TerminalBackend.cs | 110 ++++++++++++++++++-------- 6 files changed, 176 insertions(+), 49 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.Objects/ClientSave.cs b/ShiftOS.Objects/ClientSave.cs index edbb7dc..fbe1044 100644 --- a/ShiftOS.Objects/ClientSave.cs +++ b/ShiftOS.Objects/ClientSave.cs @@ -34,5 +34,14 @@ namespace ShiftOS.Objects { public string Username { get; set; } public string Password { get; set; } + public UserPermissions Permissions { get; set; } + } + + public enum UserPermissions + { + Root, + Admin, + User, + Guest } } diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 7208de5..1adaf3b 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -93,6 +93,8 @@ namespace ShiftOS.Objects } return count; } + + public List Users = new List(); } public class SettingsObject : DynamicObject diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 3b1a020..d35f7e0 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -283,6 +283,7 @@ namespace ShiftOS.WinForms.Applications } TerminalBackend.LastCommand = text3; TextSent?.Invoke(text4); + TerminalBackend.SendText(text4); if (TerminalBackend.InStory == false) { if (text3 == "stop theme") diff --git a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs index daf385b..f510393 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs @@ -51,9 +51,9 @@ this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(16, 82); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(58, 13); + this.label2.Size = new System.Drawing.Size(35, 13); this.label2.TabIndex = 1; - this.label2.Text = "Username:"; + this.label2.Text = "Email:"; // // label3 // diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index bd9a14f..2df914e 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -50,6 +50,9 @@ namespace ShiftOS.Engine { public static bool ShuttingDown = false; + public static ClientSave CurrentUser { get; set; } + + public static Save CurrentSave { get; set; } /// @@ -189,28 +192,96 @@ namespace ShiftOS.Engine Thread.Sleep(50); Console.WriteLine("{SYSTEM_INITIATED}"); + + + if(CurrentSave.Users.Count == 0) + { + CurrentSave.Users.Add(new ClientSave + { + Username = "root", + Password = "", + Permissions = UserPermissions.Root + }); + Console.WriteLine("No users found. Creating new user with username \"root\", with no password."); + } TerminalBackend.InStory = false; + + TerminalBackend.PrefixEnabled = false; + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => + { + if (progress == 0) + { + if (!string.IsNullOrWhiteSpace(text)) + { + if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = text; + progress++; + } + else + { + Console.WriteLine("Username not provided."); + TerminalBackend.TextSent -= ev; + goback = true; + progress++; + } + } + else if (progress == 1) + { + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == text) + { + Console.WriteLine("Welcome to ShiftOS."); + CurrentUser = user; + Thread.Sleep(2000); + progress++; + } + else + { + Console.WriteLine("Access denied."); + goback = true; + progress++; + } + TerminalBackend.TextSent -= ev; + } + }; + TerminalBackend.TextSent += ev; + Console.WriteLine(CurrentSave.SystemName + " login:"); + while(progress == 0) + { + Thread.Sleep(10); + } + if (goback) + goto Login; + Console.WriteLine("password:"); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; + + TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => { ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); })); - Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); - if (CurrentSave.StoryPosition == 1) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - TutorialManager.StartTutorial(); - })); - while (TutorialManager.IsInTutorial == true) { } - GameReady?.Invoke(); - } - else - { - GameReady?.Invoke(); - } + + Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); + GameReady?.Invoke(); } public delegate void EmptyEventHandler(); diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 318c818..3bfdeff 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -32,21 +32,26 @@ using System.Threading.Tasks; using Newtonsoft.Json; using static ShiftOS.Engine.SaveSystem; -namespace ShiftOS.Engine { - public static class TerminalBackend { +namespace ShiftOS.Engine +{ + public static class TerminalBackend + { public static event Action CommandProcessed; public static bool Elevated { get; set; } - public static Dictionary GetArgs(ref string text) { + public static Dictionary GetArgs(ref string text) + { bool shouldParse = false; int argStart = 0; - if (text.Contains("{")) { + if (text.Contains("{")) + { shouldParse = true; argStart = text.IndexOf('{'); } - if (shouldParse == false) { + if (shouldParse == false) + { string replacement = Regex.Replace(text, @"\t|\n|\r", ""); text = replacement + "{}"; shouldParse = true; @@ -61,15 +66,18 @@ namespace ShiftOS.Engine { public static string LastCommand = ""; - public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) { - try { + public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) + { + try + { if (string.IsNullOrWhiteSpace(ns)) return; bool commandWasClient = RunClient(ns, command, arguments, isRemote); - if (!commandWasClient && !string.IsNullOrWhiteSpace(ns)) { + if (!commandWasClient && !string.IsNullOrWhiteSpace(ns)) + { PrefixEnabled = false; ServerManager.SendMessage("script", $@"{{ @@ -80,23 +88,29 @@ namespace ShiftOS.Engine { } CommandProcessed?.Invoke(ns + "." + command, JsonConvert.SerializeObject(arguments)); - } catch (Exception ex) { + } + catch (Exception ex) + { Console.WriteLine($"Command parse error: {ex.Message}"); // This shouldn't ever be called now PrefixEnabled = true; } } - public static string GetSentArgs(Dictionary argss) { + public static string GetSentArgs(Dictionary argss) + { Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) { + foreach (KeyValuePair arg in argss) + { args[arg.Key] = arg.Value; } return JsonConvert.SerializeObject(args); } - public static void InvokeCommand(string text, bool isRemote = false) { - try { + public static void InvokeCommand(string text, bool isRemote = false) + { + try + { if (string.IsNullOrWhiteSpace(text)) return; @@ -104,7 +118,8 @@ namespace ShiftOS.Engine { bool commandWasClient = RunClient(text, args, isRemote); - if (!commandWasClient) { + if (!commandWasClient) + { PrefixEnabled = false; ServerManager.SendMessage("script", $@"{{ @@ -114,7 +129,9 @@ namespace ShiftOS.Engine { }}"); } CommandProcessed?.Invoke(text, GetSentArgs(args)); - } catch (Exception ex) { + } + catch (Exception ex) + { Console.WriteLine($"Command parse error: {ex.Message}"); PrefixEnabled = true; @@ -129,15 +146,18 @@ namespace ShiftOS.Engine { public static event EmptyEventHandler TerminalRequested; - internal static void OpenTerminal() { + internal static void OpenTerminal() + { TerminalRequested?.Invoke(); } - public static bool CanRunRemotely(MethodInfo mth, bool isRemote) { + public static bool CanRunRemotely(MethodInfo mth, bool isRemote) + { if (!isRemote) return true; - foreach (var attr in mth.GetCustomAttributes(false)) { + foreach (var attr in mth.GetCustomAttributes(false)) + { if (attr is RemoteLockAttribute) return false; } @@ -145,26 +165,32 @@ namespace ShiftOS.Engine { return true; } - public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) { + public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) + { return RunClient(ns + "." + cmd, args, isRemote); } - public static bool RunClient(string text, Dictionary argss, bool isRemote = false) { + public static bool RunClient(string text, Dictionary argss, bool isRemote = false) + { Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) { + foreach (KeyValuePair arg in argss) + { args[arg.Key] = arg.Value; } return RunClient(text, args, isRemote); } - public static bool RunClient(string text, Dictionary args, bool isRemote = false) { + public static bool RunClient(string text, Dictionary args, bool isRemote = false) + { latestCommmand = text; //Console.WriteLine(text + " " + "{" + string.Join(",", args.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}" + " " + isRemote); - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) { - try { + foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + try + { var asm = Assembly.LoadFile(asmExec); var types = asm.GetTypes(); @@ -315,7 +341,9 @@ namespace ShiftOS.Engine { } } - } else { + } + else + { Console.WriteLine(text + " cannot be ran in a remote session"); return true; } @@ -360,7 +388,8 @@ namespace ShiftOS.Engine { } } } - } catch { } + } + catch { } } return false; } @@ -375,7 +404,7 @@ namespace ShiftOS.Engine { ConsoleEx.ForegroundColor = ConsoleColor.Magenta; ConsoleEx.Bold = true; - Console.Write(SaveSystem.CurrentSave.Username); + Console.Write(SaveSystem.CurrentUser.Username); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.Gray; Console.Write("@"); @@ -410,26 +439,34 @@ namespace ShiftOS.Engine { string text3 = ""; string text4 = msg.Contents; - if (TerminalBackend.PrefixEnabled) { + if (TerminalBackend.PrefixEnabled) + { text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); } IsForwardingConsoleWrites = true; - if (TerminalBackend.InStory == false) { + if (TerminalBackend.InStory == false) + { TerminalBackend.InvokeCommand(text3, true); } - if (TerminalBackend.PrefixEnabled) { + if (TerminalBackend.PrefixEnabled) + { Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); } IsForwardingConsoleWrites = false; - } else if (msg.Name == "pleasewrite") { + } + else if (msg.Name == "pleasewrite") + { Console.Write(msg.Contents); - } else if (msg.Name == "handshake_from") { + } + else if (msg.Name == "handshake_from") + { var a = JsonConvert.DeserializeObject>(msg.Contents); string uName = a["username"] as string; string pass = a["password"] as string; string sys = a["sysname"] as string; string guid = msg.GUID; - if (SaveSystem.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) { + if (SaveSystem.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) + { ForwardGUID = guid; ServerManager.SendMessage("trm_handshake_accept", $@"{{ guid: ""{ServerManager.thisGuid}"", @@ -450,5 +487,12 @@ namespace ShiftOS.Engine { public static bool IsForwardingConsoleWrites { get; internal set; } public static string ForwardGUID { get; internal set; } + public static event TextSentEventHandler TextSent; + + public static void SendText(string text) + { + TextSent?.Invoke(text); + } + } } -- cgit v1.2.3 From 097afe3dfe6af3ed10753434c1475a8771b4d3c8 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 1 May 2017 14:56:56 -0400 Subject: Unbind save handshake after message receive. --- ShiftOS_TheReturn/SaveSystem.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 2df914e..a27b04f 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -159,17 +159,23 @@ namespace ShiftOS.Engine { KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); - ServerManager.MessageReceived += (msg) => + ServerMessageReceived savehandshake = null; + + savehandshake = (msg) => { if (msg.Name == "mud_savefile") { CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + ServerManager.MessageReceived -= savehandshake; } else if (msg.Name == "mud_login_denied") { oobe.PromptForLogin(); + ServerManager.MessageReceived -= savehandshake; } }; + ServerManager.MessageReceived += savehandshake; + ReadSave(); -- cgit v1.2.3 From f26bab83109fec93d51fb845094c21b874971490 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 1 May 2017 16:13:21 -0400 Subject: create user list if it is null --- ShiftOS_TheReturn/SaveSystem.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index a27b04f..945869b 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -198,7 +198,10 @@ namespace ShiftOS.Engine Thread.Sleep(50); Console.WriteLine("{SYSTEM_INITIATED}"); - + + if (CurrentSave.Users == null) + CurrentSave.Users = new List(); + if(CurrentSave.Users.Count == 0) { @@ -294,8 +297,10 @@ namespace ShiftOS.Engine public static List Users { - get; - private set; + get + { + return CurrentSave.Users; + } } public static event EmptyEventHandler GameReady; -- cgit v1.2.3 From a57b5855f5a2b7e5f89e411a5cbe66dd0dcb50d6 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 4 May 2017 16:41:17 -0400 Subject: fix blank sysname bug --- ShiftOS_TheReturn/SaveSystem.cs | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 945869b..c3289ea 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -198,6 +198,52 @@ namespace ShiftOS.Engine Thread.Sleep(50); Console.WriteLine("{SYSTEM_INITIATED}"); + Sysname: + bool waitingForNewSysName = false; + bool gobacktosysname = false; + + if (string.IsNullOrWhiteSpace(CurrentSave.SystemName)) + { + Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name)=> + { + if (string.IsNullOrWhiteSpace(name)) + Infobox.Show("Invalid name", "Please enter a valid name.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else if (name.Length < 5) + Infobox.Show("Value too small.", "Your system name must have at least 5 characters in it.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else + { + CurrentSave.SystemName = name; + if (!string.IsNullOrWhiteSpace(CurrentSave.UniteAuthToken)) + { + var unite = new Unite.UniteClient("http://getshiftos.ml", CurrentSave.UniteAuthToken); + unite.SetSysName(name); + } + SaveSystem.SaveGame(); + gobacktosysname = false; + waitingForNewSysName = false; + } + }); + + + } + + while (waitingForNewSysName) + { + Thread.Sleep(10); + } + + if (gobacktosysname) + { + goto Sysname; + } if (CurrentSave.Users == null) CurrentSave.Users = new List(); -- cgit v1.2.3 From bbc5a738b1b3d86d2a71c1188fad89b533f251ce Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 5 May 2017 11:52:43 -0400 Subject: shiftfs permissions --- ShiftOS.Objects/ShiftFS.cs | 37 +++++++++++++++---------------------- ShiftOS_TheReturn/SaveSystem.cs | 2 +- 2 files changed, 16 insertions(+), 23 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index c2121f0..45cdb14 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -32,23 +32,16 @@ using System.Threading; namespace ShiftOS.Objects.ShiftFS { - public enum Permissions - { - User, - Administrator, - Superuser, - All - } public class File { public string Name; public byte[] Data; public byte[] HeaderData; public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public System.IO.Stream GetStream() { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return new System.IO.MemoryStream(Data); } @@ -59,7 +52,7 @@ namespace ShiftOS.Objects.ShiftFS return null; } - public File(string name, byte[] data, bool ReadAccess_to_low_users, Permissions perm) + public File(string name, byte[] data, bool ReadAccess_to_low_users, UserPermissions perm) { Name = name; Data = data; @@ -73,31 +66,31 @@ namespace ShiftOS.Objects.ShiftFS public List Files = new List(); public List Subdirectories = new List(); public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public void AddFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Add(file); } } public void RemoveFile(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(Files.Find(x => x.Name == name)); } } public void RemoveFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(file); } } public File FindFileByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Files.Find(x => x.Name == name); } @@ -105,28 +98,28 @@ namespace ShiftOS.Objects.ShiftFS } public void AddDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Add(dir); } } public void RemoveDirectory(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(Subdirectories.Find(x => x.Name == name)); } } public void RemoveDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(dir); } } public Directory FindDirectoryByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Subdirectories.Find(x => x.Name == name); } @@ -136,7 +129,7 @@ namespace ShiftOS.Objects.ShiftFS public static class Utils { - public static Permissions CurrentUser { get; set; } + public static UserPermissions CurrentUser { get; set; } public static List Mounts { get; set; } @@ -232,7 +225,7 @@ namespace ShiftOS.Objects.ShiftFS { try { - dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, CurrentUser)); } catch { } } @@ -281,7 +274,7 @@ namespace ShiftOS.Objects.ShiftFS if (!FileExists(path)) { - dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, CurrentUser)); } else { diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index c3289ea..f29e5b8 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,7 @@ namespace ShiftOS.Engine { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; - root.permissions = Permissions.All; + root.permissions = UserPermissions.Guest; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } -- cgit v1.2.3 From d0d193bb1b869697d633d7ccac35179241f8e981 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2017 19:24:57 -0400 Subject: GUI-based login screen with skinning! --- ShiftOS.WinForms/GUILogin.Designer.cs | 135 ++++++++++++++++++++++++++++++ ShiftOS.WinForms/GUILogin.cs | 131 +++++++++++++++++++++++++++++ ShiftOS.WinForms/GUILogin.resx | 120 ++++++++++++++++++++++++++ ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Resources/Shiftorium.txt | 7 ++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ ShiftOS_TheReturn/LoginManager.cs | 65 ++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 120 +++++++++++++++----------- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/Skinning.cs | 16 ++++ 10 files changed, 555 insertions(+), 50 deletions(-) create mode 100644 ShiftOS.WinForms/GUILogin.Designer.cs create mode 100644 ShiftOS.WinForms/GUILogin.cs create mode 100644 ShiftOS.WinForms/GUILogin.resx create mode 100644 ShiftOS_TheReturn/LoginManager.cs (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/GUILogin.Designer.cs b/ShiftOS.WinForms/GUILogin.Designer.cs new file mode 100644 index 0000000..9125d98 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.Designer.cs @@ -0,0 +1,135 @@ +namespace ShiftOS.WinForms +{ + partial class GUILogin + { + /// + /// 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.pnlloginform = new System.Windows.Forms.Panel(); + this.btnlogin = new System.Windows.Forms.Button(); + this.txtpassword = new System.Windows.Forms.TextBox(); + this.txtusername = new System.Windows.Forms.TextBox(); + this.lblogintitle = new System.Windows.Forms.Label(); + this.btnshutdown = new System.Windows.Forms.Button(); + this.pnlloginform.SuspendLayout(); + this.SuspendLayout(); + // + // pnlloginform + // + this.pnlloginform.Controls.Add(this.btnlogin); + this.pnlloginform.Controls.Add(this.txtpassword); + this.pnlloginform.Controls.Add(this.txtusername); + this.pnlloginform.Location = new System.Drawing.Point(13, 13); + this.pnlloginform.Name = "pnlloginform"; + this.pnlloginform.Size = new System.Drawing.Size(358, 236); + this.pnlloginform.TabIndex = 0; + this.pnlloginform.Tag = ""; + // + // btnlogin + // + this.btnlogin.AutoSize = true; + this.btnlogin.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnlogin.Location = new System.Drawing.Point(129, 184); + this.btnlogin.Name = "btnlogin"; + this.btnlogin.Size = new System.Drawing.Size(43, 23); + this.btnlogin.TabIndex = 2; + this.btnlogin.Text = "Login"; + this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); + // + // txtpassword + // + this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtpassword.Location = new System.Drawing.Point(24, 157); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(301, 20); + this.txtpassword.TabIndex = 1; + this.txtpassword.UseSystemPasswordChar = true; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(24, 131); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(301, 20); + this.txtusername.TabIndex = 0; + // + // lblogintitle + // + this.lblogintitle.AutoSize = true; + this.lblogintitle.Location = new System.Drawing.Point(99, 553); + this.lblogintitle.Name = "lblogintitle"; + this.lblogintitle.Size = new System.Drawing.Size(103, 13); + this.lblogintitle.TabIndex = 1; + this.lblogintitle.Tag = "header1 keepbg"; + this.lblogintitle.Text = "Welcome to ShiftOS"; + // + // btnshutdown + // + this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnshutdown.AutoSize = true; + this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnshutdown.Location = new System.Drawing.Point(924, 652); + this.btnshutdown.Name = "btnshutdown"; + this.btnshutdown.Size = new System.Drawing.Size(65, 23); + this.btnshutdown.TabIndex = 2; + this.btnshutdown.Text = "Shutdown"; + this.btnshutdown.UseVisualStyleBackColor = true; + this.btnshutdown.Click += new System.EventHandler(this.btnshutdown_Click); + // + // GUILogin + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(1001, 687); + this.Controls.Add(this.btnshutdown); + this.Controls.Add(this.lblogintitle); + this.Controls.Add(this.pnlloginform); + this.ForeColor = System.Drawing.Color.White; + this.Name = "GUILogin"; + this.Text = "GUILogin"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GUILogin_FormClosing); + this.Load += new System.EventHandler(this.GUILogin_Load); + this.pnlloginform.ResumeLayout(false); + this.pnlloginform.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel pnlloginform; + private System.Windows.Forms.Button btnlogin; + private System.Windows.Forms.TextBox txtpassword; + private System.Windows.Forms.TextBox txtusername; + private System.Windows.Forms.Label lblogintitle; + private System.Windows.Forms.Button btnshutdown; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/GUILogin.cs b/ShiftOS.WinForms/GUILogin.cs new file mode 100644 index 0000000..66ff06d --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.cs @@ -0,0 +1,131 @@ +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; +using ShiftOS.Engine; +using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms +{ + public partial class GUILogin : Form + { + public GUILogin() + { + InitializeComponent(); + uiTimer.Tick += (o, a) => + { + btnlogin.Left = txtusername.Left + ((txtusername.Width - btnlogin.Width) / 2); + btnlogin.Top = txtpassword.Top + txtpassword.Height + 5; + + lblogintitle.Left = pnlloginform.Left + ((pnlloginform.Width - lblogintitle.Width) / 2); + lblogintitle.Top = pnlloginform.Top - lblogintitle.Width - 5; + + }; + uiTimer.Interval = 100; + this.FormBorderStyle = FormBorderStyle.None; + this.WindowState = FormWindowState.Maximized; + this.TopMost = true; + } + + Timer uiTimer = new Timer(); + + public event Action LoginComplete; + + private void GUILogin_Load(object sender, EventArgs e) + { + uiTimer.Start(); + ControlManager.SetupControl(lblogintitle); + ControlManager.SetupControls(pnlloginform); + ControlManager.SetupControl(btnshutdown); + pnlloginform.CenterParent(); + this.BackColor = SkinEngine.LoadedSkin.LoginScreenColor; + this.BackgroundImage = SkinEngine.GetImage("login"); + this.BackgroundImageLayout = SkinEngine.GetImageLayout("login"); + } + + private ClientSave User = null; + + bool userRequestClose = true; + bool shuttingdown = false; + + private void GUILogin_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = userRequestClose; + if (!e.Cancel) + { + uiTimer.Stop(); + if (shuttingdown == false) + { + LoginComplete?.Invoke(User); + } + } + } + + private void btnlogin_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(txtusername.Text)) + { + Infobox.Show("Enter a username", "You must enter your username to login."); + return; + } + + //Don't check for blank passwords. + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == txtusername.Text); + if(user == null) + { + Infobox.Show("Invalid username", "That username was not found on your system."); + return; + } + + if (user.Password != txtpassword.Text) + { + Infobox.Show("Access denied.", "That password didn't work. Please try a different one."); + return; + } + + User = user; + userRequestClose = false; + shuttingdown = false; + this.Close(); + } + + private void btnshutdown_Click(object sender, EventArgs e) + { + userRequestClose = false; + shuttingdown = true; + this.Close(); + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); + TerminalBackend.InvokeCommand("sos.shutdown"); + } + } + + public class GUILoginFrontend : ILoginFrontend + { + public bool UseGUILogin + { + get + { + return Shiftorium.UpgradeInstalled("gui_based_login_screen"); + } + } + + public event Action LoginComplete; + + public void Login() + { + var lform = new GUILogin(); + lform.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + lform.Show(); + } + } +} diff --git a/ShiftOS.WinForms/GUILogin.resx b/ShiftOS.WinForms/GUILogin.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.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.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index b2f064d..ad8fc83 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,7 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index b528c72..c3d27ae 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,13 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "GUI Based Login Screen", + Cost: 500, + Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, why not use these tools to create a functioning and awesome-looking login screen?", + Dependencies: "skinning;desktop;wm_free_placement", + Category: "Kernel & System" + }, { Name: "Shift Screensavers", Cost: 100, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1607ae9..411d701 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -323,6 +323,12 @@ DownloadControl.cs + + Form + + + GUILogin.cs + @@ -520,6 +526,9 @@ DownloadControl.cs + + GUILogin.cs + Oobe.cs diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs new file mode 100644 index 0000000..d326f2c --- /dev/null +++ b/ShiftOS_TheReturn/LoginManager.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + public static class LoginManager + { + private static ILoginFrontend _login = null; + + public static void Init(ILoginFrontend login) + { + _login = login; + } + + public static void PromptForLogin() + { + _login.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + _login.Login(); + } + + public static bool ShouldUseGUILogin + { + get + { + if (_login == null) + return false; + return _login.UseGUILogin; + } + } + + public static event Action LoginComplete; + } + + /// + /// Interface for GUI-based logins. + /// + public interface ILoginFrontend + { + /// + /// When implemented, shows the login UI. + /// + void Login(); + + /// + /// Gets whether the ShiftOS engine should use a GUI-based login system or the default one. + /// + bool UseGUILogin { get; } + + + /// + /// Occurs when the login is complete. + /// + event Action LoginComplete; + + + + } +} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f29e5b8..93a8add 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -263,70 +263,90 @@ namespace ShiftOS.Engine TerminalBackend.PrefixEnabled = false; - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => + if (LoginManager.ShouldUseGUILogin) { - if (progress == 0) + Action Completed = null; + Completed += (user) => { - if (!string.IsNullOrWhiteSpace(text)) + CurrentUser = user; + LoginManager.LoginComplete -= Completed; + }; + LoginManager.LoginComplete += Completed; + Desktop.InvokeOnWorkerThread(() => + { + LoginManager.PromptForLogin(); + }); + while (CurrentUser == null) + { + Thread.Sleep(10); + } + } + else + { + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => + { + if (progress == 0) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + if (!string.IsNullOrWhiteSpace(text)) { - Console.WriteLine("User not found."); - goback = true; + if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = text; progress++; + } + else + { + Console.WriteLine("Username not provided."); TerminalBackend.TextSent -= ev; - return; + goback = true; + progress++; } - username = text; - progress++; } - else + else if (progress == 1) { - Console.WriteLine("Username not provided."); + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == text) + { + Console.WriteLine("Welcome to ShiftOS."); + CurrentUser = user; + Thread.Sleep(2000); + progress++; + } + else + { + Console.WriteLine("Access denied."); + goback = true; + progress++; + } TerminalBackend.TextSent -= ev; - goback = true; - progress++; } - } - else if (progress == 1) + }; + TerminalBackend.TextSent += ev; + Console.WriteLine(CurrentSave.SystemName + " login:"); + while (progress == 0) { - var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == text) - { - Console.WriteLine("Welcome to ShiftOS."); - CurrentUser = user; - Thread.Sleep(2000); - progress++; - } - else - { - Console.WriteLine("Access denied."); - goback = true; - progress++; - } - TerminalBackend.TextSent -= ev; + Thread.Sleep(10); } - }; - TerminalBackend.TextSent += ev; - Console.WriteLine(CurrentSave.SystemName + " login:"); - while(progress == 0) - { - Thread.Sleep(10); + if (goback) + goto Login; + Console.WriteLine("password:"); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; } - if (goback) - goto Login; - Console.WriteLine("password:"); - while (progress == 1) - Thread.Sleep(10); - if (goback) - goto Login; - - TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index fb33dc5..3b5eadd 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -111,6 +111,7 @@ + diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4cc9bbd..b731c4f 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -267,6 +267,22 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("gui_based_login_screen")] + [ShifterName("Login Screen Background Color")] + [ShifterDescription("Change the background color of the login screen.")] + public Color LoginScreenColor = Skin.DesktopBG; + + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("skinning;gui_based_login_screen")] + [ShifterName("Login Screen Background Image")] + [ShifterDescription("Set an image as your login screen!")] + [Image("login")] + public byte[] LoginScreenBG = null; + + [RequiresUpgrade("shift_screensaver")] [ShifterMeta("System")] [ShifterCategory("Screen saver")] -- cgit v1.2.3 From 7d744a64d05250e3883126db90f4e4c265ccfffa Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 6 May 2017 16:48:08 -0700 Subject: weew new boot sequence --- ShiftOS_TheReturn/SaveSystem.cs | 47 ++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f29e5b8..1feb6d8 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -98,13 +98,25 @@ namespace ShiftOS.Engine } Thread.Sleep(350); - Console.WriteLine("Initiating kernel..."); + Console.WriteLine("ShiftKernel v0.4.2"); + Console.WriteLine("(MIT) DevX 2017, Very Little Rights Reserved"); + Console.WriteLine(""); + Console.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); + Console.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); + Console.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); + Console.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); + Console.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); + Console.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); + Console.WriteLine("SOFTWARE."); + Console.WriteLine(""); Thread.Sleep(250); - Console.WriteLine("Reading filesystem..."); + Console.WriteLine("[init] Kernel boot complete."); + Console.WriteLine("[sfs] Loading SFS driver v3"); Thread.Sleep(100); - Console.WriteLine("Reading configuration..."); + Console.WriteLine("[sfs] 4096 blocks read."); + Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); - Console.WriteLine("{CONNECTING_TO_MUD}"); + Console.WriteLine("[inetd] Connecting to network..."); if (defaultConf.ConnectToMud == true) { @@ -113,7 +125,7 @@ namespace ShiftOS.Engine { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("Connection successful."); + Console.WriteLine("[inetd] Connection successful."); }; try @@ -125,20 +137,20 @@ namespace ShiftOS.Engine { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } catch (Exception ex) { //No errors, this never gets called. - Console.WriteLine("{ERROR}: " + ex.Message); + Console.WriteLine("[inetd] SEVERE: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); while (ServerManager.thisGuid == new Guid()) { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } } @@ -196,7 +208,7 @@ namespace ShiftOS.Engine Thread.Sleep(75); Thread.Sleep(50); - Console.WriteLine("{SYSTEM_INITIATED}"); + Console.WriteLine("[usr-man] Accepting logins on local tty 1."); Sysname: bool waitingForNewSysName = false; @@ -257,7 +269,7 @@ namespace ShiftOS.Engine Password = "", Permissions = UserPermissions.Root }); - Console.WriteLine("No users found. Creating new user with username \"root\", with no password."); + Console.WriteLine("[usr-man] WARN: No users found. Creating new user with username \"root\", with no password."); } TerminalBackend.InStory = false; @@ -274,7 +286,9 @@ namespace ShiftOS.Engine { if (!string.IsNullOrWhiteSpace(text)) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + string loginstr = CurrentSave.SystemName + " login: "; + string getuser = text.Remove(0, loginstr.Length); + if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) { Console.WriteLine("User not found."); goback = true; @@ -282,7 +296,7 @@ namespace ShiftOS.Engine TerminalBackend.TextSent -= ev; return; } - username = text; + username = getuser; progress++; } else @@ -295,8 +309,10 @@ namespace ShiftOS.Engine } else if (progress == 1) { + string passwordstr = "password: "; + string getpass = text.Remove(0, passwordstr.Length); var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == text) + if (user.Password == getpass) { Console.WriteLine("Welcome to ShiftOS."); CurrentUser = user; @@ -313,14 +329,15 @@ namespace ShiftOS.Engine } }; TerminalBackend.TextSent += ev; - Console.WriteLine(CurrentSave.SystemName + " login:"); + + Console.Write(CurrentSave.SystemName + " login: "); while(progress == 0) { Thread.Sleep(10); } if (goback) goto Login; - Console.WriteLine("password:"); + Console.Write("password: "); while (progress == 1) Thread.Sleep(10); if (goback) -- cgit v1.2.3 From 1d4df69ee98427b6d9ad5175910de8b6b156284c Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2017 19:57:59 -0400 Subject: Fix merge conflicts. --- ShiftOS_TheReturn/SaveSystem.cs | 54 ++++------------------------------------- 1 file changed, 5 insertions(+), 49 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 50aa260..1f2532a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -216,7 +216,7 @@ namespace ShiftOS.Engine if (string.IsNullOrWhiteSpace(CurrentSave.SystemName)) { - Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name)=> + Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name) => { if (string.IsNullOrWhiteSpace(name)) Infobox.Show("Invalid name", "Please enter a valid name.", () => @@ -261,7 +261,7 @@ namespace ShiftOS.Engine CurrentSave.Users = new List(); - if(CurrentSave.Users.Count == 0) + if (CurrentSave.Users.Count == 0) { CurrentSave.Users.Add(new ClientSave { @@ -305,13 +305,9 @@ namespace ShiftOS.Engine { if (progress == 0) { -<<<<<<< HEAD string loginstr = CurrentSave.SystemName + " login: "; string getuser = text.Remove(0, loginstr.Length); if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) -======= - if (!string.IsNullOrWhiteSpace(text)) ->>>>>>> origin/master { if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) { @@ -331,11 +327,8 @@ namespace ShiftOS.Engine goback = true; progress++; } -<<<<<<< HEAD username = getuser; progress++; -======= ->>>>>>> origin/master } else if (progress == 1) { @@ -357,57 +350,20 @@ namespace ShiftOS.Engine } }; TerminalBackend.TextSent += ev; - Console.WriteLine(CurrentSave.SystemName + " login:"); + + Console.Write(CurrentSave.SystemName + " login: "); while (progress == 0) { -<<<<<<< HEAD - string passwordstr = "password: "; - string getpass = text.Remove(0, passwordstr.Length); - var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == getpass) - { - Console.WriteLine("Welcome to ShiftOS."); - CurrentUser = user; - Thread.Sleep(2000); - progress++; - } - else - { - Console.WriteLine("Access denied."); - goback = true; - progress++; - } - TerminalBackend.TextSent -= ev; - } - }; - TerminalBackend.TextSent += ev; - - Console.Write(CurrentSave.SystemName + " login: "); - while(progress == 0) - { - Thread.Sleep(10); - } - if (goback) - goto Login; - Console.Write("password: "); - while (progress == 1) - Thread.Sleep(10); - if (goback) - goto Login; - - -======= Thread.Sleep(10); } if (goback) goto Login; - Console.WriteLine("password:"); + Console.Write("password: "); while (progress == 1) Thread.Sleep(10); if (goback) goto Login; } ->>>>>>> origin/master TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => -- cgit v1.2.3 From 5fbf30dbc0350fe805686e4299604225f5bc4739 Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 6 May 2017 17:27:39 -0700 Subject: fixed textlogin --- ShiftOS_TheReturn/SaveSystem.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 1f2532a..e635a7a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -307,9 +307,9 @@ namespace ShiftOS.Engine { string loginstr = CurrentSave.SystemName + " login: "; string getuser = text.Remove(0, loginstr.Length); - if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) + if (!string.IsNullOrWhiteSpace(getuser)) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) { Console.WriteLine("User not found."); goback = true; @@ -317,7 +317,7 @@ namespace ShiftOS.Engine TerminalBackend.TextSent -= ev; return; } - username = text; + username = getuser; progress++; } else @@ -327,13 +327,13 @@ namespace ShiftOS.Engine goback = true; progress++; } - username = getuser; - progress++; } else if (progress == 1) { + string passwordstr = "password: "; + string getpass = text.Remove(0, passwordstr.Length); var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == text) + if (user.Password == getpass) { Console.WriteLine("Welcome to ShiftOS."); CurrentUser = user; -- cgit v1.2.3 From 75ed7e9215ba88358d9b838dd82fa3841f78ae5a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 8 May 2017 11:31:20 -0400 Subject: Fix softlocks on pre-user OOBE. --- .vs/config/applicationhost.config | 1030 ++++++++++++++++++++++++++++++++ ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/UserConfig.cs | 37 ++ ShiftOS.Server/Program.cs | 1 + ShiftOS.Server/SaveManager.cs | 2 +- ShiftOS.WinForms/OobeStory.cs | 10 +- ShiftOS.WinForms/UniteLoginDialog.cs | 3 +- ShiftOS.WinForms/UniteSignupDialog.cs | 3 +- ShiftOS_TheReturn/SaveSystem.cs | 2 +- ShiftOS_TheReturn/UniteClient.cs | 12 +- 10 files changed, 1091 insertions(+), 10 deletions(-) create mode 100644 .vs/config/applicationhost.config create mode 100644 ShiftOS.Objects/UserConfig.cs (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 0000000..b42cd34 --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1030 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 7a19aeb..c2ef5ed 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -58,6 +58,7 @@ + diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs new file mode 100644 index 0000000..61d11b8 --- /dev/null +++ b/ShiftOS.Objects/UserConfig.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace ShiftOS.Objects +{ + public class UserConfig + { + public string UniteUrl { get; set; } + public string DigitalSocietyAddress { get; set; } + public int DigitalSocietyPort { get; set; } + + public static UserConfig Get() + { + var conf = new UserConfig + { + UniteUrl = "http://getshiftos.ml", + DigitalSocietyAddress = "michaeltheshifter.me", + DigitalSocietyPort = 13370 + }; + + if (!File.Exists("servers.json")) + { + File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented)); + } + else + { + conf = JsonConvert.DeserializeObject(File.ReadAllText("servers.json")); + } + return conf; + } + } +} diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 97c8a66..75af56f 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -86,6 +86,7 @@ namespace ShiftOS.Server /// The command-line arguments. public static void Main(string[] args) { + UserConfig.Get(); System.Timers.Timer tmr = new System.Timers.Timer(5000); tmr.Elapsed += (o, a) => { diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 63aa2bf..d81a1a7 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -189,7 +189,7 @@ namespace ShiftOS.Server //Update the shiftos website with the user's codepoints. if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken)) { - var wreq = WebRequest.Create("http://getshiftos.ml/API/SetCodepoints/" + sav.Codepoints.ToString()); + var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString()); wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken); wreq.GetResponse(); } diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index bab4889..39ca5b5 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -120,7 +120,7 @@ namespace ShiftOS.WinForms Console.Write(" "); ConsoleEx.BackgroundColor = ConsoleColor.Black; } - Engine.AudioManager.PlayStream(Properties.Resources.typesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound)); formatProgress++; Thread.Sleep(175); } @@ -135,14 +135,16 @@ namespace ShiftOS.WinForms { Console.WriteLine("Creating: " + dir); Thread.Sleep(125); - Engine.AudioManager.PlayStream(Properties.Resources.writesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.writesound)); } } Console.WriteLine(); Console.WriteLine("Next, let's get user information."); Console.WriteLine(); - ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); - + Desktop.InvokeOnWorkerThread(() => + { + ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); + }); } private static bool isValid(string text, string chars) { diff --git a/ShiftOS.WinForms/UniteLoginDialog.cs b/ShiftOS.WinForms/UniteLoginDialog.cs index 4c85005..c78e987 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -59,7 +60,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs index a46a9b0..7d0fd33 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using ShiftOS.Engine; using Newtonsoft.Json; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -99,7 +100,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index e635a7a..31db58a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -131,7 +131,7 @@ namespace ShiftOS.Engine try { - ServerManager.Initiate("secondary4162.cloudapp.net", 13370); + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); //This haults the client until the connection is successful. while (ServerManager.thisGuid == new Guid()) { diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs index 1136b5c..8d6a58d 100644 --- a/ShiftOS_TheReturn/UniteClient.cs +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -5,13 +5,20 @@ using System.Net; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using ShiftOS.Objects; namespace ShiftOS.Unite { public class UniteClient { public string Token { get; private set; } - public string BaseURL { get; private set; } + public string BaseURL + { + get + { + return UserConfig.Get().UniteUrl; + } + } public string GetDisplayNameId(string id) { @@ -25,7 +32,8 @@ namespace ShiftOS.Unite public UniteClient(string baseurl, string usertoken) { - BaseURL = baseurl; + //Handled by the servers.json file + //BaseURL = baseurl; Token = usertoken; } -- cgit v1.2.3 From bded9d1250575e6b9824be9048ac7ac8669a303b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 12 May 2017 19:17:47 -0400 Subject: ShiftOS is a hydra. You pop one bug off, 2,000 more grow in its place. --- ShiftOS.WinForms/Applications/About.Designer.cs | 10 +- ShiftOS.WinForms/Applications/About.cs | 71 +++++- ShiftOS.WinForms/AudioManager.cs | 62 +++++ ShiftOS.WinForms/Program.cs | 13 ++ ShiftOS.WinForms/Properties/Resources.Designer.cs | 110 ++++++++- ShiftOS.WinForms/Properties/Resources.resx | 39 +++- ShiftOS.WinForms/Resources/Ambient1.mp3 | Bin 0 -> 5765139 bytes ShiftOS.WinForms/Resources/Ambient2.mp3 | Bin 0 -> 5017165 bytes ShiftOS.WinForms/Resources/Ambient3.mp3 | Bin 0 -> 6948747 bytes ShiftOS.WinForms/Resources/Ambient4.mp3 | Bin 0 -> 6121813 bytes ShiftOS.WinForms/Resources/Ambient5.mp3 | Bin 0 -> 6025921 bytes ShiftOS.WinForms/Resources/Ambient6.mp3 | Bin 0 -> 5303077 bytes ShiftOS.WinForms/Resources/Ambient7.mp3 | Bin 0 -> 8237719 bytes ShiftOS.WinForms/Resources/Ambient8.mp3 | Bin 0 -> 8077862 bytes ShiftOS.WinForms/Resources/Ambient9.mp3 | Bin 0 -> 3859193 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 + ShiftOS_TheReturn/AppearanceManager.cs | 2 +- ShiftOS_TheReturn/AudioManager.cs | 9 +- ShiftOS_TheReturn/Commands.cs | 1 - ShiftOS_TheReturn/SaveSystem.cs | 15 ++ ShiftOS_TheReturn/TerminalBackend.cs | 269 +++++++++++----------- 21 files changed, 435 insertions(+), 175 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/Ambient1.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient2.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient3.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient4.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient5.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient6.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient7.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient8.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient9.mp3 (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Applications/About.Designer.cs b/ShiftOS.WinForms/Applications/About.Designer.cs index ab76eab..989d79b 100644 --- a/ShiftOS.WinForms/Applications/About.Designer.cs +++ b/ShiftOS.WinForms/Applications/About.Designer.cs @@ -55,7 +55,7 @@ namespace ShiftOS.WinForms.Applications this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); this.lbshiftit = new System.Windows.Forms.Label(); - this.lbaboutdesc = new System.Windows.Forms.Label(); + this.lbaboutdesc = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -94,11 +94,11 @@ namespace ShiftOS.WinForms.Applications this.lbaboutdesc.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.lbaboutdesc.Location = new System.Drawing.Point(14, 126); + this.lbaboutdesc.Location = new System.Drawing.Point(23, 158); + this.lbaboutdesc.Multiline = true; this.lbaboutdesc.Name = "lbaboutdesc"; - this.lbaboutdesc.Size = new System.Drawing.Size(498, 328); + this.lbaboutdesc.Size = new System.Drawing.Size(492, 302); this.lbaboutdesc.TabIndex = 3; - this.lbaboutdesc.Text = "label2"; // // About // @@ -121,6 +121,6 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lbshiftit; - private System.Windows.Forms.Label lbaboutdesc; + private System.Windows.Forms.TextBox lbaboutdesc; } } diff --git a/ShiftOS.WinForms/Applications/About.cs b/ShiftOS.WinForms/Applications/About.cs index f91e0cc..a27238d 100644 --- a/ShiftOS.WinForms/Applications/About.cs +++ b/ShiftOS.WinForms/Applications/About.cs @@ -53,18 +53,73 @@ namespace ShiftOS.WinForms.Applications lbaboutdesc.Text = $@"ShiftOS Copyright (c) 2015-{DateTime.Now.Year} Michael VanOverbeek and ShiftOS devs -Engine version: Milestone 3, 1.0 Beta Series (Developer mode ON) -Frontend version: 1.0 Beta 1.2 -Multi-user domain version: 1.0 Rolling-Release - -Music courtesy of Selulance. Listen to the Fractal Forest album here: -https://www.youtube.com/watch?v=LB5jAYDL3VU&t=913s +Engine version: Milestone 4, 1.0 Beta Series (Developer mode ON) +Frontend version: 1.0 Beta 2.5 +Digital Society version: 1.0 Rolling-Release +Project: Unite version: 1.0 Beta 1.7 Special thanks to Philip Adams, the original creator of ShiftOS for helping us grow our community of amazing Shifters by featuring us on the YouTube Millionaire series and advertising us throughout various other series ran by him. Also, thanks to Rylan Arbour, Victor Tran and the other community moderators and administrators for helping us keep the community peaceful. -Lastly, a huge special thanks to the community themselves - for testing, debugging, fixing, reporting bugs for, and enjoying our game even through its many failures, successes, revamps, etc. You guys are the reason we develop the game!"; +Lastly, a huge special thanks to the community themselves - for testing, debugging, fixing, reporting bugs for, and enjoying our game even through its many failures, successes, revamps, etc. You guys are the reason we develop the game! + + === Licensing information + +ShiftOS is licensed under the MIT license. + +Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the ""Software""), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is + +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + == Credit where credit is due + + -- Development and staff team: + - Rylan Arbour (Lead community administrator) + - Victor Tran (Discord administrator) + - cjhannah (ShiftFS backend developer) + - AShifter (Project: Unite penetration tester) + - arencllc (ShiftLetters developer) + - Michael VanOverbeek (Lead developer, system administrator, the guy who wrote this text) + - fixylol, Nebble, TravisNC, Neptune (Community moderators) + - bandic00t_ (Skin Engine stresstesting) + + -- System audio + + - Default system event sounds (Infobox, Network Connecting, System Beeps) are from the original ShiftOS 0.0.x source code. + - Ambient music list courtesy of https://www.youtube.com/channel/UC56Qctnsu8wAyvzf4Yx6LIw (ArgoFox | Royalty Free Music) + +Tracklist: + + Dylan Hardy - Strangely Unaffected +Noxive - Home +Dylan Hardy and Abraham Alberto - Slow Drift +A Himitsu - Easier To Fade +Noxive - Resilience +Wanderflux - Visions +Aerocity - Cold Weather Kids +Aether - Wanderlust +Aerocity - Love Lost + + +Finally, special thanks to our Patreon supporters. Without you guys, our servers wouldn't be running, and you wouldn't be reading this."; } public string GetEngineVersion() @@ -107,7 +162,7 @@ Lastly, a huge special thanks to the community themselves - for testing, debuggi public bool OnUnload() { - return false; + return true; } public void OnUpgrade() diff --git a/ShiftOS.WinForms/AudioManager.cs b/ShiftOS.WinForms/AudioManager.cs index 5c43ac4..eb0e798 100644 --- a/ShiftOS.WinForms/AudioManager.cs +++ b/ShiftOS.WinForms/AudioManager.cs @@ -24,8 +24,10 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace ShiftOS.WinForms @@ -37,5 +39,65 @@ namespace ShiftOS.WinForms { } + + internal static byte[] GetRandomSong() + { + var r = new Random().Next(1, 10); + switch (r) + { + case 1: + return Properties.Resources.Ambient1; + case 2: + return Properties.Resources.Ambient2; + case 3: + return Properties.Resources.Ambient3; + case 4: + return Properties.Resources.Ambient4; + case 5: + return Properties.Resources.Ambient5; + case 6: + return Properties.Resources.Ambient6; + case 7: + return Properties.Resources.Ambient7; + case 8: + return Properties.Resources.Ambient8; + default: + return Properties.Resources.Ambient9; + + } + } + + internal static void StartAmbientLoop() + { + var athread = new Thread(() => + { + MemoryStream str = null; + NAudio.Wave.Mp3FileReader mp3 = null; + NAudio.Wave.WaveOut o = null; + while (!Engine.SaveSystem.ShuttingDown) + { + str = new MemoryStream(GetRandomSong()); + mp3 = new NAudio.Wave.Mp3FileReader(str); + o = new NAudio.Wave.WaveOut(); + o.Init(mp3); + bool c = false; + o.Play(); + o.PlaybackStopped += (s, a) => + { + c = true; + }; + while (!c) + Thread.Sleep(10); + str.Dispose(); + o.Dispose(); + mp3.Dispose(); + } + str?.Dispose(); + o?.Dispose(); + mp3?.Dispose(); + }); + athread.IsBackground = true; + athread.Start(); + } } } diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index ad8fc83..256894d 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,19 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + SaveSystem.PreDigitalSocietyConnection += () => + { + Action completed = null; + completed = () => + { + SaveSystem.Ready = true; + Engine.AudioManager.PlayCompleted -= completed; + AudioManager.StartAmbientLoop(); + }; + Engine.AudioManager.PlayCompleted += completed; + Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02); + + }; LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index caaf503..0152be8 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -69,6 +69,96 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient1 { + get { + object obj = ResourceManager.GetObject("Ambient1", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient2 { + get { + object obj = ResourceManager.GetObject("Ambient2", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient3 { + get { + object obj = ResourceManager.GetObject("Ambient3", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient4 { + get { + object obj = ResourceManager.GetObject("Ambient4", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient5 { + get { + object obj = ResourceManager.GetObject("Ambient5", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient6 { + get { + object obj = ResourceManager.GetObject("Ambient6", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient7 { + get { + object obj = ResourceManager.GetObject("Ambient7", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient8 { + get { + object obj = ResourceManager.GetObject("Ambient8", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient9 { + get { + object obj = ResourceManager.GetObject("Ambient9", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -994,22 +1084,18 @@ namespace ShiftOS.WinForms.Properties { /// /// Looks up a localized string similar to [ - /// //TEMPORARY - /// { - /// Name: "Desktop Widgets", - /// Cost: 0, - /// Description: "Temporary upgrade. Will be replaced by either a Shiftnet app or a story element.", - /// Dependencies: "advanced_app_launcher;wm_free_placement", - /// Category: "Work-in-progress" - /// }, - /// - /// - /// ///// SCREENSAVER /// { /// Name: "Screensavers", /// Cost: 750, - /// Description: "Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it." [rest of string was truncated]";. + /// Description: "Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it.", + /// Dependencies: "desktop", + /// Category: "Enhancements", + /// }, + /// { + /// Name: "GUI Based Login Screen", + /// Cost: 500, + /// Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, w [rest of string was truncated]";. /// internal static string Shiftorium { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 688bcac..a90e69b 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -122,7 +122,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAJKjAACSowAAAAEAAQoPAgAAAJKjAAACUklGRoqjAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAAkqMAAJKjAACSowAAAAEAAQoPAgAAAJKjAAACUklGRoqjAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YWajAAABAP7/AgD9/wMA/f8DAPz/BAD8/wQA/f8BAP//AAABAAAA//8C AP3/BAD9/wIAAAD//wIA//8BAAAAAAABAP//AQAAAAEAAAACAP7/AQABAAAAAQAAAAEAAAACAP7/AwD+ /wIAAAD//wIA/v8DAP7/AwD9/wMA//8AAAIA/f8DAAAA//8BAAAA/v8CAP////8CAPz/BAD8/wMA/f8A @@ -838,7 +838,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAEwYAABMGAAAAAEAAQoPAgAAAEwYAAACUklGRkQYAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAATBgAAEwYAABMGAAAAAEAAQoPAgAAAEwYAAACUklGRkQYAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YSAYAAD/X5Vil2TRZUJmF2ZLZadjS2FqXt9aj1awUVtMc0b4PyQ57DFS KmUiSxoDEo4JEQGO+Bzwweee35zX9c+pyK7BGLsYtZqvlqoipneiW5/YnBCbFZq3mfOZEJvknD6fSqIg poaqcK/rtAq7i8FvyMrPgNdo347n7e9h+N8AXwnPERoaQSIlKrcx+zjmP0lGKUykUYJWs1pKXlJhpWMl @@ -964,7 +964,7 @@ ..\Resources\SweeperNormalFace.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\strings_en.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + ..\Resources\strings_en.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;iso-8859-1 ..\Resources\SweeperTile5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -974,7 +974,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAPwBHgD8AR4AAAEAAQoPAgAAAPwBHgACUklGRvQBHgBXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAA/AEeAPwBHgD8AR4AAAEAAQoPAgAAAPwBHgACUklGRvQBHgBXQVZFZm10IBAAAAAB AAIAgLsAAADuAgAEABAATElTVBQAAABJTkZPSUFSVAgAAABQaGlsaXAAAGRhdGG0AR4A//8CAAwA5v8a APT/8P8sAMf/OADX/xoA5v8bAPL/8/8aAOb/DQAOANb/KgDk/w4AAQDh/zwAt/9HAMj/GwACAPH/DgDy /w0AAQDy/xwA1f8sAO//5v84ALn/OQDk//7/AwD+/xAA4v8dANX/LADw//T/GgDl/w4AAADx/x4A4f8R @@ -33831,7 +33831,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAPBWAADwVgAAAAEAAQoPAgAAAPBWAAACUklGRuhWAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAA8FYAAPBWAADwVgAAAAEAAQoPAgAAAPBWAAACUklGRuhWAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YcRWAAAAAGQL6gtkDL8MEA3kDLUMaAwUDKULKwuYCvcJQAl4CJ0Hrwaw BaAEfgNQAg4Bwf9p/v/8mfsn+rD4OPe59T/0wPJH8dPvYu7+7JzrTeoG6dLnreaX5Z/kruPl4jHinOEk 4cTgh+Bl4GLgguDC4B7hpeFC4g3j7uP35B/mZufO6FXq9eu67ZHviPGT87L15/cr+oL84f5QAcMDPwa9 @@ -34456,7 +34456,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAIwWAACMFgAAAAEAAQoPAgAAAIwWAAACUklGRoQWAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAAjBYAAIwWAACMFgAAAAEAAQoPAgAAAIwWAAACUklGRoQWAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YWAWAAAAAKYLIxdYIhQtQjexQFBJ81CUVwddTmFLZP9lXmZqZSRjl1/J WtFUu02mRao84jJzKHsdJRKPBub6TO/q4+XYZM6FxG67ObMCrOel8aA9ncuar5nimWybQZ5eoq+nKa6t tTC+hcec0U3cbefr8on+MQq6FfQgxSsFNo8/R0gRUMpWblzSYAFk2WVlZpxlfmMbYHJboVWsTrdG1D0l @@ -34573,4 +34573,31 @@ ..\Resources\SuperDesk screenshot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Ambient1.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient2.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient3.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient4.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient5.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient6.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient7.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient8.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient9.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/Ambient1.mp3 b/ShiftOS.WinForms/Resources/Ambient1.mp3 new file mode 100644 index 0000000..d623b29 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient1.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient2.mp3 b/ShiftOS.WinForms/Resources/Ambient2.mp3 new file mode 100644 index 0000000..b16e72f Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient2.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient3.mp3 b/ShiftOS.WinForms/Resources/Ambient3.mp3 new file mode 100644 index 0000000..cf06069 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient3.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient4.mp3 b/ShiftOS.WinForms/Resources/Ambient4.mp3 new file mode 100644 index 0000000..7813b4f Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient4.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient5.mp3 b/ShiftOS.WinForms/Resources/Ambient5.mp3 new file mode 100644 index 0000000..521330e Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient5.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient6.mp3 b/ShiftOS.WinForms/Resources/Ambient6.mp3 new file mode 100644 index 0000000..86cb4a4 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient6.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient7.mp3 b/ShiftOS.WinForms/Resources/Ambient7.mp3 new file mode 100644 index 0000000..9c5047a Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient7.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient8.mp3 b/ShiftOS.WinForms/Resources/Ambient8.mp3 new file mode 100644 index 0000000..ac908b6 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient8.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient9.mp3 b/ShiftOS.WinForms/Resources/Ambient9.mp3 new file mode 100644 index 0000000..46cb670 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient9.mp3 differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 411d701..1079203 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -757,6 +757,15 @@ + + + + + + + + + diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 4c1754e..42642f8 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -223,9 +223,9 @@ namespace ShiftOS.Engine ///
internal static void Exit() { - OnExit?.Invoke(); //disconnect from MUD ServerManager.Disconnect(); + Environment.Exit(0); } /// diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index a636497..c50bd24 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -47,9 +47,12 @@ namespace ShiftOS.Engine /// public static void Stop() { - _out?.Stop(); - _reader?.Dispose(); - _out?.Dispose(); + Desktop.InvokeOnWorkerThread(() => + { + _out?.Stop(); + _reader?.Dispose(); + _out?.Dispose(); + }); } /// diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index dc0b3a2..d622bb9 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -366,7 +366,6 @@ namespace ShiftOS.Engine public static bool Shutdown() { TerminalBackend.InvokeCommand("sos.save"); - SaveSystem.ShuttingDown = true; AppearanceManager.Exit(); return true; } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 31db58a..948f95e 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -52,6 +52,9 @@ namespace ShiftOS.Engine public static ClientSave CurrentUser { get; set; } + public static bool Ready = false; + + public static event Action PreDigitalSocietyConnection; public static Save CurrentSave { get; set; } @@ -118,6 +121,18 @@ namespace ShiftOS.Engine Console.WriteLine("[inetd] Connecting to network..."); + Ready = false; + + if (PreDigitalSocietyConnection != null) + { + PreDigitalSocietyConnection?.Invoke(); + + while (!Ready) + { + Thread.Sleep(10); + } + } + if (defaultConf.ConnectToMud == true) { bool guidReceived = false; diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 9c57aa8..086ff40 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -213,211 +213,201 @@ namespace ShiftOS.Engine { if (Shiftorium.UpgradeAttributesUnlocked(method)) { - if (CanRunRemotely(method, isRemote)) + foreach (var ma in method.GetCustomAttributes(false)) { - foreach (var ma in method.GetCustomAttributes(false)) + if (ma is Command) { - if (ma is Command) + var cmd = ma as Command; + if (text.Split('.')[1] == cmd.name) { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) + if (KernelWatchdog.IsSafe(method)) { - if (KernelWatchdog.IsSafe(method)) + if (KernelWatchdog.CanRunOffline(method)) { - if (KernelWatchdog.CanRunOffline(method)) - { - var attr = method.GetCustomAttribute(); + var attr = method.GetCustomAttribute(); - if (attr != null) + if (attr != null) + { + string newcommand = attr.newcommand; + if (attr.warn) { - string newcommand = attr.newcommand; - if (attr.warn) - { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { + Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { {"%newcommand", newcommand} })); - } - if (newcommand != "") - { - // redo the entire process running newcommand + } + if (newcommand != "") + { + // redo the entire process running newcommand - return RunClient(newcommand, args); - } + return RunClient(newcommand, args); } + } - var requiresArgs = method.GetCustomAttributes(); - bool error = false; - bool providedusage = false; + var requiresArgs = method.GetCustomAttributes(); + bool error = false; + bool providedusage = false; - foreach (RequiresArgument argument in requiresArgs) + foreach (RequiresArgument argument in requiresArgs) + { + if (!args.ContainsKey(argument.argument)) { - if (!args.ContainsKey(argument.argument)) - { - if (!providedusage) - { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { + if (!providedusage) + { + string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; + if (usageparse == Localization.Parse(usageparse)) + usageparse = ""; + else + usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { {"%ns", ns.name}, {"%cmd", cmd.name} }) : ""; - Console.WriteLine(usageparse); + Console.WriteLine(usageparse); - providedusage = true; - } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { + providedusage = true; + } + if (Shiftorium.UpgradeInstalled("help_usage")) + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { {"%argument", argument.argument} })); - } - else - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); - } - - error = true; } - } + else + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + } - if (error) - { - throw new Exception("{ERROR_COMMAND_WRONG}"); + error = true; } + } - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); - return true; - } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } + if (error) + { + throw new Exception("{ERROR_COMMAND_WRONG}"); + } + + try + { + return (bool)method.Invoke(null, new[] { args }); } - else + catch (TargetInvocationException e) { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); + Console.WriteLine(e.InnerException.Message); + Console.WriteLine(e.InnerException.StackTrace); return true; - + } + catch + { + return (bool)method.Invoke(null, new object[] { }); } } else { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } Console.Write("<"); ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); + Console.Write("session_mgr"); ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; ConsoleEx.Bold = false; Console.Write(">"); ConsoleEx.Italic = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); + Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + return true; + + } + } + else + { + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) + { + Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => + { + if (pass == SaveSystem.CurrentUser.Password) + { + KernelWatchdog.EnterKernelMode(); + RunClient(text, args, isRemote); + KernelWatchdog.LeaveKernelMode(); + } + else + { + Infobox.Show("Access denied.", "You did not type in the correct password."); + } + }, true); return true; } + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("watchdog"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); + KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); + return true; } } + } - } } } + else { - Console.WriteLine(text + " cannot be ran in a remote session"); + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("session_mgr"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); return true; - } - } - - } + } + } + } else { + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) + { + Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => + { + if (pass == SaveSystem.CurrentUser.Password) + { + KernelWatchdog.EnterKernelMode(); + RunClient(text, args, isRemote); + KernelWatchdog.LeaveKernelMode(); + } + else + { + Infobox.Show("Access denied.", "You did not type in the correct password."); + } + }, true); + return true; + } Console.Write("<"); ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); + Console.Write("watchdog"); ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; ConsoleEx.Bold = false; Console.Write(">"); ConsoleEx.Italic = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); + KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); return true; - } - - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; } } } @@ -429,6 +419,7 @@ namespace ShiftOS.Engine } return false; } + public static void PrintPrompt() { if (SaveSystem.CurrentSave != null && CurrentUser != null) -- cgit v1.2.3 From fc6563651389b54f2dca0090218430d774c8de38 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 May 2017 07:58:18 -0400 Subject: Document SaveSystem. --- ShiftOS_TheReturn/SaveSystem.cs | 65 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 948f95e..9c812c7 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -39,6 +39,7 @@ using static System.Net.Mime.MediaTypeNames; namespace ShiftOS.Engine { + [Obsolete("Use the servers.conf file instead.")] public class EngineConfig { public bool ConnectToMud = true; @@ -46,16 +47,34 @@ namespace ShiftOS.Engine public int MudDefaultPort = 13370; } + /// + /// Management class for the ShiftOS save system. + /// public static class SaveSystem { + /// + /// Boolean representing whether the system is shutting down. + /// public static bool ShuttingDown = false; + /// + /// Gets or sets the current logged in client-side user. + /// public static ClientSave CurrentUser { get; set; } + /// + /// Boolean representing whether the save system is ready to be used. + /// public static bool Ready = false; + /// + /// Occurs before the save system connects to the ShiftOS Digital Society. + /// public static event Action PreDigitalSocietyConnection; + /// + /// Gets or sets the current server-side save file. + /// public static Save CurrentSave { get; set; } /// @@ -182,7 +201,10 @@ namespace ShiftOS.Engine thread.Start(); } - public static void FinishBootstrap() + /// + /// Finish bootstrapping the engine. + /// + private static void FinishBootstrap() { KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); @@ -391,8 +413,14 @@ namespace ShiftOS.Engine GameReady?.Invoke(); } + /// + /// Delegate type for events with no caller objects or event arguments. You can use the () => {...} (C#) lambda expression with this delegate + /// public delegate void EmptyEventHandler(); + /// + /// Gets a list of all client-side users. + /// public static List Users { get @@ -401,20 +429,35 @@ namespace ShiftOS.Engine } } + /// + /// Occurs when the engine is loaded and the game can take over. + /// public static event EmptyEventHandler GameReady; + /// + /// Deducts a set amount of Codepoints from the save file... and sends them to a place where they'll never be seen again. + /// + /// The amount of Codepoints to deduct. public static void TransferCodepointsToVoid(long amount) { + if (amount < 0) + throw new ArgumentOutOfRangeException("We see what you did there. Trying to pull Codepoints from the void? That won't work."); CurrentSave.Codepoints -= amount; NotificationDaemon.AddNotification(NotificationType.CodepointsSent, amount); } + /// + /// Restarts the game. + /// public static void Restart() { TerminalBackend.InvokeCommand("sos.shutdown"); System.Windows.Forms.Application.Restart(); } + /// + /// Requests the save file from the server. If authentication fails, this will cause the user to be prompted for their website login and a new save will be created if none is associated with the login. + /// public static void ReadSave() { //Migrate old saves. @@ -458,6 +501,9 @@ namespace ShiftOS.Engine } + /// + /// Creates a new save, starting the Out Of Box Experience (OOBE). + /// public static void NewSave() { AppearanceManager.Invoke(new Action(() => @@ -470,6 +516,9 @@ namespace ShiftOS.Engine })); } + /// + /// Saves the game to the server, updating website stats if possible. + /// public static void SaveGame() { if(!Shiftorium.Silent) @@ -486,15 +535,29 @@ namespace ShiftOS.Engine System.IO.File.WriteAllText(Paths.SaveFile, Utils.ExportMount(0)); } + /// + /// Transfers codepoints from an arbitrary character to the save file. + /// + /// The character name + /// The amount of Codepoints. public static void TransferCodepointsFrom(string who, long amount) { + if (amount < 0) + throw new ArgumentOutOfRangeException("We see what you did there... You can't just give a fake character Codepoints like that. It's better if you transfer them to the void."); NotificationDaemon.AddNotification(NotificationType.CodepointsReceived, amount); CurrentSave.Codepoints += amount; } } + /// + /// Delegate for handling Terminal text input. + /// + /// The text inputted by the user (including prompt text). public delegate void TextSentEventHandler(string text); + /// + /// Denotes that this Terminal command or namespace is for developers. + /// public class DeveloperAttribute : Attribute { -- cgit v1.2.3 From 8e345174ee0796084c542681208c57fa8f962f61 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 24 May 2017 16:41:49 -0400 Subject: Dramatically increase terminal performance. --- ShiftOS.WinForms/Controls/TerminalBox.cs | 2 + ShiftOS_TheReturn/Commands.cs | 133 ++------- ShiftOS_TheReturn/KernelWatchdog.cs | 34 +-- ShiftOS_TheReturn/SaveSystem.cs | 3 +- ShiftOS_TheReturn/Shiftorium.cs | 2 + ShiftOS_TheReturn/TerminalBackend.cs | 496 ++++++++++++++++--------------- 6 files changed, 302 insertions(+), 368 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index e95d038..a6dd610 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -63,6 +63,7 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { + Thread.Sleep(5); this.SuspendLayout(); this.HideSelection = true; this.SelectionFont = ConstructFont(); @@ -88,6 +89,7 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { + Thread.Sleep(5); this.SuspendLayout(); Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index c2005f2..96e5af5 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -330,8 +330,13 @@ namespace ShiftOS.Engine { foreach (var upg in Shiftorium.GetDefaults()) { - Shiftorium.Buy(upg.ID, 0); + if (!SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.ID)) + SaveSystem.CurrentSave.Upgrades.Add(upg.ID, true); + else + SaveSystem.CurrentSave.Upgrades[upg.ID] = true; } + Shiftorium.InvokeUpgradeInstalled(); + SkinEngine.LoadSkin(); return true; } @@ -453,122 +458,40 @@ namespace ShiftOS.Engine [Command("help", "{COMMAND_HELP_USAGE", "{COMMAND_HELP_DESCRIPTION}")] public static bool Help(Dictionary args) { - Console.WriteLine("Retrieving help data..."); + var sb = new StringBuilder(); + sb.AppendLine("Retrieving help data."); + if (args.ContainsKey("ns")) { - if (args["ns"] is string) + string ns = args["ns"].ToString(); + //First let's check for a command that has this namespace. + var cmdtest = TerminalBackend.Commands.FirstOrDefault(x => x.NamespaceInfo.name == ns); + if (cmdtest == null) //Namespace not found. + sb.AppendLine("Error retrieving help for namespace \"" + ns + "\". Namespace not found."); + else { - string ns = args["ns"].ToString(); - bool foundNS = false; - foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + //Now do the actual scan. + sb.AppendLine("Namespace: " + ns); + foreach(var cmd in TerminalBackend.Commands.Where(x => x.NamespaceInfo.name == ns)) { - if (exec.EndsWith(".exe") || exec.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(exec); - - var types = asm.GetTypes(); - - foreach (var type in types) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - var nsa = (Namespace)type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace && (x as Namespace).name == ns); - - if (nsa != null) - { - - if (!nsa.hide) - { - foundNS = true; - string descp = "{NAMESPACE_" + nsa.name.ToUpper() + "_DESCRIPTION}"; - if (descp == Localization.Parse(descp)) - descp = ""; - else - descp = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descp) : ""; - - Console.WriteLine($"{{NAMESPACE}}{nsa.name}" + descp); - - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (Shiftorium.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - - if (!cmd.hide) - { - string descriptionparse = "{COMMAND_" + nsa.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}"; - string usageparse = "{COMMAND_" + nsa.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (descriptionparse == Localization.Parse(descriptionparse)) - descriptionparse = ""; - else - descriptionparse = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descriptionparse) : ""; - - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{SEPERATOR}" + usageparse, new Dictionary() { - {"%ns", nsa.name}, - {"%cmd", cmd.name} - }) : ""; - - Console.WriteLine($"{{COMMAND}}{nsa.name}.{cmd.name}" + usageparse + descriptionparse); - } - } - } - } - - } - } - } - } - } - - } - - - - - catch { } - } + string str = cmd.ToString(); + str = str.Replace(str.Substring(str.LastIndexOf("|")), ""); + sb.AppendLine(str); } - if (foundNS == false) - { - Console.WriteLine("Error: Namespace not found! Couldn't retrieve help info."); - } - } - return true; } - - foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + else { - if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + + //print all unique namespaces. + foreach(var n in TerminalBackend.Commands.Select(x => x.NamespaceInfo.name).Distinct()) { - try - { - var asm = Assembly.LoadFile(exec); - foreach(var type in asm.GetTypes()) - { - Namespace ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace; - if(ns != null) - { - if(!ns.hide) - { - Console.WriteLine("sos.help{ns:\"" + ns.name + "\"}"); - } - } - } - } - catch { } + sb.AppendLine("sos.help{ns:\"" + n + "\"}"); } } + Console.WriteLine(sb.ToString()); + return true; } diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs index 66ec1f7..0608c46 100644 --- a/ShiftOS_TheReturn/KernelWatchdog.cs +++ b/ShiftOS_TheReturn/KernelWatchdog.cs @@ -66,41 +66,19 @@ namespace ShiftOS.Engine } } - //determines if user is root - public static bool IsSafe(Type type) + public static bool IsSafe(TerminalBackend.TerminalCommand cmd) { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) + if (!cmd.RequiresElevation) return true; - - foreach (var attrib in type.GetCustomAttributes(false)) + else { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) + return true; + else return false; - } } - return true; } - //also determines if user is root, only for a method instead - public static bool IsSafe(MethodInfo type) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - - foreach (var attrib in type.GetCustomAttributes(false)) - { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - return false; - } - } - return true; - } static string regularUsername = ""; //put regular username in here later diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 9c812c7..d74006a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -137,7 +137,8 @@ namespace ShiftOS.Engine Thread.Sleep(100); Console.WriteLine("[sfs] 4096 blocks read."); Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); - + Console.WriteLine("[termdb] Building command database from filesystem..."); + TerminalBackend.PopulateTerminalCommands(); Console.WriteLine("[inetd] Connecting to network..."); Ready = false; diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index fe436d4..0ac784e 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -312,6 +312,8 @@ namespace ShiftOS.Engine /// Whether the upgrade is installed. public static bool UpgradeInstalled(string id) { + if (string.IsNullOrWhiteSpace(id)) + return true; if (SaveSystem.CurrentSave != null) { if (!IsInitiated) diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 79c6349..6a15d3e 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; @@ -136,6 +137,218 @@ namespace ShiftOS.Engine return JsonConvert.SerializeObject(args); } + public class TerminalCommand + { + public override int GetHashCode() + { + int hash = 0; + foreach (char c in ToString()) + { + hash += (int)c; + } + return hash; + } + + public Namespace NamespaceInfo { get; set; } + public Command CommandInfo { get; set; } + + public List RequiredArguments { get; set; } + public string Dependencies { get; set; } + + public MethodInfo CommandHandler; + + public Type CommandType; + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append(this.NamespaceInfo.name); + sb.Append("."); + sb.Append(this.CommandInfo.name); + if (this.RequiredArguments.Count > 0) + { + sb.Append("{"); + foreach (var arg in RequiredArguments) + { + sb.Append(arg); + sb.Append(":"); + if (RequiredArguments.IndexOf(arg) < RequiredArguments.Count - 1) + sb.Append(','); + } + sb.Append("}"); + } + sb.Append("|"); + sb.Append(CommandHandler.Name + "()"); + return sb.ToString(); + } + + public bool RequiresElevation { get; set; } + + public void Invoke(Dictionary args) + { + List errors = new List(); + bool requiresAuth = false; + if (!KernelWatchdog.IsSafe(this)) + { + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) + requiresAuth = true; + else + errors.Add("You can't run this command - you do not have permission."); + } + if (errors.Count > 0) + { + foreach (var error in errors) + { + Console.WriteLine("Command error: " + error); + } + return; + } + if (requiresAuth) + { + Infobox.PromptText("Enter your password.", "This command requires you to have elevated permissions. Please enter your password to confirm this action.", (pass) => + { + if (pass == SaveSystem.CurrentUser.Password) + { + var uname = SaveSystem.CurrentUser.Username; + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); + try + { + var h = CommandHandler; + h.Invoke(null, new[] { args }); + } + catch + { + var h = CommandHandler; + h.Invoke(null, null); + } + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == uname); + } + else + { + Infobox.Show("Access denied.", "Incorrect password provided. The command will not run."); + } + }, true); + } + + try + { + CommandHandler.Invoke(null, new[] { args }); + } + catch + { + CommandHandler.Invoke(null, null); + } + } + } + + public class MemoryTextWriter : System.IO.TextWriter + { + public override Encoding Encoding + { + get + { + return Encoding.Unicode; + } + } + + private StringBuilder sb = null; + + public MemoryTextWriter() + { + sb = new StringBuilder(); + } + + public override string ToString() + { + return sb.ToString(); + } + + public override void Write(char value) + { + sb.Append(value); + } + + public override void WriteLine() + { + sb.AppendLine(); + } + + public override void Write(string value) + { + sb.Append(value); + } + + public override void Close() + { + sb.Clear(); + sb = null; + base.Close(); + } + + public override void WriteLine(string value) + { + sb.AppendLine(value); + } + } + + public static List Commands { get; private set; } + + public static void PopulateTerminalCommands() + { + Commands = new List(); + foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes()) + { + var ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace; + if(ns != null) + { + foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + { + var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command); + if(cmd != null) + { + var tc = new TerminalCommand(); + tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + + tc.NamespaceInfo = ns; + + tc.CommandInfo = cmd as Command; + tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + tc.RequiredArguments = new List(); + foreach (var arg in mth.GetCustomAttributes(false).Where(x=>x is RequiresArgument)) + { + var rarg = arg as RequiresArgument; + tc.RequiredArguments.Add(rarg.argument); + } + var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; + if (rupg != null) + tc.Dependencies = rupg.Upgrade; + else + tc.Dependencies = ""; + tc.CommandType = type; + tc.CommandHandler = mth; + if (!Commands.Contains(tc)) + Commands.Add(tc); + } + } + } + } + } + catch(Exception e) + { + Console.WriteLine("[termdb] Error: " + e.ToString()); + } + } + } + Console.WriteLine("[termdb] " + Commands.Count + " commands found."); + } + /// /// Invokes a ShiftOS terminal command. /// @@ -150,19 +363,27 @@ namespace ShiftOS.Engine var args = GetArgs(ref text); + Stopwatch debugger = new Stopwatch(); + debugger.Start(); bool commandWasClient = RunClient(text, args, isRemote); if (!commandWasClient) { - PrefixEnabled = false; - - ServerManager.SendMessage("script", $@"{{ - user: ""{text.Split('.')[0]}"", - script: ""{text.Split('.')[1]}"", - args: ""{GetSentArgs(args)}"" -}}"); + Console.WriteLine("Command not found."); + debugger.Stop(); + return; } CommandProcessed?.Invoke(text, GetSentArgs(args)); + debugger.Stop(); + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Blue; + Console.Write("debugger"); + ConsoleEx.ForegroundColor = ConsoleColor.White; + ConsoleEx.Bold = false; + Console.Write("> "); + Console.WriteLine("Command " + text + " took " + debugger.Elapsed.ToString() + " to execute."); } catch (Exception ex) { @@ -263,237 +484,44 @@ namespace ShiftOS.Engine //Console.WriteLine(text + " " + "{" + string.Join(",", args.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}" + " " + isRemote); - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + var tw = new MemoryTextWriter(); + Console.SetOut(tw); + + string[] split = text.Split('.'); + var cmd = Commands.FirstOrDefault(x => x.NamespaceInfo.name == split[0] && x.CommandInfo.name == split[1]); + if (cmd == null) + return false; + if (!Shiftorium.UpgradeInstalled(cmd.Dependencies)) + return false; + if(cmd.RequiredArguments.Count != args.Count) { - try + Console.WriteLine("Command error: Argument count mismatch! You supplied " + args.Count + " arguments to a command that expects " + cmd.RequiredArguments.Count + "."); + return true; + } + bool res = false; + foreach (var arg in cmd.RequiredArguments) + { + if (!args.ContainsKey(arg)) { - var asm = Assembly.LoadFile(asmExec); - - var types = asm.GetTypes(); - foreach (var type in types) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - foreach (var a in type.GetCustomAttributes(false)) - { - if (a is Namespace) - { - var ns = a as Namespace; - if (text.Split('.')[0] == ns.name) - { - if (KernelWatchdog.IsSafe(type)) - { - if (KernelWatchdog.CanRunOffline(type)) - { - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (Shiftorium.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) - { - if (KernelWatchdog.IsSafe(method)) - { - if (KernelWatchdog.CanRunOffline(method)) - { - var attr = method.GetCustomAttribute(); - - if (attr != null) - { - string newcommand = attr.newcommand; - if (attr.warn) - { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { - {"%newcommand", newcommand} - })); - } - if (newcommand != "") - { - // redo the entire process running newcommand - - return RunClient(newcommand, args); - } - } - - var requiresArgs = method.GetCustomAttributes(); - bool error = false; - bool providedusage = false; - - foreach (RequiresArgument argument in requiresArgs) - { - if (!args.ContainsKey(argument.argument)) - { - - if (!providedusage) - { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { - {"%ns", ns.name}, - {"%cmd", cmd.name} - }) : ""; - - Console.WriteLine(usageparse); - - providedusage = true; - } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { - {"%argument", argument.argument} - })); - } - else - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); - } - - error = true; - } - } - - if (error) - { - throw new Exception("{ERROR_COMMAND_WRONG}"); - } - - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); - return true; - } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } - } - else - { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); - return true; - - } - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; - } - } - } - - - } - } - - else - { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); - return true; - - } - - } - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; - } - } - } - } - } - } - } + res = true; + Console.WriteLine("You are missing an argument with the key \"" + arg + "\"."); } - catch { } } - return false; + if (res == true) + return true; + try + { + cmd.Invoke(args); + } + catch(Exception ex) + { + Console.WriteLine("Command error: " + ex.Message); + } + + string buffer = tw.ToString(); + Console.SetOut(new TerminalTextWriter()); + Console.Write(buffer); + return true; } /// -- cgit v1.2.3 From dc0b8c66885593f7412e24bf7132bc08f6c40a9c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 06:44:58 -0400 Subject: Fix a bug with command-line login. --- ShiftOS.WinForms/Applications/Terminal.cs | 7 +++++++ ShiftOS_TheReturn/SaveSystem.cs | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index ea24686..4cd4806 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -269,6 +269,13 @@ namespace ShiftOS.WinForms.Applications try { a.SuppressKeyPress = true; + if (!TerminalBackend.PrefixEnabled) + { + string textraw = txt.Lines[txt.Lines.Length - 1]; + TextSent?.Invoke(textraw); + TerminalBackend.SendText(textraw); + return; + } Console.WriteLine(""); var text = txt.Lines.ToArray(); var text2 = text[text.Length - 2]; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index d74006a..f3d95be 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -349,6 +349,7 @@ namespace ShiftOS.Engine { if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) { + Console.WriteLine(); Console.WriteLine("User not found."); goback = true; progress++; @@ -360,6 +361,7 @@ namespace ShiftOS.Engine } else { + Console.WriteLine(); Console.WriteLine("Username not provided."); TerminalBackend.TextSent -= ev; goback = true; @@ -373,13 +375,14 @@ namespace ShiftOS.Engine var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); if (user.Password == getpass) { + Console.WriteLine(); Console.WriteLine("Welcome to ShiftOS."); CurrentUser = user; - Thread.Sleep(2000); progress++; } else { + Console.WriteLine(); Console.WriteLine("Access denied."); goback = true; progress++; @@ -388,7 +391,7 @@ namespace ShiftOS.Engine } }; TerminalBackend.TextSent += ev; - + Console.WriteLine(); Console.Write(CurrentSave.SystemName + " login: "); while (progress == 0) { @@ -396,6 +399,7 @@ namespace ShiftOS.Engine } if (goback) goto Login; + Console.WriteLine(); Console.Write("password: "); while (progress == 1) Thread.Sleep(10); -- cgit v1.2.3 From 8e3bdf71e71096711f11a0d51b2b384e117391ee Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 07:21:16 -0400 Subject: strip things down but make things better --- ShiftOS.WinForms/Applications/Terminal.cs | 6 ++--- ShiftOS.WinForms/Controls/TerminalBox.cs | 6 ----- ShiftOS_TheReturn/ConsoleEx.cs | 7 +++++ ShiftOS_TheReturn/SaveSystem.cs | 2 ++ ShiftOS_TheReturn/TerminalBackend.cs | 11 +++----- ShiftOS_TheReturn/TerminalTextWriter.cs | 45 ++++++++++++++++++------------- 6 files changed, 42 insertions(+), 35 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 4cd4806..6039456 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -268,7 +268,8 @@ namespace ShiftOS.WinForms.Applications { try { - a.SuppressKeyPress = true; + if (!TerminalBackend.InStory) + a.SuppressKeyPress = false; if (!TerminalBackend.PrefixEnabled) { string textraw = txt.Lines[txt.Lines.Length - 1]; @@ -276,9 +277,8 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.SendText(textraw); return; } - Console.WriteLine(""); var text = txt.Lines.ToArray(); - var text2 = text[text.Length - 2]; + var text2 = text[text.Length - 1]; var text3 = ""; var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 7658c8c..25f7144 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -64,9 +64,6 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } @@ -89,9 +86,6 @@ namespace ShiftOS.WinForms.Controls Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; } diff --git a/ShiftOS_TheReturn/ConsoleEx.cs b/ShiftOS_TheReturn/ConsoleEx.cs index 90f9cc0..74483dc 100644 --- a/ShiftOS_TheReturn/ConsoleEx.cs +++ b/ShiftOS_TheReturn/ConsoleEx.cs @@ -48,5 +48,12 @@ namespace ShiftOS.Engine /// Gets or sets whether text in the Terminal is underlined. /// public static bool Underline { get; set; } + + internal static void Flush() + { + OnFlush?.Invoke(); + } + + public static Action OnFlush; } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f3d95be..24a491d 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -393,6 +393,7 @@ namespace ShiftOS.Engine TerminalBackend.TextSent += ev; Console.WriteLine(); Console.Write(CurrentSave.SystemName + " login: "); + ConsoleEx.Flush(); while (progress == 0) { Thread.Sleep(10); @@ -401,6 +402,7 @@ namespace ShiftOS.Engine goto Login; Console.WriteLine(); Console.Write("password: "); + ConsoleEx.Flush(); while (progress == 1) Thread.Sleep(10); if (goback) diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index b18e27c..1c024eb 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -361,14 +361,12 @@ namespace ShiftOS.Engine /// Whether the command should be sent through Remote Terminal Session (RTS). public static void InvokeCommand(string text, bool isRemote = false) { + if (string.IsNullOrWhiteSpace(text)) + return; var tw = new MemoryTextWriter(); Console.SetOut(tw); try { - - if (string.IsNullOrWhiteSpace(text)) - return; - var args = GetArgs(ref text); Stopwatch debugger = new Stopwatch(); @@ -533,10 +531,9 @@ namespace ShiftOS.Engine /// public static void PrintPrompt() { + Console.WriteLine(); if (SaveSystem.CurrentSave != null && CurrentUser != null) { - Desktop.InvokeOnWorkerThread(() => - { ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; ConsoleEx.Italic = false; ConsoleEx.Underline = false; @@ -566,7 +563,7 @@ namespace ShiftOS.Engine ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; Console.Write(" "); - }); + ConsoleEx.Flush(); } } diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index 010e02c..4c0c3a0 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -37,14 +37,19 @@ namespace ShiftOS.Engine /// public class TerminalTextWriter : TextWriter { - /// - /// Win32 API call to lock the window from being updated. - /// - /// The Win32 window handle - /// ...I....have no idea. - [System.Runtime.InteropServices.DllImport("user32.dll")] - public static extern bool LockWindowUpdate(IntPtr hWndLock); + public TerminalTextWriter() + { + ConsoleEx.OnFlush = () => + { + Desktop.InvokeOnWorkerThread(() => + { + UnderlyingControl?.Write(buffer); + buffer = ""; + }); + }; + } + /// /// Gets the encoding format for this . God bless the Unicode Consortiem. /// @@ -94,11 +99,17 @@ namespace ShiftOS.Engine } else { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.Write(value.ToString()); - select(); - })); + buffer += value; + } + } + + private string buffer = ""; + + public string Buffer + { + get + { + return buffer; } } @@ -118,11 +129,8 @@ namespace ShiftOS.Engine else { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.WriteLine(value); - select(); - })); + buffer += value + Environment.NewLine; + ConsoleEx.Flush(); } } @@ -149,8 +157,7 @@ namespace ShiftOS.Engine Desktop.InvokeOnWorkerThread(new Action(() => { - UnderlyingControl?.Write(value.ToString()); - select(); + buffer += value; })); } } -- cgit v1.2.3 From 80899fc5de1c0c194043ce94a10707bf8b7afcf0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 10:12:59 -0400 Subject: Cool startup logo :smiley: --- ShiftOS.WinForms/Applications/ShiftLetters.cs | 2 +- ShiftOS.WinForms/Applications/ShiftSweeper.cs | 2 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 14 --- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ .../ShiftnetSites/ShiftGames.Designer.cs | 74 ++++++++++++ ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs | 39 +++++++ ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx | 125 +++++++++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 26 +++++ 8 files changed, 275 insertions(+), 16 deletions(-) create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index b5e9aa4..42e19f8 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -38,7 +38,7 @@ namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] [Launcher("ShiftLetters", false, null, "Games")] - [RequiresUpgrade("shiftletters")] + [AppscapeEntry("ShiftLetters", "Let's see how much you know about ShiftOS by playing this tiny little Hangman game! Shiftorium Upgrades exist to allow you to buy different word sets!", 300, 150, null, "Games")] [WinOpen("shiftletters")] [DefaultIcon("iconShiftLetters")] public partial class ShiftLetters : UserControl, IShiftOSWindow diff --git a/ShiftOS.WinForms/Applications/ShiftSweeper.cs b/ShiftOS.WinForms/Applications/ShiftSweeper.cs index 72e9062..f23ed73 100644 --- a/ShiftOS.WinForms/Applications/ShiftSweeper.cs +++ b/ShiftOS.WinForms/Applications/ShiftSweeper.cs @@ -35,7 +35,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [Launcher("ShiftSweeper", true, "al_shiftsweeper", "Games")] - [RequiresUpgrade("shiftsweeper")] + [AppscapeEntry("ShiftSweeper", "A simple Minesweeper game built for ShiftOS! Careful, it's a hard one.", 1600, 800, "shiftletters", "Games")] [MultiplayerOnly] [WinOpen("shiftsweeper")] [DefaultIcon("iconShiftSweeper")] diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index cc68c6f..41b50a7 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -151,13 +151,6 @@ }, // SHIFTLETTERS AND WORDLISTS - { - Name: "ShiftLetters", - Cost: 150, - Dependencies: null, - Category: "Applications", - Description: "Sick and tired of playing Pong? Buy this upgrade to get a whole new game!" - }, { Name: "AL ShiftLetters", Cost: 150, @@ -1028,13 +1021,6 @@ // SHIFTSWEEPER - { - Name: "ShiftSweeper", - Cost: 800, - Dependencies: "shiftletters", - Category: "Applications", - Description: "Getting bored with Pong and ShiftLetters? Try this BRAND NEW game called ShiftSweeper!" - }, { Name: "AL ShiftSweeper", Cost: 100, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index da8eafc..9844657 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -382,6 +382,12 @@ MainHomepage.cs + + UserControl + + + ShiftGames.cs + @@ -574,6 +580,9 @@ MainHomepage.cs + + ShiftGames.cs + UniteLoginDialog.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs new file mode 100644 index 0000000..3b4bf9e --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs @@ -0,0 +1,74 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class ShiftGames + { + /// + /// 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 Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShiftGames)); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(571, 65); + this.label1.TabIndex = 0; + this.label1.Tag = "header2"; + this.label1.Text = "ShiftGames/Minimatch"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Fill; + this.label2.Location = new System.Drawing.Point(0, 65); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(571, 309); + this.label2.TabIndex = 1; + this.label2.Text = resources.GetString("label2.Text"); + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // ShiftGames + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "ShiftGames"; + this.Size = new System.Drawing.Size(571, 374); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs new file mode 100644 index 0000000..4ce0435 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms.ShiftnetSites +{ + [ShiftnetSite("shiftnet/main/shiftgames", "ShiftGames (formerly Minimatch)", "The one true Shiftnet site for virus-free, quality games.")] + public partial class ShiftGames : UserControl, IShiftnetSite + { + public ShiftGames() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + public void Setup() + { + } + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx new file mode 100644 index 0000000..ef8aebe --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + ShiftGames has been shut down as of May 2016. We have moved our inventory to the Appscape Repository. Thanks for being with us, and apologies for the inconvenience. + +Copyright (c) 2014-2016 Maureen Fenn + + \ No newline at end of file diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 24a491d..489b718 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -298,6 +298,32 @@ namespace ShiftOS.Engine if (CurrentSave.Users == null) CurrentSave.Users = new List(); + Console.WriteLine($@" + `-:/++++::.` + .+ydNMMMMMNNMMMMMNhs/. + /yNMMmy+:-` `````.-/ohNMMms- + `oNMMh/.`:oydmNMMMMNmhs+- .+dMMm+` Welcome to ShiftOS. + `oMMmo``+dMMMMMMMMMMMMMMMMMNh/`.sNMN+ + :NMN+ -yMMMMMMMNdhyssyyhdmNMMMMNs``sMMd. SYSTEM STATUS: + oMMd.`sMMMMMMd+. `/MMMMN+ -mMN: ---------------------- + oMMh .mMMMMMM/ `-::::-.` :MMMMMMh`.mMM: + :MMd .NMMMMMMs .dMMMMMMMMMNddMMMMMMMd`.NMN. Codepoints: {SaveSystem.CurrentSave.Codepoints} + mMM. dMMMMMMMo -mMMMMMMMMMMMMMMMMMMMMs /MMy Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed + :MMh :MMMMMMMMm` .+shmMMMMMMMMMMMMMMMN` NMN` {Shiftorium.GetAvailable().Count()} available + oMM+ sMMMMMMMMMN+` `-/smMMMMMMMMMMM: hMM: Filesystems: {Utils.Mounts.Count} filesystems mounted in memory. + sMM+ sMMMMMMMMMMMMds/-` .sMMMMMMMMM/ yMM/ + +MMs +MMMMMMMMMMMMMMMMMmhs:` +MMMMMMMM- dMM- System name: {CurrentSave.SystemName.ToUpper()} + .MMm `NMMMMMMMMMMMMMMMMMMMMMo `NMMMMMMd .MMN Users: {Users.Count()} found. + hMM+ +MMMMMMmsdNMMMMMMMMMMN/ -MMMMMMN- yMM+ + `NMN- oMMMMMd `-/+osso+- .mMMMMMN: +MMd + -NMN: /NMMMm` :yMMMMMMm- oMMd` + -mMMs``sMMMMNdhso++///+oydNMMMMMMNo .hMMh` + `yMMm/ .omMMMMMMMMMMMMMMMMMMMMd+``oNMNo + -hMMNo. -ohNMMMMMMMMMMMMmy+. -yNMNy` + .sNMMms/. `-/+++++/:-` ./yNMMmo` + :sdMMMNdyso+++ooshdNMMMdo- + `:+yhmNNMMMMNNdhs+- + ```` "); if (CurrentSave.Users.Count == 0) { -- cgit v1.2.3 From 9914c18456a0c08019e778479ce727ac937b1e57 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 14:40:42 -0400 Subject: Fuck --- ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/Controls/TerminalBox.cs | 6 +++ ShiftOS.WinForms/Tools/ControlManager.cs | 6 +-- ShiftOS_TheReturn/SaveSystem.cs | 64 +++++++++++++++---------------- ShiftOS_TheReturn/ServerManager.cs | 17 -------- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 4 -- 6 files changed, 42 insertions(+), 56 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 3d17d35..de4888b 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -232,6 +232,7 @@ namespace ShiftOS.WinForms.Applications var text = txt.Lines.ToArray(); var text2 = text[text.Length - 1]; var text3 = ""; + Console.WriteLine(); var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); if (IsInRemoteSystem == true) diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 25f7144..c188321 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -64,6 +64,9 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); + this.SelectionFont = ConstructFont(); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } @@ -85,6 +88,9 @@ namespace ShiftOS.WinForms.Controls { Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); + this.SelectionFont = ConstructFont(); this.Select(this.TextLength, 0); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index fe77884..92482fa 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -207,19 +207,19 @@ namespace ShiftOS.WinForms.Tools if (ctrl is Button) { Button b = ctrl as Button; - if (!b.Tag.ToString().ToLower().Contains("keepbg")) + if (!tag.Contains("keepbg")) { b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; b.BackgroundImage = SkinEngine.GetImage("buttonidle"); b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); } b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth; - if (!b.Tag.ToString().ToLower().Contains("keepfg")) + if (!tag.Contains("keepfg")) { b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; } - if (!b.Tag.ToString().ToLower().Contains("keepfont")) + if (!tag.Contains("keepfont")) b.Font = SkinEngine.LoadedSkin.ButtonTextFont; Color orig_bg = b.BackColor; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 489b718..55f5cd5 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -153,50 +153,50 @@ namespace ShiftOS.Engine } } - if (defaultConf.ConnectToMud == true) + + + bool guidReceived = false; + ServerManager.GUIDReceived += (str) => { - bool guidReceived = false; - ServerManager.GUIDReceived += (str) => - { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("[inetd] Connection successful."); - }; + Console.WriteLine("[inetd] Connection successful."); + }; - try - { - - ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); - //This haults the client until the connection is successful. - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); - } - catch (Exception ex) + try + { + + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); + //This haults the client until the connection is successful. + while (ServerManager.thisGuid == new Guid()) { - //No errors, this never gets called. - Console.WriteLine("[inetd] SEVERE: " + ex.Message); - Thread.Sleep(3000); - ServerManager.StartLANServer(); - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); + Thread.Sleep(10); } + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); + FinishBootstrap(); } - else + catch (Exception ex) { - ServerManager.StartLANServer(); + //No errors, this never gets called. + Console.WriteLine("[inetd] SEVERE: " + ex.Message); + Thread.Sleep(3000); + Console.WriteLine("[sys] SEVERE: Cannot connect to server. Shutting down in 5..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 4..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 3..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 2..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 1..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] Bye bye."); + System.Diagnostics.Process.GetCurrentProcess().Kill(); } //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. - + })); thread.IsBackground = true; thread.Start(); diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 217b9ee..f0acaa2 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -316,23 +316,6 @@ Ping: {ServerManager.DigitalSocietyPing} ms private static bool singleplayer = false; public static bool IsSingleplayer { get { return singleplayer; } } - public static void StartLANServer() - { - singleplayer = true; - ShiftOS.Server.Program.ServerStarted += (address) => - { - Console.WriteLine($"Connecting to {address}..."); - Initiate(address, 13370); - }; - Disconnected += () => - { - ShiftOS.Server.Program.Stop(); - }; - ShiftOS.Server.Program.Main(new[] { "" }); - - - } - /// /// Occurs when the server sends a message to this client. /// diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 9d7d696..4cbce72 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -162,10 +162,6 @@ {A069089A-8962-4607-B2B2-4CF4A371066E} ShiftOS.Objects - - {226C63B4-E60D-4949-B4E7-7A2DDBB96776} - ShiftOS.Server - -- cgit v1.2.3