mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Merge pull request #3017 from BruceChenQAQ/master
Add tryout command for TUI onboarding
This commit is contained in:
commit
17d4b78022
4 changed files with 152 additions and 1 deletions
63
MinecraftClient/Commands/Tryout.cs
Normal file
63
MinecraftClient/Commands/Tryout.cs
Normal file
|
|
@ -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<CmdResult> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -193,6 +193,9 @@ namespace MinecraftClient
|
|||
if (!ProcessStartupState(startupState))
|
||||
return;
|
||||
|
||||
// Wait for this issue to be fixed before enabling it: https://github.com/Consolonia/Consolonia/issues/602
|
||||
// MaybePrintClassicModeTuiRecommendation();
|
||||
|
||||
RunStartupSequence(args);
|
||||
}
|
||||
|
||||
|
|
@ -247,6 +250,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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a failed config load by prompting the user to fix or regenerate the config file.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -3558,6 +3558,51 @@ namespace MinecraftClient {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to quickly enable recommended features..
|
||||
/// </summary>
|
||||
internal static string cmd_tryout_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("cmd.tryout.desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Available quick actions:.
|
||||
/// </summary>
|
||||
internal static string cmd_tryout_list_header {
|
||||
get {
|
||||
return ResourceManager.GetString("cmd.tryout.list.header", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to tui: set [Console.General] ConsoleMode = "tui" for the next restart..
|
||||
/// </summary>
|
||||
internal static string cmd_tryout_list_tui {
|
||||
get {
|
||||
return ResourceManager.GetString("cmd.tryout.list.tui", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
internal static string cmd_tryout_tui_already_enabled {
|
||||
get {
|
||||
return ResourceManager.GetString("cmd.tryout.tui.already_enabled", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
internal static string cmd_tryout_tui_enabled {
|
||||
get {
|
||||
return ResourceManager.GetString("cmd.tryout.tui.enabled", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Display Health and Food saturation..
|
||||
/// </summary>
|
||||
|
|
@ -5534,6 +5579,15 @@ namespace MinecraftClient {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
internal static string mcc_console_mode_tui_recommendation {
|
||||
get {
|
||||
return ResourceManager.GetString("mcc.console_mode_tui_recommendation", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to To sign in, open {0} in your browser and enter the code: {1}.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1249,6 +1249,21 @@ Change EnableEmoji=false in the settings if the display is confusing.</value>
|
|||
<data name="cmd.effects.none" xml:space="preserve">
|
||||
<value>No active effects.</value>
|
||||
</data>
|
||||
<data name="cmd.tryout.desc" xml:space="preserve">
|
||||
<value>try a recommended feature.</value>
|
||||
</data>
|
||||
<data name="cmd.tryout.list.header" xml:space="preserve">
|
||||
<value>Available tryouts:</value>
|
||||
</data>
|
||||
<data name="cmd.tryout.list.tui" xml:space="preserve">
|
||||
<value>tui: set [Console.General] ConsoleMode = "tui" for the next restart.</value>
|
||||
</data>
|
||||
<data name="cmd.tryout.tui.already_enabled" xml:space="preserve">
|
||||
<value>[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.</value>
|
||||
</data>
|
||||
<data name="cmd.tryout.tui.enabled" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="cmd.health.desc" xml:space="preserve">
|
||||
<value>Display Health and Food saturation.</value>
|
||||
</data>
|
||||
|
|
@ -1863,6 +1878,9 @@ You can use "/chunk status {0:0.0} {1:0.0} {2:0.0}" to check the chunk loading s
|
|||
<data name="mcc.connecting" xml:space="preserve">
|
||||
<value>Connecting to {0}...</value>
|
||||
</data>
|
||||
<data name="mcc.console_mode_tui_recommendation" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="mcc.device_code_prompt" xml:space="preserve">
|
||||
<value>To sign in, open {0} in your browser and enter the code: §e{1}</value>
|
||||
</data>
|
||||
|
|
@ -2392,4 +2410,4 @@ see item details.</value>
|
|||
<data name="tui.crafting.grid" xml:space="preserve">
|
||||
<value>Crafting</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue