Merge pull request #3018 from BruceChenQAQ/master

Handle TUI startup failures with classic fallback
This commit is contained in:
BruceChen 2026-03-29 01:58:18 +08:00 committed by GitHub
commit c2475ea9e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 60 additions and 3 deletions

View file

@ -177,9 +177,16 @@ namespace MinecraftClient
if (!ConsoleIO.BasicIO && Config.Console.General.ConsoleMode == ConsoleModeType.tui) if (!ConsoleIO.BasicIO && Config.Console.General.ConsoleMode == ConsoleModeType.tui)
{ {
ConsoleIO.Backend?.Shutdown(); ConsoleIO.Backend?.Shutdown();
var tuiBackend = new Tui.TuiConsoleBackend(); try
ConsoleIO.Backend = tuiBackend; {
tuiBackend.RunTuiMainLoop(args, startupState); var tuiBackend = new Tui.TuiConsoleBackend();
ConsoleIO.Backend = tuiBackend;
tuiBackend.RunTuiMainLoop(args, startupState);
}
catch (Exception ex)
{
HandleTuiStartupFailure(ex);
}
return; return;
} }
@ -199,6 +206,20 @@ namespace MinecraftClient
RunStartupSequence(args); RunStartupSequence(args);
} }
private static void HandleTuiStartupFailure(Exception exception)
{
Config.Console.General.ConsoleMode = ConsoleModeType.classic;
WriteBackSettings(enableBackup: false);
ConsoleIO.Backend = new ClassicConsoleBackend();
ConsoleIO.Backend.Init();
ConsoleIO.WriteLineFormatted("§c" + Translations.mcc_tui_startup_failed);
ConsoleIO.WriteLine(exception.ToString());
ConsoleIO.WriteLineFormatted("§e" + Translations.mcc_report_issue);
ConsoleIO.WriteLineFormatted("§e" + Translations.mcc_tui_startup_fallback_classic);
}
/// <summary> /// <summary>
/// Prints the application banner and processes the startup state collected before /// Prints the application banner and processes the startup state collected before
/// the console backend was ready. Called once from classic mode or from TUI after /// the console backend was ready. Called once from classic mode or from TUI after

View file

@ -5587,6 +5587,33 @@ namespace MinecraftClient {
return ResourceManager.GetString("mcc.console_mode_tui_recommendation", resourceCulture); return ResourceManager.GetString("mcc.console_mode_tui_recommendation", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to MCC encountered a problem while starting TUI mode..
/// </summary>
internal static string mcc_tui_startup_failed {
get {
return ResourceManager.GetString("mcc.tui_startup_failed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to As a fallback, MCC has automatically switched [Console.General] ConsoleMode to &quot;classic&quot;. This will take effect after you restart MCC..
/// </summary>
internal static string mcc_tui_startup_fallback_classic {
get {
return ResourceManager.GetString("mcc.tui_startup_fallback_classic", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Please report this issue to the MCC Team..
/// </summary>
internal static string mcc_report_issue {
get {
return ResourceManager.GetString("mcc.report_issue", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to To sign in, open {0} in your browser and enter the code: {1}. /// Looks up a localized string similar to To sign in, open {0} in your browser and enter the code: {1}.

View file

@ -1881,6 +1881,15 @@ You can use "/chunk status {0:0.0} {1:0.0} {2:0.0}" to check the chunk loading s
<data name="mcc.console_mode_tui_recommendation" xml:space="preserve"> <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> <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>
<data name="mcc.tui_startup_failed" xml:space="preserve">
<value>MCC encountered a problem while starting TUI mode.</value>
</data>
<data name="mcc.tui_startup_fallback_classic" xml:space="preserve">
<value>As a fallback, MCC has automatically switched [Console.General] ConsoleMode to "classic". This will take effect after you restart MCC.</value>
</data>
<data name="mcc.report_issue" xml:space="preserve">
<value>Please report this issue to the MCC Team.</value>
</data>
<data name="mcc.device_code_prompt" xml:space="preserve"> <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> <value>To sign in, open {0} in your browser and enter the code: §e{1}</value>
</data> </data>