From a64eec381d01cf02c94eabccca30f5d4606d400a Mon Sep 17 00:00:00 2001 From: iRebbok Date: Wed, 10 Feb 2021 19:09:38 +0300 Subject: [PATCH 1/8] fix key not being detected if tmux send-keys is used --- MultiAdmin/ServerIO/InputHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MultiAdmin/ServerIO/InputHandler.cs b/MultiAdmin/ServerIO/InputHandler.cs index cd00f46..8325df5 100644 --- a/MultiAdmin/ServerIO/InputHandler.cs +++ b/MultiAdmin/ServerIO/InputHandler.cs @@ -114,7 +114,7 @@ public static async Task GetInputLineOld(Server server, CancellationToke StringBuilder message = new StringBuilder(); while (true) { - await WaitForKey(cancellationToken); + //await WaitForKey(cancellationToken); ConsoleKeyInfo key = Console.ReadKey(server.ServerConfig.HideInput.Value); @@ -151,7 +151,7 @@ public static async Task GetInputLineNew(Server server, CancellationToke { #region Key Press Handling - await WaitForKey(cancellationToken); + //await WaitForKey(cancellationToken); ConsoleKeyInfo key = Console.ReadKey(true); From 2b662b01f2d508ed87e14a98c29f879031f4000c Mon Sep 17 00:00:00 2001 From: iRebbok Date: Wed, 10 Feb 2021 22:31:43 +0300 Subject: [PATCH 2/8] add a new config entry 'console_input_system' & remove the config entry 'use_new_input_system' --- MultiAdmin/Config/Config.cs | 17 +++++++++++++++++ MultiAdmin/Config/MultiAdminConfig.cs | 12 +++++++++--- MultiAdmin/Program.cs | 2 +- MultiAdmin/Server.cs | 15 +++++++++++++-- MultiAdmin/ServerIO/InputHandler.cs | 14 +++++++++----- MultiAdmin/Utility/Utils.cs | 4 ++++ 6 files changed, 53 insertions(+), 11 deletions(-) diff --git a/MultiAdmin/Config/Config.cs b/MultiAdmin/Config/Config.cs index 6778c33..76911d4 100644 --- a/MultiAdmin/Config/Config.cs +++ b/MultiAdmin/Config/Config.cs @@ -241,5 +241,22 @@ public bool GetBool(string key, bool def = false) return def; } + + public ConsoleInputSystem GetConsoleInputSystem(string key, ConsoleInputSystem def = ConsoleInputSystem.New) + { + try + { + string value = GetString(key); + + if (!string.IsNullOrEmpty(value) && Enum.TryParse(value, out var consoleInputSystem)) + return consoleInputSystem; + } + catch (Exception e) + { + Program.LogDebugException(nameof(GetConsoleInputSystem), e); + } + + return def; + } } } diff --git a/MultiAdmin/Config/MultiAdminConfig.cs b/MultiAdmin/Config/MultiAdminConfig.cs index 28a6e14..1732d0b 100644 --- a/MultiAdmin/Config/MultiAdminConfig.cs +++ b/MultiAdmin/Config/MultiAdminConfig.cs @@ -50,9 +50,9 @@ public class MultiAdminConfig : InheritableConfigRegister new ConfigEntry("multiadmin_debug_log_whitelist", new string[0], "MultiAdmin Debug Logging Whitelist", "Which tags to log for MultiAdmin debug logging (Defaults to logging all if none are provided)"); - public ConfigEntry UseNewInputSystem { get; } = - new ConfigEntry("use_new_input_system", true, - "Use New Input System", "Whether to use the new input system, if false, the original input system will be used"); + public ConfigEntry ConsoleInputSystem { get; } = + new ConfigEntry("console_input_system", MultiAdmin.ConsoleInputSystem.New, + "Console Input System", "Which console input system to use"); public ConfigEntry HideInput { get; } = new ConfigEntry("hide_input", false, @@ -299,6 +299,12 @@ public override void UpdateConfigValueInheritable(ConfigEntry configEntry) break; } + case ConfigEntry config: + { + config.Value = Config.GetConsoleInputSystem(config.Key, config.Default); + break; + } + default: { throw new ArgumentException( diff --git a/MultiAdmin/Program.cs b/MultiAdmin/Program.cs index 5d24ef2..59f0c40 100644 --- a/MultiAdmin/Program.cs +++ b/MultiAdmin/Program.cs @@ -81,7 +81,7 @@ public static void Write(string message, ConsoleColor color = ConsoleColor.DarkY if (Headless) return; new ColoredMessage(Utils.TimeStampMessage(message), color).WriteLine((!MultiAdminConfig.GlobalConfig?.HideInput?.Value ?? false) && - (MultiAdminConfig.GlobalConfig?.UseNewInputSystem?.Value ?? false)); + (MultiAdminConfig.GlobalConfig?.ConsoleInputSystem.Value.IsNewInputSystem() ?? false)); } } diff --git a/MultiAdmin/Server.cs b/MultiAdmin/Server.cs index 11fb793..29513c9 100644 --- a/MultiAdmin/Server.cs +++ b/MultiAdmin/Server.cs @@ -650,9 +650,9 @@ public void Write(ColoredMessage[] messages, ConsoleColor? timeStampColor = null ColoredMessage[] timeStampedMessage = Utils.TimeStampMessage(messages, timeStampColor); - timeStampedMessage.WriteLine(!ServerConfig.HideInput.Value && ServerConfig.UseNewInputSystem.Value); + timeStampedMessage.WriteLine(!ServerConfig.HideInput.Value && ServerConfig.ConsoleInputSystem.Value.IsNewInputSystem()); - if (!ServerConfig.HideInput.Value && ServerConfig.UseNewInputSystem.Value) + if (!ServerConfig.HideInput.Value && ServerConfig.ConsoleInputSystem.Value.IsNewInputSystem()) InputHandler.WriteInputAndSetCursor(ServerConfig); } } @@ -760,4 +760,15 @@ public enum ServerStatus Stopped, StoppedUnexpectedly } + + public enum ConsoleInputSystem + { + // Represents the default input system, which calls Console.ReadLine and blocks the calling context + Original, + // Represents the "old" input system, which calls non-blocking methods + Old, + // Represents the "new" input system, which also calls non-blocking methods, + // but the main difference is great display + New, + } } diff --git a/MultiAdmin/ServerIO/InputHandler.cs b/MultiAdmin/ServerIO/InputHandler.cs index 8325df5..e319c9a 100644 --- a/MultiAdmin/ServerIO/InputHandler.cs +++ b/MultiAdmin/ServerIO/InputHandler.cs @@ -61,14 +61,18 @@ public static async void Write(Server server, CancellationToken cancellationToke } string message; - if (!server.ServerConfig.HideInput.Value && server.ServerConfig.UseNewInputSystem.Value && SectionBufferWidth - TotalIndicatorLength > 0) + if (!server.ServerConfig.HideInput.Value && server.ServerConfig.ConsoleInputSystem.Value.IsNewInputSystem() && SectionBufferWidth - TotalIndicatorLength > 0) { message = await GetInputLineNew(server, cancellationToken, prevMessages); } - else + else if (server.ServerConfig.ConsoleInputSystem.Value.IsOldInputSystem()) { message = await GetInputLineOld(server, cancellationToken); } + else + { + message = Console.ReadLine(); + } if (string.IsNullOrEmpty(message)) continue; @@ -114,7 +118,7 @@ public static async Task GetInputLineOld(Server server, CancellationToke StringBuilder message = new StringBuilder(); while (true) { - //await WaitForKey(cancellationToken); + await WaitForKey(cancellationToken); ConsoleKeyInfo key = Console.ReadKey(server.ServerConfig.HideInput.Value); @@ -151,7 +155,7 @@ public static async Task GetInputLineNew(Server server, CancellationToke { #region Key Press Handling - //await WaitForKey(cancellationToken); + await WaitForKey(cancellationToken); ConsoleKeyInfo key = Console.ReadKey(true); @@ -407,7 +411,7 @@ public static void WriteInput(ColoredMessage[] message, MultiAdminConfig config if (Program.Headless) return; MultiAdminConfig curConfig = config ?? MultiAdminConfig.GlobalConfig; - message?.Write(!curConfig.HideInput.Value && curConfig.UseNewInputSystem.Value); + message?.Write(!curConfig.HideInput.Value && curConfig.ConsoleInputSystem.Value.IsNewInputSystem()); CurrentInput = message; } diff --git a/MultiAdmin/Utility/Utils.cs b/MultiAdmin/Utility/Utils.cs index 782d783..d1221ce 100644 --- a/MultiAdmin/Utility/Utils.cs +++ b/MultiAdmin/Utility/Utils.cs @@ -253,5 +253,9 @@ public static int CompareVersionStrings(string firstVersion, string secondVersio // If the versions are perfectly identical, return 0 return 0; } + + public static bool IsNewInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.New; + public static bool IsOldInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.Old; + public static bool IsOriginInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.Original; } } From 056a6087f13f63844e0de61c1811e24a5e7da7c1 Mon Sep 17 00:00:00 2001 From: iRebbok Date: Wed, 10 Feb 2021 22:35:37 +0300 Subject: [PATCH 3/8] add support for ConfigInputSystem enum into GitHubGenerator --- MultiAdmin/Features/GithubGenerator.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MultiAdmin/Features/GithubGenerator.cs b/MultiAdmin/Features/GithubGenerator.cs index 156532c..1ab5e00 100644 --- a/MultiAdmin/Features/GithubGenerator.cs +++ b/MultiAdmin/Features/GithubGenerator.cs @@ -122,6 +122,12 @@ public void OnCall(string[] args) break; } + case ConfigEntry config: + { + stringBuilder.Append($"ConsoleInputSystem{ColumnSeparator}{config.Default}"); + break; + } + default: { stringBuilder.Append( From 389ea13fa95f54af343e485d645540bebbcf42a7 Mon Sep 17 00:00:00 2001 From: iRebbok Date: Wed, 10 Feb 2021 22:43:00 +0300 Subject: [PATCH 4/8] add a warn when the original input system is used --- MultiAdmin/Server.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MultiAdmin/Server.cs b/MultiAdmin/Server.cs index 29513c9..331180c 100644 --- a/MultiAdmin/Server.cs +++ b/MultiAdmin/Server.cs @@ -388,6 +388,9 @@ public void StartServer(bool restartOnCrash = true) Write($"Starting server with the following parameters:\n{scpslExe} {startInfo.Arguments}"); + if (ServerConfig.ConsoleInputSystem.Value.IsOriginInputSystem()) + Write("You are using the original input system. It may prevent MultiAdmin from closing and cause ghost game processes.", ConsoleColor.Red); + // Reset the supported mod features supportedModFeatures = ModFeatures.None; From 3fb6034fb4298234b7384795dd4f725630ea0193 Mon Sep 17 00:00:00 2001 From: iRebbok Date: Wed, 10 Feb 2021 22:43:54 +0300 Subject: [PATCH 5/8] fix typo; Origin -> Original --- MultiAdmin/Server.cs | 2 +- MultiAdmin/Utility/Utils.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MultiAdmin/Server.cs b/MultiAdmin/Server.cs index 331180c..228ddf5 100644 --- a/MultiAdmin/Server.cs +++ b/MultiAdmin/Server.cs @@ -388,7 +388,7 @@ public void StartServer(bool restartOnCrash = true) Write($"Starting server with the following parameters:\n{scpslExe} {startInfo.Arguments}"); - if (ServerConfig.ConsoleInputSystem.Value.IsOriginInputSystem()) + if (ServerConfig.ConsoleInputSystem.Value.IsOriginalInputSystem()) Write("You are using the original input system. It may prevent MultiAdmin from closing and cause ghost game processes.", ConsoleColor.Red); // Reset the supported mod features diff --git a/MultiAdmin/Utility/Utils.cs b/MultiAdmin/Utility/Utils.cs index d1221ce..287d90c 100644 --- a/MultiAdmin/Utility/Utils.cs +++ b/MultiAdmin/Utility/Utils.cs @@ -256,6 +256,6 @@ public static int CompareVersionStrings(string firstVersion, string secondVersio public static bool IsNewInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.New; public static bool IsOldInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.Old; - public static bool IsOriginInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.Original; + public static bool IsOriginalInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.Original; } } From 56a58f9f931a764904c8a998896da4865a5c57fd Mon Sep 17 00:00:00 2001 From: iRebbok Date: Wed, 10 Feb 2021 23:01:20 +0300 Subject: [PATCH 6/8] update readme - add info about ConsoleInputSystem --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 676f4c0..64388cf 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ multiadmin_nolog | Boolean | False | Disable logging to file multiadmin_debug_log | Boolean | True | Enables MultiAdmin debug logging, this logs to a separate file than any other logs multiadmin_debug_log_blacklist | String List | HandleMessage, StringMatches, MessageListener | Which tags to block for MultiAdmin debug logging multiadmin_debug_log_whitelist | String List | **Empty** | Which tags to log for MultiAdmin debug logging (Defaults to logging all if none are provided) -use_new_input_system | Boolean | True | Whether to use the new input system, if false, the original input system will be used +console_input_system | [ConsoleInputSystem](#ConsoleInputSystem) | New | Which console input system to use hide_input | Boolean | False | Whether to hide console input, if true, typed input will not be printed port | Unsigned Integer | 7777 | The port for the server to use copy_from_folder_on_reload | String | **Empty** | The location of a folder to copy files from into the folder defined by `config_location` whenever the configuration file is reloaded @@ -101,3 +101,13 @@ multiadmin_tick_delay | Integer | 1000 | The time in milliseconds between MultiA servers_folder | String | servers | The location of the `servers` folder for MultiAdmin to load multiple server configurations from set_title_bar | Boolean | True | Whether to set the console window's titlebar, if false, this feature won't be used start_config_on_full | String | **Empty** | Start server with this config folder once the server becomes full [Requires Modding] + + +## ConsoleInputSystem +If you are running into issues with the `tmux send-keys` command, switch to the original input system. + +String value | Intenger value | Description +--- | :---: | :----: +Original | 0 | Represents the original input system. It may prevent MultiAdmin from closing and cause ghost game processes +Old | 1 | Represents the old input system +New | 2 | Represents the new input system. The main difference from the original input system is great display From 29a533c437f3073db1dca773eacdeafad455191c Mon Sep 17 00:00:00 2001 From: Dankrushen Date: Sun, 23 May 2021 18:37:08 -0400 Subject: [PATCH 7/8] Add "ActualConsoleInputSystem" to decide which system to use dynamically --- MultiAdmin/Config/Config.cs | 5 ++-- MultiAdmin/Config/MultiAdminConfig.cs | 30 ++++++++++++++++++--- MultiAdmin/Features/GithubGenerator.cs | 3 ++- MultiAdmin/Program.cs | 3 +-- MultiAdmin/Server.cs | 21 ++++----------- MultiAdmin/ServerIO/InputHandler.cs | 36 ++++++++++++++++---------- MultiAdmin/Utility/Utils.cs | 4 --- README.md | 13 +++++----- 8 files changed, 67 insertions(+), 48 deletions(-) diff --git a/MultiAdmin/Config/Config.cs b/MultiAdmin/Config/Config.cs index 76911d4..133de2e 100644 --- a/MultiAdmin/Config/Config.cs +++ b/MultiAdmin/Config/Config.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using MultiAdmin.ConsoleTools; +using MultiAdmin.ServerIO; using MultiAdmin.Utility; namespace MultiAdmin.Config @@ -242,13 +243,13 @@ public bool GetBool(string key, bool def = false) return def; } - public ConsoleInputSystem GetConsoleInputSystem(string key, ConsoleInputSystem def = ConsoleInputSystem.New) + public InputHandler.ConsoleInputSystem GetConsoleInputSystem(string key, InputHandler.ConsoleInputSystem def = InputHandler.ConsoleInputSystem.New) { try { string value = GetString(key); - if (!string.IsNullOrEmpty(value) && Enum.TryParse(value, out var consoleInputSystem)) + if (!string.IsNullOrEmpty(value) && Enum.TryParse(value, out var consoleInputSystem)) return consoleInputSystem; } catch (Exception e) diff --git a/MultiAdmin/Config/MultiAdminConfig.cs b/MultiAdmin/Config/MultiAdminConfig.cs index 1732d0b..7911b7e 100644 --- a/MultiAdmin/Config/MultiAdminConfig.cs +++ b/MultiAdmin/Config/MultiAdminConfig.cs @@ -50,8 +50,12 @@ public class MultiAdminConfig : InheritableConfigRegister new ConfigEntry("multiadmin_debug_log_whitelist", new string[0], "MultiAdmin Debug Logging Whitelist", "Which tags to log for MultiAdmin debug logging (Defaults to logging all if none are provided)"); - public ConfigEntry ConsoleInputSystem { get; } = - new ConfigEntry("console_input_system", MultiAdmin.ConsoleInputSystem.New, + public ConfigEntry UseNewInputSystem { get; } = + new ConfigEntry("use_new_input_system", true, + "Use New Input System", "**OBSOLETE: Use `console_input_system` instead, this config option may be removed in a future version of MultiAdmin.** Whether to use the new input system, if false, the original input system will be used"); + + public ConfigEntry ConsoleInputSystem { get; } = + new ConfigEntry("console_input_system", InputHandler.ConsoleInputSystem.New, "Console Input System", "Which console input system to use"); public ConfigEntry HideInput { get; } = @@ -172,6 +176,26 @@ public class MultiAdminConfig : InheritableConfigRegister #endregion + public InputHandler.ConsoleInputSystem ActualConsoleInputSystem + { + get + { + if (UseNewInputSystem.Value) + { + switch (ConsoleInputSystem.Value) + { + case InputHandler.ConsoleInputSystem.New: + return HideInput.Value ? InputHandler.ConsoleInputSystem.Old : InputHandler.ConsoleInputSystem.New; + + case InputHandler.ConsoleInputSystem.Old: + return InputHandler.ConsoleInputSystem.Old; + } + } + + return InputHandler.ConsoleInputSystem.Original; + } + } + public const string ConfigFileName = "scp_multiadmin.cfg"; public static readonly string GlobalConfigFilePath = Utils.GetFullPathSafe(ConfigFileName); @@ -299,7 +323,7 @@ public override void UpdateConfigValueInheritable(ConfigEntry configEntry) break; } - case ConfigEntry config: + case ConfigEntry config: { config.Value = Config.GetConsoleInputSystem(config.Key, config.Default); break; diff --git a/MultiAdmin/Features/GithubGenerator.cs b/MultiAdmin/Features/GithubGenerator.cs index 1ab5e00..3da39b2 100644 --- a/MultiAdmin/Features/GithubGenerator.cs +++ b/MultiAdmin/Features/GithubGenerator.cs @@ -4,6 +4,7 @@ using MultiAdmin.Config; using MultiAdmin.Config.ConfigHandler; using MultiAdmin.Features.Attributes; +using MultiAdmin.ServerIO; using MultiAdmin.Utility; namespace MultiAdmin.Features @@ -122,7 +123,7 @@ public void OnCall(string[] args) break; } - case ConfigEntry config: + case ConfigEntry config: { stringBuilder.Append($"ConsoleInputSystem{ColumnSeparator}{config.Default}"); break; diff --git a/MultiAdmin/Program.cs b/MultiAdmin/Program.cs index 59f0c40..b96fcf9 100644 --- a/MultiAdmin/Program.cs +++ b/MultiAdmin/Program.cs @@ -80,8 +80,7 @@ public static void Write(string message, ConsoleColor color = ConsoleColor.DarkY { if (Headless) return; - new ColoredMessage(Utils.TimeStampMessage(message), color).WriteLine((!MultiAdminConfig.GlobalConfig?.HideInput?.Value ?? false) && - (MultiAdminConfig.GlobalConfig?.ConsoleInputSystem.Value.IsNewInputSystem() ?? false)); + new ColoredMessage(Utils.TimeStampMessage(message), color).WriteLine(MultiAdminConfig.GlobalConfig?.ActualConsoleInputSystem == InputHandler.ConsoleInputSystem.New); } } diff --git a/MultiAdmin/Server.cs b/MultiAdmin/Server.cs index 228ddf5..e1f1873 100644 --- a/MultiAdmin/Server.cs +++ b/MultiAdmin/Server.cs @@ -388,8 +388,8 @@ public void StartServer(bool restartOnCrash = true) Write($"Starting server with the following parameters:\n{scpslExe} {startInfo.Arguments}"); - if (ServerConfig.ConsoleInputSystem.Value.IsOriginalInputSystem()) - Write("You are using the original input system. It may prevent MultiAdmin from closing and cause ghost game processes.", ConsoleColor.Red); + if (ServerConfig.ActualConsoleInputSystem == InputHandler.ConsoleInputSystem.Original) + Write("You are using the original input system. It may prevent MultiAdmin from closing and/or cause ghost game processes", ConsoleColor.Red); // Reset the supported mod features supportedModFeatures = ModFeatures.None; @@ -653,10 +653,10 @@ public void Write(ColoredMessage[] messages, ConsoleColor? timeStampColor = null ColoredMessage[] timeStampedMessage = Utils.TimeStampMessage(messages, timeStampColor); - timeStampedMessage.WriteLine(!ServerConfig.HideInput.Value && ServerConfig.ConsoleInputSystem.Value.IsNewInputSystem()); + timeStampedMessage.WriteLine(ServerConfig.ActualConsoleInputSystem == InputHandler.ConsoleInputSystem.New); - if (!ServerConfig.HideInput.Value && ServerConfig.ConsoleInputSystem.Value.IsNewInputSystem()) - InputHandler.WriteInputAndSetCursor(ServerConfig); + if (ServerConfig.ActualConsoleInputSystem == InputHandler.ConsoleInputSystem.New) + InputHandler.WriteInputAndSetCursor(true); } } @@ -763,15 +763,4 @@ public enum ServerStatus Stopped, StoppedUnexpectedly } - - public enum ConsoleInputSystem - { - // Represents the default input system, which calls Console.ReadLine and blocks the calling context - Original, - // Represents the "old" input system, which calls non-blocking methods - Old, - // Represents the "new" input system, which also calls non-blocking methods, - // but the main difference is great display - New, - } } diff --git a/MultiAdmin/ServerIO/InputHandler.cs b/MultiAdmin/ServerIO/InputHandler.cs index e319c9a..4888a65 100644 --- a/MultiAdmin/ServerIO/InputHandler.cs +++ b/MultiAdmin/ServerIO/InputHandler.cs @@ -4,7 +4,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using MultiAdmin.Config; using MultiAdmin.ConsoleTools; using MultiAdmin.Utility; @@ -61,11 +60,11 @@ public static async void Write(Server server, CancellationToken cancellationToke } string message; - if (!server.ServerConfig.HideInput.Value && server.ServerConfig.ConsoleInputSystem.Value.IsNewInputSystem() && SectionBufferWidth - TotalIndicatorLength > 0) + if (server.ServerConfig.ActualConsoleInputSystem == ConsoleInputSystem.New && SectionBufferWidth - TotalIndicatorLength > 0) { message = await GetInputLineNew(server, cancellationToken, prevMessages); } - else if (server.ServerConfig.ConsoleInputSystem.Value.IsOldInputSystem()) + else if (server.ServerConfig.ActualConsoleInputSystem == ConsoleInputSystem.Old) { message = await GetInputLineOld(server, cancellationToken); } @@ -256,8 +255,7 @@ public static async Task GetInputLineNew(Server server, CancellationToke SetCurrentInput(curSection.Value.Section); CurrentCursor = curSection.Value.GetRelativeIndex(messageCursor); - - WriteInputAndSetCursor(server.ServerConfig); + WriteInputAndSetCursor(true); } else { @@ -271,7 +269,7 @@ public static async Task GetInputLineNew(Server server, CancellationToke SetCurrentInput(message); CurrentCursor = messageCursor; - WriteInputAndSetCursor(server.ServerConfig); + WriteInputAndSetCursor(true); } } else if (CurrentCursor != messageCursor) @@ -295,7 +293,7 @@ public static async Task GetInputLineNew(Server server, CancellationToke SetCurrentInput(curSection.Value.Section); - WriteInputAndSetCursor(server.ServerConfig); + WriteInputAndSetCursor(true); } // Otherwise, if only the relative cursor index has changed, set only the cursor @@ -404,29 +402,28 @@ public static void SetCursor() SetCursor(CurrentCursor); } - public static void WriteInput(ColoredMessage[] message, MultiAdminConfig config = null) + public static void WriteInput(ColoredMessage[] message, bool clearConsoleLine = false) { lock (ColoredConsole.WriteLock) { if (Program.Headless) return; - MultiAdminConfig curConfig = config ?? MultiAdminConfig.GlobalConfig; - message?.Write(!curConfig.HideInput.Value && curConfig.ConsoleInputSystem.Value.IsNewInputSystem()); + message?.Write(clearConsoleLine); CurrentInput = message; } } - public static void WriteInput(MultiAdminConfig config = null) + public static void WriteInput(bool clearConsoleLine = false) { - WriteInput(CurrentInput, config); + WriteInput(CurrentInput, clearConsoleLine); } - public static void WriteInputAndSetCursor(MultiAdminConfig config = null) + public static void WriteInputAndSetCursor(bool clearConsoleLine = false) { lock (ColoredConsole.WriteLock) { - WriteInput(config); + WriteInput(clearConsoleLine); SetCursor(); } } @@ -454,5 +451,16 @@ public static void RandomizeInputColors() Program.LogDebugException(nameof(RandomizeInputColors), e); } } + + public enum ConsoleInputSystem + { + // Represents the default input system, which calls Console.ReadLine and blocks the calling context + Original, + // Represents the "old" input system, which calls non-blocking methods + Old, + // Represents the "new" input system, which also calls non-blocking methods, + // but the main difference is great display + New, + } } } diff --git a/MultiAdmin/Utility/Utils.cs b/MultiAdmin/Utility/Utils.cs index 287d90c..782d783 100644 --- a/MultiAdmin/Utility/Utils.cs +++ b/MultiAdmin/Utility/Utils.cs @@ -253,9 +253,5 @@ public static int CompareVersionStrings(string firstVersion, string secondVersio // If the versions are perfectly identical, return 0 return 0; } - - public static bool IsNewInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.New; - public static bool IsOldInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.Old; - public static bool IsOriginalInputSystem(this ConsoleInputSystem consoleInputSystem) => consoleInputSystem == ConsoleInputSystem.Original; } } diff --git a/README.md b/README.md index 64388cf..f5d306a 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Make sure that you are running Mono 5.18.0 or higher, otherwise you might have i 4. Optional: Create a file named `scp_multiadmin.cfg` within your server's folder for configuring MultiAdmin specifically for that server ## Features + - Config Generator: Generates a full default MultiAdmin config file - Config Reload: Reloads the MultiAdmin configuration file - Exit Command: Adds a graceful exit command @@ -71,7 +72,8 @@ multiadmin_nolog | Boolean | False | Disable logging to file multiadmin_debug_log | Boolean | True | Enables MultiAdmin debug logging, this logs to a separate file than any other logs multiadmin_debug_log_blacklist | String List | HandleMessage, StringMatches, MessageListener | Which tags to block for MultiAdmin debug logging multiadmin_debug_log_whitelist | String List | **Empty** | Which tags to log for MultiAdmin debug logging (Defaults to logging all if none are provided) -console_input_system | [ConsoleInputSystem](#ConsoleInputSystem) | New | Which console input system to use +use_new_input_system | Boolean | True | **OBSOLETE: Use `console_input_system` instead, this config option may be removed in a future version of MultiAdmin.** Whether to use the new input system, if false, the original input system will be used +console_input_system | ConsoleInputSystem | New | Which console input system to use hide_input | Boolean | False | Whether to hide console input, if true, typed input will not be printed port | Unsigned Integer | 7777 | The port for the server to use copy_from_folder_on_reload | String | **Empty** | The location of a folder to copy files from into the folder defined by `config_location` whenever the configuration file is reloaded @@ -102,12 +104,11 @@ servers_folder | String | servers | The location of the `servers` folder for Mul set_title_bar | Boolean | True | Whether to set the console window's titlebar, if false, this feature won't be used start_config_on_full | String | **Empty** | Start server with this config folder once the server becomes full [Requires Modding] - ## ConsoleInputSystem If you are running into issues with the `tmux send-keys` command, switch to the original input system. -String value | Intenger value | Description +String String | Integer Value | Description --- | :---: | :----: -Original | 0 | Represents the original input system. It may prevent MultiAdmin from closing and cause ghost game processes -Old | 1 | Represents the old input system -New | 2 | Represents the new input system. The main difference from the original input system is great display +Original | 0 | Represents the original input system. It may prevent MultiAdmin from closing and/or cause ghost game processes. +Old | 1 | Represents the old input system. This input system should operate similarly to the original input system but won't cause issues with MultiAdmin's functionality. +New | 2 | Represents the new input system. The main difference from the original input system is an improved display. From 4ccd67a20a90924d4d5bc7e7205496d9532564be Mon Sep 17 00:00:00 2001 From: Dankrushen Date: Mon, 24 May 2021 00:04:18 -0400 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5d306a..9b640c5 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ start_config_on_full | String | **Empty** | Start server with this config folder ## ConsoleInputSystem If you are running into issues with the `tmux send-keys` command, switch to the original input system. -String String | Integer Value | Description +String Value | Integer Value | Description --- | :---: | :----: Original | 0 | Represents the original input system. It may prevent MultiAdmin from closing and/or cause ghost game processes. Old | 1 | Represents the old input system. This input system should operate similarly to the original input system but won't cause issues with MultiAdmin's functionality.