// RynthAiPlugin.LocalFeatures.cs — the Mini Remote's universal tabs, floating HUDs, chat
// translation, item info, the nav overlay and the UB damage seed. (The ILT Hub moved to the RynthILT
// plugin 2026-10-13: its tabs come through RynthILT.Hub, MiniRemote/IltClient.cs, and RynthILT
// borrows from RynthAi through RynthAi.Hub, HubInterface.cs.)
//
// The engine draws the main panels. These features draw their own ImGui windows from
// RynthPluginRender / RynthPluginRenderOverlay. Lifecycle methods on RynthAiPlugin call into
// this file; they add to combat, loot and navigation and never replace them.
using System;
using System.Collections.Generic;
using ImGuiNET;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.RynthAi.MiniRemote;
using RynthCore.PluginSdk;
namespace RynthCore.Plugin.RynthAi;
public sealed partial class RynthAiPlugin
{
private NavBreadcrumbTracker? _navBreadcrumbs;
private NavOverlayRenderer? _navOverlay;
private MiniRemote.MiniRemoteController? _miniRemote;
// RynthILT's side of the Mini Remote (its ILT tabs, sections, feature bits); lives for the plugin.
private MiniRemote.IltClient? _ilt;
private Huds.HudController? _huds;
private Huds.HudIconCache? _hudIcons;
private Translate.ChatTranslator? _translator;
private Translate.TranslateUi? _translateUi;
private LegacyItemInfoUi? _itemInfoUi;
private CreatureData.UbMobSeedStore? _mobSeedStore;
// Mini Remote session stats: RynthTracker's SessionStats (Plugins\Shared), so the Mini Remote and
// the Tracker panel count the same way. Lives for the plugin; starts and ends with each login.
private RynthCore.Plugin.Shared.SessionStatsTracker? _sessionStats;
// One-time overlay diagnostics (render thread only).
private string? _overlaySkipReasonLogged;
private bool _overlayEnteredLogged;
/// Daily diagnostics log. Feature code writes through .
private void InitLocalDiagnostics()
{
try { RynthLog.Init(Host); }
catch (Exception ex) { Host.Log($"[RynthAi] diagnostics init failed: {ex.Message}"); }
try { _mobSeedStore = new CreatureData.UbMobSeedStore(); }
catch (Exception ex) { Host.Log($"[RynthAi] mob seed store failed: {ex.Message}"); }
}
/// Session stats for the Mini Remote, saved in their own folder (never RynthTracker's).
private void InitSessionStats()
{
try
{
_sessionStats = new RynthCore.Plugin.Shared.SessionStatsTracker(Host, "[RynthAi] Mini Remote stats:",
RynthCore.Plugin.Shared.TrackerSessionStore.DirectoryFor("miniremote-stats"));
}
catch (Exception ex) { Host.Log($"[RynthAi] session stats init failed: {ex.Message}"); }
}
///
/// CombatManager.MobSeedLookup: the seed's damage types for a monster, best first (highest
/// Score), or null when the seed has nothing for it. Feeds the Auto element ranking only
/// after the server table and the learned element (see CreatureWeakness.Rank).
///
private IReadOnlyList? LookupMobSeed(uint wcid, string name)
{
var store = _mobSeedStore;
if (store == null || !store.TryGetRanked(wcid, name, out var ranked) || ranked.Count == 0)
return null;
var ordered = new List(ranked);
ordered.Sort((a, b) => b.Score.CompareTo(a.Score));
var elements = new List(ordered.Count);
foreach (var e in ordered) elements.Add(e.Element);
return elements;
}
/// Chat translator survives logout; session language resets on each login.
private void EnsureTranslator()
{
try
{
if (_translator == null)
{
_translator = new Translate.ChatTranslator(Host, CurrentCharacterName);
_translateUi = new Translate.TranslateUi(_translator);
}
_translator.ResetSession();
if (_huds != null) _huds.Translate = _translateUi;
}
catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator init"); }
}
/// The logged-in character's name, or empty before login.
private string CurrentCharacterName()
=> _playerId != 0 && Host.HasGetObjectName && Host.TryGetObjectName(_playerId, out string name) ? name ?? string.Empty : string.Empty;
/// Waypoint HUD, labels, guide line, and the breadcrumb recorder.
private void CreateNavOverlay()
{
if (_dashboard == null) return;
_navBreadcrumbs = new NavBreadcrumbTracker(Host, _dashboard.Settings, DescribeNavPortal, ChatLine);
_navOverlay = new NavOverlayRenderer(Host, _dashboard.Settings, _navBreadcrumbs);
_dashboard.NavBreadcrumbs = _navBreadcrumbs; // Nav panel: trail -> route, trail stats
}
/// Nav recorder hook: (name, object class) when is a portal.
private (string Name, int ObjectClass)? DescribeNavPortal(uint id)
{
WorldObject? wo = _objectCache?[unchecked((int)id)];
if (wo == null || wo.ObjectClass != AcObjectClass.Portal || string.IsNullOrEmpty(wo.Name)) return null;
return (wo.Name, (int)AcObjectClass.Portal);
}
///
/// The Mini Remote's universal tabs and the floating HUDs for the loaded character. No-op until
/// the per-character folder exists, so login and the deferred settings load in OnTick both call this.
///
private void CreateMiniRemote()
{
if (_dashboard == null || string.IsNullOrEmpty(_dashboard.CharFolder) || _miniRemote != null)
return;
var dash = _dashboard;
_ilt ??= new MiniRemote.IltClient(Host);
_miniRemote = new MiniRemote.MiniRemoteController(Host, dash.CharFolder,
() => _objectCache, () => dash.Settings, () => _questTracker,
() => dash.SaveSettings(), _ilt);
_hudIcons ??= new Huds.HudIconCache(Host, () => _raycast?.GeometryLoader?.PortalDat);
_huds = new Huds.HudController(Host, dash.CharFolder, () => _objectCache, dash, () => _miniRemote, _hudIcons,
() => _combatManager?.activeTargetId ?? 0)
{
SessionStats = _sessionStats,
};
if (_translateUi != null) _huds.Translate = _translateUi;
// "/ra hub [show|hide|toggle]" drives the remote, "/ra hub open " its tabs.
var huds = _huds;
_miniRemote.MiniRemoteCommand = mode => "[Mini Remote] " + huds.HandleCommand("remote", mode);
_miniRemote.MiniRemoteTabCommand = (tab, mode) => huds.HandleTabCommand(tab, mode);
EnsureItemInfoUi();
EnsureSpellsUi();
}
// ── RynthAi.Hub (HubInterface.cs): what RynthILT borrows ────────────────
/// The Mini Remote on a tab for RynthILT (any thread): show / hide / toggle the remote for tab "", else the tab. Null before login.
internal string? MiniRemoteTabForIlt(string tab, string mode)
{
var huds = _huds;
if (huds == null) return null;
if (tab.Length == 0 && mode is "show" or "hide" or "toggle") return huds.HandleCommand("remote", mode);
return huds.HandleTabCommand(tab, mode);
}
/// The Mini Remote is on screen (any thread).
internal bool MiniRemoteVisibleForIlt => _huds?.MiniRemoteActive == true;
internal RynthCoreHost HostForIlt => Host;
internal Meta.QuestTracker? QuestTrackerForIlt => _questTracker;
internal MiniRemote.MiniRemoteController? MiniRemoteForIlt => _miniRemote;
internal WorldObjectCache? ObjectCacheForIlt => _objectCache;
internal RynthCore.Plugin.Shared.SessionStatsTracker? SessionStatsForIlt => _sessionStats;
/// Item Info window, created once settings exist.
private void EnsureItemInfoUi()
{
if (_dashboard == null || _itemInfoUi != null) return;
_itemInfoUi = new LegacyItemInfoUi(_dashboard.Settings);
_itemInfoUi.SetHooks(DescribeSelectedItemForPreview, PrintSelectedItemInfo, TestItemInfoChatType);
}
/// Pump-thread work for the ported features. Safe before login (each call is null-checked).
private void TickLocalFeatures()
{
try { RynthLog.Pump(); }
catch (Exception ex) { Host.Log($"[RynthAi] diagnostics pump: {ex.Message}"); }
try { _sessionStats?.Tick(); }
catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats tick"); }
try { _ilt?.Tick(); }
catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "RynthILT lookup"); }
try { _miniRemote?.Tick(); }
catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "Mini Remote Tick"); }
try { _huds?.Tick(); }
catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "Tick"); }
try { _translator?.Tick(); }
catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator Tick"); }
try { TickItemInfo(); }
catch (Exception ex) { RynthLog.Exception(LogCat.General, ex, "item info tick"); }
try { TickSpellsUi(); }
catch (Exception ex) { RynthLog.Exception(LogCat.General, ex, "spells window tick"); }
try { _navBreadcrumbs?.Tick(); }
catch (Exception ex) { RynthLog.Exception(LogCat.Navigation, ex, "nav breadcrumbs tick"); }
Loot.T11ItemSupport.SyncOverride(_dashboard?.Settings.T11ItemAugsOverride ?? -1);
}
/// Drop per-character feature objects. The translator is disposed only on plugin shutdown.
private void TeardownLocalFeatures(bool disposeTranslator)
{
try { _navBreadcrumbs?.Shutdown(); }
catch (Exception ex) { RynthLog.Exception(LogCat.Navigation, ex, "nav recorder shutdown"); }
_navBreadcrumbs = null;
if (_dashboard != null) _dashboard.NavBreadcrumbs = null;
_navOverlay = null;
try { _miniRemote?.OnLogout(); }
catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "Mini Remote logout"); }
_miniRemote = null;
_ilt?.Reset();
try { _huds?.OnLogout(); }
catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "logout"); }
_huds = null;
Huds.ServerCommandModel.Clear();
_itemInfoUi = null;
_spellsUi = null;
ResetGroundLoot(clearCaches: true);
Loot.T11ItemSupport.Reset();
if (!disposeTranslator) return;
try { _translator?.Dispose(); }
catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator dispose"); }
_translator = null;
_translateUi = null;
}
/// The Pets tab watches for its heal pet's heal; the translator records the line either way.
private void OnChatLocalFeatures(string text, int chatType, ref int eat)
{
try { _miniRemote?.OnChat(text); }
catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "Mini Remote OnChat"); }
try { _translator?.OnChatWindowText(text, chatType); }
catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator inbound"); }
}
/// True when the translator swallowed an outbound chat line (it will resend the translation).
private bool TryEatOutboundTranslation(string trimmed)
{
try
{
return _translator != null && _translator.TryInterceptOutbound(trimmed);
}
catch (Exception ex)
{
RynthLog.Exception(LogCat.Chat, ex, "translator outbound");
return false;
}
}
/// ImGui windows the engine panels do not draw.
public override void OnRender()
{
if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero)
return;
IntPtr previousContext = ImGui.GetCurrentContext();
ImGui.SetCurrentContext(Host.ImGuiContext);
try
{
DetectItemInfoClick();
_navOverlay?.Render();
_itemInfoUi?.Render();
_spellsUi?.Render();
_miniRemote?.Render();
_huds?.Render();
RenderTranslateWindow();
}
catch (Exception ex)
{
RynthLog.Exception(LogCat.UI, ex, "OnRender");
}
finally
{
ImGui.SetCurrentContext(previousContext);
}
}
///
/// Called when the engine's ImGui shell is off. Same local windows as ;
/// the engine panels are absent in that mode, so these windows are the only UI for them.
///
public void OnRenderOverlay()
{
if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero)
{
string reason = !_initialized ? "not initialized" : !_loginComplete ? "login not complete" : "no ImGui context";
if (reason != _overlaySkipReasonLogged)
{
_overlaySkipReasonLogged = reason;
RynthLog.Write(LogCat.UI, $"[Overlay] OnRenderOverlay skipped: {reason}.");
}
return;
}
if (!_overlayEnteredLogged)
{
_overlayEnteredLogged = true;
RynthLog.Write(LogCat.UI, $"[Overlay] OnRenderOverlay drawing (miniRemote={(_miniRemote != null ? "ready" : "null")}).");
}
IntPtr previousContext = ImGui.GetCurrentContext();
ImGui.SetCurrentContext(Host.ImGuiContext);
try
{
DetectItemInfoClick();
int pushedColors = LegacyDashboardRenderer.PushDashboardStyle();
try { _miniRemote?.Render(); }
finally { ImGui.PopStyleColor(pushedColors); }
_huds?.Render();
RenderTranslateWindow();
_navOverlay?.Render();
_itemInfoUi?.Render();
_spellsUi?.Render();
}
catch (Exception ex)
{
RynthLog.Exception(LogCat.UI, ex, "OnRenderOverlay");
}
finally
{
ImGui.SetCurrentContext(previousContext);
}
}
///
/// The ImGui context an embedded surface draws in: the engine's current one, which is the
/// context of the window it has begun (a popped-out panel has its own, not
/// Host.ImGuiContext; switching to Host.ImGuiContext there drew into a context that wasn't
/// mid-frame and crashed the client, 2026-10-11). Host.ImGuiContext only if none is current.
///
private IntPtr EmbedContext()
{
IntPtr current = ImGui.GetCurrentContext();
return current != IntPtr.Zero ? current : Host.ImGuiContext;
}
///
/// RynthPluginRenderEmbed "miniremote" / "miniremote-window": the Mini Remote inside the
/// engine's RynthAi dashboard drawer, or () inside the engine's Mini
/// Remote window, docked or popped out, drawn into the engine's current ImGui window (and
/// context, see ). False (nothing drawn) until login and the HUDs
/// exist. Render thread.
///
public bool RenderEmbeddedMiniRemote(bool window, out System.Numerics.Vector2 want, bool tabs = true)
{
want = default;
var huds = _huds;
if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero || huds == null)
return false;
IntPtr previousContext = ImGui.GetCurrentContext();
ImGui.SetCurrentContext(EmbedContext());
try
{
want = huds.RenderEmbedded(window, tabs);
return true;
}
catch (Exception ex)
{
RynthLog.Exception(LogCat.UI, ex, "RenderEmbeddedMiniRemote");
return false;
}
finally
{
ImGui.SetCurrentContext(previousContext);
}
}
///
/// RynthPluginRenderEmbed "miniremote-host": RynthCore's Mini Remote window is open on one of
/// its sections, so it is still the one Mini Remote (the floating copy stays hidden). Draws
/// nothing. Render thread.
///
public bool MarkEngineMiniRemote()
{
var huds = _huds;
if (!_initialized || !_loginComplete || huds == null) return false;
huds.MarkEngineWindow();
return true;
}
private Huds.FellowshipSectionUi? _fellowshipUi;
///
/// The fellowship view RynthCore's Fellowship section draws ("section:fellowship"); the
/// player's main fellowship window is RynthOracle's Fellowship tab. Render thread.
///
private Huds.FellowshipSectionUi FellowshipUi() =>
_fellowshipUi ??= new Huds.FellowshipSectionUi(() => _fellowshipTracker,
() => Host.HasGetPlayerId ? Host.GetPlayerId() : 0,
QueueServerCommand);
/// Render thread: queues a server chat command (a fellowship button) for the plugin tick.
private bool QueueServerCommand(string command)
{
if (!Host.HasInvokeChatParser || _engineCommands.Count >= MaxQueuedEngineCommands) return false;
_engineCommands.Enqueue(command);
return true;
}
///
/// RynthPluginRenderEmbed "section:<name>": one of RynthAi's views in RynthCore's Mini
/// Remote sections (Huds/SectionsManifest.cs lists them), drawn into the engine's current
/// window (and context, see ) at .
/// is the size the view would like. False (nothing drawn) for an
/// unknown view, or until login and the view's owner exist (RynthILT for the ILT tabs). Render thread.
///
public bool RenderEmbeddedSection(string surface, System.Numerics.Vector2 size, out System.Numerics.Vector2 want)
{
want = size;
var huds = _huds;
var remote = _miniRemote;
if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero) return false;
Func? draw = null;
if (surface == Huds.SectionsManifest.SessionSurface)
{
// The one session (RynthCore's Session Stats section).
if (huds == null) return false;
draw = () => { huds.RenderSessionSection(); return true; };
}
else if (surface == Huds.SectionsManifest.FellowshipSurface)
{
// RynthILT's own pane carries ILT's /fship commands in RynthCore's section.
draw = () => { FellowshipUi().Render(withServerCommands: false); return true; };
}
else if (Huds.SectionsManifest.TryOwnTabOf(surface, out string ownTab))
{
if (remote == null) return false;
want = MiniRemoteTabs.Size(ownTab);
draw = () => remote.RenderTab(ownTab);
}
else if (Huds.SectionsManifest.TryIltTabOf(surface, out string iltTab))
{
if (remote == null || !remote.Ilt.Loaded) return false;
foreach (IltTabInfo t in remote.Ilt.Tabs())
if (string.Equals(t.Id, iltTab, StringComparison.OrdinalIgnoreCase) && t.Width > 0 && t.Height > 0)
want = new System.Numerics.Vector2(t.Width, t.Height);
draw = () => remote.Ilt.RenderTab(iltTab);
}
else if (surface == Huds.SectionsManifest.SpellsSurface)
{
EnsureSpellsUi();
var spells = _spellsUi;
if (spells == null) return false;
draw = () => { spells.RenderEmbedded(); return true; };
}
if (draw == null) return false;
// The engine's Mini Remote window shows this section: it is still the one Mini Remote.
huds?.MarkEngineWindow();
IntPtr previousContext = ImGui.GetCurrentContext();
ImGui.SetCurrentContext(EmbedContext());
int pushedColors = LegacyDashboardRenderer.PushDashboardStyle();
try
{
return draw();
}
catch (Exception ex)
{
RynthLog.Exception(LogCat.UI, ex, "RenderEmbeddedSection " + surface);
return false;
}
finally
{
ImGui.PopStyleColor(pushedColors);
ImGui.SetCurrentContext(previousContext);
}
}
///
/// RynthPluginGetSectionsJson: what RynthAi adds to RynthCore's Mini Remote sections, from
/// what is available now (Huds/SectionsManifest.cs; RynthILT's tabs through RynthILT.Hub).
/// Null before login (RynthCore then shows none of RynthAi's views). Render thread.
///
public string? BuildSectionsJson()
{
if (!_initialized || !_loginComplete) return null;
var remote = _miniRemote;
IReadOnlyList iltTabs = remote != null ? remote.Ilt.Tabs() : Array.Empty();
return Huds.SectionsManifest.Build(Huds.SectionsManifest.Views(iltTabs), Huds.SectionsManifest.OwnSections);
}
/// Chat Translate window in the dashboard colours (no-op while hidden).
private void RenderTranslateWindow()
{
var ui = _translateUi;
if (ui == null || _translator?.Settings.ShowWindow != true) return;
int pushedColors = LegacyDashboardRenderer.PushDashboardStyle();
try { ui.RenderWindow(); }
finally { ImGui.PopStyleColor(pushedColors); }
}
/// "/ra huds|itemhud|remote|miniremote [show|hide|toggle]".
private void HandleHudCommand(string which, string mode)
{
if (_huds == null) { ChatLine("[RynthAi] HUDs not ready (log in first)."); return; }
ChatLine("[RynthAi] " + _huds.HandleCommand(which, mode));
}
///
/// "prog ..." from an older engine's Skills panel (newer engines send it to RynthILT, which owns
/// the progression planners since 2026-10-13): passed on to RynthILT. Pump thread.
///
private void HandleProgressionRemote(string value)
{
if (!Host.HasSendPluginCommand || !Host.SendPluginCommand("RynthILT", "prog", value))
ChatLine("[RynthAi] Progression is an Infinite Leaftide feature: it comes with the RynthILT plugin.");
}
/// "/ra itemhud add <name>" and the inventory panel's "Add to item count HUD". Pump thread.
private void HandleItemHudAdd(string name)
{
if (_huds == null) { ChatLine("[RynthAi] HUDs not ready (log in first)."); return; }
if (string.IsNullOrWhiteSpace(name)) { ChatLine("[RynthAi] Usage: /ra itemhud add - "); return; }
ChatLine("[RynthAi] " + _huds.AddToItemHudAndShow(name));
}
/// /ra translate ... — forwards to the chat translator.
private void HandleTranslateCommand(string[] parts)
{
if (_translator == null) { ChatLine("[RynthAi] Chat translator not ready (log in first)."); return; }
_translator.HandleCommand(parts.Length > 2 ? parts[2..] : Array.Empty(), ChatLine);
}
/// Parses an on/off word; returns null for anything else (caller treats it as status).
private static bool? ParseOnOff(string? word) => word?.ToLowerInvariant() switch
{
"on" or "true" or "1" or "enable" => true,
"off" or "false" or "0" or "disable" => false,
_ => null,
};
/// "/ra debug [on|off|status]" — echoes trace and exception lines to chat.
private void HandleDebugCommand(string[] parts)
{
string arg = parts.Length > 2 ? parts[2] : "status";
bool? state = arg.Equals("toggle", StringComparison.OrdinalIgnoreCase) ? !RynthLog.DebugToChat : ParseOnOff(arg);
if (state.HasValue) RynthLog.DebugToChat = state.Value;
ChatLine($"[RynthAi] Debug-to-chat is {(RynthLog.DebugToChat ? "ON" : "off")}."
+ (RynthLog.DebugToChat && RynthLog.TracedCategories().Count == 0 ? " (no categories traced — see /ra trace list)" : ""));
}
/// "/ra trace <cat|all|ilt|list> [on|off|status]".
private void HandleTraceCommand(string[] parts)
{
string target = parts.Length > 2 ? parts[2] : "status";
string? action = parts.Length > 3 ? parts[3] : null;
if (target.Equals("status", StringComparison.OrdinalIgnoreCase))
{
foreach (string l in RynthLog.StatusLines()) ChatLine(l);
return;
}
if (target.Equals("list", StringComparison.OrdinalIgnoreCase))
{
var names = new System.Collections.Generic.List();
foreach (LogCat c in Enum.GetValues())
names.Add(RynthLog.IsTracing(c) ? c + "*" : c.ToString());
ChatLine("[RynthAi] Trace categories (* = on): " + string.Join(", ", names));
return;
}
bool? state = ParseOnOff(action);
bool isAll = target.Equals("all", StringComparison.OrdinalIgnoreCase);
if (target.Equals("ilt", StringComparison.OrdinalIgnoreCase))
{
ChatLine("[RynthAi] The ILT features trace in RynthILT now: /ilt trace all on|off.");
return;
}
if (isAll)
{
if (!state.HasValue) { foreach (string l in RynthLog.StatusLines()) ChatLine(l); return; }
int n = RynthLog.SetTracingByPrefix(string.Empty, state.Value);
ChatLine($"[RynthAi] Tracing {(state.Value ? "enabled" : "disabled")} for {n} categories.");
return;
}
if (!RynthLog.TryParseCategory(target, out LogCat cat))
{
ChatLine($"[RynthAi] Unknown trace category '{target}'. Use /ra trace list.");
return;
}
if (action != null && action.Equals("status", StringComparison.OrdinalIgnoreCase))
{
ChatLine($"[RynthAi] Trace {cat}: {(RynthLog.IsTracing(cat) ? "ON" : "off")}");
return;
}
bool enable = state ?? !RynthLog.IsTracing(cat);
RynthLog.SetTracing(cat, enable);
ChatLine($"[RynthAi] Trace {cat}: {(enable ? "ON" : "off")} → {RynthLog.TraceDirectory}");
}
/// "/ra logs [open|prune|flush|file on|off]".
private void HandleLogsCommand(string[] parts)
{
string sub = parts.Length > 2 ? parts[2].ToLowerInvariant() : "status";
switch (sub)
{
case "open":
try
{
RynthLog.Flush();
System.IO.Directory.CreateDirectory(RynthLog.Directory);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("explorer.exe", $"\"{RynthLog.Directory}\"") { UseShellExecute = true });
}
catch (Exception ex) { RynthLog.Exception(LogCat.Commands, ex, "logs open"); ChatLine($"[RynthAi] Could not open {RynthLog.Directory}: {ex.Message}"); }
break;
case "prune":
ChatLine($"[RynthAi] Pruned {RynthLog.Prune()} old diagnostics file(s).");
break;
case "flush":
RynthLog.Flush();
ChatLine("[RynthAi] Diagnostics flushed to disk.");
break;
case "file":
bool? state = ParseOnOff(parts.Length > 3 ? parts[3] : null);
if (state.HasValue) RynthLog.FileLogAll = state.Value;
ChatLine($"[RynthAi] Daily RynthAi log file is {(RynthLog.FileLogAll ? "ON" : "off")}.");
break;
default:
foreach (string l in RynthLog.StatusLines()) ChatLine(l);
break;
}
}
/// /ra navrec [on|off] — toggles route recording.
private void HandleNavRecordCommand(string[] parts)
{
if (_dashboard == null) return;
var s = _dashboard.Settings;
string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : "";
s.IsRecordingNav = arg switch { "on" => true, "off" => false, _ => !s.IsRecordingNav };
ChatLine($"[RynthAi] Nav recording {(s.IsRecordingNav ? "ON — walk the route; portals are captured" : "OFF")}.");
}
/// /ra navhud [on|off] — shows or hides the navigation HUD window.
private void HandleNavHudCommand(string[] parts)
{
if (_dashboard == null) return;
var o = _dashboard.Settings.NavOverlay;
string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : "";
o.ShowHud = arg switch { "on" => true, "off" => false, _ => !o.ShowHud };
ChatLine($"[RynthAi] Nav HUD {(o.ShowHud ? "shown" : "hidden")}.");
}
/// /ra navtrail [on|off|toggle|clear] — breadcrumb tracking switch, wipe, or a status report.
private void HandleNavTrailCommand(string[] parts)
{
string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : "";
if (arg == "clear")
{
_navBreadcrumbs?.RequestClear();
ChatLine("[RynthAi] Breadcrumb trail cleared.");
return;
}
if (arg is "on" or "off" or "toggle")
{
if (_dashboard == null) return;
var o = _dashboard.Settings.NavOverlay;
o.TrackBreadcrumbs = arg switch { "on" => true, "off" => false, _ => !o.TrackBreadcrumbs };
_dashboard.SaveSettings();
ChatLine($"[RynthAi] Breadcrumb tracking {(o.TrackBreadcrumbs ? "on" : "off")}.");
return;
}
bool tracking = _dashboard?.Settings.NavOverlay.TrackBreadcrumbs ?? false;
int n = _navBreadcrumbs?.Trail.Length ?? 0;
double yd = _navBreadcrumbs?.TrailYards ?? 0;
ChatLine($"[RynthAi] Breadcrumbs {(tracking ? "on" : "off")}: {n} points, {yd:F0} yd. Use /ra navtrail on|off|clear.");
}
/// /ra navoverlay [on|off] — route overlay (rings / lines, waypoint labels, guide line); no argument toggles.
private void HandleNavOverlayCommand(string[] parts)
{
if (_dashboard == null) return;
var o = _dashboard.Settings.NavOverlay;
string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : "";
o.ShowRouteMarkers = arg switch { "on" => true, "off" => false, _ => !o.ShowRouteMarkers };
_dashboard.SaveSettings();
ChatLine($"[RynthAi] Route overlay {(o.ShowRouteMarkers ? "on" : "off")}.");
}
}