aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.WinForms')
-rw-r--r--ShiftOS.WinForms/Applications/Terminal.cs46
-rw-r--r--ShiftOS.WinForms/Commands.cs24
-rw-r--r--ShiftOS.WinForms/Resources/Shiftorium.txt6
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.",