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("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 - { - username = MySave.Username, - password = MySave.Password - })); - Shiftorium.Silent = true; - SaveSystem.SaveGame(); //Yknow, just incase it crashes. - } - else + 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("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); + this.Invoke(new Action(() => + { + this.Opacity -= 0.01f; + })); + 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