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/Applications/Terminal.cs | |
| 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/Applications/Terminal.cs')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Terminal.cs | 46 |
1 files changed, 36 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() |
