From 2ac1033c2dcd0e70114ab9ee5c7bd129bff6c1fa Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 9 Apr 2017 15:56:14 -0400 Subject: [PATCH] Legion story work (SPOILERS!) --- ShiftOS.Objects/Reputation.cs | 21 ++- .../Applications/Installer.Designer.cs | 104 +++++++++++ ShiftOS.WinForms/Applications/Installer.cs | 150 ++++++++++++++++ ShiftOS.WinForms/Applications/Installer.resx | 120 +++++++++++++ .../Applications/MUDControlCentre.Designer.cs | 88 +++++++++ .../Applications/MUDControlCentre.cs | 54 +++++- ShiftOS.WinForms/Controls/TerminalBox.cs | 1 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 10 ++ ShiftOS.WinForms/Stories/LegionStory.cs | 169 ++++++++++++++++++ 9 files changed, 707 insertions(+), 10 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/Installer.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/Installer.cs create mode 100644 ShiftOS.WinForms/Applications/Installer.resx create mode 100644 ShiftOS.WinForms/Stories/LegionStory.cs diff --git a/ShiftOS.Objects/Reputation.cs b/ShiftOS.Objects/Reputation.cs index 32bb911..0ddea0a 100644 --- a/ShiftOS.Objects/Reputation.cs +++ b/ShiftOS.Objects/Reputation.cs @@ -23,38 +23,43 @@ namespace ShiftOS.Objects public enum UserClass { + /// + /// The user has no class. + /// + None = 0, + /// /// Skinners, otherwise known as "Shifters" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints. /// - Skinner, + Skinner = 1, /// /// Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target. /// - Hacker, + Hacker = 2, /// /// Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations. /// - Investigator, + Investigator = 3, /// /// Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent. /// - Explorer, + Explorer = 4, /// /// Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe. /// - SafetyActivist, + SafetyActivist = 5, /// /// Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful. /// - PenetrationTester, + PenetrationTester = 6, /// /// Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints. /// - Collector, + Collector = 7, /// /// Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions. /// - Programmer + Programmer = 8 } } diff --git a/ShiftOS.WinForms/Applications/Installer.Designer.cs b/ShiftOS.WinForms/Applications/Installer.Designer.cs new file mode 100644 index 0000000..8b4ae81 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Installer.Designer.cs @@ -0,0 +1,104 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class Installer + { + /// + /// 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.lbtitle = new System.Windows.Forms.Label(); + this.pnlselectfile = new System.Windows.Forms.Panel(); + this.pginstall = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); + this.lbprogress = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbtitle + // + this.lbtitle.AutoSize = true; + this.lbtitle.Location = new System.Drawing.Point(14, 13); + this.lbtitle.Name = "lbtitle"; + this.lbtitle.Size = new System.Drawing.Size(155, 13); + this.lbtitle.TabIndex = 0; + this.lbtitle.Tag = "header2"; + this.lbtitle.Text = "Installing MUD Control Centre..."; + // + // pnlselectfile + // + this.pnlselectfile.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.pnlselectfile.Location = new System.Drawing.Point(17, 48); + this.pnlselectfile.Name = "pnlselectfile"; + this.pnlselectfile.Size = new System.Drawing.Size(414, 85); + this.pnlselectfile.TabIndex = 1; + this.pnlselectfile.VisibleChanged += new System.EventHandler(this.pnlselectfile_VisibleChanged); + // + // pginstall + // + this.pginstall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pginstall.BlockSize = 5; + this.pginstall.Location = new System.Drawing.Point(17, 161); + this.pginstall.Maximum = 100; + this.pginstall.Name = "pginstall"; + this.pginstall.Size = new System.Drawing.Size(414, 23); + this.pginstall.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.pginstall.TabIndex = 2; + this.pginstall.Text = "shiftedProgressBar1"; + this.pginstall.Value = 0; + // + // lbprogress + // + this.lbprogress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbprogress.AutoSize = true; + this.lbprogress.Location = new System.Drawing.Point(17, 140); + this.lbprogress.Name = "lbprogress"; + this.lbprogress.Size = new System.Drawing.Size(35, 13); + this.lbprogress.TabIndex = 3; + this.lbprogress.Text = "label1"; + // + // Installer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbprogress); + this.Controls.Add(this.pginstall); + this.Controls.Add(this.pnlselectfile); + this.Controls.Add(this.lbtitle); + this.Name = "Installer"; + this.Size = new System.Drawing.Size(447, 203); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbtitle; + private System.Windows.Forms.Panel pnlselectfile; + private Controls.ShiftedProgressBar pginstall; + private System.Windows.Forms.Label lbprogress; + } +} diff --git a/ShiftOS.WinForms/Applications/Installer.cs b/ShiftOS.WinForms/Applications/Installer.cs new file mode 100644 index 0000000..1b5521e --- /dev/null +++ b/ShiftOS.WinForms/Applications/Installer.cs @@ -0,0 +1,150 @@ +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; + +namespace ShiftOS.WinForms.Applications +{ + public partial class Installer : UserControl, IShiftOSWindow + { + public Installer() + { + InitializeComponent(); + lbtitle.Text = "Select file"; + } + + public void InitiateInstall(Installation install) + { + pnlselectfile.Hide(); + install.ProgressReported += (p) => + { + this.Invoke(new Action(() => + { + pginstall.Value = p; + })); + }; + install.StatusReported += (s) => + { + this.Invoke(new Action(() => + { + lbprogress.Text = s; + })); + }; + install.InstallCompleted += () => + { + this.Invoke(new Action(() => + { + lbtitle.Text = "Select file"; + pnlselectfile.Show(); + })); + isInstalling = false; + InstallCompleted?.Invoke(); + }; + isInstalling = true; + install.Install(); + } + + public void OnLoad() + { + } + + private bool isInstalling = false; + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + return !isInstalling; //Don't close if an install is running. + } + + public void OnUpgrade() + { + + } + + private void pnlselectfile_VisibleChanged(object sender, EventArgs e) + { + if(this.ParentForm != null) + { + this.ParentForm.Height = (pnlselectfile.Visible == true) ? this.ParentForm.Height + pnlselectfile.Height : this.ParentForm.Height - pnlselectfile.Height; + } + } + public event Action InstallCompleted; + } + + public abstract class Installation + { + /// + /// The display name of the installation. + /// + public string Name { get; set; } + + /// + /// Occurs when the installation updates its status. + /// + public event Action StatusReported; + /// + /// Occurs when the installation updates its progress percentage. + /// + public event Action ProgressReported; + /// + /// Occurs when the installation completes. + /// + public event Action InstallCompleted; + + /// + /// Start the installation. + /// + public void Install() + { + var t = new System.Threading.Thread(() => + { + ProgressReported?.Invoke(0); + StatusReported?.Invoke(""); + Run(); + ProgressReported?.Invoke(100); + StatusReported?.Invoke("Installation completed."); + InstallCompleted?.Invoke(); + }); + t.IsBackground = true; + t.Start(); + } + + /// + /// Sets the install progress percentage. + /// + /// The installation percentage. + protected void SetProgress(int value) + { + if (value < 0 || value > 100) + throw new ArgumentOutOfRangeException("value", "A percentage is typically between 0 and 100.... derp..."); + ProgressReported?.Invoke(value); + } + + /// + /// Sets the install status text. + /// + /// Text to display as status. + protected void SetStatus(string status) + { + StatusReported?.Invoke(status); + } + + /// + /// User-defined code to run during install. Once this code is ran, the installation is complete. + /// + protected abstract void Run(); + } + + + + +} diff --git a/ShiftOS.WinForms/Applications/Installer.resx b/ShiftOS.WinForms/Applications/Installer.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Installer.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/Applications/MUDControlCentre.Designer.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs index ba4c4f1..e2c0af3 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs @@ -144,6 +144,12 @@ namespace ShiftOS.WinForms.Applications this.you_memos = new System.Windows.Forms.Panel(); this.flmemos = new System.Windows.Forms.FlowLayoutPanel(); this.label3 = new System.Windows.Forms.Label(); + this.pnlclasses = new System.Windows.Forms.Panel(); + this.lbclasstitle = new System.Windows.Forms.Label(); + this.lbclassdesc = new System.Windows.Forms.Label(); + this.lbclasses = new System.Windows.Forms.ListBox(); + this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel(); + this.btnchooseclass = new System.Windows.Forms.Button(); this.menuStrip1.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -172,6 +178,8 @@ namespace ShiftOS.WinForms.Applications this.panel3.SuspendLayout(); this.flowLayoutPanel2.SuspendLayout(); this.you_memos.SuspendLayout(); + this.pnlclasses.SuspendLayout(); + this.flowLayoutPanel6.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -301,6 +309,7 @@ namespace ShiftOS.WinForms.Applications // // toolStripContainer1.ContentPanel // + this.toolStripContainer1.ContentPanel.Controls.Add(this.pnlclasses); this.toolStripContainer1.ContentPanel.Controls.Add(this.you_systemstatus); this.toolStripContainer1.ContentPanel.Controls.Add(this.shop_all); this.toolStripContainer1.ContentPanel.Controls.Add(this.shop_view); @@ -1182,6 +1191,75 @@ namespace ShiftOS.WinForms.Applications this.label3.Tag = "header1"; this.label3.Text = "Memos"; // + // pnlclasses + // + this.pnlclasses.Controls.Add(this.flowLayoutPanel6); + this.pnlclasses.Controls.Add(this.lbclasses); + this.pnlclasses.Controls.Add(this.lbclassdesc); + this.pnlclasses.Controls.Add(this.lbclasstitle); + this.pnlclasses.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlclasses.Location = new System.Drawing.Point(0, 0); + this.pnlclasses.Name = "pnlclasses"; + this.pnlclasses.Size = new System.Drawing.Size(756, 464); + this.pnlclasses.TabIndex = 3; + // + // lbclasstitle + // + this.lbclasstitle.AutoSize = true; + this.lbclasstitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbclasstitle.Location = new System.Drawing.Point(0, 0); + this.lbclasstitle.Name = "lbclasstitle"; + this.lbclasstitle.Padding = new System.Windows.Forms.Padding(10); + this.lbclasstitle.Size = new System.Drawing.Size(82, 33); + this.lbclasstitle.TabIndex = 0; + this.lbclasstitle.Tag = "header1"; + this.lbclasstitle.Text = "Join a class"; + // + // lbclassdesc + // + this.lbclassdesc.AutoSize = true; + this.lbclassdesc.Dock = System.Windows.Forms.DockStyle.Top; + this.lbclassdesc.Location = new System.Drawing.Point(0, 33); + this.lbclassdesc.Name = "lbclassdesc"; + this.lbclassdesc.Padding = new System.Windows.Forms.Padding(10); + this.lbclassdesc.Size = new System.Drawing.Size(727, 33); + this.lbclassdesc.TabIndex = 1; + this.lbclassdesc.Text = "A class is a way for the multi-user domain to better understand you. It defines w" + + "ho you are as a sentient being, what you do, what you like, and so on."; + // + // lbclasses + // + this.lbclasses.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbclasses.FormattingEnabled = true; + this.lbclasses.Location = new System.Drawing.Point(0, 66); + this.lbclasses.Name = "lbclasses"; + this.lbclasses.Size = new System.Drawing.Size(756, 398); + this.lbclasses.TabIndex = 2; + // + // flowLayoutPanel6 + // + this.flowLayoutPanel6.AutoSize = true; + this.flowLayoutPanel6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel6.Controls.Add(this.btnchooseclass); + this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 415); + this.flowLayoutPanel6.Name = "flowLayoutPanel6"; + this.flowLayoutPanel6.Padding = new System.Windows.Forms.Padding(10); + this.flowLayoutPanel6.Size = new System.Drawing.Size(756, 49); + this.flowLayoutPanel6.TabIndex = 3; + // + // btnchooseclass + // + this.btnchooseclass.AutoSize = true; + this.btnchooseclass.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnchooseclass.Location = new System.Drawing.Point(13, 13); + this.btnchooseclass.Name = "btnchooseclass"; + this.btnchooseclass.Size = new System.Drawing.Size(53, 23); + this.btnchooseclass.TabIndex = 0; + this.btnchooseclass.Text = "Choose"; + this.btnchooseclass.UseVisualStyleBackColor = true; + this.btnchooseclass.Click += new System.EventHandler(this.btnchooseclass_Click); + // // MUDControlCentre // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1242,6 +1320,10 @@ namespace ShiftOS.WinForms.Applications this.flowLayoutPanel2.PerformLayout(); this.you_memos.ResumeLayout(false); this.you_memos.PerformLayout(); + this.pnlclasses.ResumeLayout(false); + this.pnlclasses.PerformLayout(); + this.flowLayoutPanel6.ResumeLayout(false); + this.flowLayoutPanel6.PerformLayout(); this.ResumeLayout(false); } @@ -1339,5 +1421,11 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem joinAChatToolStripMenuItem; private System.Windows.Forms.Button btndeletesave; + private System.Windows.Forms.Panel pnlclasses; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel6; + private System.Windows.Forms.Button btnchooseclass; + private System.Windows.Forms.ListBox lbclasses; + private System.Windows.Forms.Label lbclassdesc; + private System.Windows.Forms.Label lbclasstitle; } } diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index e2668bd..5a51f48 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -39,7 +39,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] - [RequiresUpgrade("mud_fundamentals")] + [RequiresUpgrade("mud_control_centre")] [Launcher("MUD Control Centre", true, "al_mud_control_centre", "Networking")] [WinOpen("mud_control_centre")] [DefaultIcon("iconSysinfo")] @@ -177,6 +177,42 @@ namespace ShiftOS.WinForms.Applications }; } + + + internal void ShowClasses() + { + var descriptions = new Dictionary { + + { UserClass.Skinner, "Skinners, otherwise known as \"Shifters\" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints." }, + { UserClass.Hacker, "Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target." }, + { UserClass.Investigator, "Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations."}, + { UserClass.Explorer, "Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent."}, + { UserClass.SafetyActivist, "Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe." }, + { UserClass.PenetrationTester, "Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful." }, + { UserClass.Collector, "Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints." }, + {UserClass.Programmer, "Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions." }, + + }; + + lbclasses.Items.Clear(); + lbclasses.SelectedIndexChanged += (o, a) => + { + newClass = (UserClass)Enum.Parse(typeof(UserClass), lbclasses.SelectedItem.ToString()); + lbclassdesc.Text = descriptions[newClass]; + lbclasstitle.Text = newClass.ToString(); + }; + foreach (var kv in descriptions) + { + lbclasses.Items.Add(kv.Key.ToString()); + + } + menuStrip1.Hide(); + pnlclasses.Show(); + pnlclasses.BringToFront(); + } + + UserClass newClass = UserClass.None; + public void ListAllChats(Channel[] channels) { shop_all.BringToFront(); @@ -890,5 +926,21 @@ Current legions: {legionname}"; } }); } + + public event Action ClassChanged; + + private void btnchooseclass_Click(object sender, EventArgs e) + { + if(newClass != UserClass.None) + { + SaveSystem.CurrentSave.Class = newClass; + SaveSystem.SaveGame(); + ClassChanged?.Invoke(); + menuStrip1.Show(); + pnlclasses.SendToBack(); + this.SetupSystemStatus(); + return; + } + } } } diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index bc2bcc0..df820f7 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -64,7 +64,6 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; - this.Select(this.TextLength, 0); this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index ca0001e..95612ef 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -131,6 +131,12 @@ GraphicPicker.cs + + UserControl + + + Installer.cs + UserControl @@ -279,6 +285,7 @@ + @@ -336,6 +343,9 @@ GraphicPicker.cs + + Installer.cs + ShiftLetters.cs diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs new file mode 100644 index 0000000..424c54b --- /dev/null +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Stories +{ + public static class LegionStory + { + private static void WriteLine(string text, bool showCharacterName=true) + { + Console.WriteLine(); + if (showCharacterName == true) + { + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkMagenta; + Console.Write("DevX"); + Console.ForegroundColor = ConsoleColor.White; + Console.Write("@"); + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + Console.Write("mud: "); + } + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + ConsoleEx.Bold = false; + + foreach (var c in text) + { + Desktop.InvokeOnWorkerThread(() => + { + Console.Write(c); + }); + Thread.Sleep(75); + } + Thread.Sleep(1000); + } + + public static bool terminalOpen() + { + foreach(var win in AppearanceManager.OpenForms) + { + if (win.ParentWindow is Applications.Terminal) + return true; + } + return false; + } + + [Story("mud_control_centre")] + public static void MCC_Placeholder() + { + //What a way to create unbuyable, engine-managed Shiftorium Upgrades... :P + } + + [Story("devx_legions")] + public static void DevXLegionStory() + { + bool waiting = false; + //Used for DevX dialogue. + //Used for legion selection. + var mud = new Applications.MUDControlCentre(); + //For installing the MCC + var installer = new Applications.Installer(); + installer.InstallCompleted += () => + { + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.Close(installer); + }); + waiting = false; + }; + + if (!terminalOpen()) + { + var term = new Applications.Terminal(); + AppearanceManager.SetupWindow(term); + } + + var t = new Thread(() => + { + WriteLine("DevX@mud - user connecting to your system.", false); + Thread.Sleep(2000); + WriteLine($"Hello, {SaveSystem.CurrentSave.Username}. It's been a while."); + WriteLine("My intelligence suggests you've installed all GUI-based Shiftorium upgrades."); + WriteLine("Bet you're liking ShiftOS now that the terminal isn't the only way you can control it."); + WriteLine("Well, now it's time to introduce your next task."); + WriteLine("In the multi-user domain, each user has a reputation value associated with them."); + WriteLine("Right now, you have a reputation of 0, Neutral."); + WriteLine("This means that nobody has an opinion on you, yet."); + WriteLine("What a good time to make your presence known?"); + WriteLine("I have an application for you to try, that will help you out in the multi-user domain, and help you make yourself famous."); + WriteLine("In the digital society, you can't survive long as a lone sentience. You must kongregate with a group, and these groups are called \"legions\"."); + WriteLine("This application will assist you in finding one. A legion is a group of sentiences who carry out actions together. They're like... a pack of wolves, or a family, if you will."); + WriteLine("They share Codepoints, documents, applications, and other things with each other."); + WriteLine("And they all have their own goals."); + WriteLine("Up until now, you've been blindly following my directions, with the goal of upgrading ShiftOS. Now, it's time for you to join a legion, and fulfill their goals, to become known within the digital society."); + + WriteLine("You'll do all of this through the MUD Control Centre."); + WriteLine("I'll set it up on your system now."); + //Set up an Installer. + waiting = true; + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.SetupWindow(installer); + installer.InitiateInstall(new MCCInstallation()); + }); + while (waiting == true) + Thread.Sleep(25); + + WriteLine("There, it's all installed, so let's get you set up with a legion, shall we?"); + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.SetupWindow(mud); + mud.ShowClasses(); + mud.ClassChanged += () => + { + waiting = false; + }; + }); + WriteLine("First, select a class. A class will help define your personality within the multi-user domain. It'll determine the best legions for you."); + waiting = true; + while (waiting == true) + Thread.Sleep(25); + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + }); + t.IsBackground = true; + t.Start(); + + TerminalBackend.PrefixEnabled = false; + } + + public class MCCInstallation : Applications.Installation + { + protected override void Run() + { + SetStatus("Beginning installation..."); + Thread.Sleep(1270); + SetProgress(10); + SetStatus("Installing base application..."); + for(int i = 0; i < 45; i++) + { + Thread.Sleep(25); + SetProgress(10 + i); + } + SetStatus("Configuring system..."); + //First, we initialize the user's legion value. + SaveSystem.CurrentSave.CurrentLegions = new List(); + Thread.Sleep(250); + SetProgress(65); + //Now we initialize their shop value. + SaveSystem.CurrentSave.MyShop = null; + Thread.Sleep(200); + SetProgress(75); + //Now for their reputation... + SaveSystem.CurrentSave.RawReputation = 0.000; + Thread.Sleep(250); + SetProgress(90); + //Now their class. + SaveSystem.CurrentSave.Class = Objects.UserClass.None; + Thread.Sleep(200); + Story.Start("mud_control_centre"); + SaveSystem.SaveGame(); + SetProgress(100); + } + } + } +}