feat(engine): Settings > Charms Tracking tab

- CharmsSource polls RynthPluginGetCharmsJson while the Settings panel is open
- New last sidebar tab lists every ACECustom charm: acquired, ON/OFF, tier, server state
- Changelog: 2026-10-05-charms-tracking-tab.md

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
BlankenshipG 2026-10-05 11:44:49 -04:00
commit b0a3a7737d
4 changed files with 288 additions and 5 deletions

View file

@ -54,13 +54,24 @@ internal sealed class SettingsFace : IImGuiPanel
}
private readonly Dictionary<SettingRow, NumberEdit> _edits = new();
/// <summary>Extra sidebar tab after the schema tabs; drawn from UiSources.Charms, not settings rows.</summary>
private const string CharmsTabName = "Charms Tracking";
private static int CharmsTab => SettingsSchema.Tabs.Length;
private const string CharmsHeader = "Advanced Settings > " + CharmsTabName;
public void OnShown()
{
UiSources.Settings.Subscribe();
UiSources.Settings.RequestRefresh();
UiSources.Charms.Subscribe();
UiSources.Charms.RequestRefresh();
}
public void OnHidden() => UiSources.Settings.Unsubscribe();
public void OnHidden()
{
UiSources.Settings.Unsubscribe();
UiSources.Charms.Unsubscribe();
}
public void Draw()
{
@ -100,9 +111,9 @@ internal sealed class SettingsFace : IImGuiPanel
var dl = ImGuiNET.ImGui.GetWindowDrawList();
float w = ImGuiNET.ImGui.GetContentRegionAvail().X;
SettingsTab[] tabs = SettingsSchema.Tabs;
for (int i = 0; i < tabs.Length; i++)
for (int i = 0; i <= tabs.Length; i++)
{
string tabName = tabs[i].Name;
string tabName = i < tabs.Length ? tabs[i].Name : CharmsTabName;
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
ImGuiNET.ImGui.PushID(i);
@ -133,14 +144,23 @@ internal sealed class SettingsFace : IImGuiPanel
float w = ImGuiNET.ImGui.GetContentRegionAvail().X;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
if (_tab >= SettingsSchema.Tabs.Length) _tab = 0;
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), Headers[_tab]);
if (_tab > CharmsTab) _tab = 0;
bool charms = _tab == CharmsTab;
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), charms ? CharmsHeader : Headers[_tab]);
ImGuiNET.ImGui.PopFont();
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
Vector2 lp = ImGuiNET.ImGui.GetCursorScreenPos();
dl.AddLine(lp, lp + new Vector2(w, 0), BtnBord);
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
if (charms)
{
CharmsTabContent(w);
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.EndChild();
return;
}
SettingRow[] rows = SettingsSchema.Tabs[_tab].Rows;
for (int i = 0; i < rows.Length; i++)
{
@ -397,6 +417,130 @@ internal sealed class SettingsFace : IImGuiPanel
}
}
// ── Charms Tracking tab ───────────────────────────────────────────────
private static readonly uint CharmOn = C(0xFF33FF33), CharmDisabled = C(0xFFFF5555);
/// <summary>Summary line, one table row per ACECustom registry charm, then how each column is known.</summary>
private static void CharmsTabContent(float w)
{
var snap = UiSources.Charms.Current;
if (snap == null)
{
Note("Waiting for RynthAi...", w);
return;
}
CharmsInfo info = snap.Value;
if (!info.Available)
{
Note("Charm tracking is for ILT (Infinite Leaftide / ACECustom) worlds."
+ (info.World.Length > 0 ? " Current world: " + info.World + "." : ""), w);
Note("Use /ra hub force on to treat this world as ILT.", w);
return;
}
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFE8B333),
$"{info.AcquiredCount} of {info.Total} acquired | {info.ActiveCount} active");
ImGuiNET.ImGui.PopFont();
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(4, 3));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.TableRowBg, PanelBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.TableRowBgAlt, ShellBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.TableHeaderBg, TabActive);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.TableBorderLight, BtnBord);
const ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerH | ImGuiTableFlags.SizingFixedFit;
if (ImGuiNET.ImGui.BeginTable("##charms", 5, flags, new Vector2(w, 0)))
{
ImGuiNET.ImGui.TableSetupColumn("Charm", ImGuiTableColumnFlags.WidthStretch);
ImGuiNET.ImGui.TableSetupColumn("Acquired", ImGuiTableColumnFlags.WidthFixed, 70);
ImGuiNET.ImGui.TableSetupColumn("Status", ImGuiTableColumnFlags.WidthFixed, 44);
ImGuiNET.ImGui.TableSetupColumn("Tier", ImGuiTableColumnFlags.WidthFixed, 32);
ImGuiNET.ImGui.TableSetupColumn("Server", ImGuiTableColumnFlags.WidthFixed, 56);
ImGuiNET.ImGui.TableHeadersRow();
CharmRow[] rows = info.Charms;
for (int i = 0; i < rows.Length; i++)
{
CharmRow r = rows[i];
ImGuiNET.ImGui.PushID(i);
ImGuiNET.ImGui.TableNextRow();
ImGuiNET.ImGui.TableNextColumn();
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), r.Name);
if (r.Effect.Length > 0) ImGuiNET.ImGui.SetItemTooltip(r.Effect);
ImGuiNET.ImGui.TableNextColumn();
switch (r.Acquired)
{
case "carried":
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), r.Count > 1 ? $"Carried x{r.Count}" : "Carried");
ImGuiNET.ImGui.SetItemTooltip("In your pack or equipped.");
break;
case "seen":
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFE8B333), "Stored");
ImGuiNET.ImGui.SetItemTooltip("Owned but not carried"
+ (r.LastSeen.Length > 0 ? " (last carried " + r.LastSeen + ")" : "")
+ ". The client only sees items you carry.");
break;
default:
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "Not yet");
break;
}
ImGuiNET.ImGui.TableNextColumn();
if (r.Acquired != "carried")
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "-");
else if (r.Active == "on")
ColoredText(CharmOn, "ON");
else if (r.Active == "off")
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "OFF");
else
{
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFE8B333), "?");
ImGuiNET.ImGui.SetItemTooltip("Waiting for the charm's appraisal (requested automatically).");
}
ImGuiNET.ImGui.TableNextColumn();
string tier = r.Tier <= 0 ? "-" : r.MaxTier > 0 ? $"{r.Tier}/{r.MaxTier}" : r.Tier.ToString(CultureInfo.InvariantCulture);
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), tier);
ImGuiNET.ImGui.TableNextColumn();
if (r.Server == "off")
{
ColoredText(CharmDisabled, "Disabled");
ImGuiNET.ImGui.SetItemTooltip("The server refused or reported this charm as disabled.");
}
else if (r.Server == "on")
ColoredText(CharmOn, "Enabled");
else
{
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "-");
ImGuiNET.ImGui.SetItemTooltip("Not reported. The server only tells players when a charm is refused.");
}
ImGuiNET.ImGui.PopID();
}
ImGuiNET.ImGui.EndTable();
}
ImGuiNET.ImGui.PopStyleColor(4);
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
Note("Double-click a carried charm in your pack to toggle it. Status comes from the charm's appraisal "
+ "(Status: ON/OFF) or your character's ability flag. Charms not carried are inactive.", w);
Note("Stored = carried by this character before; RynthAi remembers it per character.", w);
}
/// <summary>TextUnformatted in a packed ImGui colour.</summary>
private static void ColoredText(uint abgr, string text)
{
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, abgr);
ImGuiNET.ImGui.TextUnformatted(text);
ImGuiNET.ImGui.PopStyleColor();
}
private static bool StepButton(string id, Vector2 pos, string glyph)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
@ -424,6 +568,7 @@ internal sealed class SettingsFace : IImGuiPanel
["Crafting"] = PhosphorIcons.Hammer,
["Looting"] = PhosphorIcons.Bag,
["Vendoring"] = PhosphorIcons.Storefront,
[CharmsTabName] = PhosphorIcons.Gift,
};
private static readonly System.Collections.Generic.Dictionary<string, string> TabLabels = new();

View file

@ -0,0 +1,78 @@
// ============================================================================
// RynthCore.Engine - UI/Data/CharmsData.cs
// RynthAi's ACECustom charm tracker for the Settings panel's "Charms
// Tracking" tab. RynthAi owns the charm registry (WCIDs, ability flags) and
// the per-character "seen" memory; this side only shows the snapshot.
// ============================================================================
using System;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text.Json.Serialization;
using RynthCore.Engine.Plugins;
namespace RynthCore.Engine.UI.Data;
/// <summary>RynthPluginGetCharmsJson's payload.</summary>
internal sealed class CharmsInfo
{
/// <summary>False off ILT-like worlds (or before RynthAi's ILT Hub exists).</summary>
[JsonPropertyName("available")] public bool Available { get; set; }
[JsonPropertyName("world")] public string World { get; set; } = "";
[JsonPropertyName("total")] public int Total { get; set; }
[JsonPropertyName("acquiredCount")] public int AcquiredCount { get; set; }
[JsonPropertyName("activeCount")] public int ActiveCount { get; set; }
[JsonPropertyName("charms")] public CharmRow[] Charms { get; set; } = Array.Empty<CharmRow>();
}
internal sealed class CharmRow
{
[JsonPropertyName("name")] public string Name { get; set; } = "";
[JsonPropertyName("effect")] public string Effect { get; set; } = "";
/// <summary>"carried" (in pack / equipped now), "seen" (carried before, now elsewhere) or "no".</summary>
[JsonPropertyName("acquired")] public string Acquired { get; set; } = "no";
/// <summary>Copies carried right now.</summary>
[JsonPropertyName("count")] public int Count { get; set; }
/// <summary>Best tier carried or last seen; 0 until an appraisal reports it.</summary>
[JsonPropertyName("tier")] public int Tier { get; set; }
[JsonPropertyName("maxTier")] public int MaxTier { get; set; }
/// <summary>Ability toggled on: "on", "off" or "unknown".</summary>
[JsonPropertyName("active")] public string Active { get; set; } = "unknown";
/// <summary>Server-side global switch as far as the client has learned it: "on", "off" or "unknown".</summary>
[JsonPropertyName("server")] public string Server { get; set; } = "unknown";
/// <summary>yyyy-MM-dd the charm was last carried (empty when never).</summary>
[JsonPropertyName("lastSeen")] public string LastSeen { get; set; } = "";
}
[JsonSerializable(typeof(CharmsInfo))]
internal sealed partial class CharmsJsonContext : JsonSerializerContext { }
/// <summary>
/// RynthPluginGetCharmsJson (single static buffer: one caller only) while the Settings panel
/// is open. Every 2 s is plenty: charm state only changes when one is picked up or toggled.
/// </summary>
internal sealed unsafe class CharmsSource : UiSource<CharmsInfo>
{
private delegate* unmanaged[Cdecl]<IntPtr> _getCharmsJson;
public CharmsSource() : base("Charms", periodMs: 2000) { }
protected internal override void Poll()
{
if (_getCharmsJson == null)
_getCharmsJson = (delegate* unmanaged[Cdecl]<IntPtr>)PluginExportBinder.Resolve("RynthAi", "RynthPluginGetCharmsJson");
if (_getCharmsJson == null) return;
IntPtr p = _getCharmsJson();
string json = p == IntPtr.Zero ? "{}" : Marshal.PtrToStringAnsi(p) ?? "{}";
CharmsInfo info;
try { info = JsonSerializer.Deserialize(json, CharmsJsonContext.Default.CharmsInfo) ?? new CharmsInfo(); }
catch (JsonException) { info = new CharmsInfo(); }
Publish(info);
}
protected internal override void Reset()
{
_getCharmsJson = null;
ClearSnapshot();
}
}

View file

@ -17,6 +17,7 @@ internal static class UiSources
public static readonly RynthAiSource RynthAi = new();
public static readonly PatrolSource Patrol = new();
public static readonly ProgressionSource Progression = new();
public static readonly CharmsSource Charms = new();
public static readonly RadarSource Radar = new();
public static readonly SettingsSource Settings = new();
public static readonly MetaSource Meta = new();
@ -54,6 +55,7 @@ internal static class UiSources
UiDataHub.Register(RynthAi);
UiDataHub.Register(Patrol);
UiDataHub.Register(Progression);
UiDataHub.Register(Charms);
UiDataHub.Register(PluginStatus);
UiDataHub.Register(Log);
UiDataHub.Register(Tracker);