From c73611e5c5d681dae2da7b2b3aa186e60c7cf896 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 6 Feb 2017 15:21:53 -0500 Subject: [PATCH] OSFT-ifying part 1: infobox debug commands --- ShiftOS_TheReturn/Commands.cs | 49 ++++++++++++++++++++++++++++ ShiftOS_TheReturn/TerminalBackend.cs | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index bfcdb7e..455da27 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -44,6 +44,55 @@ using ShiftOS.Objects.ShiftFS; namespace ShiftOS.Engine { + [Namespace("infobox", hide = true)] + [RequiresUpgrade("desktop;wm_free_placement")] + public static class InfoboxDebugCommands + { + + [RequiresArgument("title")] + [RequiresArgument("msg")] + [Command("show")] + public static bool ShowInfo(Dictionary args) + { + Infobox.Show(args["title"].ToString(), args["msg"].ToString()); + return true; + } + + [RequiresArgument("title")] + [RequiresArgument("msg")] + [Command("yesno")] + public static bool ShowYesNo(Dictionary args) + { + bool forwarding = TerminalBackend.IsForwardingConsoleWrites; + Action callback = (result) => + { + TerminalBackend.IsForwardingConsoleWrites = forwarding; + string resultFriendly = (result == true) ? "yes" : "no"; + Console.WriteLine($"{SaveSystem.CurrentSave.Username} says {resultFriendly}."); + TerminalBackend.IsForwardingConsoleWrites = false; + }; + Infobox.PromptYesNo(args["title"].ToString(), args["msg"].ToString(), callback); + return true; + } + + [RequiresArgument("title")] + [RequiresArgument("msg")] + [Command("text")] + public static bool ShowText(Dictionary args) + { + bool forwarding = TerminalBackend.IsForwardingConsoleWrites; + Action callback = (result) => + { + TerminalBackend.IsForwardingConsoleWrites = forwarding; + Console.WriteLine($"{SaveSystem.CurrentSave.Username} says \"{result}\"."); + TerminalBackend.IsForwardingConsoleWrites = false; + }; + Infobox.PromptText(args["title"].ToString(), args["msg"].ToString(), callback); + return true; + } + + } + [Namespace("audio")] public static class AudioCommands { diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 7a1ce3e..8a8828e 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -316,7 +316,7 @@ namespace ShiftOS.Engine ServerManager.MessageReceived += onMessageReceived; } - public static bool IsForwardingConsoleWrites { get; private set; } + public static bool IsForwardingConsoleWrites { get; internal set; } public static string ForwardGUID { get; private set; } }