mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
Add TUI support for /map
This commit is contained in:
parent
871bc7651f
commit
0dde017ecc
4 changed files with 254 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Threading;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using ImageMagick;
|
||||
|
|
@ -11,6 +12,7 @@ using MinecraftClient.CommandHandler;
|
|||
using MinecraftClient.CommandHandler.Patch;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Scripting;
|
||||
using MinecraftClient.Tui;
|
||||
using Tomlet.Attributes;
|
||||
|
||||
namespace MinecraftClient.ChatBots
|
||||
|
|
@ -142,7 +144,12 @@ namespace MinecraftClient.ChatBots
|
|||
SaveToFile(map);
|
||||
|
||||
if (Config.Render_In_Console)
|
||||
RenderInConsole(map);
|
||||
{
|
||||
if (ConsoleIO.Backend is TuiConsoleBackend)
|
||||
RenderInTui(map);
|
||||
else
|
||||
RenderInConsole(map);
|
||||
}
|
||||
|
||||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
|
|
@ -213,7 +220,12 @@ namespace MinecraftClient.ChatBots
|
|||
SaveToFile(map);
|
||||
|
||||
if (Config.Render_In_Console)
|
||||
RenderInConsole(map);
|
||||
{
|
||||
if (ConsoleIO.Backend is TuiConsoleBackend)
|
||||
RenderInTui(map);
|
||||
else
|
||||
RenderInConsole(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -342,6 +354,24 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
}
|
||||
|
||||
private static void RenderInTui(McMap map)
|
||||
{
|
||||
var view = TuiConsoleBackend.Instance?.GetView();
|
||||
if (view is null)
|
||||
return;
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
if (view.HasOverlay && view.OverlayContent is MapOverlay existing)
|
||||
{
|
||||
existing.UpdateMap(map);
|
||||
return;
|
||||
}
|
||||
|
||||
view.ShowOverlay(new MapOverlay(map));
|
||||
});
|
||||
}
|
||||
|
||||
private static void RenderInConsole(McMap map)
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue