diff --git a/MinecraftClient/Commands/Tryout.cs b/MinecraftClient/Commands/Tryout.cs new file mode 100644 index 00000000..8ae0829b --- /dev/null +++ b/MinecraftClient/Commands/Tryout.cs @@ -0,0 +1,63 @@ +using Brigadier.NET; +using Brigadier.NET.Builder; +using MinecraftClient.CommandHandler; +using static MinecraftClient.Settings.ConsoleConfigHealper.ConsoleConfig; + +namespace MinecraftClient.Commands +{ + public class Tryout : Command + { + public override string CmdName => "tryout"; + public override string CmdUsage => "tryout [list|tui]"; + public override string CmdDesc => Translations.cmd_tryout_desc; + + public override void RegisterCommand(CommandDispatcher dispatcher) + { + dispatcher.Register(l => l.Literal("help") + .Then(l => l.Literal(CmdName) + .Executes(r => GetUsage(r.Source)) + ) + ); + + dispatcher.Register(l => l.Literal(CmdName) + .Executes(r => ListTryouts(r.Source)) + .Then(l => l.Literal("list") + .Executes(r => ListTryouts(r.Source))) + .Then(l => l.Literal("tui") + .Executes(r => EnableTuiMode(r.Source))) + .Then(l => l.Literal("_help") + .Executes(r => GetUsage(r.Source)) + .Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName))) + ); + } + + private int GetUsage(CmdResult r) + { + return r.SetAndReturn(GetCmdDescTranslated()); + } + + private int ListTryouts(CmdResult r) + { + return r.SetAndReturn(string.Join('\n', + GetCmdDescTranslated(), + string.Empty, + Translations.cmd_tryout_list_header, + $" - {Translations.cmd_tryout_list_tui}")); + } + + private int EnableTuiMode(CmdResult r) + { + var previousMode = Settings.Config.Console.General.ConsoleMode; + if (previousMode == ConsoleModeType.tui) + { + return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_tryout_tui_already_enabled); + } + + Settings.Config.Console.General.ConsoleMode = ConsoleModeType.tui; + Program.WriteBackSettings(); + + return r.SetAndReturn(CmdResult.Status.Done, + string.Format(Translations.cmd_tryout_tui_enabled, previousMode, ConsoleModeType.tui)); + } + } +} diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index c0e7710d..18d8ce88 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -193,6 +193,7 @@ namespace MinecraftClient if (!ProcessStartupState(startupState)) return; + MaybePrintClassicModeTuiRecommendation(); RunStartupSequence(args); } @@ -247,6 +248,19 @@ namespace MinecraftClient return true; } + private static void MaybePrintClassicModeTuiRecommendation() + { + if (ConsoleIO.BasicIO + || Config.Console.General.ConsoleMode != ConsoleModeType.classic + || Console.IsInputRedirected) + { + return; + } + + char cmdChar = Config.Main.Advanced.InternalCmdChar.ToChar(); + ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_console_mode_tui_recommendation, cmdChar)); + } + /// /// Handles a failed config load by prompting the user to fix or regenerate the config file. /// diff --git a/MinecraftClient/Resources/Translations/Translations.Designer.cs b/MinecraftClient/Resources/Translations/Translations.Designer.cs index 3a2c4bc9..242752e6 100644 --- a/MinecraftClient/Resources/Translations/Translations.Designer.cs +++ b/MinecraftClient/Resources/Translations/Translations.Designer.cs @@ -3558,6 +3558,51 @@ namespace MinecraftClient { } } + /// + /// Looks up a localized string similar to quickly enable recommended features.. + /// + internal static string cmd_tryout_desc { + get { + return ResourceManager.GetString("cmd.tryout.desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Available quick actions:. + /// + internal static string cmd_tryout_list_header { + get { + return ResourceManager.GetString("cmd.tryout.list.header", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tui: set [Console.General] ConsoleMode = "tui" for the next restart.. + /// + internal static string cmd_tryout_list_tui { + get { + return ResourceManager.GetString("cmd.tryout.list.tui", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [Console.General] ConsoleMode is already "tui" in the config. To switch back, set [Console.General] ConsoleMode = "classic". Restart MCC after changing it for the new mode to take effect.. + /// + internal static string cmd_tryout_tui_already_enabled { + get { + return ResourceManager.GetString("cmd.tryout.tui.already_enabled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Updated [Console.General] ConsoleMode from "{0}" to "{1}" in the config. To switch back, set [Console.General] ConsoleMode = "classic". Restart MCC to apply the change.. + /// + internal static string cmd_tryout_tui_enabled { + get { + return ResourceManager.GetString("cmd.tryout.tui.enabled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Display Health and Food saturation.. /// @@ -5534,6 +5579,15 @@ namespace MinecraftClient { } } + /// + /// Looks up a localized string similar to Tip: try TUI mode for a cleaner interface, mouse-friendly container actions, and a nicer layout. Run {0}feature tui§8 to switch [Console.General] ConsoleMode to "tui" for the next restart.. + /// + internal static string mcc_console_mode_tui_recommendation { + get { + return ResourceManager.GetString("mcc.console_mode_tui_recommendation", resourceCulture); + } + } + /// /// Looks up a localized string similar to To sign in, open {0} in your browser and enter the code: {1}. /// diff --git a/MinecraftClient/Resources/Translations/Translations.resx b/MinecraftClient/Resources/Translations/Translations.resx index 68202894..b028064d 100644 --- a/MinecraftClient/Resources/Translations/Translations.resx +++ b/MinecraftClient/Resources/Translations/Translations.resx @@ -1249,6 +1249,21 @@ Change EnableEmoji=false in the settings if the display is confusing. No active effects. + + try a recommended feature. + + + Available tryouts: + + + tui: set [Console.General] ConsoleMode = "tui" for the next restart. + + + [Console.General] ConsoleMode is already "tui" in the config. To switch back, set [Console.General] ConsoleMode = "classic". Restart MCC after changing it for the new mode to take effect. + + + Updated [Console.General] ConsoleMode from "{0}" to "{1}" in the config. To switch back, set [Console.General] ConsoleMode = "classic". Restart MCC to apply the change. + Display Health and Food saturation. @@ -1863,6 +1878,9 @@ You can use "/chunk status {0:0.0} {1:0.0} {2:0.0}" to check the chunk loading s Connecting to {0}... + + Tip: try TUI mode for a cleaner interface, mouse-friendly inventory actions, and a nicer layout. Run {0}tryout tui§8 to switch [Console.General] ConsoleMode to "tui" for the next restart. + To sign in, open {0} in your browser and enter the code: §e{1} @@ -2392,4 +2410,4 @@ see item details. Crafting - \ No newline at end of file +