aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ShiftOS.WinForms/Applications/Terminal.cs214
-rw-r--r--ShiftOS.WinForms/Oobe.cs177
-rw-r--r--ShiftOS.WinForms/Oobe.resx12
-rw-r--r--ShiftOS.WinForms/Program.cs7
-rw-r--r--ShiftOS.WinForms/Tools/ControlManager.cs2
-rw-r--r--ShiftOS_TheReturn/Commands.cs299
-rw-r--r--ShiftOS_TheReturn/SaveSystem.cs21
-rw-r--r--ShiftOS_TheReturn/TerminalBackend.cs3
-rw-r--r--ShiftOS_TheReturn/TutorialManager.cs32
9 files changed, 586 insertions, 181 deletions
diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs
index 02a1f85..01ed194 100644
--- a/ShiftOS.WinForms/Applications/Terminal.cs
+++ b/ShiftOS.WinForms/Applications/Terminal.cs
@@ -43,10 +43,12 @@ using System.Collections;
using static ShiftOS.Engine.SkinEngine;
using ShiftOS.Engine;
-namespace ShiftOS.WinForms.Applications {
+namespace ShiftOS.WinForms.Applications
+{
[Launcher("Terminal", false)]
[WinOpen("terminal")]
- public partial class Terminal : UserControl, IShiftOSWindow {
+ public partial class Terminal : UserControl, IShiftOSWindow
+ {
public static Stack<string> ConsoleStack = new Stack<string>();
public static System.Windows.Forms.Timer ti = new System.Windows.Forms.Timer();
@@ -92,29 +94,48 @@ namespace ShiftOS.WinForms.Applications {
}
}
+ public int TutorialProgress
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
[Obsolete("This is used for compatibility with old parts of the backend. Please use TerminalBackend instead.")]
public static void InvokeCommand(string text)
{
TerminalBackend.InvokeCommand(text);
}
- public Terminal() {
+ public Terminal()
+ {
InitializeComponent();
- SaveSystem.GameReady += () => {
- try {
- this.Invoke(new Action(() => {
+ SaveSystem.GameReady += () =>
+ {
+ try
+ {
+ this.Invoke(new Action(() =>
+ {
ResetAllKeywords();
rtbterm.Text = "";
TerminalBackend.PrefixEnabled = true;
TerminalBackend.InStory = false;
Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
- if (SaveSystem.CurrentSave.StoryPosition == 6) {
+ if (SaveSystem.CurrentSave.StoryPosition == 6)
+ {
Infobox.Show("Welcome to ShiftOS.", "Welcome to the ShiftOS multi-user domain. Your goal is to upgrade your system as much as possible, and gain as much wealth as possible. The first step is to get a feel for the environment. Go forth and explore, young Shifter.");
SaveSystem.CurrentSave.StoryPosition++;
}
}));
- } catch { }
+ }
+ catch { }
};
@@ -122,31 +143,44 @@ namespace ShiftOS.WinForms.Applications {
}
- public void FocusOnTerminal() {
+ public void FocusOnTerminal()
+ {
rtbterm.Focus();
}
- public static string GetTime() {
+ public static string GetTime()
+ {
var time = DateTime.Now;
- if (ShiftoriumFrontend.UpgradeInstalled("full_precision_time")) {
+ if (ShiftoriumFrontend.UpgradeInstalled("full_precision_time"))
+ {
return DateTime.Now.ToString("h:mm:ss tt");
- } else if (ShiftoriumFrontend.UpgradeInstalled("clock_am_and_pm")) {
+ }
+ else if (ShiftoriumFrontend.UpgradeInstalled("clock_am_and_pm"))
+ {
return time.TimeOfDay.TotalHours > 12 ? $"{time.Hour - 12} PM" : $"{time.Hour} AM";
- } else if (ShiftoriumFrontend.UpgradeInstalled("clock_hours")) {
+ }
+ else if (ShiftoriumFrontend.UpgradeInstalled("clock_hours"))
+ {
return ((int)time.TimeOfDay.TotalHours).ToString();
- } else if (ShiftoriumFrontend.UpgradeInstalled("clock_minutes")) {
+ }
+ else if (ShiftoriumFrontend.UpgradeInstalled("clock_minutes"))
+ {
return ((int)time.TimeOfDay.TotalMinutes).ToString();
- } else if (ShiftoriumFrontend.UpgradeInstalled("clock")) {
+ }
+ else if (ShiftoriumFrontend.UpgradeInstalled("clock"))
+ {
return ((int)time.TimeOfDay.TotalSeconds).ToString();
}
return "";
}
-
+
public static event TextSentEventHandler TextSent;
+ public event EventHandler OnComplete;
- public void ResetAllKeywords() {
+ public void ResetAllKeywords()
+ {
string primary = SaveSystem.CurrentSave.Username + " ";
string secondary = "shiftos ";
@@ -155,18 +189,27 @@ namespace ShiftOS.WinForms.Applications {
var types = asm.GetTypes();
- foreach (var type in types) {
- foreach (var a in type.GetCustomAttributes(false)) {
- if (ShiftoriumFrontend.UpgradeAttributesUnlocked(type)) {
- if (a is Namespace) {
+ foreach (var type in types)
+ {
+ foreach (var a in type.GetCustomAttributes(false))
+ {
+ if (ShiftoriumFrontend.UpgradeAttributesUnlocked(type))
+ {
+ if (a is Namespace)
+ {
var ns = a as Namespace;
- if (!primary.Contains(ns.name)) {
+ if (!primary.Contains(ns.name))
+ {
primary += ns.name + " ";
}
- foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) {
- if (ShiftoriumFrontend.UpgradeAttributesUnlocked(method)) {
- foreach (var ma in method.GetCustomAttributes(false)) {
- if (ma is Command) {
+ foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
+ {
+ if (ShiftoriumFrontend.UpgradeAttributesUnlocked(method))
+ {
+ foreach (var ma in method.GetCustomAttributes(false))
+ {
+ if (ma is Command)
+ {
var cmd = ma as Command;
if (!secondary.Contains(cmd.name))
secondary += cmd.name + " ";
@@ -182,14 +225,19 @@ namespace ShiftOS.WinForms.Applications {
}
- public static void MakeWidget(Controls.TerminalBox txt) {
+ public static void MakeWidget(Controls.TerminalBox txt)
+ {
AppearanceManager.StartConsoleOut();
- txt.GotFocus += (o, a) => {
+ txt.GotFocus += (o, a) =>
+ {
AppearanceManager.ConsoleOut = txt;
};
- txt.KeyDown += (o, a) => {
- if (a.KeyCode == Keys.Enter) {
- try {
+ txt.KeyDown += (o, a) =>
+ {
+ if (a.KeyCode == Keys.Enter)
+ {
+ try
+ {
a.SuppressKeyPress = true;
Console.WriteLine("");
var text = txt.Lines.ToArray();
@@ -197,30 +245,48 @@ namespace ShiftOS.WinForms.Applications {
var text3 = "";
var text4 = Regex.Replace(text2, @"\t|\n|\r", "");
- if (TerminalBackend.PrefixEnabled) {
+ if (TerminalBackend.PrefixEnabled)
+ {
text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length);
}
TerminalBackend.LastCommand = text3;
TextSent?.Invoke(text4);
- if (TerminalBackend.InStory == false) {
+ if (TerminalBackend.InStory == false)
+ {
TerminalBackend.InvokeCommand(text3);
}
- if (TerminalBackend.PrefixEnabled) {
+ if (TerminalBackend.PrefixEnabled)
+ {
Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
}
- } catch {
}
- } else if (a.KeyCode == Keys.Back) {
- var tostring3 = txt.Lines[txt.Lines.Length - 1];
- var tostringlen = tostring3.Length + 1;
- var workaround = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
- var derp = workaround.Length + 1;
- if (tostringlen != derp) {
- AppearanceManager.CurrentPosition--;
- } else {
- a.SuppressKeyPress = true;
+ catch
+ {
}
- } else if (a.KeyCode == Keys.Left)
+ }
+ else if (a.KeyCode == Keys.Back)
+ {
+ try
+ {
+ var tostring3 = txt.Lines[txt.Lines.Length - 1];
+ var tostringlen = tostring3.Length + 1;
+ var workaround = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
+ var derp = workaround.Length + 1;
+ if (tostringlen != derp)
+ {
+ AppearanceManager.CurrentPosition--;
+ }
+ else
+ {
+ a.SuppressKeyPress = true;
+ }
+ }
+ catch
+ {
+ Debug.WriteLine("Drunky alert in terminal.");
+ }
+ }
+ else if (a.KeyCode == Keys.Left)
{
var getstring = txt.Lines[txt.Lines.Length - 1];
var stringlen = getstring.Length + 1;
@@ -240,13 +306,16 @@ namespace ShiftOS.WinForms.Applications {
}
}
//( ͡° ͜ʖ ͡° ) You found the lennyface without looking at the commit message. Message Michael in the #shiftos channel on Discord saying "ladouceur" somewhere in your message if you see this.
- else if (a.KeyCode == Keys.Up) {
+ else if (a.KeyCode == Keys.Up)
+ {
var tostring3 = txt.Lines[txt.Lines.Length - 1];
if (tostring3 == $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ")
Console.Write(TerminalBackend.LastCommand);
a.SuppressKeyPress = true;
- } else {
+ }
+ else
+ {
if (TerminalBackend.InStory)
{
a.SuppressKeyPress = true;
@@ -266,19 +335,24 @@ namespace ShiftOS.WinForms.Applications {
}
- private void Terminal_Load(object sender, EventArgs e) {
+ private void Terminal_Load(object sender, EventArgs e)
+ {
}
- private void Terminal_FormClosing(object sender, FormClosingEventArgs e) {
+ private void Terminal_FormClosing(object sender, FormClosingEventArgs e)
+ {
ti.Stop();
}
- public void OnLoad() {
+ public void OnLoad()
+ {
MakeWidget(rtbterm);
- if (SaveSystem.CurrentSave != null) {
- if (!ShiftoriumFrontend.UpgradeInstalled("window_manager")) {
+ if (SaveSystem.CurrentSave != null)
+ {
+ if (!ShiftoriumFrontend.UpgradeInstalled("window_manager"))
+ {
rtbterm.Text = AppearanceManager.LastTerminalText;
rtbterm.Select(rtbterm.TextLength, 0);
}
@@ -289,30 +363,42 @@ namespace ShiftOS.WinForms.Applications {
}
- public void OnSkinLoad() {
- try {
+ public void OnSkinLoad()
+ {
+ try
+ {
rtbterm.Font = LoadedSkin.TerminalFont;
rtbterm.ForeColor = LoadedSkin.TerminalForeColor;
rtbterm.BackColor = LoadedSkin.TerminalBackColor;
- } catch {
+ }
+ catch
+ {
}
}
- public bool OnUnload() {
- if (SaveSystem.ShuttingDown == false) {
- if (!ShiftoriumFrontend.UpgradeInstalled("desktop")) {
- if (AppearanceManager.OpenForms.Count <= 1) {
+ public bool OnUnload()
+ {
+ if (SaveSystem.ShuttingDown == false)
+ {
+ if (!ShiftoriumFrontend.UpgradeInstalled("desktop"))
+ {
+ if (AppearanceManager.OpenForms.Count <= 1)
+ {
Console.WriteLine("");
Console.WriteLine("{WIN_CANTCLOSETERMINAL}");
- try {
+ try
+ {
Console.WriteLine("");
- if (TerminalBackend.PrefixEnabled) {
+ if (TerminalBackend.PrefixEnabled)
+ {
Console.Write($"{SaveSystem.CurrentSave.Username}@shiftos:~$ ");
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
Console.WriteLine(ex);
}
return false;
@@ -322,13 +408,15 @@ namespace ShiftOS.WinForms.Applications {
return true;
}
- public void OnUpgrade() {
+ public void OnUpgrade()
+ {
}
private void rtbterm_TextChanged(object sender, EventArgs e)
{
}
+
}
}
//lol you found this comment i made so i chould push a change to make a point. \ No newline at end of file
diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs
index b7bc3d8..7623d82 100644
--- a/ShiftOS.WinForms/Oobe.cs
+++ b/ShiftOS.WinForms/Oobe.cs
@@ -39,7 +39,7 @@ using ShiftOS.Objects.ShiftFS;
namespace ShiftOS.WinForms
{
- public partial class Oobe : Form, IOobe
+ public partial class Oobe : Form, IOobe, ITutorial
{
public Oobe()
{
@@ -87,6 +87,23 @@ namespace ShiftOS.WinForms
public Save MySave = null;
+ public event EventHandler OnComplete;
+
+ private int tutPrg = 0;
+
+ public int TutorialProgress
+ {
+ get
+ {
+ return tutPrg;
+ }
+
+ set
+ {
+ tutPrg = value;
+ }
+ }
+
public void StartShowing(Save save)
{
var t = new Thread(new ThreadStart(() =>
@@ -204,5 +221,163 @@ namespace ShiftOS.WinForms
{
throw new NotImplementedException();
}
+
+ public void Start()
+ {
+ foreach(var frm in AppearanceManager.OpenForms)
+ {
+ frm.Close();
+ }
+
+ TerminalBackend.CommandProcessed += (cmd, args) =>
+ {
+ if(cmd == "sos.help")
+ {
+ if (TutorialProgress == 0)
+ TutorialProgress = 1;
+ }
+ else if(cmd == "sos.status")
+ {
+ if (TutorialProgress == 1)
+ TutorialProgress = 2;
+
+ }
+ else if(cmd == "shiftorium.list")
+ {
+ if (TutorialProgress == 2)
+ TutorialProgress = 3;
+ }
+ else if(cmd == "shiftorium.info" && args == "{\"upgrade\":\"mud_fundamentals\"}")
+ {
+ if (TutorialProgress == 3)
+ TutorialProgress = 4;
+ }
+ else if(cmd == "win.open")
+ {
+ if (TutorialProgress == 4)
+ TutorialProgress = 5;
+ }
+ };
+ this.Show();
+ var t = new Thread(() =>
+ {
+ textgeninput = lblHijack;
+ Clear();
+ textgeninput = lblhackwords;
+ Clear();
+
+ this.Invoke(new Action(() =>
+ {
+ textgeninput.Font = SkinEngine.LoadedSkin.TerminalFont;
+ }));
+ TextType("ShiftOS has been installed successfully.");
+ Thread.Sleep(500);
+ TextType("Before you can continue to the operating system, here's a little tutorial on how to use it.");
+ Thread.Sleep(500);
+ TextType("Starting a Terminal...");
+ Applications.Terminal term = null;
+ this.Invoke(new Action(() =>
+ {
+ term = new Applications.Terminal();
+ this.Controls.Add(term);
+ term.Location = new Point(
+ (this.Width - term.Width) / 2,
+ (this.Height - term.Height) / 2
+ );
+ term.Show();
+ term.OnLoad();
+ term.OnSkinLoad();
+ term.OnUpgrade();
+ }));
+ TextType("This little text box is called a Terminal.");
+ Thread.Sleep(500);
+ TextType("Normally, it would appear in full-screen, but this window is hosting it as a control so you can see this text as well.");
+ Thread.Sleep(500);
+ TextType("In ShiftOS, the Terminal is your main control centre for the operating system. You can see system status, check Codepoints, open other programs, buy upgrades, and more.");
+ Thread.Sleep(500);
+ TextType("Go ahead and type 'sos.help' to see a list of commands.");
+ while(TutorialProgress == 0)
+ {
+
+ }
+ TextType("As you can see, sos.help gives you a list of all commands in the system.");
+ Thread.Sleep(500);
+ TextType("You can run any command, by typing in their Namespace, followed by a period (.), followed by their Command Name.");
+ Thread.Sleep(500);
+ TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does.");
+ while(TutorialProgress == 1)
+ {
+
+ }
+ TextType("Brilliant. The sos.status command will tell you how many Codepoints you have, as well as how many upgrades you have installed and how many are available.");
+ Thread.Sleep(500);
+ TextType("Codepoints, as you know, are a special currency within ShiftOS. They are used to buy things within the multi-user domain, such as upgrades, scripts, and applications.");
+ Thread.Sleep(500);
+ TextType("You can earn Codepoints by doing things in ShiftOS - such as completing jobs for other users, making things like skins, scripts, documents, etc, and playing games like Pong.");
+ Thread.Sleep(500);
+ TextType("At times, you'll be given Codepoints to help complete a task. You will receive Codepoints from 'sys' - the multi-user domain itself.");
+ SaveSystem.TransferCodepointsFrom("sys", 50);
+ TextType("Right now, you don't have any upgrades. Upgrades can give ShiftOS additional features and capabilities - like new core applications, supported file types, and new Terminal commands.");
+ Thread.Sleep(500);
+ TextType("You can easily get upgrades using the Shiftorium - a repository of approved ShiftOS upgrades.");
+ Thread.Sleep(500);
+ TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades.");
+ while(TutorialProgress == 2)
+ {
+
+ }
+ TextType("Right now, you have enough Codepoints to buy the 'mud_fundamentals' upgrade. You can use shiftorium.info to see information about this upgrade.");
+ Thread.Sleep(500);
+ TextType("Some commands, like shiftorium.info, require you to pass information to them in the form of arguments.");
+ Thread.Sleep(500);
+ TextType("Argument pairs sit at the end of the command, and are enclosed in curly braces.");
+ Thread.Sleep(500);
+ TextType("Inside these curly braces, you can input an argument key, followed by a colon, followed by the value. Then, if you need multiple arguments, you can put a comma after the value, and then insert another argument pair.");
+ Thread.Sleep(500);
+ TextType("There are different value types - numeric values, which can be any positive or negative 32-bit integer");
+ Thread.Sleep(500);
+ TextType("Then there are boolean values which can be either 'true' or 'false'");
+ Thread.Sleep(500);
+ TextType("Then there are string values, which are enclosed in double-quotes. If for some reason you need to use a double-quote inside a string, you must escape it using a single backslash followed by the quote, like this: key:\"My \\\"awesome\\\" value.\"");
+ Thread.Sleep(500);
+ TextType("If you want to escape a backslash inside a string, simply type two backslashes instead of one - for example key:\"Back\\\\slash.\"");
+ Thread.Sleep(500);
+ TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID.");
+ while(TutorialProgress == 3)
+ {
+
+ }
+ TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!");
+ Thread.Sleep(500);
+ TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!");
+ while (!Shiftorium.UpgradeInstalled("mud_fundamentals"))
+ {
+
+ }
+ TextType("Hooray! You now have the MUD Fundamentals upgrade.");
+ Thread.Sleep(500);
+ TextType("You can also earn more Codepoints by playing Pong. To open Pong, you can use the win.open command.");
+ Thread.Sleep(500);
+ TextType("If you run win.open without arguments, you can see a list of applications that you can open.");
+ Thread.Sleep(500);
+ TextType("Just run win.open without arguments, and this tutorial will be completed!");
+ while(TutorialProgress == 4)
+ {
+
+ }
+ TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world.");
+ Thread.Sleep(2000);
+ this.Invoke(new Action(() =>
+ {
+ OnComplete?.Invoke(this, EventArgs.Empty);
+ this.Close();
+ SaveSystem.CurrentSave.StoryPosition = 2;
+ SaveSystem.SaveGame();
+ AppearanceManager.SetupWindow(new Applications.Terminal());
+ }));
+ });
+ t.IsBackground = true;
+ t.Start();
+ }
}
}
diff --git a/ShiftOS.WinForms/Oobe.resx b/ShiftOS.WinForms/Oobe.resx
index 1af7de1..2f015af 100644
--- a/ShiftOS.WinForms/Oobe.resx
+++ b/ShiftOS.WinForms/Oobe.resx
@@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <metadata name="conversationtimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="textgen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 56</value>
+ </metadata>
+ <metadata name="hackeffecttimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 95</value>
+ </metadata>
+ <metadata name="BackgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 134</value>
+ </metadata>
</root> \ No newline at end of file
diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs
index 7db25b9..dfb935e 100644
--- a/ShiftOS.WinForms/Program.cs
+++ b/ShiftOS.WinForms/Program.cs
@@ -44,6 +44,9 @@ namespace ShiftOS.WinForms
[STAThread]
static void Main()
{
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael
Localization.RegisterProvider(new WFLanguageProvider());
Shiftorium.RegisterProvider(new WinformsShiftoriumProvider());
AppearanceManager.OnExit += () =>
@@ -51,12 +54,12 @@ namespace ShiftOS.WinForms
Environment.Exit(0);
};
+ TutorialManager.RegisterTutorial(new Oobe());
+
TerminalBackend.TerminalRequested += () =>
{
AppearanceManager.SetupWindow(new Applications.Terminal());
};
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
AppearanceManager.Initiate(new WinformsWindowManager());
OutOfBoxExperience.Init(new Oobe());
Infobox.Init(new WinformsInfobox());
diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs
index 30fd296..456e46d 100644
--- a/ShiftOS.WinForms/Tools/ControlManager.cs
+++ b/ShiftOS.WinForms/Tools/ControlManager.cs
@@ -120,7 +120,7 @@ namespace ShiftOS.WinForms.Tools
{
var frm = OpenForms[0] as WindowBorder;
frm.Location = new Point(0, 0);
- frm.Size = frm.ParentForm.Size;
+ frm.Size = Desktop.Size;
OpenForms[0] = frm;
}
diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs
index 9822c1c..70486bb 100644
--- a/ShiftOS_TheReturn/Commands.cs
+++ b/ShiftOS_TheReturn/Commands.cs
@@ -42,11 +42,14 @@ using Discoursistency.Base.Models.Authentication;
using ShiftOS.Engine.Scripting;
using ShiftOS.Objects.ShiftFS;
-namespace ShiftOS.Engine {
+namespace ShiftOS.Engine
+{
[Namespace("virus")]
- public class VirusTestCommands {
+ public class VirusTestCommands
+ {
[Command("infect")]
- public static void InfectFileWithMUDVirus(Dictionary<string, object> args) {
+ public static void InfectFileWithMUDVirus(Dictionary<string, object> args)
+ {
string signature = "";
if (args.ContainsKey("signature"))
@@ -56,15 +59,18 @@ namespace ShiftOS.Engine {
string script = "";
- Action<string> scriptFound = new Action<string>((s) => {
+ Action<string> scriptFound = new Action<string>((s) =>
+ {
script = s;
Virus v = new LuaVirus(s, 1);
VirusEngine.Add(v);
VirusEngine.Infect($"lua.{v.Signature}.1");
});
- ServerManager.MessageReceived += (srv) => {
- if (srv.Name == "mud_virus") {
+ ServerManager.MessageReceived += (srv) =>
+ {
+ if (srv.Name == "mud_virus")
+ {
scriptFound?.Invoke(srv.Contents);
scriptFound = null;
}
@@ -77,9 +83,11 @@ namespace ShiftOS.Engine {
[RequiresUpgrade("mud_fundamentals")]
[Namespace("mud")]
- public static class MUDCommands {
+ public static class MUDCommands
+ {
[Command("addvirus")]
- public static void Virus_AddToDatabase(Dictionary<string, object> args) {
+ public static void Virus_AddToDatabase(Dictionary<string, object> args)
+ {
string file = "";
int threatLevel = 0;
@@ -100,23 +108,31 @@ namespace ShiftOS.Engine {
[Command("status")]
- public static bool Status() {
+ public static bool Status()
+ {
ServerManager.PrintDiagnostics();
return true;
}
[Command("connect")]
- public static bool Connect(Dictionary<string, object> args) {
- try {
+ public static bool Connect(Dictionary<string, object> args)
+ {
+ try
+ {
string ip = (args.ContainsKey("addr") == true) ? args["addr"] as string : "michaeltheshifter.me";
int port = (args.ContainsKey("port") == true) ? Convert.ToInt32(args["port"] as string) : 13370;
- try {
+ try
+ {
ServerManager.Initiate(ip, port);
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
Console.WriteLine("{ERROR}: " + ex.Message);
}
return true;
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
Console.WriteLine("Error running script:" + ex);
return false;
}
@@ -127,34 +143,39 @@ namespace ShiftOS.Engine {
[RequiresUpgrade("mud_fundamentals")]
[Namespace("chat")]
- public static class ChatCommands {
+ public static class ChatCommands
+ {
[RequiresArgument("id")]
[RequiresArgument("name")]
[RequiresArgument("topic")]
[Command("create")]
- public static bool CreateChat(Dictionary<string, object> args) {
+ public static bool CreateChat(Dictionary<string, object> args)
+ {
string id = "";
string topic = "";
string name = "";
int max_users = 0;
- id = args["id"] as string;
- name = args["topic"] as string;
- topic = args["name"] as string;
+ id = args["id"] as string;
+ name = args["topic"] as string;
+ topic = args["name"] as string;
bool valid = true;
if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(topic))
valid = false;
- if (valid) {
+ if (valid)
+ {
ServerManager.SendMessage("chat_create", $@"{{
id: ""{id}"",
name: ""{name}"",
topic: ""{topic}"",
max_users: {max_users}
}}");
- } else {
+ }
+ else
+ {
Console.WriteLine("{CHAT_PLEASE_PROVIDE_VALID_CHANNEL_DATA}");
}
return true;
@@ -162,17 +183,21 @@ namespace ShiftOS.Engine {
}
+ [TutorialLock]
[Namespace("trm")]
- public static class TerminalCommands {
+ public static class TerminalCommands
+ {
[Command("clear")]
- public static bool Clear() {
+ public static bool Clear()
+ {
AppearanceManager.ConsoleOut.Clear();
return true;
}
-
+
[Command("echo")]
[RequiresArgument("text")]
- public static bool Echo(Dictionary<string, object> args) {
+ public static bool Echo(Dictionary<string, object> args)
+ {
Console.WriteLine(args["text"]);
return true;
}
@@ -180,33 +205,41 @@ namespace ShiftOS.Engine {
#if DEVEL
[Namespace("cheats", true)]
- public static class CheatCommands {
+ public static class CheatCommands
+ {
[Command("freecp", true)]
[CommandObsolete("{OBSOLETE_CHEATS_FREECP}", "dev.freecp", true)]
- public static bool FreeCodepoints(Dictionary<string, object> args) {
+ public static bool FreeCodepoints(Dictionary<string, object> args)
+ {
// never called
return true;
}
}
[Namespace("dev")]
- public static class ShiftOSDevCommands {
+ public static class ShiftOSDevCommands
+ {
[Command("multarg")]
[RequiresArgument("id")]
[RequiresArgument("name")]
[RequiresArgument("type")]
- public static bool MultArg(Dictionary<string, object> args) {
+ public static bool MultArg(Dictionary<string, object> args)
+ {
return true;
}
[Command("freecp")]
- public static bool FreeCodepoints(Dictionary<string, object> args) {
+ public static bool FreeCodepoints(Dictionary<string, object> args)
+ {
if (args.ContainsKey("amount"))
- try {
+ try
+ {
int codepointsToAdd = Convert.ToInt32(args["amount"].ToString());
SaveSystem.TransferCodepointsFrom("dev", codepointsToAdd);
return true;
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
Console.WriteLine("{ERROR}: " + ex.Message);
return true;
}
@@ -216,41 +249,55 @@ namespace ShiftOS.Engine {
}
[Command("unlockeverything")]
- public static bool GetAllUpgrades() {
- foreach (var upg in Shiftorium.GetDefaults()) {
+ public static bool GetAllUpgrades()
+ {
+ foreach (var upg in Shiftorium.GetDefaults())
+ {
Shiftorium.Buy(upg.ID, 0);
}
return true;
}
[Command("info")]
- public static bool DevInformation() {
+ public static bool DevInformation()
+ {
Console.WriteLine("{SHIFTOS_PLUS_MOTTO}");
Console.WriteLine("{SHIFTOS_VERSION_INFO}" + Assembly.GetExecutingAssembly().GetName().Version);
return true;
}
[Command("pullfile")]
- public static bool PullFile(Dictionary<string, object> args) {
- if (args.ContainsKey("physical") && args.ContainsKey("virtual")) {
+ public static bool PullFile(Dictionary<string, object> args)
+ {
+ if (args.ContainsKey("physical") && args.ContainsKey("virtual"))
+ {
string file = (string)args["physical"];
string dest = (string)args["virtual"];
- if (System.IO.File.Exists(file)) {
+ if (System.IO.File.Exists(file))
+ {
Console.WriteLine("Pulling physical file to virtual drive...");
byte[] filebytes = System.IO.File.ReadAllBytes(file);
ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(dest, filebytes);
- } else {
+ }
+ else
+ {
Console.WriteLine("The specified file does not exist on the physical drive.");
}
- } else {
+ }
+ else
+ {
Console.WriteLine("You must supply a physical path.");
}
return true;
}
[Command("crash")]
- public static bool CrashInstantly() {
- try {
+ public static bool CrashInstantly()
+ {
+ try
+ {
throw new Exception("ShiftOS was sent a command to forcefully crash.");
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
CrashHandler.Start(e);
return true;
}
@@ -259,46 +306,36 @@ namespace ShiftOS.Engine {
#endif
[Namespace("sos")]
- public static class ShiftOSCommands {
-
+ public static class ShiftOSCommands
+ {
[Command("shutdown")]
- public static bool Shutdown() {
+ public static bool Shutdown()
+ {
SaveSystem.ShuttingDown = true;
TerminalBackend.InvokeCommand("sos.save");
AppearanceManager.Exit();
return true;
}
- [Command("verify")]
- public static bool Verify(Dictionary<string, object> args) {
- if (SaveSystem.CurrentSave.StoryPosition == 4) {
- if (args.ContainsKey(Localization.Parse("{ARGS_PASSWORD}"))) {
- if (args[Localization.Parse("{ARGS_PASSWORD}")] as string == "theepicwin") {
- SaveSystem.CurrentSave.StoryPosition++;
- } else {
- Console.WriteLine("{SENTIENCE_INVALIDPASSWORD}");
- }
- } else {
- Console.WriteLine("{SENTIENCE_INVALIDPASSWORD}");
- }
- return true;
- } else {
- return false;
- }
- }
[Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")]
- public static bool Help() {
+ public static bool Help()
+ {
var asm = Assembly.GetExecutingAssembly();
var types = asm.GetTypes();
- foreach (var type in types) {
- if (Shiftorium.UpgradeAttributesUnlocked(type)) {
- foreach (var a in type.GetCustomAttributes(false)) {
- if (a is Namespace) {
+ 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 (!ns.hide) {
+ if (!ns.hide)
+ {
string descp = "{NAMESPACE_" + ns.name.ToUpper() + "_DESCRIPTION}";
if (descp == Localization.Parse(descp))
descp = "";
@@ -307,13 +344,18 @@ namespace ShiftOS.Engine {
Console.WriteLine($"{{NAMESPACE}}{ns.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) {
+ 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) {
+ if (!cmd.hide)
+ {
string descriptionparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}";
string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}";
if (descriptionparse == Localization.Parse(descriptionparse))
@@ -347,13 +389,15 @@ namespace ShiftOS.Engine {
}
[Command("save")]
- public static bool Save() {
+ public static bool Save()
+ {
SaveSystem.SaveGame();
return true;
}
[Command("status")]
- public static bool Status() {
+ public static bool Status()
+ {
Console.WriteLine($@"ShiftOS version {Assembly.GetExecutingAssembly().GetName().Version.ToString()}
Codepoints: {SaveSystem.CurrentSave.Codepoints}
@@ -365,11 +409,14 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed,
[Namespace("shiftorium")]
- public static class ShiftoriumCommands {
+ public static class ShiftoriumCommands
+ {
[Command("buy")]
[RequiresArgument("upgrade")]
- public static bool BuyUpgrade(Dictionary<string, object> userArgs) {
- try {
+ public static bool BuyUpgrade(Dictionary<string, object> userArgs)
+ {
+ try
+ {
string upgrade = "";
if (userArgs.ContainsKey("upgrade"))
@@ -377,15 +424,19 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed,
else
throw new Exception("You must specify a valid 'upgrade' value.");
- foreach (var upg in Shiftorium.GetAvailable()) {
- if (upg.ID == upgrade) {
+ foreach (var upg in Shiftorium.GetAvailable())
+ {
+ if (upg.ID == upgrade)
+ {
Shiftorium.Buy(upgrade, upg.Cost);
return true;
}
}
throw new Exception($"Couldn't find upgrade with ID: {upgrade}");
- } catch {
+ }
+ catch
+ {
return false;
}
}
@@ -393,15 +444,20 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed,
[RequiresUpgrade("shiftorium_bulk_buy")]
[Command("bulkbuy")]
[RequiresArgument("upgrades")]
- public static bool BuyBulk(Dictionary<string, object> args) {
- if (args.ContainsKey("upgrades")) {
+ public static bool BuyBulk(Dictionary<string, object> args)
+ {
+ if (args.ContainsKey("upgrades"))
+ {
string[] upgrade_list = (args["upgrades"] as string).Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
- foreach (var upg in upgrade_list) {
+ foreach (var upg in upgrade_list)
+ {
var dict = new Dictionary<string, object>();
dict.Add("upgrade", upg);
BuyUpgrade(dict);
}
- } else {
+ }
+ else
+ {
throw new Exception("Please specify a list of upgrades in the 'upgrades' argument. Each upgrade is separated by a comma.");
}
return true;
@@ -409,8 +465,10 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed,
[Command("info")]
- public static bool ViewInfo(Dictionary<string, object> userArgs) {
- try {
+ public static bool ViewInfo(Dictionary<string, object> userArgs)
+ {
+ try
+ {
string upgrade = "";
if (userArgs.ContainsKey("upgrade"))
@@ -418,8 +476,10 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed,
else
throw new Exception("You must specify a valid 'upgrade' value.");
- foreach (var upg in Shiftorium.GetDefaults()) {
- if (upg.ID == upgrade) {
+ foreach (var upg in Shiftorium.GetDefaults())
+ {
+ if (upg.ID == upgrade)
+ {
Console.WriteLine($@"Information for {upgrade}:
{upg.Name} - {upg.Cost} Codepoints
@@ -434,18 +494,24 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}");
}
throw new Exception($"Couldn't find upgrade with ID: {upgrade}");
- } catch {
+ }
+ catch
+ {
return false;
}
}
[Command("list")]
- public static bool ListAll() {
- try {
+ public static bool ListAll()
+ {
+ try
+ {
Dictionary<string, int> upgrades = new Dictionary<string, int>();
int maxLength = 5;
- foreach (var upg in Shiftorium.GetAvailable()) {
- if (upg.ID.Length > maxLength) {
+ foreach (var upg in Shiftorium.GetAvailable())
+ {
+ if (upg.ID.Length > maxLength)
+ {
maxLength = upg.ID.Length;
}
@@ -454,11 +520,14 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}");
Console.WriteLine("ID".PadRight((maxLength + 5) - 2) + "Cost (Codepoints)");
- foreach (var upg in upgrades) {
+ foreach (var upg in upgrades)
+ {
Console.WriteLine(upg.Key.PadRight((maxLength + 5) - upg.Key.Length) + " " + upg.Value.ToString());
}
return true;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
CrashHandler.Start(e);
return false;
}
@@ -466,15 +535,18 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}");
}
[Namespace("win")]
- public static class WindowCommands {
+ public static class WindowCommands
+ {
[Command("list")]
- public static bool List() {
+ public static bool List()
+ {
Console.WriteLine("{ID}\t{WINDOW}");
- foreach (var app in AppearanceManager.OpenForms) {
+ foreach (var app in AppearanceManager.OpenForms)
+ {
//All .NET object instances have a unique hash code. Good for fake process management.
Console.WriteLine($"{app.GetHashCode()}\t{app.Text}");
}
@@ -536,7 +608,32 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}");
}
else
{
- Console.WriteLine("Please specify a valid 'app' param.");
+ foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
+ {
+ if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll"))
+ {
+ var asm = Assembly.LoadFile(asmExec);
+
+ foreach (var type in asm.GetTypes())
+ {
+ if (type.GetInterfaces().Contains(typeof(IShiftOSWindow)))
+ {
+ foreach (var attr in type.GetCustomAttributes(false))
+ {
+ if (attr is WinOpenAttribute)
+ {
+ if (Shiftorium.UpgradeAttributesUnlocked(type))
+ {
+ Console.WriteLine("win.open{app:\"" + (attr as WinOpenAttribute).ID + "\"}");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
return true;
}
Console.WriteLine("Couldn't find the specified app on your system.");
diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs
index 4b5312a..7678bca 100644
--- a/ShiftOS_TheReturn/SaveSystem.cs
+++ b/ShiftOS_TheReturn/SaveSystem.cs
@@ -154,19 +154,6 @@ namespace ShiftOS.Engine
}
- if(CurrentSave.StoryPosition == 1)
- {
- Desktop.InvokeOnWorkerThread(new Action(() =>
- {
- TutorialManager.StartTutorial();
- }));
-
- while(CurrentSave.StoryPosition < 2)
- {
-
- }
- }
-
Thread.Sleep(75);
@@ -189,6 +176,14 @@ namespace ShiftOS.Engine
Shiftorium.LogOrphanedUpgrades = true;
Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher()));
GameReady?.Invoke();
+ if (CurrentSave.StoryPosition == 1)
+ {
+ Desktop.InvokeOnWorkerThread(new Action(() =>
+ {
+ TutorialManager.StartTutorial();
+ }));
+ }
+
}));
thread.IsBackground = true;
thread.Start();
diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs
index bba5510..156a916 100644
--- a/ShiftOS_TheReturn/TerminalBackend.cs
+++ b/ShiftOS_TheReturn/TerminalBackend.cs
@@ -36,6 +36,8 @@ namespace ShiftOS.Engine
{
public static class TerminalBackend
{
+ public static event Action<string, string> CommandProcessed;
+
public static bool Elevated { get; set; }
public static Dictionary<string, object> GetArgs(ref string text)
@@ -84,6 +86,7 @@ namespace ShiftOS.Engine
args: ""{JsonConvert.SerializeObject(args)}""
}}");
}
+ CommandProcessed?.Invoke(text, JsonConvert.SerializeObject(args));
}
catch (Exception ex)
{
diff --git a/ShiftOS_TheReturn/TutorialManager.cs b/ShiftOS_TheReturn/TutorialManager.cs
index 1d8943e..2145977 100644
--- a/ShiftOS_TheReturn/TutorialManager.cs
+++ b/ShiftOS_TheReturn/TutorialManager.cs
@@ -12,22 +12,54 @@ namespace ShiftOS.Engine
public static void RegisterTutorial(ITutorial tut)
{
+ IsInTutorial = false;
_tut = tut;
_tut.OnComplete += (o, a) =>
{
SaveSystem.CurrentSave.StoryPosition = 2;
+ IsInTutorial = false;
};
}
+ public static bool IsInTutorial
+ {
+ get; private set;
+ }
+
+ public static int Progress
+ {
+ get
+ {
+ return _tut.TutorialProgress;
+ }
+ }
+
public static void StartTutorial()
{
+ IsInTutorial = true;
_tut.Start();
}
}
public interface ITutorial
{
+ int TutorialProgress { get; set; }
void Start();
event EventHandler OnComplete;
}
+
+ public class TutorialLockAttribute : Attribute
+ {
+ public TutorialLockAttribute(int progress)
+ {
+ Progress = progress;
+ }
+
+ public TutorialLockAttribute() : this(0)
+ {
+
+ }
+
+ public int Progress { get; private set; }
+ }
}