feat(menus): Character and server sections in the Char menu; server plugin registry

See Changelog/2026-10-11-character-and-server-menus.md.
This commit is contained in:
BlankenshipG 2026-10-12 00:32:09 -04:00
commit eefd0a87ec
6 changed files with 364 additions and 28 deletions

View file

@ -0,0 +1,45 @@
# Char and Mini Remote menus: Character on top, server plugin windows below
## What changed
- **New server-section registry** (`UI/ServerMenus.cs`).
- Each server is defined once, with how to detect it and the command that forces it.
- Each installed plugin with windows for that server adds its items.
- A section shows only while its server is detected or forced, and only when it has at least
one item. So it appears exactly when you're on that server with one of its plugins
installed.
- Infinite Leaftide is registered in `EntryPoint.RegisterServerMenus`:
- detection: `IltInfo.IsIlt`;
- force: `/rc ilt on`;
- with RynthAi installed: the Mini Remote's Character, Quests, Pets, Banking, Gear and Games
tabs, Guardian, and Progression;
- with RynthILT installed: Bounties.
- Items are `/rc` commands, so the engine and RynthAi run the same thing.
- The engine pushes the sections to RynthAi as the `"servermenu"` remote command. It sends them
whenever they change (checked once a second from the bar's draw) and again every 30 s.
- **RynthAi dashboard, Char right-click menu:**
- Top, **Character**: Mini Remote, Spells, Skills, Inventory and Item Count.
- Bottom: the active server sections (`ServerMenus.DrawImGuiMenu`).
- When server plugins are installed but none matches the world, the bottom half shows a note
and "Treat this world as <server>".
- The menu's fixed list of ILT tabs, Guardian and Progression is replaced by the registry.
- **New and extended `/rc` commands:**
- `/rc spells [show|hide|toggle]`: RynthAi's Spells window.
- `/rc skills [show|hide|toggle]`: the Skills panel.
- `/rc progression`: the Skills panel on its Progression tab.
- `/rc miniremote tab <tab>`: opens the Mini Remote window on one of RynthAi's tabs.
## Files
- `src/RynthCore.Engine/UI/ServerMenus.cs`: new.
- `src/RynthCore.Engine/EntryPoint.cs`: `RegisterServerMenus`.
- `src/RynthCore.Engine/ImGui/ImGuiBar.cs`: calls `ServerMenus.Tick()` each frame.
- `src/RynthCore.Engine/ImGui/Panels/RynthAiFace.cs`: the Char menu (`CharMenu`,
`PanelMenuItem`) and the launcher tooltip.
- `src/RynthCore.Engine/Compatibility/RynthCoreChatCommands.cs`: `/rc spells`, `/rc skills`,
`/rc progression` and `/rc miniremote tab`.
## Testing
- The engine builds in Release, and ItemHudTests pass.
- In-game checks are listed in the matching RynthSuite changelog.

View file

@ -324,19 +324,58 @@ internal static class RynthCoreChatCommands
return true;
}
// /rc miniremote [show|hide|toggle] : the ImGui Mini Remote panel, like its bar button
// (RynthAi's dashboard and "/ra hub" use show / hide).
// /rc miniremote [show|hide|toggle|tab <tab>] : the ImGui Mini Remote panel, like its bar
// button (RynthAi's dashboard and "/ra hub" use show / hide). "tab" opens it on one of
// RynthAi's tabs (character, quests, pets, banking, gear, games; none = the remote).
if (IsVerb(sub, "miniremote", out string remoteArgs) || IsVerb(sub, "remote", out remoteArgs))
{
if (!ImGuiBackend.ImGuiPanelHost.HasFace(ImGuiBackend.Panels.MiniRemoteFace.Title))
Reply("The Mini Remote panel isn't available (the ImGui layer is off?).");
else if (IsVerb(remoteArgs, "tab", out string tab))
{
ImGuiBackend.ImGuiPanelHost.Open(ImGuiBackend.Panels.MiniRemoteFace.Title);
UI.Data.RynthAiCommands.ApplyRemoteCommand("hub", tab.Length > 0 ? "tab " + tab : "tab");
}
else if (!TryPanelMode(remoteArgs, out bool? show))
Reply("Usage: /rc miniremote [show|hide|toggle]");
Reply("Usage: /rc miniremote [show|hide|toggle|tab <tab>]");
else
SetPanelOpen(ImGuiBackend.Panels.MiniRemoteFace.Title, show);
return true;
}
// /rc skills [show|hide|toggle] : the ImGui Skills panel; /rc progression opens it on its
// Progression tab (ILT worlds; the tab shows once RynthAi reports ILT features).
if (IsVerb(sub, "skills", out string skillsArgs))
{
if (!ImGuiBackend.ImGuiPanelHost.HasFace(ImGuiBackend.Panels.SkillsFace.Title))
Reply("The Skills panel isn't available (the ImGui layer is off?).");
else if (!TryPanelMode(skillsArgs, out bool? show))
Reply("Usage: /rc skills [show|hide|toggle]");
else
SetPanelOpen(ImGuiBackend.Panels.SkillsFace.Title, show);
return true;
}
if (sub.Equals("progression", StringComparison.OrdinalIgnoreCase))
{
if (!ImGuiBackend.ImGuiPanelHost.HasFace(ImGuiBackend.Panels.SkillsFace.Title))
Reply("The Skills panel isn't available (the ImGui layer is off?).");
else
ImGuiBackend.Panels.SkillsFace.ShowProgression();
return true;
}
// /rc spells [show|hide|toggle] : RynthAi's Spells window (spell catalog, buff profiles).
if (IsVerb(sub, "spells", out string spellsArgs))
{
if (!ImGuiBackend.ImGuiPanelHost.HasFace(ImGuiBackend.Panels.RynthAiFace.Title))
Reply("The Spells window comes with RynthAi; it isn't installed.");
else if (!TryPanelMode(spellsArgs, out bool? show))
Reply("Usage: /rc spells [show|hide|toggle]");
else
UI.Data.RynthAiCommands.ApplyRemoteCommand("spells", show == null ? "toggle" : show.Value ? "show" : "hide");
return true;
}
switch (sub.ToLowerInvariant())
{
case "rl":

View file

@ -566,6 +566,44 @@ public static class EntryPoint
/// (RynthAi/RynthChat/RynthVision) on the user's launcher selection.
/// Filename match (not full-path) so users can keep the DLL anywhere.
/// </summary>
private static bool _serverMenusRegistered;
/// <summary>
/// The server sections of the Char and Mini Remote menus (UI.ServerMenus): each server once,
/// then the items of the installed plugins that have windows for it. A server whose plugins
/// are all missing gets no items, so its section never shows.
/// </summary>
private static void RegisterServerMenus(bool rynthAi, bool rynthIlt)
{
if (_serverMenusRegistered) return;
_serverMenusRegistered = true;
// Infinite Leaftide: IltInfo (host / world name lists, or "/rc ilt on" for the session).
UI.ServerMenus.DefineServer("ilt", "Infinite Leaftide", static () => IltInfo.IsIlt, "/rc ilt on");
if (rynthAi)
{
// RynthAi's ILT features: the Mini Remote's tabs (shown once the server reports each on).
foreach ((string label, string tab) in new[]
{
("Character", "character"), ("Quests", "quests"), ("Pets", "pets"),
("Banking", "banking"), ("Gear", "gear"), ("Games", "games"),
})
{
UI.ServerMenus.AddItem("ilt", new UI.ServerMenuItem(label, "/rc miniremote tab " + tab,
$"The Mini Remote's {label} tab (RynthAi).", "tab:" + tab));
}
UI.ServerMenus.AddItem("ilt", new UI.ServerMenuItem("Guardian", "/rc guardian toggle",
"Temple of Enlightenment guardians: riddle answers and Give (RynthAi)."));
}
if (rynthIlt)
UI.ServerMenus.AddItem("ilt", new UI.ServerMenuItem("Bounties", "/rc bounties toggle",
"ACECustom bounties and your progress on each (RynthILT)."));
if (rynthAi)
UI.ServerMenus.AddItem("ilt", new UI.ServerMenuItem("Progression", "/rc progression",
"XP planner, augmentations and enlightenment (the Skills panel's Progression tab)."));
UI.ServerMenus.PushToRynthAi = rynthAi;
}
private static bool HasPluginDll(string dllFileName)
{
var paths = Plugins.EngineSettings.PluginPaths;
@ -1074,6 +1112,7 @@ public static class EntryPoint
// RynthAiPanel: see the dispatcher invariant above ChatModel.EnsureSettingsLoaded.
RynthAiDashboardState.EnsureLoaded();
}
RegisterServerMenus(HasPluginDll("RynthCore.Plugin.RynthAi.dll"), HasPluginDll("RynthCore.Plugin.RynthILT.dll"));
if (trackerPresent)
TrackerSettings.EnsureLoaded();
// Hide the docked Avalonia bar before it is built if the ImGui bar stands in.

View file

@ -262,6 +262,8 @@ internal static class ImGuiBar
public static void Draw(float s)
{
// The bar draws every frame the ImGui shell is up: keep RynthAi's server menu current.
RynthCore.Engine.UI.ServerMenus.Tick();
EnsureButtons();
int step = ChromeStep(out float factor);
s *= factor;

View file

@ -540,7 +540,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
// Char and Hub open the Mini Remote window (MiniRemoteFace, hosting RynthAi's remote): Char
// on its Character tab (an ILT tab; elsewhere the remote shows), Hub as it was left.
Launcher("##l_char", PhosphorIcons.User, "Char",
"Char. Left-click: the Mini Remote on its Character tab (ILT worlds). Right-click: the Mini Remote's tabs, Guardian, Progression (Skills panel).",
"Char. Left-click: the Mini Remote on its Character tab (ILT worlds). Right-click: Character windows (Spells, Skills, Inventory...), then this server's plugin windows.",
x, y, bw, labels, () => ShowMiniRemoteTab("character"));
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
@ -753,14 +753,9 @@ internal sealed partial class RynthAiFace : IImGuiPanel
dl.AddText(font, font.FontSize, new Vector2(x + 4 + CalcWidth(font, icon) + 3, ty), White, bar.Text ?? "");
}
// ── Char menu (right-click Char): RynthAi's character windows ──────────
/// <summary>The Mini Remote's ILT tabs: menu label and the "/ra hub tab" name RynthAi parses.</summary>
private static readonly (string Label, string Section)[] HubSections =
{
("Character", "character"), ("Quests", "quests"), ("Pets", "pets"),
("Banking", "banking"), ("Gear", "gear"), ("Games", "games"),
};
// ── Char menu (right-click Char) ───────────────────────────────────
// Top: "Character", the windows every server has. Bottom: the server section
// (UI.ServerMenus): the installed server plugins' windows for the world you're on.
/// <summary>
/// Opens the Mini Remote window on one of its tabs ("" = the remote). RynthAi shows the tab
@ -772,6 +767,14 @@ internal sealed partial class RynthAiFace : IImGuiPanel
RynthAiCommands.ApplyRemoteCommand("hub", section.Length > 0 ? "tab " + section : "tab");
}
/// <summary>A Char menu item that toggles a registered ImGui panel (checked while open).</summary>
private static void PanelMenuItem(string title, string command)
{
if (!ImGuiPanelHost.HasFace(title)) return;
if (ImGuiNET.ImGui.MenuItem(title, command, ImGuiPanelHost.IsOpen(title)))
PanelRouter.Toggle(title);
}
private static void CharMenu()
{
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
@ -783,23 +786,17 @@ internal sealed partial class RynthAiFace : IImGuiPanel
if (!open) return;
try
{
// The ILT sections are tabs of the one Mini Remote window; Guardian is an ILT panel.
if (ImGuiNET.ImGui.MenuItem("Mini Remote", "/rc miniremote"))
ImGuiNET.ImGui.TextDisabled("Character");
if (ImGuiNET.ImGui.MenuItem("Mini Remote", "/rc miniremote", ImGuiPanelHost.IsOpen(MiniRemoteFace.Title)))
ShowMiniRemoteTab("");
ImGuiNET.ImGui.Separator();
ImGuiNET.ImGui.TextDisabled("Mini Remote tabs (ILT worlds)");
foreach ((string label, string section) in HubSections)
{
if (ImGuiNET.ImGui.MenuItem(label, "/ra hub open " + section))
ShowMiniRemoteTab(section);
}
if (ImGuiPanelHost.HasFace(GuardianFace.Title)
&& ImGuiNET.ImGui.MenuItem("Guardian", "/rc guardian", ImGuiPanelHost.IsOpen(GuardianFace.Title)))
PanelRouter.Toggle(GuardianFace.Title);
ImGuiNET.ImGui.Separator();
if (ImGuiNET.ImGui.MenuItem("Progression (Skills panel)"))
SkillsFace.ShowProgression();
ImGuiNET.ImGui.SetItemTooltip("XP planner, augmentations and enlightenment (ILT worlds)");
if (ImGuiNET.ImGui.MenuItem("Spells", "/rc spells"))
RynthAiCommands.ApplyRemoteCommand("spells", "toggle");
ImGuiNET.ImGui.SetItemTooltip("RynthAi Spells: the spell catalog and buff profiles.");
PanelMenuItem(SkillsFace.Title, "/rc skills");
PanelMenuItem(InventoryFace.Title, "/rc inventory");
PanelMenuItem(ItemCountFace.Title, "/rc itemcount");
UI.ServerMenus.DrawImGuiMenu(separatorFirst: true);
}
finally
{

View file

@ -0,0 +1,214 @@
// ============================================================================
// RynthCore.Engine - UI/ServerMenus.cs
// Server sections: the bottom half of the RynthAi dashboard's Char menu and of
// the Mini Remote's right-click menu (the top half, "Character", is the
// windows every server has).
//
// A server (Infinite Leaftide today) is defined once: how to tell the client
// is on it, and the command that forces it. Each installed plugin with windows
// for that server adds its items (EntryPoint, by which plugin DLLs exist). A
// section shows only while its server is detected or forced, and only with at
// least one item, so it appears exactly when you are on that server with one
// of its plugins installed. A new server or server plugin is one DefineServer
// plus its AddItem calls; neither menu changes.
//
// Items are "/rc" chat commands: the engine runs them itself
// (RynthCoreChatCommands) and RynthAi runs them through InvokeChatParser.
// RynthAi learns the sections from the "servermenu" remote command this file
// pushes (Tick: when they change, and every ResendMs in case it missed one).
// Payload: one line per section ("S", id, name, active 0/1, force command)
// followed by its items ("I", label, command, tooltip, feature), tab-separated.
// ============================================================================
using System;
using System.Collections.Generic;
using System.Text;
using RynthCore.Engine.UI.Data;
namespace RynthCore.Engine.UI;
/// <summary>
/// One menu item of a server section. <paramref name="Feature"/> is an optional key RynthAi
/// checks before enabling it ("tab:quests": that Mini Remote tab is available).
/// </summary>
internal sealed record ServerMenuItem(string Label, string Command, string Tooltip, string Feature = "");
/// <summary>A server's menu section: detection, force command and the installed plugins' items.</summary>
internal sealed class ServerMenuSection
{
public ServerMenuSection(string id, string name, Func<bool> isActive, string forceCommand)
{
Id = id;
Name = name;
IsActiveFn = isActive;
ForceCommand = forceCommand;
}
public string Id { get; }
public string Name { get; }
public string ForceCommand { get; }
internal Func<bool> IsActiveFn { get; }
internal List<ServerMenuItem> ItemList { get; } = new();
public IReadOnlyList<ServerMenuItem> Items => ItemList;
/// <summary>On this server (detected or forced). A failing check counts as not active.</summary>
public bool IsActive
{
get
{
try { return IsActiveFn(); }
catch { return false; }
}
}
}
internal static class ServerMenus
{
/// <summary>How often RynthAi gets the sections again even when nothing changed.</summary>
private const long ResendMs = 30_000;
/// <summary>How often the payload is rebuilt to look for a change.</summary>
private const long CheckMs = 1_000;
private static readonly object Gate = new();
private static readonly List<ServerMenuSection> Defined = new();
// Copy-on-write view for the render thread (definitions only change during engine init).
private static volatile ServerMenuSection[] _sections = Array.Empty<ServerMenuSection>();
private static long _nextCheckMs;
private static long _lastPushMs;
private static string _lastPayload = string.Empty;
/// <summary>RynthAi is installed: Tick pushes it the sections.</summary>
public static bool PushToRynthAi { get; set; }
/// <summary>Every defined server, in definition order (with or without items).</summary>
public static IReadOnlyList<ServerMenuSection> All => _sections;
/// <summary>
/// Defines a server (once; a second call with the same id is ignored).
/// <paramref name="isActive"/> runs on the render thread, so it must be cheap.
/// </summary>
public static void DefineServer(string id, string name, Func<bool> isActive, string forceCommand)
{
lock (Gate)
{
if (Find(id) != null) return;
Defined.Add(new ServerMenuSection(id, name, isActive, forceCommand));
_sections = Defined.ToArray();
}
}
/// <summary>An installed plugin's window for server <paramref name="serverId"/> (ignored for an unknown server).</summary>
public static void AddItem(string serverId, ServerMenuItem item)
{
lock (Gate)
{
ServerMenuSection? section = Find(serverId);
if (section == null)
{
RynthLog.UI($"ServerMenus: item '{item.Label}' names unknown server '{serverId}'; ignored.");
return;
}
section.ItemList.Add(item);
_sections = Defined.ToArray();
}
}
private static ServerMenuSection? Find(string id)
{
foreach (ServerMenuSection s in Defined)
if (s.Id.Equals(id, StringComparison.OrdinalIgnoreCase)) return s;
return null;
}
/// <summary>Runs an item's command through the engine's /rc dispatcher.</summary>
public static void Run(string command)
{
if (!Compatibility.RynthCoreChatCommands.TryHandle(command))
RynthLog.UI($"ServerMenus: '{command}' is not an engine command.");
}
// ── RynthAi push ───────────────────────────────────────────────────
/// <summary>
/// Render thread, every frame: sends RynthAi the sections when they changed (a server
/// detected or forced, or not any more) and every <see cref="ResendMs"/>.
/// </summary>
public static void Tick()
{
if (!PushToRynthAi) return;
long now = Environment.TickCount64;
if (now < _nextCheckMs) return;
_nextCheckMs = now + CheckMs;
string payload = BuildPayload();
if (payload == _lastPayload && now - _lastPushMs < ResendMs) return;
_lastPayload = payload;
_lastPushMs = now;
RynthAiCommands.ApplyRemoteCommand("servermenu", payload);
}
private static string BuildPayload()
{
var sb = new StringBuilder(256);
foreach (ServerMenuSection s in _sections)
{
if (s.Items.Count == 0) continue; // no plugin for it is installed
sb.Append('S').Append('\t').Append(Clean(s.Id)).Append('\t').Append(Clean(s.Name)).Append('\t')
.Append(s.IsActive ? '1' : '0').Append('\t').Append(Clean(s.ForceCommand)).Append('\n');
foreach (ServerMenuItem i in s.Items)
sb.Append('I').Append('\t').Append(Clean(i.Label)).Append('\t').Append(Clean(i.Command)).Append('\t')
.Append(Clean(i.Tooltip)).Append('\t').Append(Clean(i.Feature)).Append('\n');
}
return sb.ToString();
}
/// <summary>Field text without the payload's separators (the push is ANSI, so ASCII only).</summary>
private static string Clean(string text)
{
var sb = new StringBuilder(text.Length);
foreach (char c in text)
sb.Append(c is '\t' or '\n' or '\r' ? ' ' : c < 128 ? c : '?');
return sb.ToString();
}
// ── ImGui menu ─────────────────────────────────────────────────────
/// <summary>
/// The server half of an ImGui popup menu: each active section's name and items. With
/// sections installed but none active, a note and one "Treat this world as ..." item per
/// installed server. Draws nothing (not even <paramref name="separatorFirst"/>'s separator)
/// when no server plugin is installed. Returns true when it drew something.
/// </summary>
public static bool DrawImGuiMenu(bool separatorFirst = false)
{
ServerMenuSection[] sections = _sections;
bool any = false, installed = false;
foreach (ServerMenuSection s in sections)
{
if (s.Items.Count == 0) continue;
if (!installed && separatorFirst) ImGuiNET.ImGui.Separator();
installed = true;
if (!s.IsActive) continue;
any = true;
ImGuiNET.ImGui.TextDisabled(s.Name);
foreach (ServerMenuItem item in s.Items)
{
if (ImGuiNET.ImGui.MenuItem(item.Label + "##srv_" + s.Id, item.Command))
Run(item.Command);
if (item.Tooltip.Length > 0) ImGuiNET.ImGui.SetItemTooltip(item.Tooltip);
}
}
if (any || !installed) return any;
ImGuiNET.ImGui.TextDisabled("Server: no installed server plugin matches this world");
foreach (ServerMenuSection s in sections)
{
if (s.Items.Count == 0 || s.ForceCommand.Length == 0) continue;
if (ImGuiNET.ImGui.MenuItem("Treat this world as " + s.Name + "##srvforce_" + s.Id, s.ForceCommand))
Run(s.ForceCommand);
ImGuiNET.ImGui.SetItemTooltip("For this session only (testing); the world check goes back to automatic on restart.");
}
return true;
}
}