diff --git a/Changelog/2026-10-05-char-panel-rework-progression-pets-quests.md b/Changelog/2026-10-05-char-panel-rework-progression-pets-quests.md new file mode 100644 index 0000000..fbeafc4 --- /dev/null +++ b/Changelog/2026-10-05-char-panel-rework-progression-pets-quests.md @@ -0,0 +1,73 @@ +# Char panel rework: Progression on the Skills panel, Pets and Quests windows (RynthAi 0.5.4-legacy-ui) + +Date: 2026-10-05 +Branches (local): RynthCore `merge/aelrynth-2026.10.5.1`; RynthSuite `fix/rynthai-launcher-remote-commands` +Previous plugin version: 0.5.3-legacy-ui + +## Why + +The ILT Hub's Character tab mixed three different things: + +- live session stats; +- character progression (XP, augmentations, enlightenment), which belongs with skills; +- quests. + +Pets and quests are things you keep open while playing, so they get their own windows. + +## Skills panel: new Progression tab (ILT worlds only) + +The engine's Skills panel gains a third tab, **Progression**, next to Skills and Attributes & +Vitals. It shows only when RynthAi reports an ILT-like world. It has three sections: + +- **XP planner**: XP for the next raise and for the next N raises (slider 1-100) of every attribute + and vital. Costs are computed exactly from the client's XP tables (`SkillDat.CostOf`). The Hub's + version used `/xp all` and +7.5-7.7% per-level estimates. Raising stays on the Attributes & Vitals + tab. +- **Augmentations**: the Hub's planner with the same controls. It has Load /aug, Lum per Enlightened + Coin, and per-aug targets. It shows luminance and coin totals, coins short and banked luminance. +- **Enlightenment**: same controls as the Hub had: + - next step, plan-to-level totals, coins per token and tokens short; + - the requirement checklist; + - Enlighten now, auto-enlighten (arm / spend XP first / check interval). + - "Enlighten now" and arming auto-enlighten ask in a Skills-panel confirmation first. The server + still shows its own Yes/No dialog. + +How it works: + +- RynthAi still owns the planner math and the saved inputs, so the numbers can't drift from the + Hub's. +- New export `RynthPluginGetProgressionJson` (built by `IltHubController.BuildProgressionJson` and + `IltProgression.AppendSnapshotJson`). The engine polls it through the new + `UiSources.Progression` (once a second while the Skills panel is open). +- Edits go back as the remote command `prog `, handled by `IltProgression.HandleRemote` + on the pump thread. The subcommands are `augload`, `augtarget`, `lumpercoin`, `enltarget`, + `coinspertoken`, `enlighten`, `autoenl on|off|arm`, `spendfirst` and `checkevery`. + +## Pets and Quests windows + +- **Pets**: new undocked "Pets" window. Open it with `/ra pets [show|hide|toggle]`, the Pet tab's + "Pop out" button, or Char right-click > Pets window. Closing it docks the roster back into the Pet + tab. It draws only on ILT worlds. The open state is saved per character (`PetsWindowOpen`). +- **Quests**: the existing undocked quest window now carries Quest bonus (`/qb`) above the tracker. + Open it with `/ra quests window [show|hide|toggle]` or Char right-click > Quests window. + +## ILT Hub layout + +- Tabs: **Character · Quests · Pet · Banking · Gear · Games**. Tab buttons are narrower (92 px) so + all six fit the Hub's width. +- **Character**: Session rates, plus a note pointing to the Skills panel's Progression tab. +- **Quests** (new tab): Quest tracker + Quest bonus. It shows "open in its own window / Dock back" + while the Quests window is open. +- **Pet**: the roster with a "Pop out" button. It shows "Dock back" while the Pets window is open. +- Saved tab selections still open the same tab. New tabs are appended to the persisted index list, + and only the display order changed. +- Removed from the Hub: the XP calculator (replaced by the exact Skills-panel planner) and the Hub's + copies of the Augmentations / Enlightenment UI. Unused `/xp all` capture and `/attr` raise code + went with them. The spend-XP-before-auto-enlighten loop is unchanged. + +## Dashboard + +- **Char** launcher, left-click: ILT Hub (unchanged). +- **Char** launcher, right-click (new menu): ILT Hub, Pets window, Quests window, and + Progression (Skills panel). Progression opens the Skills panel on the Progression tab + (`SkillsFace.ShowProgression`). diff --git a/src/RynthCore.Engine/ImGui/Panels/RynthAiFace.cs b/src/RynthCore.Engine/ImGui/Panels/RynthAiFace.cs index fb50349..c379cce 100644 --- a/src/RynthCore.Engine/ImGui/Panels/RynthAiFace.cs +++ b/src/RynthCore.Engine/ImGui/Panels/RynthAiFace.cs @@ -145,6 +145,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel } Bars(view, raw, x0, width, boxBg); PatrolPopup(); + CharMenu(); MeasureAndFit(start.Y); // Last: a window of its own, placed against this one's rect (hidden popped out). _drawers.Draw(); @@ -520,8 +521,14 @@ internal sealed partial class RynthAiFace : IImGuiPanel // Char and Hub open RynthAi's own ImGui overlay windows (ILT Hub, Mini Remote, Inventory // HUDs). They draw only when the engine hands plugins its ImGui context. - Launcher("##l_char", PhosphorIcons.User, "Char", "Character hub (ILT Hub) - same as /ra hub show", + Launcher("##l_char", PhosphorIcons.User, "Char", + "Char. Left-click: ILT Hub (/ra hub show). Right-click: Pets, Quests, Progression (Skills panel).", x, y, bw, labels, () => RynthAiCommands.ApplyRemoteCommand("hub", "show")); + if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + ImGuiNET.ImGui.SetNextWindowPos(ImGuiNET.ImGui.GetItemRectMin(), ImGuiCond.Always, new Vector2(0, 1)); + ImGuiNET.ImGui.OpenPopup("##charmenu"); + } x += bw + LauncherGap; Launcher("##l_hub", PhosphorIcons.SquaresFour, "Hub", "Hub. Left-click: Mini Remote (/ra remote). Right-click: Inventory HUDs setup (/ra huds).", @@ -694,6 +701,36 @@ 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 ────────── + + private static void CharMenu() + { + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord); + ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8, 8)); + bool open = ImGuiNET.ImGui.BeginPopup("##charmenu"); + ImGuiNET.ImGui.PopStyleVar(); + ImGuiNET.ImGui.PopStyleColor(2); + if (!open) return; + try + { + if (ImGuiNET.ImGui.MenuItem("ILT Hub", "/ra hub")) + RynthAiCommands.ApplyRemoteCommand("hub", "show"); + if (ImGuiNET.ImGui.MenuItem("Pets window", "/ra pets")) + RynthAiCommands.ApplyRemoteCommand("pets", "toggle"); + if (ImGuiNET.ImGui.MenuItem("Quests window", "/ra quests window")) + RynthAiCommands.ApplyRemoteCommand("quests", "window toggle"); + ImGuiNET.ImGui.Separator(); + if (ImGuiNET.ImGui.MenuItem("Progression (Skills panel)")) + SkillsFace.ShowProgression(); + ImGuiNET.ImGui.SetItemTooltip("XP planner, augmentations and enlightenment (ILT worlds)"); + } + finally + { + ImGuiNET.ImGui.EndPopup(); + } + } + // ── Patrol popup (right-click Patrol, popped out; docked it's the Patrol drawer) ── private void PatrolPopup() diff --git a/src/RynthCore.Engine/ImGui/Panels/SkillsFace.Progression.cs b/src/RynthCore.Engine/ImGui/Panels/SkillsFace.Progression.cs new file mode 100644 index 0000000..774dd03 --- /dev/null +++ b/src/RynthCore.Engine/ImGui/Panels/SkillsFace.Progression.cs @@ -0,0 +1,326 @@ +// ============================================================================ +// RynthCore.Engine - ImGui/Panels/SkillsFace.Progression.cs +// The Skills panel's Progression tab, shown on ILT-like worlds only: +// - XP planner: exact XP for the next N raises of every attribute and vital, +// from the client's XP tables (raising stays on the Attributes & Vitals tab). +// - Augmentations / Enlightenment: RynthAi's ILT Hub planners. RynthAi owns the +// math and the saved inputs (UiSources.Progression snapshot); edits and +// actions go back as "prog ..." remote commands. /enl and arming +// auto-enlighten ask here first; the server still shows its own dialog. +// ============================================================================ + +using System; +using System.Globalization; +using System.Numerics; +using ImGuiNET; +using RynthCore.Engine.UI; +using RynthCore.Engine.UI.Data; +using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit; + +namespace RynthCore.Engine.ImGuiBackend.Panels; + +internal sealed partial class SkillsFace +{ + private const string ProgConfirmId = "##skills_prog_confirm"; + + private int _planLevels = 10; // XP planner: raises to price per row + private bool _progSubscribed; + + // The confirm the Progression tab asked for; the command is sent only on its Yes button. + private string _progConfirmTitle = "", _progConfirmText = "", _progConfirmYes = "", _progConfirmCommand = ""; + private bool _progConfirmOpenRequested; + + // Set by ShowProgression (any panel, AC thread); the tab is selected once RynthAi's snapshot + // says it exists (the first poll lands a step after the panel opens). + private static bool _progressionRequested; + + /// RynthAi reports an ILT-like world (its ILT Hub exists and the server has ILT features). + private static bool ProgressionTabVisible => UiSources.Progression.Current?.Value.Available == true; + + /// Opens the Skills panel (if closed) on the Progression tab. AC thread. + public static void ShowProgression() + { + _progressionRequested = true; + if (!ImGuiPanelHost.IsOpen(Title)) PanelRouter.Toggle(Title); + } + + /// Draw: applies a pending ShowProgression once the tab exists. + private void ApplyProgressionRequest() + { + if (!_progressionRequested || !ProgressionTabVisible) return; + _progressionRequested = false; + _tab = 2; + } + + private void ProgressionShown() + { + if (_progSubscribed) return; + _progSubscribed = true; + UiSources.Progression.Subscribe(); + UiSources.Progression.RequestRefresh(); + } + + private void ProgressionHidden() + { + _progressionRequested = false; + if (!_progSubscribed) return; + _progSubscribed = false; + UiSources.Progression.Unsubscribe(); + } + + /// Sends "prog <value>" to RynthAi; the snapshot re-polls after its next tick applies it. + private static void SendProg(string value) + { + RynthAiCommands.ApplyRemoteCommand("prog", value); + UiSources.Progression.RequestRefreshAfterPluginTick(); + } + + private void AskProgConfirm(string title, string text, string yes, string command) + { + _progConfirmTitle = title; + _progConfirmText = text; + _progConfirmYes = yes; + _progConfirmCommand = command; + _progConfirmOpenRequested = true; + } + + // ── Body ──────────────────────────────────────────────────────────── + + private void DrawProgression(float w) + { + ProgressionInfo? info = UiSources.Progression.Current?.Value; + ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(6, 4)); + try + { + DrawXpPlanner(w); + ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); + if (info == null || !info.Available) + { + Message("Augmentations and Enlightenment need RynthAi's ILT Hub on an ILT world.", w); + return; + } + DrawAugPlanner(info.Aug, w); + ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); + DrawEnlPlanner(info.Enl, w); + ImGuiNET.ImGui.Dummy(new Vector2(0, 8)); + } + finally + { + ImGuiNET.ImGui.PopStyleVar(); + } + } + + private void DrawXpPlanner(float w) + { + Section("XP planner", w); + if (_snap == null || _dat == null || _attributes.Count == 0) + { + Message("Waiting for your character's data...", w); + return; + } + ImGuiNET.ImGui.Indent(8); + long have = _snap.UnassignedXp; + Label($"Unassigned XP: {have:N0}", have > 0 ? Teal : Mute); + ImGuiNET.ImGui.SetNextItemWidth(160); + ImGuiNET.ImGui.SliderInt("Raises to plan##prog_lv", ref _planLevels, 1, 100); + + if (ImGuiNET.ImGui.BeginTable("##prog_xp", 4, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp, + new Vector2(w - 16, 0))) + { + ImGuiNET.ImGui.TableSetupColumn("Stat"); + ImGuiNET.ImGui.TableSetupColumn("Base", ImGuiTableColumnFlags.WidthFixed, 50); + ImGuiNET.ImGui.TableSetupColumn("Next raise", ImGuiTableColumnFlags.WidthFixed, 100); + ImGuiNET.ImGui.TableSetupColumn($"Next {_planLevels}", ImGuiTableColumnFlags.WidthFixed, 120); + ImGuiNET.ImGui.TableHeadersRow(); + foreach (Row r in _attributes) PlannerRow(r, have); + foreach (Row r in _vitals) PlannerRow(r, have); + ImGuiNET.ImGui.EndTable(); + } + Label("Exact costs from the client's XP tables. Raise on the Attributes & Vitals tab.", Dim); + ImGuiNET.ImGui.Unindent(8); + } + + private void PlannerRow(Row r, long have) + { + ImGuiNET.ImGui.TableNextRow(); + ImGuiNET.ImGui.TableNextColumn(); ImGuiNET.ImGui.TextUnformatted(r.Name); + ImGuiNET.ImGui.TableNextColumn(); ImGuiNET.ImGui.TextUnformatted(r.Base.ToString(CultureInfo.InvariantCulture)); + uint[]? table = r.Table; + int left = table == null ? 0 : Math.Max(0, table.Length - 1 - (int)Math.Min(r.Ranks, (uint)int.MaxValue)); + ImGuiNET.ImGui.TableNextColumn(); + if (table == null || left == 0) { Label(table == null ? "-" : "max", Dim); ImGuiNET.ImGui.TableNextColumn(); Label("-", Dim); return; } + long one = SkillDat.CostOf(table, r.Ranks, r.Spent, 1); + Label(one >= 0 ? one.ToString("N0", CultureInfo.InvariantCulture) : "-", one >= 0 && one <= have ? Teal : Dim); + ImGuiNET.ImGui.TableNextColumn(); + int n = Math.Min(_planLevels, left); + long many = SkillDat.CostOf(table, r.Ranks, r.Spent, n); + string text = many >= 0 ? many.ToString("N0", CultureInfo.InvariantCulture) : "-"; + if (n < _planLevels) text += $" ({n} to max)"; + Label(text, many >= 0 && many <= have ? Teal : Dim); + } + + private void DrawAugPlanner(AugPlanner a, float w) + { + Section("Augmentations", w); + ImGuiNET.ImGui.Indent(8); + try + { + if (a.Off) { Label("/aug is not available on this server.", Mute); return; } + if (ImGuiNET.ImGui.SmallButton("Load /aug##prog")) SendProg("augload"); + ImGuiNET.ImGui.SameLine(); + Label(a.Status, Dim); + + string lpc = a.LumPerCoin.ToString(CultureInfo.InvariantCulture); + ImGuiNET.ImGui.SetNextItemWidth(160); + if (ImGuiNET.ImGui.InputTextWithHint("Lum per Enlightened Coin##prog_lpc", "0 = don't price coins", ref lpc, 24u)) + SendProg("lumpercoin " + lpc.Replace(" ", "", StringComparison.Ordinal)); + + if (ImGuiNET.ImGui.BeginTable("##prog_augs", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp, + new Vector2(w - 16, 0))) + { + ImGuiNET.ImGui.TableSetupColumn("Aug"); + ImGuiNET.ImGui.TableSetupColumn("Current", ImGuiTableColumnFlags.WidthFixed, 56); + ImGuiNET.ImGui.TableSetupColumn("Target", ImGuiTableColumnFlags.WidthFixed, 86); + ImGuiNET.ImGui.TableSetupColumn("Luminance", ImGuiTableColumnFlags.WidthFixed, 80); + ImGuiNET.ImGui.TableSetupColumn("Coins", ImGuiTableColumnFlags.WidthFixed, 60); + ImGuiNET.ImGui.TableHeadersRow(); + foreach (AugRow row in a.Rows) + { + ImGuiNET.ImGui.TableNextRow(); + ImGuiNET.ImGui.TableNextColumn(); ImGuiNET.ImGui.TextUnformatted(row.Label); + ImGuiNET.ImGui.TableNextColumn(); ImGuiNET.ImGui.TextUnformatted(row.Current.ToString(CultureInfo.InvariantCulture)); + ImGuiNET.ImGui.TableNextColumn(); + int tgt = row.Target; + ImGuiNET.ImGui.SetNextItemWidth(80); + if (ImGuiNET.ImGui.InputInt("##prog_tgt_" + row.Key, ref tgt, 0)) + SendProg($"augtarget {row.Key} {Math.Clamp(tgt, 0, Math.Max(row.Cap, 0))}"); + ImGuiNET.ImGui.TableNextColumn(); ImGuiNET.ImGui.TextUnformatted(row.Lum); + ImGuiNET.ImGui.TableNextColumn(); ImGuiNET.ImGui.TextUnformatted(row.Coins > 0 ? row.Coins.ToString(CultureInfo.InvariantCulture) : "-"); + } + ImGuiNET.ImGui.EndTable(); + } + Label(a.Total, Amber); + if (a.Short.Length > 0) Label(a.Short, Text); + Label(a.Banked, Dim); + } + finally + { + ImGuiNET.ImGui.Unindent(8); + } + } + + private void DrawEnlPlanner(EnlPlanner e, float w) + { + Section("Enlightenment", w); + ImGuiNET.ImGui.Indent(8); + float wrap = ImGuiNET.ImGui.GetCursorPosX() + w - 24; // window-local x + ImGuiNET.ImGui.PushTextWrapPos(wrap); + try + { + if (e.Off) { Label("/enl is not available on this server.", Mute); return; } + Label(e.Header, Text); + Label(e.Next, Teal); + + int target = e.Target; + ImGuiNET.ImGui.SetNextItemWidth(100); + if (ImGuiNET.ImGui.InputInt("Plan to level##prog_enlt", ref target)) + SendProg("enltarget " + Math.Max(e.Level + 1, target).ToString(CultureInfo.InvariantCulture)); + foreach (string line in e.Plan) ImGuiNET.ImGui.BulletText(line); + + int coinsPerToken = e.CoinsPerToken; + ImGuiNET.ImGui.SetNextItemWidth(100); + if (ImGuiNET.ImGui.InputInt("Coins per token (shop price)##prog_cpt", ref coinsPerToken)) + SendProg("coinspertoken " + Math.Max(0, coinsPerToken).ToString(CultureInfo.InvariantCulture)); + if (e.TokensShort.Length > 0) Label(e.TokensShort, Dim); + + ImGuiNET.ImGui.Separator(); + if (e.Blockers.Length == 0) Label("Client-side checks pass.", Green); + foreach (string b in e.Blockers) Label(b, Amber); + Label(e.ServerChecks, Dim); + + Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos(); + if (Button("##prog_enl", "Enlighten now...", p, new Vector2(150, 24), Text, BtnFill, border: Teal)) + AskProgConfirm("Enlighten", + "Send /enl now?\n\nEnlightening resets your level and wipes unassigned XP.\n" + + "The server will show its own Yes/No dialog - you must click Yes there.", + "Send /enl", "enlighten"); + NextLine(p, 28); + + ImGuiNET.ImGui.Separator(); + bool auto = e.Auto; + if (ImGuiNET.ImGui.Checkbox("Auto-enlighten when ready##prog_auto", ref auto)) + { + if (auto) + AskProgConfirm("Arm auto-enlighten", + "Auto-enlighten will send /enl whenever the checks pass (peace mode, level, materials).\n" + + "You still have to click Yes in the AC dialog each time.\n\nArm it for this session?", + "Arm", "autoenl on"); + else + SendProg("autoenl off"); + } + if (e.Auto && !e.Armed) + { + ImGuiNET.ImGui.SameLine(); + if (ImGuiNET.ImGui.SmallButton("Arm for this session...##prog_arm")) + AskProgConfirm("Arm auto-enlighten", "Arm auto-enlighten for this session?", "Arm", "autoenl arm"); + } + bool spend = e.SpendFirst; + if (ImGuiNET.ImGui.Checkbox("Spend unassigned XP on attributes first##prog_spend", ref spend)) + SendProg("spendfirst " + (spend ? "on" : "off")); + int every = e.CheckEvery; + ImGuiNET.ImGui.SetNextItemWidth(100); + if (ImGuiNET.ImGui.InputInt("Check every (s)##prog_every", ref every)) + SendProg("checkevery " + Math.Max(10, every).ToString(CultureInfo.InvariantCulture)); + Label(e.Armed ? "Armed." : "Disarmed.", e.Armed ? Amber : Dim); + if (e.Status.Length > 0) ImGuiNET.ImGui.TextWrapped(e.Status); + } + finally + { + ImGuiNET.ImGui.PopTextWrapPos(); + ImGuiNET.ImGui.Unindent(8); + } + } + + // ── Confirm ───────────────────────────────────────────────────────── + + /// The Progression tab's Yes/No popup (outside the body child, like DrawConfirm). + private void DrawProgressionConfirm() + { + if (_progConfirmOpenRequested) + { + _progConfirmOpenRequested = false; + ImGuiNET.ImGui.OpenPopup(ProgConfirmId); + } + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, Teal); + ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.PopupRounding, 4f); + ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(10, 8)); + bool open = ImGuiNET.ImGui.BeginPopup(ProgConfirmId); + ImGuiNET.ImGui.PopStyleVar(2); + ImGuiNET.ImGui.PopStyleColor(2); + if (!open) return; + try + { + ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11)); + Label(_progConfirmTitle, Amber); + ImGuiNET.ImGui.PopFont(); + ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + 320); + Label(_progConfirmText, Text); + ImGuiNET.ImGui.PopTextWrapPos(); + + Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos() + new Vector2(0, 4); + if (Button("##prog_yes", _progConfirmYes, p, new Vector2(120, 24), Text, StartBg)) + { + SendProg(_progConfirmCommand); + ImGuiNET.ImGui.CloseCurrentPopup(); + } + if (Button("##prog_no", "Cancel", new Vector2(p.X + 126, p.Y), new Vector2(90, 24), Text, BtnFill)) + ImGuiNET.ImGui.CloseCurrentPopup(); + NextLine(p, 28); + } + finally + { + ImGuiNET.ImGui.EndPopup(); + } + } +} diff --git a/src/RynthCore.Engine/ImGui/Panels/SkillsFace.cs b/src/RynthCore.Engine/ImGui/Panels/SkillsFace.cs index d4b55a0..beb9412 100644 --- a/src/RynthCore.Engine/ImGui/Panels/SkillsFace.cs +++ b/src/RynthCore.Engine/ImGui/Panels/SkillsFace.cs @@ -45,7 +45,7 @@ using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit; namespace RynthCore.Engine.ImGuiBackend.Panels; -internal sealed class SkillsFace : IImGuiPanel +internal sealed partial class SkillsFace : IImGuiPanel { public const string Title = "Skills"; @@ -127,7 +127,7 @@ internal sealed class SkillsFace : IImGuiPanel } // ── State ─────────────────────────────────────────────────────────── - private int _tab; // 0 skills, 1 attributes & vitals + private int _tab; // 0 skills, 1 attributes & vitals, 2 progression (ILT worlds) private SortKey _sort = SortKey.Name; private bool _descending; private readonly bool[] _collapsed = { false, false, false, true }; @@ -193,18 +193,23 @@ internal sealed class SkillsFace : IImGuiPanel SkillDat.EnsureLoadQueued(); PortalSpellTable.EnsureLoadQueued(); MasteryFeed.PanelOpened(); // asks only on Aelrynth, and only if the last reply is stale + ProgressionShown(); } + public void OnHidden() => ProgressionHidden(); + public void Draw() { PlayerProgressHooks.Want(); Refresh(); + ApplyProgressionRequest(); + if (_tab == 2 && !ProgressionTabVisible) _tab = 0; float w = Begin(out Vector2 origin, out Vector2 size); DrawSummary(w); DrawTabs(w); if (_tab == 0) DrawToolbar(w); - DrawColumnHeader(w, _tab == 0 ? "Skill" : "Attribute"); + if (_tab != 2) DrawColumnHeader(w, _tab == 0 ? "Skill" : "Attribute"); float bodyH = Math.Max(60, Remaining(origin, size) - GripOverlap()); ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ChildBg, PanelBg); @@ -212,7 +217,9 @@ internal sealed class SkillsFace : IImGuiPanel ImGuiNET.ImGui.BeginChild("##skills_body", new Vector2(w, bodyH)); float bw = ImGuiNET.ImGui.GetContentRegionAvail().X; EnsureWidths(); - if (_snap == null || !_snap.SkillTableRead && !_snap.AttributeCacheRead) + if (_tab == 2) + DrawProgression(bw); + else if (_snap == null || !_snap.SkillTableRead && !_snap.AttributeCacheRead) Message("Waiting for your character's data...", bw); else if (_dat == null) Message("Loading skill names from the client's portal.dat: " + SkillDat.Status, bw); @@ -228,6 +235,7 @@ internal sealed class SkillsFace : IImGuiPanel _picker.Draw(); DrawMulti(); DrawConfirm(); + DrawProgressionConfirm(); } // ── Data ──────────────────────────────────────────────────────────── @@ -691,13 +699,18 @@ internal sealed class SkillsFace : IImGuiPanel private void DrawTabs(float w) { Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos(); - float half = (w - 4) * 0.5f; - if (Button("##tab_skills", "Skills", p, new Vector2(half, 22), _tab == 0 ? Teal : Text, _tab == 0 ? Selected : BtnFill, + // The Progression tab only exists on ILT-like worlds (RynthAi's snapshot says so). + int count = ProgressionTabVisible ? 3 : 2; + float tabW = (w - 4 * (count - 1)) / count; + if (Button("##tab_skills", "Skills", p, new Vector2(tabW, 22), _tab == 0 ? Teal : Text, _tab == 0 ? Selected : BtnFill, border: _tab == 0 ? Teal : 0)) _tab = 0; - if (Button("##tab_attrs", "Attributes & Vitals", new Vector2(p.X + half + 4, p.Y), new Vector2(half, 22), + if (Button("##tab_attrs", "Attributes & Vitals", new Vector2(p.X + tabW + 4, p.Y), new Vector2(tabW, 22), _tab == 1 ? Teal : Text, _tab == 1 ? Selected : BtnFill, border: _tab == 1 ? Teal : 0)) _tab = 1; + if (count == 3 && Button("##tab_prog", "Progression", new Vector2(p.X + 2 * (tabW + 4), p.Y), new Vector2(tabW, 22), + _tab == 2 ? Teal : Text, _tab == 2 ? Selected : BtnFill, border: _tab == 2 ? Teal : 0)) + _tab = 2; NextLine(p, 26); } diff --git a/src/RynthCore.Engine/UI/Data/ProgressionData.cs b/src/RynthCore.Engine/UI/Data/ProgressionData.cs new file mode 100644 index 0000000..60bef5a --- /dev/null +++ b/src/RynthCore.Engine/UI/Data/ProgressionData.cs @@ -0,0 +1,105 @@ +// ============================================================================ +// RynthCore.Engine - UI/Data/ProgressionData.cs +// RynthAi's ILT progression planners (augmentations, enlightenment) for the +// Skills panel's Progression tab. RynthAi owns the math and the persisted +// inputs; this side only shows the snapshot and sends "prog ..." remote +// commands (RynthAiCommands.ApplyRemoteCommand) for edits and actions. +// ============================================================================ + +using System; +using System.Runtime.InteropServices; +using System.Text.Json; +using System.Text.Json.Serialization; +using RynthCore.Engine.Plugins; + +namespace RynthCore.Engine.UI.Data; + +/// RynthPluginGetProgressionJson's payload. Display strings arrive preformatted. +internal sealed class ProgressionInfo +{ + /// False off ILT-like worlds (or before the ILT Hub exists): the tab is hidden. + [JsonPropertyName("available")] public bool Available { get; set; } + [JsonPropertyName("world")] public string World { get; set; } = ""; + [JsonPropertyName("aug")] public AugPlanner Aug { get; set; } = new(); + [JsonPropertyName("enl")] public EnlPlanner Enl { get; set; } = new(); +} + +internal sealed class AugPlanner +{ + /// The server reports /aug off. + [JsonPropertyName("off")] public bool Off { get; set; } + [JsonPropertyName("status")] public string Status { get; set; } = ""; + [JsonPropertyName("lumPerCoin")] public long LumPerCoin { get; set; } + [JsonPropertyName("rows")] public AugRow[] Rows { get; set; } = Array.Empty(); + [JsonPropertyName("total")] public string Total { get; set; } = ""; + /// Empty when the bank holds enough Enlightened Coins. + [JsonPropertyName("short")] public string Short { get; set; } = ""; + [JsonPropertyName("banked")] public string Banked { get; set; } = ""; +} + +internal sealed class AugRow +{ + [JsonPropertyName("key")] public string Key { get; set; } = ""; + [JsonPropertyName("label")] public string Label { get; set; } = ""; + [JsonPropertyName("cur")] public int Current { get; set; } + [JsonPropertyName("tgt")] public int Target { get; set; } + /// Highest target allowed (the aug's cap, or the current level when the server reports more). + [JsonPropertyName("cap")] public int Cap { get; set; } + [JsonPropertyName("lum")] public string Lum { get; set; } = "-"; + [JsonPropertyName("coins")] public long Coins { get; set; } +} + +internal sealed class EnlPlanner +{ + /// The server reports /enl off. + [JsonPropertyName("off")] public bool Off { get; set; } + [JsonPropertyName("header")] public string Header { get; set; } = ""; + [JsonPropertyName("next")] public string Next { get; set; } = ""; + [JsonPropertyName("enl")] public int Level { get; set; } + [JsonPropertyName("target")] public int Target { get; set; } + [JsonPropertyName("plan")] public string[] Plan { get; set; } = Array.Empty(); + [JsonPropertyName("coinsPerToken")] public int CoinsPerToken { get; set; } + [JsonPropertyName("tokensShort")] public string TokensShort { get; set; } = ""; + /// Client-side requirements not yet met; empty = the client checks pass. + [JsonPropertyName("blockers")] public string[] Blockers { get; set; } = Array.Empty(); + [JsonPropertyName("serverChecks")] public string ServerChecks { get; set; } = ""; + [JsonPropertyName("auto")] public bool Auto { get; set; } + /// Auto-enlighten is disarmed every session until confirmed again. + [JsonPropertyName("armed")] public bool Armed { get; set; } + [JsonPropertyName("spendFirst")] public bool SpendFirst { get; set; } + [JsonPropertyName("checkEvery")] public int CheckEvery { get; set; } + [JsonPropertyName("status")] public string Status { get; set; } = ""; +} + +[JsonSerializable(typeof(ProgressionInfo))] +internal sealed partial class ProgressionJsonContext : JsonSerializerContext { } + +/// +/// RynthPluginGetProgressionJson (single static buffer: one caller only) while the Skills +/// panel is open, and right after each Progression edit (RequestRefreshAfterPluginTick). +/// +internal sealed unsafe class ProgressionSource : UiSource +{ + private delegate* unmanaged[Cdecl] _getProgressionJson; + + public ProgressionSource() : base("Progression", periodMs: 1000) { } + + protected internal override void Poll() + { + if (_getProgressionJson == null) + _getProgressionJson = (delegate* unmanaged[Cdecl])PluginExportBinder.Resolve("RynthAi", "RynthPluginGetProgressionJson"); + if (_getProgressionJson == null) return; + IntPtr p = _getProgressionJson(); + string json = p == IntPtr.Zero ? "{}" : Marshal.PtrToStringAnsi(p) ?? "{}"; + ProgressionInfo info; + try { info = JsonSerializer.Deserialize(json, ProgressionJsonContext.Default.ProgressionInfo) ?? new ProgressionInfo(); } + catch (JsonException) { info = new ProgressionInfo(); } + Publish(info); + } + + protected internal override void Reset() + { + _getProgressionJson = null; + ClearSnapshot(); + } +} diff --git a/src/RynthCore.Engine/UI/Data/UiSources.cs b/src/RynthCore.Engine/UI/Data/UiSources.cs index a4cdd47..62aab2e 100644 --- a/src/RynthCore.Engine/UI/Data/UiSources.cs +++ b/src/RynthCore.Engine/UI/Data/UiSources.cs @@ -16,6 +16,7 @@ internal static class UiSources public static readonly TrackerSource Tracker = new(); public static readonly RynthAiSource RynthAi = new(); public static readonly PatrolSource Patrol = new(); + public static readonly ProgressionSource Progression = new(); public static readonly RadarSource Radar = new(); public static readonly SettingsSource Settings = new(); public static readonly MetaSource Meta = new(); @@ -52,6 +53,7 @@ internal static class UiSources UiDataHub.Register(Radar); UiDataHub.Register(RynthAi); UiDataHub.Register(Patrol); + UiDataHub.Register(Progression); UiDataHub.Register(PluginStatus); UiDataHub.Register(Log); UiDataHub.Register(Tracker);