diff options
| author | Michael <[email protected]> | 2017-01-21 16:23:10 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-01-21 16:23:10 -0500 |
| commit | a531cefa00923cc89fe94750bb1b4af12a50df93 (patch) | |
| tree | 7c56b04db83b6d21351fff375e4311a264f16c12 /ShiftOS.WinForms | |
| parent | 5c9629c4c61d823dfc49693355072b38c09ffb7a (diff) | |
| download | shiftos_thereturn-a531cefa00923cc89fe94750bb1b4af12a50df93.tar.gz shiftos_thereturn-a531cefa00923cc89fe94750bb1b4af12a50df93.tar.bz2 shiftos_thereturn-a531cefa00923cc89fe94750bb1b4af12a50df93.zip | |
Terminal remote control!
Diffstat (limited to 'ShiftOS.WinForms')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Terminal.cs | 46 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Commands.cs | 24 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Resources/Shiftorium.txt | 6 |
3 files changed, 66 insertions, 10 deletions
diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 01ed194..2708e85 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -42,6 +42,7 @@ using System.Text.RegularExpressions; using System.Collections; using static ShiftOS.Engine.SkinEngine; using ShiftOS.Engine; +using ShiftOS.Objects; namespace ShiftOS.WinForms.Applications { @@ -55,6 +56,10 @@ namespace ShiftOS.WinForms.Applications public static string latestCommmand = ""; + + public static bool IsInRemoteSystem = false; + public static string RemoteGuid = ""; + [Obsolete("This is used for compatibility with old parts of the backend. Please use TerminalBackend instead.")] public static bool PrefixEnabled { @@ -110,6 +115,7 @@ namespace ShiftOS.WinForms.Applications [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); } @@ -245,19 +251,29 @@ namespace ShiftOS.WinForms.Applications var text3 = ""; var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); - if (TerminalBackend.PrefixEnabled) + if (IsInRemoteSystem == true) { - text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); + ServerManager.SendMessage("trm_invcmd", $@"{{ + guid = ""{RemoteGuid}"", + command: ""{text4}"" +}}"); } - TerminalBackend.LastCommand = text3; - TextSent?.Invoke(text4); - if (TerminalBackend.InStory == false) - { - TerminalBackend.InvokeCommand(text3); - } - if (TerminalBackend.PrefixEnabled) + else { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + if (TerminalBackend.PrefixEnabled) + { + text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); + } + TerminalBackend.LastCommand = text3; + TextSent?.Invoke(text4); + if (TerminalBackend.InStory == false) + { + TerminalBackend.InvokeCommand(text3); + } + if (TerminalBackend.PrefixEnabled) + { + Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + } } } catch @@ -337,12 +353,22 @@ namespace ShiftOS.WinForms.Applications private void Terminal_Load(object sender, EventArgs e) { + ServerManager.MessageReceived += (msg) => + { + if(msg.Name == "trm_handshake_guid") + { + IsInRemoteSystem = true; + RemoteGuid = msg.GUID; + } + }; } private void Terminal_FormClosing(object sender, FormClosingEventArgs e) { ti.Stop(); + IsInRemoteSystem = false; + RemoteGuid = ""; } public void OnLoad() diff --git a/ShiftOS.WinForms/Commands.cs b/ShiftOS.WinForms/Commands.cs index a0a1692..ba0ed31 100644 --- a/ShiftOS.WinForms/Commands.cs +++ b/ShiftOS.WinForms/Commands.cs @@ -32,12 +32,36 @@ using System.IO; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; +using Newtonsoft.Json; /// <summary> /// Coherence commands. /// </summary> namespace ShiftOS.WinForms { + [Namespace("trm")] + public static class TerminalExtensions + { + [Command("setpass", true)] + [RequiresArgument("pass")] + public static bool setPass(Dictionary<string, object> args) + { + SaveSystem.CurrentSave.Password = args["pass"] as string; + return true; + } + + [Command("remote", "username:,sysname:,pass:", "Allows you to control a remote system on the multi-user domain given a username, password and system name.")] + [RequiresArgument("username")] + [RequiresArgument("sysname")] + [RequiresArgument("pass")] + public static bool RemoteControl(Dictionary<string, object> args) + { + ServerManager.SendMessage("trm_handshake_request", JsonConvert.SerializeObject(args)); + return true; + } + } + + [Namespace("coherence")] [RequiresUpgrade("kernel_coherence")] public static class CoherenceCommands diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 614c668..575cfaa 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -303,6 +303,12 @@ Dependencies: "mud_fundamentals;app_launcher" }, { + Name: "Another test upgrade", + Cost: 1, + Description: "Read the ID or Name", + Dependencies: "test_upgrade" + }, + { Name: "Draggable windows", Cost: 400, Description: "Allows you to drag windows around with the mouse using the title bar.", |
