Snapshot for release 2026.10.19.1 (internal fa7a8f6)
This commit is contained in:
parent
605ec6f0e6
commit
44074df011
110 changed files with 8017 additions and 291 deletions
|
|
@ -278,6 +278,11 @@ internal static class EngineFrameController
|
|||
// in ImGui-off mode so Avalonia owner-window binding works.
|
||||
EnsureCore(pDevice);
|
||||
|
||||
// Settings > Display: borderless windowed + AC window placement. Throttled; reads only
|
||||
// here - the window itself is changed from the game WndProc (AcWindowChrome).
|
||||
try { UI.AcWindowChrome.Tick(_gameHwnd); }
|
||||
catch (Exception ex) { RynthLog.UI($"AcWindowChrome.Tick threw {ex.GetType().Name}: {ex.Message}"); }
|
||||
|
||||
// Cache the D3D9 device function pointers used by Nav3DRenderInjector,
|
||||
// RenderNav3D, and the always-on render path. This is a strict subset
|
||||
// of what InitImGui needs and is safe to run without ImGui state.
|
||||
|
|
|
|||
|
|
@ -67,10 +67,18 @@ internal static class ImGuiBar
|
|||
ScriptWindow? Window = null);
|
||||
|
||||
// Engine panels with an ImGui face only (no OverlayHost entry) that get a bar button.
|
||||
// Item Count has no icon of its own since 2026-10-18: Inventory's Count button, /rc itemcount, the Character menu.
|
||||
// Skills moves under RynthOracle (Skills / Attributes / Progress tabs): its icon shows only while Oracle's
|
||||
// tabs can't be reached (SkillsRouting.ShowSkillsBarIcon), so nobody loses the way in. Mini Remote stays.
|
||||
private static readonly string[] ImGuiOnlyBarPanels =
|
||||
{ Panels.InventoryFace.Title, Panels.SkillsFace.Title, Panels.SenseFace.Title, Panels.ItemCountFace.Title, Panels.MiniRemoteFace.Title,
|
||||
{ Panels.InventoryFace.Title, Panels.SkillsFace.Title, Panels.SenseFace.Title, Panels.MiniRemoteFace.Title,
|
||||
Panels.CharactersFace.Title };
|
||||
|
||||
/// <summary>An ImGui-only panel's bar button is wanted: it has a face, and Skills only while Oracle can't host it.</summary>
|
||||
private static bool ImGuiOnlyWanted(string title) =>
|
||||
ImGuiPanelHost.HasFace(title)
|
||||
&& (title != Panels.SkillsFace.Title || Panels.SkillsRouting.ShowSkillsBarIcon);
|
||||
|
||||
// The ILT section: ImGui-only Infinite Leaftide panels (Bounties and Guardian, both RynthILT's).
|
||||
// They never get buttons of their own; one ILT button stands for them, shown only on Infinite
|
||||
// Leaftide (IltInfo.IsIlt) with RynthILT loaded (IltInfo.PluginLoaded), and only for the ones
|
||||
|
|
@ -726,12 +734,12 @@ internal static class ImGuiBar
|
|||
ImGuiNET.ImGui.PopStyleVar(3);
|
||||
}
|
||||
|
||||
/// <summary>Bit i set: ImGuiOnlyBarPanels[i] has a face now.</summary>
|
||||
/// <summary>Bit i set: ImGuiOnlyBarPanels[i] gets a button now (a face, and for Skills no Oracle tabs).</summary>
|
||||
private static int ImGuiOnlyMask()
|
||||
{
|
||||
int mask = 0;
|
||||
for (int i = 0; i < ImGuiOnlyBarPanels.Length; i++)
|
||||
if (ImGuiPanelHost.HasFace(ImGuiOnlyBarPanels[i])) mask |= 1 << i;
|
||||
if (ImGuiOnlyWanted(ImGuiOnlyBarPanels[i])) mask |= 1 << i;
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
|
@ -755,7 +763,7 @@ internal static class ImGuiBar
|
|||
list.Add(new ButtonInfo(title, "##bar_" + title, icon, letter, title));
|
||||
}
|
||||
foreach (string title in ImGuiOnlyBarPanels)
|
||||
if (ImGuiPanelHost.HasFace(title) && !LauncherOnly.Contains(title))
|
||||
if (ImGuiOnlyWanted(title) && !LauncherOnly.Contains(title))
|
||||
{
|
||||
string icon = IconFor(title, out bool letter);
|
||||
list.Add(new ButtonInfo(title, "##bar_" + title, icon, letter, title));
|
||||
|
|
|
|||
|
|
@ -459,6 +459,7 @@ internal static class ImGuiPanelHost
|
|||
Apply(req.Title, req.Kind, placeScale);
|
||||
RemoveUnregistered();
|
||||
SweepEmbedded();
|
||||
Panels.OracleSkillsEmbed.Sweep(Environment.TickCount64); // Oracle's Skills embed that stopped drawing
|
||||
|
||||
List<Entry> order;
|
||||
lock (Sync) order = DrawOrder;
|
||||
|
|
@ -512,6 +513,8 @@ internal static class ImGuiPanelHost
|
|||
{
|
||||
if (_restored) return;
|
||||
_restored = true;
|
||||
// Settings > Display "Remember Open Windows and Positions" (default on).
|
||||
if (!Plugins.EngineSettings.RememberWindowLayout) return;
|
||||
List<string> titles = new();
|
||||
// Script windows (dynamic) open when their owner says so, not from the saved state.
|
||||
lock (Sync)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@
|
|||
// so copy is mouse-driven). Right-click a line to copy it or to make a rule
|
||||
// from it: move / copy lines like it to a tab, hide them, colour them. A line
|
||||
// with map coordinates in it ("42.1N, 33.6E") also offers "Arrow to" and "Go
|
||||
// to" them, sent to RynthNav (UI/Data/ChatCoords.cs finds them).
|
||||
// to" them, sent to RynthNav (UI/Data/ChatCoords.cs finds them). The
|
||||
// coordinates are also drawn as underlined links: click points RynthNav's
|
||||
// arrow there (its overlay opens), Ctrl+click walks there.
|
||||
// Follows the newest line until you scroll up; the scroll for new lines is set
|
||||
// in the same frame they're drawn (DrawLines; until 2026-10-11 it landed a frame
|
||||
// late and the text bounced). Scrolled up, the view holds still. The history is
|
||||
|
|
@ -584,10 +586,18 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
dl.AddText(font, font.FontSize, tp, col, line.Text, textW);
|
||||
else
|
||||
foreach (Seg seg in lay.Segs)
|
||||
{
|
||||
dl.AddText(font, font.FontSize, tp + seg.Offset, seg.Argb == 0 ? col : RynthTheme.Argb(seg.Argb), seg.Text);
|
||||
if (seg.Link >= 0) // a map coordinate: underlined, it's clickable
|
||||
{
|
||||
Vector2 u = tp + seg.Offset + new Vector2(0, font.FontSize - 1);
|
||||
dl.AddLine(u, u + new Vector2(seg.W, 0), RynthTheme.Argb(LinkCol), 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(wrapW, Math.Max(1, total)));
|
||||
HandleSelection(basePos, wrapW, scrollY, viewH, n);
|
||||
HoverLink(basePos, tsW, n, out ChatCoord? hoveredLink);
|
||||
HandleSelection(basePos, wrapW, scrollY, viewH, n, hoveredLink);
|
||||
HandleLineMenu(basePos, wrapW, n);
|
||||
|
||||
_lastScrollY = scrollY;
|
||||
|
|
@ -675,7 +685,17 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
{
|
||||
ChatLine line = _vis[i];
|
||||
ChatSpan[]? spans = line.Route.Spans;
|
||||
if (spans != null)
|
||||
// Map coordinates ("82.3N, 34.2E") become links. Found here, when the line is measured,
|
||||
// never per frame; a line without any keeps the plain (or highlighted) path.
|
||||
List<ChatCoord> coords = ChatCoords.MayHaveCoords(line.Text) ? ChatCoords.Find(line.Text) : NoCoords;
|
||||
if (coords.Count > 0)
|
||||
{
|
||||
ChatSpan[] withLinks = ChatCoords.LinkSpans(spans, coords, LinkCol);
|
||||
SpanLayout lay = LayoutSpans(font, line.Text, withLinks, textW, coords);
|
||||
_lay[i] = lay;
|
||||
_h[i] = lay.Height;
|
||||
}
|
||||
else if (spans != null)
|
||||
{
|
||||
SpanLayout lay = LayoutSpans(font, line.Text, spans, textW);
|
||||
_lay[i] = lay;
|
||||
|
|
@ -705,21 +725,40 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
|
||||
// ── Highlighted lines: hand layout ───────────────────────────────────
|
||||
|
||||
private readonly record struct Seg(string Text, Vector2 Offset, uint Argb); // Argb 0 = the line's colour
|
||||
// Argb 0 = the line's colour. W: the run's width. Link: index into SpanLayout.Links (a map
|
||||
// coordinate drawn as a link: click = RynthNav arrow, Ctrl+click = go), -1 for plain text.
|
||||
private readonly record struct Seg(string Text, Vector2 Offset, uint Argb, float W = 0f, int Link = -1);
|
||||
|
||||
private sealed class SpanLayout
|
||||
{
|
||||
public required float Height;
|
||||
public required Seg[] Segs;
|
||||
/// <summary>The line's map coordinates (ChatCoords), when any are drawn as links.</summary>
|
||||
public ChatCoord[]? Links;
|
||||
}
|
||||
|
||||
/// <summary>Coordinate links in chat lines: soft teal, underlined (0xAARRGGBB, like ChatSpan.Argb).</summary>
|
||||
private const uint LinkCol = 0xFF5ECFE0;
|
||||
|
||||
private static readonly List<ChatCoord> NoCoords = new();
|
||||
|
||||
/// <summary>
|
||||
/// Word-wraps <paramref name="text"/> to <paramref name="wrapW"/> and cuts each
|
||||
/// row where a highlight starts or ends, so every run is drawn in its own
|
||||
/// colour. Called when a line is measured, never per frame.
|
||||
/// <paramref name="links"/>: the line's map coordinates, whose runs get a link index.
|
||||
/// </summary>
|
||||
private static SpanLayout LayoutSpans(ImFontPtr font, string text, ChatSpan[] spans, float wrapW)
|
||||
private static SpanLayout LayoutSpans(ImFontPtr font, string text, ChatSpan[] spans, float wrapW, List<ChatCoord>? links = null)
|
||||
{
|
||||
// Which coordinate link a run [s0, s1) belongs to (-1 none).
|
||||
int LinkOf(int s0, int s1)
|
||||
{
|
||||
if (links == null) return -1;
|
||||
for (int k = 0; k < links.Count; k++)
|
||||
if (s0 >= links[k].Start && s1 <= links[k].Start + links[k].Length) return k;
|
||||
return -1;
|
||||
}
|
||||
|
||||
float size = font.FontSize;
|
||||
float Width(int start, int end) => end <= start ? 0 : font.CalcTextSizeA(size, float.MaxValue, 0f, text[start..end]).X;
|
||||
|
||||
|
|
@ -776,13 +815,14 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
int s0 = Math.Max(span.Start, a), s1 = Math.Min(span.Start + span.Length, b);
|
||||
if (s1 <= s0) continue;
|
||||
if (s0 > c) { segs.Add(new Seg(text[c..s0], new Vector2(sx, y), 0)); sx += Width(c, s0); }
|
||||
segs.Add(new Seg(text[s0..s1], new Vector2(sx, y), span.Argb));
|
||||
sx += Width(s0, s1);
|
||||
float spanW = Width(s0, s1);
|
||||
segs.Add(new Seg(text[s0..s1], new Vector2(sx, y), span.Argb, spanW, LinkOf(s0, s1)));
|
||||
sx += spanW;
|
||||
c = s1;
|
||||
}
|
||||
if (c < b) segs.Add(new Seg(text[c..b], new Vector2(sx, y), 0));
|
||||
}
|
||||
return new SpanLayout { Height = Math.Max(1, rows.Count) * size, Segs = segs.ToArray() };
|
||||
return new SpanLayout { Height = Math.Max(1, rows.Count) * size, Segs = segs.ToArray(), Links = links?.ToArray() };
|
||||
}
|
||||
|
||||
/// <summary>Index of the line containing content y (clamped to the list).</summary>
|
||||
|
|
@ -797,7 +837,53 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
return Math.Min(lo, Math.Max(0, n - 1));
|
||||
}
|
||||
|
||||
private void HandleSelection(Vector2 basePos, float wrapW, float scrollY, float viewH, int n)
|
||||
/// <summary>
|
||||
/// The map coordinate link under the mouse, if any (hand cursor and a tooltip). Only the
|
||||
/// hovered line's runs are looked at.
|
||||
/// </summary>
|
||||
private void HoverLink(Vector2 basePos, float tsW, int n, out ChatCoord? link)
|
||||
{
|
||||
link = null;
|
||||
if (n == 0 || _selDragging || !ImGuiNET.ImGui.IsWindowHovered()) return;
|
||||
Vector2 mouse = ImGuiNET.ImGui.GetMousePos();
|
||||
float contentY = mouse.Y - basePos.Y;
|
||||
if (contentY < 0 || contentY >= _tops[n]) return;
|
||||
int i = FirstAtOrBelow(contentY, n);
|
||||
if (_lay[i] is not { Links: { Length: > 0 } links } lay) return;
|
||||
Vector2 tp = basePos + new Vector2(3 + tsW, _tops[i]);
|
||||
float h = ImGuiNET.ImGui.GetFontSize();
|
||||
foreach (Seg seg in lay.Segs)
|
||||
{
|
||||
if (seg.Link < 0 || seg.Link >= links.Length) continue;
|
||||
Vector2 a = tp + seg.Offset, b = a + new Vector2(seg.W, h);
|
||||
if (mouse.X < a.X || mouse.X >= b.X || mouse.Y < a.Y || mouse.Y >= b.Y) continue;
|
||||
link = links[seg.Link];
|
||||
ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
bool nav = ImGuiPanelHost.HasFace(RynthNavFace.Title);
|
||||
SafeImGui.SetTooltip(nav
|
||||
? $"Click: point the arrow at {link.Value.Text}\nCtrl+click: RynthNav walks there\nRight-click: more"
|
||||
: $"{link.Value.Text}\n(RynthNav isn't loaded: no arrow)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A click on a coordinate link: RynthNav's arrow there, or (Ctrl) walk there.</summary>
|
||||
private void ClickLink(ChatCoord c)
|
||||
{
|
||||
if (!ImGuiPanelHost.HasFace(RynthNavFace.Title)) { Flash("RynthNav isn't loaded", 1.5); return; }
|
||||
if (ImGuiNET.ImGui.GetIO().KeyCtrl)
|
||||
{
|
||||
RynthNavCommands.Go(c.Text, c.Ns, c.Ew);
|
||||
Flash("Going to " + c.Text, 1.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
RynthNavCommands.Arrow(c.Text, c.Ns, c.Ew);
|
||||
Flash("Arrow: " + c.Text, 1.5);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSelection(Vector2 basePos, float wrapW, float scrollY, float viewH, int n, ChatCoord? hoveredLink = null)
|
||||
{
|
||||
if (n == 0) { ClearSelection(); return; }
|
||||
Vector2 mouse = ImGuiNET.ImGui.GetMousePos();
|
||||
|
|
@ -814,6 +900,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
_selDragging = true;
|
||||
_selMoved = false;
|
||||
_selDown = mouse;
|
||||
_downLink = hoveredLink; // a click (no drag) on it acts on release
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -827,8 +914,15 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
|
||||
if (ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left)) return;
|
||||
_selDragging = false;
|
||||
// A drag (even within one line) copies; a plain click just clears.
|
||||
if (!_selMoved && _selEnd == _selAnchor) { ClearSelection(); return; }
|
||||
// A drag (even within one line) copies; a plain click just clears, or follows a
|
||||
// coordinate link it was pressed on.
|
||||
if (!_selMoved && _selEnd == _selAnchor)
|
||||
{
|
||||
ChatCoord? link = _downLink;
|
||||
ClearSelection();
|
||||
if (link is { } c) ClickLink(c);
|
||||
return;
|
||||
}
|
||||
int lo = Math.Min(_selAnchor, _selEnd), hi = Math.Max(_selAnchor, _selEnd);
|
||||
var parts = new List<string>(hi - lo + 1);
|
||||
for (int i = lo; i <= hi && i < _vis.Count; i++) parts.Add(CopyText(_vis[i]));
|
||||
|
|
@ -855,8 +949,12 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
{
|
||||
_selAnchor = _selEnd = -1;
|
||||
_selDragging = _selMoved = false;
|
||||
_downLink = null;
|
||||
}
|
||||
|
||||
/// <summary>The coordinate link the left button went down on (acted on if it comes up without a drag).</summary>
|
||||
private ChatCoord? _downLink;
|
||||
|
||||
// ── Input ────────────────────────────────────────────────────────────
|
||||
|
||||
private void DrawInput(Vector2 p, float w, float h)
|
||||
|
|
|
|||
|
|
@ -196,6 +196,15 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
Label("Checked after the rules above, only for lines no rule moved or hid.", Mute);
|
||||
Label("Tick to hide the lines; pick a tab to move them there instead.", Mute);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
bool retail = ChatModel.HideInRetailChat;
|
||||
if (ImGuiNET.ImGui.Checkbox("Hidden lines are hidden in the retail chat too##hideretail", ref retail))
|
||||
{
|
||||
ChatModel.HideInRetailChat = retail;
|
||||
ChatModel.SaveSettings();
|
||||
}
|
||||
SafeImGui.SetItemTooltip("On: a line a rule or standard filter hides doesn't print in AC's own chat window either.\n" +
|
||||
"Off: hiding only applies to RynthChat; the retail chat shows everything.\n" +
|
||||
"Moved / copied lines still show in the retail chat either way.");
|
||||
foreach (string group in UI.Panels.RynthChatPresets.Groups)
|
||||
{
|
||||
int on = 0, total = 0;
|
||||
|
|
|
|||
|
|
@ -409,6 +409,28 @@ internal sealed class DamageDetailFace : IImGuiPanel
|
|||
pick => DamageCommands.EditRule(name, r => r.ExVuln = pick),
|
||||
"A vulnerability of another element, on top of Vuln (which follows the attack's element).");
|
||||
|
||||
// Melee/missile attack power against it
|
||||
string power = string.IsNullOrEmpty(view.AttackPower) ? "Default" : view.AttackPower;
|
||||
Combo("Power", "##power", DamageCommands.AttackPowerModes, power,
|
||||
pick => DamageCommands.EditRule(name, r => r.AttackPower = pick),
|
||||
(isDefault
|
||||
? "Melee/missile attack power for every monster without its own. Default = the Power settings (Melee Combat).\n"
|
||||
: "Melee/missile attack power against the monsters it covers. Default = the DEFAULT line's.\n") +
|
||||
"High = 100%. Reckless = 80% (needs Recklessness trained, else 100%).\n" +
|
||||
"Variable = a new random power each attack, between Variable Min and Max (Settings).\n" +
|
||||
"Reckless + Variable = random, kept inside the Recklessness band (20-80%).");
|
||||
|
||||
// Pull-away kite: tag then run until the mob is clear of its spawn pack
|
||||
ImGuiNET.ImGui.SameLine(0, 14);
|
||||
string kite = string.IsNullOrEmpty(view.Kite) ? "Default" : view.Kite;
|
||||
Combo("Kite", "##kite", DamageCommands.KiteModes, kite,
|
||||
pick => DamageCommands.EditRule(name, r => r.Kite = pick),
|
||||
(isDefault
|
||||
? "Pull-away for every monster without its own. Default = Off (fight in place).\n"
|
||||
: "Pull-away for the monsters it covers. Default = the DEFAULT line's.\n") +
|
||||
"Off = kill where it stands. PullAway = tag, run until it has been dragged\n" +
|
||||
"Kite Pull Distance metres from its lock spot (Settings > Melee Combat), then kill.");
|
||||
|
||||
// The DEFAULT line's own choice is the Prefer chip in the Damage panel's top bar.
|
||||
if (!isDefault)
|
||||
Combo("Prefer", "##prefer", DamageCommands.PreferredDamages, string.IsNullOrEmpty(view.PreferredDamage) ? "Auto" : view.PreferredDamage,
|
||||
|
|
|
|||
|
|
@ -222,17 +222,26 @@ internal static class FaceKit
|
|||
/// <summary>
|
||||
/// One popup list per face, opened from any button: call Open from the
|
||||
/// button's click and Draw once per frame at the end of the face's Draw
|
||||
/// (outside any child window, so the popup id always matches).
|
||||
/// (outside any child window, so the popup id always matches). Long lists
|
||||
/// (Slayer Type's creature names, materials, long keys) get a type-to-filter
|
||||
/// box so players can pick by name instead of scrolling.
|
||||
/// </summary>
|
||||
internal sealed class Picker
|
||||
{
|
||||
/// <summary>Show the filter box when the list is at least this long.</summary>
|
||||
private const int FilterAt = 12;
|
||||
private const float FilterH = 22f;
|
||||
private const float RowH = 20f;
|
||||
|
||||
private readonly string _popupId;
|
||||
private readonly byte[] _filter = new byte[64];
|
||||
private string[] _items = Array.Empty<string>();
|
||||
private int _selected = -1;
|
||||
private Action<int>? _onPick;
|
||||
private Vector2 _pos;
|
||||
private float _width = 220;
|
||||
private bool _openRequested;
|
||||
private bool _focusFilter;
|
||||
|
||||
public Picker(string popupId) => _popupId = popupId;
|
||||
|
||||
|
|
@ -244,6 +253,8 @@ internal static class FaceKit
|
|||
_pos = below;
|
||||
_width = width;
|
||||
_openRequested = items.Length > 0;
|
||||
_filter[0] = 0; // clear the previous open's filter
|
||||
_focusFilter = items.Length >= FilterAt;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
|
|
@ -255,38 +266,74 @@ internal static class FaceKit
|
|||
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(Math.Clamp(_pos.X, 0, Math.Max(0, display.X - _width)), _pos.Y));
|
||||
ImGuiNET.ImGui.OpenPopup(_popupId);
|
||||
}
|
||||
bool filterOn = _items.Length >= FilterAt;
|
||||
string filterText = filterOn ? Utf8(_filter) : string.Empty;
|
||||
// Count matches so the popup height tracks a short filtered list.
|
||||
int shown = 0;
|
||||
if (!filterOn) shown = _items.Length;
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _items.Length; i++)
|
||||
if (FilterMatch(_items[i], filterText)) shown++;
|
||||
}
|
||||
float listH = Math.Min(Math.Max(shown, 1) * RowH + 4, 340);
|
||||
float totalH = listH + (filterOn ? FilterH + 4 : 0);
|
||||
|
||||
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(2, 2));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 1));
|
||||
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(_width, Math.Min(_items.Length * 21 + 4, 340)));
|
||||
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(_width, totalH));
|
||||
bool open = ImGuiNET.ImGui.BeginPopup(_popupId);
|
||||
ImGuiNET.ImGui.PopStyleVar(3);
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (!open) return;
|
||||
|
||||
if (filterOn)
|
||||
{
|
||||
Vector2 fp = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (_focusFilter)
|
||||
{
|
||||
_focusFilter = false;
|
||||
ImGuiNET.ImGui.SetKeyboardFocusHere(0); // next widget = the filter box
|
||||
}
|
||||
TextBox("##pick_filter", _filter, fp, ImGuiNET.ImGui.GetContentRegionAvail().X, "Type to filter...", out _,
|
||||
ImGuiInputTextFlags.None, FilterH);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(fp.X, fp.Y + FilterH + 2));
|
||||
filterText = Utf8(_filter);
|
||||
}
|
||||
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float iw = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||
for (int i = 0; i < _items.Length; i++)
|
||||
{
|
||||
if (filterOn && !FilterMatch(_items[i], filterText)) continue;
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
Vector2 ip = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
bool click = ImGuiNET.ImGui.InvisibleButton("##it", new Vector2(iw, 20));
|
||||
bool click = ImGuiNET.ImGui.InvisibleButton("##it", new Vector2(iw, RowH));
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
ImGuiNET.ImGui.PopID();
|
||||
bool sel = i == _selected;
|
||||
dl.AddRectFilled(ip, ip + new Vector2(iw, 20), sel ? Selected : hot ? Lighten(BtnFill) : BtnFill);
|
||||
dl.AddRect(ip, ip + new Vector2(iw, 20), BtnBord);
|
||||
dl.AddText(ip + new Vector2(6, (20 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), sel ? Teal : Text, _items[i]);
|
||||
dl.AddRectFilled(ip, ip + new Vector2(iw, RowH), sel ? Selected : hot ? Lighten(BtnFill) : BtnFill);
|
||||
dl.AddRect(ip, ip + new Vector2(iw, RowH), BtnBord);
|
||||
dl.AddText(ip + new Vector2(6, (RowH - ImGuiNET.ImGui.GetFontSize()) * 0.5f), sel ? Teal : Text, _items[i]);
|
||||
if (click)
|
||||
{
|
||||
Action<int>? act = _onPick;
|
||||
ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
act?.Invoke(i);
|
||||
act?.Invoke(i); // still the original index for the caller
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
/// <summary>Case-insensitive substring match; empty filter shows everything.</summary>
|
||||
private static bool FilterMatch(string item, string filter)
|
||||
{
|
||||
if (filter.Length == 0) return true;
|
||||
return item.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Text buffers ─────────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@
|
|||
// 25 px title band isn't stretched) follow AcClientReborn's InventoryGeometry.
|
||||
// Credit: OpenAC (Tom's project) for the layout and sprite research.
|
||||
//
|
||||
// title retail title bar "Inventory of <name>", tool toggles, close
|
||||
// title retail title bar "Inventory of <name>", Vault, Remote / Sort / Count /
|
||||
// GInv (text, icons or one menu: InventoryTitleLayout), size / tools /
|
||||
// Modern toggles, close
|
||||
// tools search, sort, category chips (toggle, the funnel in the title)
|
||||
// paperdoll the 24 equip slots at their retail places (the 3D figure isn't
|
||||
// drawn, so the retail "Slots" view is always on)
|
||||
|
|
@ -134,6 +136,10 @@ internal sealed partial class InventoryFace
|
|||
private string? _hoverLabel, _hoverLabel2;
|
||||
private string _titleText = "Inventory";
|
||||
private string? _titleFor;
|
||||
// The title cut to its room (InventoryTitleLayout.Elide), kept while the text and the room stay the same.
|
||||
private string _titleCut = string.Empty;
|
||||
private string? _titleCutFor;
|
||||
private float _titleCutRoom, _titleCutW;
|
||||
|
||||
// =====================================================================
|
||||
// Body
|
||||
|
|
@ -230,71 +236,128 @@ internal sealed partial class InventoryFace
|
|||
dl.AddRect(o, o + new Vector2(barW, h - 1), Gold, 4);
|
||||
}
|
||||
|
||||
// Two toggles at the bar's right end: the tools row and the Modern look.
|
||||
float btn = MathF.Round(18 * s);
|
||||
var b2 = new Vector2(o.X + barW - 8 * s - btn, o.Y + (h - btn) * 0.5f);
|
||||
var b1 = new Vector2(b2.X - btn - 2 * s, b2.Y);
|
||||
var bPlus = new Vector2(b1.X - btn - 6 * s, b2.Y);
|
||||
var bMinus = new Vector2(bPlus.X - btn - 2 * s, b2.Y);
|
||||
if (TitleToggle("##inv_smaller", PhosphorIcons.Minus, bMinus, btn, false))
|
||||
InventorySettingsStore.StepSize(-1);
|
||||
SafeImGui.SetItemTooltip($"Smaller ({InventorySettingsStore.SizePct}%)");
|
||||
if (TitleToggle("##inv_bigger", PhosphorIcons.Plus, bPlus, btn, false))
|
||||
InventorySettingsStore.StepSize(+1);
|
||||
SafeImGui.SetItemTooltip($"Bigger ({InventorySettingsStore.SizePct}%)");
|
||||
if (TitleToggle("##inv_tools", PhosphorIcons.Funnel, b1, btn, InventorySettingsStore.ShowTools))
|
||||
{
|
||||
// Closing the search / filter row shows every item again.
|
||||
if (InventorySettingsStore.ShowTools) ClearFilters();
|
||||
InventorySettingsStore.SetShowTools(!InventorySettingsStore.ShowTools);
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Search, sort and filter");
|
||||
if (TitleToggle("##inv_modern", PhosphorIcons.SquaresFour, b2, btn, false))
|
||||
InventorySettingsStore.SetClassic(false);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Modern look");
|
||||
|
||||
// Vault (Aelrynth only): the contents area shows the account vault instead of the open pack.
|
||||
float leftmost = bMinus.X;
|
||||
if (VaultFeed.Available)
|
||||
{
|
||||
var vsz = new Vector2(MathF.Round(38 * s), btn);
|
||||
var bV = new Vector2(bMinus.X - vsz.X - 8 * s, b2.Y);
|
||||
if (TitleTextToggle("##inv_vault", "Vault", bV, vsz, _vaultOpen))
|
||||
{
|
||||
_vaultOpen = !_vaultOpen;
|
||||
if (_vaultOpen) VaultFeed.ViewOpened();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Your Aelrynth account vault");
|
||||
leftmost = bV.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
_vaultOpen = false;
|
||||
}
|
||||
|
||||
// Drag surface: the bar left of the toggles (moves the panel, like the header).
|
||||
float dragW = Math.Max(1, leftmost - o.X - 2);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(o);
|
||||
ImGuiNET.ImGui.InvisibleButton("##inv_titledrag", new Vector2(dragW, h));
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
|
||||
// "Inventory of <name>", centred on the bar (left of the toggles when it's narrow).
|
||||
// "Inventory of <name>": its width decides how much room the layout owes the title.
|
||||
if (!ReferenceEquals(_titleFor, view.PlayerName))
|
||||
{
|
||||
_titleFor = view.PlayerName;
|
||||
_titleText = view.PlayerName.Length > 0 ? "Inventory of " + view.PlayerName : "Inventory";
|
||||
}
|
||||
ImFontPtr f = ImGuiFonts.Get(UiFont.UiBold11);
|
||||
ImGuiNET.ImGui.PushFont(f);
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(_titleText);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
float titlePx = 12 * s;
|
||||
ts *= titlePx / f.FontSize;
|
||||
float tx = o.X + (barW - ts.X) * 0.5f;
|
||||
if (tx + ts.X > leftmost - 4) tx = Math.Max(o.X + 10 * s, leftmost - 4 - ts.X);
|
||||
dl.PushClipRect(o + new Vector2(6 * s, 0), new Vector2(leftmost - 2, o.Y + h), true);
|
||||
dl.AddText(f, titlePx, new Vector2(tx, o.Y + (h - ts.Y) * 0.5f), White, _titleText);
|
||||
dl.PopClipRect();
|
||||
float titleK = titlePx / f.FontSize;
|
||||
ImGuiNET.ImGui.PushFont(f);
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(_titleText) * titleK;
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
|
||||
// Where everything goes (UI/InventoryTitleLayout, tested): the four toggles at the right end, Vault
|
||||
// next to them (always there on a vault server), then the related-panel buttons as text, as icons or
|
||||
// as one "more" menu, whichever leaves the title its room. Nothing lands off the panel.
|
||||
InventoryTitleLayout lay = InventoryTitleLayout.Compute(barW, s, VaultFeed.Available, ts.X);
|
||||
float btn = lay.Btn;
|
||||
float by = o.Y + (h - btn) * 0.5f;
|
||||
Vector2 At(TitleSlot sl) => new(o.X + sl.X, by);
|
||||
|
||||
if (TitleToggle("##inv_smaller", PhosphorIcons.Minus, At(lay.Smaller), btn, false))
|
||||
InventorySettingsStore.StepSize(-1);
|
||||
SafeImGui.SetItemTooltip($"Smaller ({InventorySettingsStore.SizePct}%)");
|
||||
if (TitleToggle("##inv_bigger", PhosphorIcons.Plus, At(lay.Bigger), btn, false))
|
||||
InventorySettingsStore.StepSize(+1);
|
||||
SafeImGui.SetItemTooltip($"Bigger ({InventorySettingsStore.SizePct}%)");
|
||||
if (TitleToggle("##inv_tools", PhosphorIcons.Funnel, At(lay.Tools), btn, InventorySettingsStore.ShowTools))
|
||||
{
|
||||
// Closing the search / filter row shows every item again.
|
||||
if (InventorySettingsStore.ShowTools) ClearFilters();
|
||||
InventorySettingsStore.SetShowTools(!InventorySettingsStore.ShowTools);
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Search, sort and filter");
|
||||
if (TitleToggle("##inv_modern", PhosphorIcons.SquaresFour, At(lay.Modern), btn, false))
|
||||
InventorySettingsStore.SetClassic(false);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Modern look");
|
||||
|
||||
// Vault (Aelrynth only): the contents area shows the account vault instead of the open pack.
|
||||
if (lay.Vault.Present)
|
||||
{
|
||||
if (TitleTextToggle("##inv_vault", "Vault", At(lay.Vault), new Vector2(lay.Vault.W, btn), _vaultOpen))
|
||||
{
|
||||
_vaultOpen = !_vaultOpen;
|
||||
if (_vaultOpen) VaultFeed.ViewOpened();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Your Aelrynth account vault");
|
||||
}
|
||||
else if (!VaultFeed.Available)
|
||||
{
|
||||
_vaultOpen = false;
|
||||
}
|
||||
|
||||
// Related panels: Mini Remote, RynthSort, Item Count, Global Inventory.
|
||||
switch (lay.Mode)
|
||||
{
|
||||
case TitleExtrasMode.Text:
|
||||
if (TitleTextToggle("##inv_miniremote", "Remote", At(lay.Remote), new Vector2(lay.Remote.W, btn), MiniRemoteOpen))
|
||||
ToggleMiniRemote();
|
||||
SafeImGui.SetItemTooltip(MiniRemoteTip);
|
||||
if (TitleTextToggle("##inv_rsort", "Sort", At(lay.Sort), new Vector2(lay.Sort.W, btn), RynthSortOpen))
|
||||
ToggleRynthSort();
|
||||
SafeImGui.SetItemTooltip(RynthSortTip());
|
||||
if (TitleTextToggle("##inv_itemcount", "Count", At(lay.Count), new Vector2(lay.Count.W, btn), ItemCountOpen))
|
||||
ToggleItemCount();
|
||||
SafeImGui.SetItemTooltip(ItemCountTip);
|
||||
if (TitleTextToggle("##inv_ginv", "GInv", At(lay.GInv), new Vector2(lay.GInv.W, btn), GlobalInventoryOpen))
|
||||
ToggleGlobalInventory();
|
||||
SafeImGui.SetItemTooltip(GlobalInventoryTip());
|
||||
break;
|
||||
case TitleExtrasMode.Icons:
|
||||
if (TitleToggle("##inv_miniremote", PhosphorIcons.SlidersHorizontal, At(lay.Remote), btn, MiniRemoteOpen))
|
||||
ToggleMiniRemote();
|
||||
SafeImGui.SetItemTooltip(MiniRemoteTip);
|
||||
if (TitleToggle("##inv_rsort", PhosphorIcons.SortAscending, At(lay.Sort), btn, RynthSortOpen))
|
||||
ToggleRynthSort();
|
||||
SafeImGui.SetItemTooltip(RynthSortTip());
|
||||
if (TitleToggle("##inv_itemcount", PhosphorIcons.Bag, At(lay.Count), btn, ItemCountOpen))
|
||||
ToggleItemCount();
|
||||
SafeImGui.SetItemTooltip(ItemCountTip);
|
||||
if (TitleToggle("##inv_ginv", PhosphorIcons.GlobeHemisphereWest, At(lay.GInv), btn, GlobalInventoryOpen))
|
||||
ToggleGlobalInventory();
|
||||
SafeImGui.SetItemTooltip(GlobalInventoryTip());
|
||||
break;
|
||||
case TitleExtrasMode.Menu:
|
||||
if (TitleToggle("##inv_more", PhosphorIcons.DotsThree, At(lay.More), btn,
|
||||
MiniRemoteOpen || RynthSortOpen || ItemCountOpen || GlobalInventoryOpen))
|
||||
_openMore = true;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Mini Remote, RynthSort, Item Count, Global Inventory");
|
||||
break;
|
||||
}
|
||||
RelatedMenu();
|
||||
|
||||
// Drag surface: the bar left of the buttons (moves the panel, like the header).
|
||||
float dragW = Math.Max(1, lay.LeftmostX - 2);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(o);
|
||||
ImGuiNET.ImGui.InvisibleButton("##inv_titledrag", new Vector2(dragW, h));
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
|
||||
// The title: centred on the bar when it fits, else against the left edge and cut with "...".
|
||||
float room = lay.TitleWidth - 4 * s;
|
||||
if (room >= 1)
|
||||
{
|
||||
string shown = _titleText;
|
||||
if (ts.X > room)
|
||||
{
|
||||
if (!ReferenceEquals(_titleCutFor, _titleText) || _titleCutRoom != room)
|
||||
{
|
||||
CutTitle(f, titleK, room);
|
||||
}
|
||||
shown = _titleCut;
|
||||
ts.X = _titleCutW;
|
||||
}
|
||||
if (shown.Length > 0)
|
||||
{
|
||||
float left = o.X + lay.TitleLeft + 4 * s;
|
||||
float tx = Math.Clamp(o.X + (barW - ts.X) * 0.5f, left, Math.Max(left, o.X + lay.TitleRight - ts.X));
|
||||
dl.PushClipRect(o + new Vector2(lay.TitleLeft, 0), new Vector2(o.X + lay.TitleRight, o.Y + h), true);
|
||||
dl.AddText(f, titlePx, new Vector2(tx, o.Y + (h - ts.Y) * 0.5f), White, shown);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
}
|
||||
|
||||
// The retail close button.
|
||||
var cp = new Vector2(o.X + barW, o.Y);
|
||||
|
|
@ -310,6 +373,17 @@ internal sealed partial class InventoryFace
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Cuts the title text to <paramref name="room"/> px (only when it changed): _titleCut and its width.</summary>
|
||||
private void CutTitle(ImFontPtr font, float k, float room)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(font);
|
||||
_titleCut = InventoryTitleLayout.Elide(_titleText, room, t => ImGuiNET.ImGui.CalcTextSize(t).X * k);
|
||||
_titleCutW = _titleCut.Length == 0 ? 0 : ImGuiNET.ImGui.CalcTextSize(_titleCut).X * k;
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
_titleCutFor = _titleText;
|
||||
_titleCutRoom = room;
|
||||
}
|
||||
|
||||
private static bool TitleToggle(string id, string glyph, Vector2 pos, float size, bool on)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
|
|
@ -640,6 +714,45 @@ internal sealed partial class InventoryFace
|
|||
private VaultItem? _vaultCtx;
|
||||
private bool _openVaultCtx;
|
||||
|
||||
/// <summary>The vault view's caption: how full it is, or the read's status before the first read.</summary>
|
||||
private static string VaultCaption(VaultSnapshot? snap)
|
||||
{
|
||||
if (snap == null) return VaultFeed.Status;
|
||||
int n = snap.Items.Length;
|
||||
return snap.Max > 0 ? $"Aelrynth Vault: {n:N0} of {snap.Max:N0}" : $"Aelrynth Vault: {n:N0}";
|
||||
}
|
||||
|
||||
/// <summary>What the vault view says before it has been read.</summary>
|
||||
private static string VaultEmptyText => VaultFeed.Unsupported ? "The vault is not open on this server yet." : "Click Refresh to read the vault.";
|
||||
|
||||
/// <summary>
|
||||
/// The vault's right-click menu (both looks): Withdraw the item. Call it in the panel's own window
|
||||
/// (not inside a child), so the popup opened and drawn here share one ID.
|
||||
/// </summary>
|
||||
private void VaultContextMenu()
|
||||
{
|
||||
if (_openVaultCtx)
|
||||
{
|
||||
_openVaultCtx = false;
|
||||
ImGuiNET.ImGui.OpenPopup("##vault_ctx");
|
||||
}
|
||||
PushMenuStyle();
|
||||
if (ImGuiNET.ImGui.BeginPopup("##vault_ctx"))
|
||||
{
|
||||
VaultItem? it = _vaultCtx;
|
||||
if (it == null) ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
else
|
||||
{
|
||||
SafeImGui.TextDisabled(it.Name);
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.MenuItem("Withdraw", "", false, VaultFeed.Available))
|
||||
VaultFeed.Withdraw(it);
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
PopMenuStyle();
|
||||
}
|
||||
|
||||
/// <summary>A small labelled button in the title bar.</summary>
|
||||
private static bool TitleTextToggle(string id, string label, Vector2 pos, Vector2 size, bool on)
|
||||
{
|
||||
|
|
@ -671,9 +784,7 @@ internal sealed partial class InventoryFace
|
|||
VaultSnapshot? snap = VaultFeed.Snapshot;
|
||||
VaultItem[] items = snap?.Items ?? Array.Empty<VaultItem>();
|
||||
int cells = snap == null ? 0 : Math.Max(snap.Max, items.Length);
|
||||
string caption = snap == null ? VaultFeed.Status
|
||||
: snap.Max > 0 ? $"Aelrynth Vault: {items.Length:N0} of {snap.Max:N0}" : $"Aelrynth Vault: {items.Length:N0}";
|
||||
CenterText(dl, ImGuiFonts.Get(UiFont.Ui14), caption, new Vector2(gridPos.X, field.Y), new Vector2(gridW, 15 * s), White, 12 * s);
|
||||
CenterText(dl, ImGuiFonts.Get(UiFont.Ui14), VaultCaption(snap), new Vector2(gridPos.X, field.Y), new Vector2(gridW, 15 * s), White, 12 * s);
|
||||
|
||||
// Read again (the vault changes when anything is deposited or withdrawn).
|
||||
var rb = new Vector2(gridPos.X + gridW - 44 * s, field.Y + 1 * s);
|
||||
|
|
@ -738,29 +849,10 @@ internal sealed partial class InventoryFace
|
|||
}
|
||||
else if (snap == null && !VaultFeed.Awaiting)
|
||||
{
|
||||
dl.AddText(gridPos + new Vector2(4, 22 * s), Mute, VaultFeed.Unsupported ? "The vault is not open on this server yet." : "Click Refresh to read the vault.");
|
||||
dl.AddText(gridPos + new Vector2(4, 22 * s), Mute, VaultEmptyText);
|
||||
}
|
||||
|
||||
if (_openVaultCtx)
|
||||
{
|
||||
_openVaultCtx = false;
|
||||
ImGuiNET.ImGui.OpenPopup("##vault_ctx");
|
||||
}
|
||||
PushMenuStyle();
|
||||
if (ImGuiNET.ImGui.BeginPopup("##vault_ctx"))
|
||||
{
|
||||
VaultItem? it = _vaultCtx;
|
||||
if (it == null) ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
else
|
||||
{
|
||||
SafeImGui.TextDisabled(it.Name);
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.MenuItem("Withdraw", "", false, VaultFeed.Available))
|
||||
VaultFeed.Withdraw(it);
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
PopMenuStyle();
|
||||
VaultContextMenu();
|
||||
|
||||
if (snap != null) // nothing to scroll before the vault has been read
|
||||
Scrollbar("##inv_vaultsb", new Vector2(gridPos.X + gridW, gridPos.Y), rows * cell, s, ref _vaultFirstRow, totalRows, rows);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@
|
|||
// pictures (InventoryFace.Classic.cs; Phase 2)
|
||||
// Modern the Phase 1 layout, below
|
||||
//
|
||||
// header burden (percent of capacity) and pyreals; item count
|
||||
// header burden (percent of capacity) and pyreals; item count; buttons for
|
||||
// Mini Remote, RynthSort (/rsort), Item Count (/rc itemcount) and
|
||||
// Global Inventory (/ginv), folded into one menu when the header is short;
|
||||
// on Aelrynth also the Vault (always there; the grid shows the account
|
||||
// vault, picking a pack goes back)
|
||||
// tools search box, attribute filter (InventoryFace.AttrFilter.cs), sort
|
||||
// picker; category chips
|
||||
// packs All, Main pack, each side pack (its icon and fill), Worn
|
||||
|
|
@ -36,6 +40,8 @@ using System.Globalization;
|
|||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
using RynthCore.Engine.Net;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.ScriptWindows;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
|
||||
|
||||
|
|
@ -201,12 +207,99 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
float bodyH = Math.Max(60, origin.Y + size.Y - 6 - bottomH - bodyPos.Y);
|
||||
float colW = w >= 380 ? 128 : 46;
|
||||
PackColumn(view, bodyPos, colW, bodyH);
|
||||
Grid(new Vector2(bodyPos.X + colW + 4, bodyPos.Y), new Vector2(w - colW - 4, bodyH));
|
||||
// The Vault (Aelrynth) takes the grid's place; picking a pack in the column goes back to it.
|
||||
if (_vaultOpen && (!VaultFeed.Available || _pack != _vaultOpenedOnPack)) _vaultOpen = false;
|
||||
if (_vaultOpen) ModernVault(new Vector2(bodyPos.X + colW + 4, bodyPos.Y), new Vector2(w - colW - 4, bodyH));
|
||||
else Grid(new Vector2(bodyPos.X + colW + 4, bodyPos.Y), new Vector2(w - colW - 4, bodyH));
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(bodyPos.X, bodyPos.Y + bodyH + 4));
|
||||
Zones(view, w);
|
||||
StatusRow(w);
|
||||
}
|
||||
|
||||
/// <summary>RynthInventory's Global Inventory script window key (UiWindow "RynthInventory/Main").</summary>
|
||||
private const string GlobalInventoryKey = "RynthInventory/Main";
|
||||
/// <summary>RynthSort's script window key (UiWindow "RynthSort/Main").</summary>
|
||||
private const string RynthSortKey = "RynthSort/Main";
|
||||
|
||||
private static bool MiniRemoteOpen => ImGuiPanelHost.IsOpen(MiniRemoteFace.Title);
|
||||
private static bool ItemCountOpen => ImGuiPanelHost.IsOpen(ItemCountFace.Title);
|
||||
private static bool RynthSortOpen => ScriptWindowRegistry.IsOpen(RynthSortKey);
|
||||
private static bool GlobalInventoryOpen => ScriptWindowRegistry.IsOpen(GlobalInventoryKey);
|
||||
|
||||
private const string MiniRemoteTip = "Mini Remote (/rc miniremote): remote, sections and HUDs";
|
||||
private const string ItemCountTip = "Item Count (/rc itemcount): how many of each named item you carry";
|
||||
private static string RynthSortTip() => ScriptWindowRegistry.Has(RynthSortKey)
|
||||
? "RynthSort (/rsort): pack sort rules and auto-sort"
|
||||
: "RynthSort (/rsort) - needs the RynthSort plugin";
|
||||
private static string GlobalInventoryTip() => ScriptWindowRegistry.Has(GlobalInventoryKey)
|
||||
? "Global Inventory (/ginv): every character's saved packs and storage"
|
||||
: "Global Inventory (/ginv) - needs the RynthInventory plugin";
|
||||
|
||||
/// <summary>Opens or closes the Item Count panel (same as /rc itemcount).</summary>
|
||||
private static void ToggleItemCount()
|
||||
{
|
||||
if (!ImGuiPanelHost.HasFace(ItemCountFace.Title)) return;
|
||||
PanelRouter.Toggle(ItemCountFace.Title);
|
||||
}
|
||||
|
||||
/// <summary>Opens or closes the Mini Remote (same as /rc miniremote).</summary>
|
||||
private static void ToggleMiniRemote()
|
||||
{
|
||||
if (!ImGuiPanelHost.HasFace(MiniRemoteFace.Title)) return;
|
||||
PanelRouter.Toggle(MiniRemoteFace.Title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens or closes a plugin script window by key, or runs <paramref name="fallbackCmd"/>
|
||||
/// when the plugin hasn't submitted it yet.
|
||||
/// </summary>
|
||||
private static void ToggleScriptWindow(string key, string fallbackCmd)
|
||||
{
|
||||
if (ScriptWindowRegistry.Has(key))
|
||||
{
|
||||
ScriptWindowRegistry.PlayerSetVisible(key, !ScriptWindowRegistry.IsOpen(key));
|
||||
return;
|
||||
}
|
||||
ServerMenus.Run(fallbackCmd);
|
||||
}
|
||||
|
||||
/// <summary>Opens or closes RynthInventory's Global Inventory (same as /ginv).</summary>
|
||||
private static void ToggleGlobalInventory() => ToggleScriptWindow(GlobalInventoryKey, "/ginv");
|
||||
|
||||
/// <summary>Opens or closes RynthSort (same as /rsort).</summary>
|
||||
private static void ToggleRynthSort() => ToggleScriptWindow(RynthSortKey, "/rsort");
|
||||
|
||||
// The "more" menu both looks use when their bar is too short for the four buttons.
|
||||
private bool _openMore;
|
||||
|
||||
/// <summary>The "more" popup: the four related panels as menu lines (checked while open). Draw where its button was.</summary>
|
||||
private void RelatedMenu()
|
||||
{
|
||||
if (_openMore)
|
||||
{
|
||||
_openMore = false;
|
||||
ImGuiNET.ImGui.OpenPopup("##inv_more_menu");
|
||||
}
|
||||
PushMenuStyle();
|
||||
if (ImGuiNET.ImGui.BeginPopup("##inv_more_menu"))
|
||||
{
|
||||
if (ImGuiNET.ImGui.MenuItem("Mini Remote", "/rc miniremote", MiniRemoteOpen, ImGuiPanelHost.HasFace(MiniRemoteFace.Title)))
|
||||
ToggleMiniRemote();
|
||||
SafeImGui.SetItemTooltip(MiniRemoteTip);
|
||||
if (ImGuiNET.ImGui.MenuItem("RynthSort", "/rsort", RynthSortOpen))
|
||||
ToggleRynthSort();
|
||||
SafeImGui.SetItemTooltip(RynthSortTip());
|
||||
if (ImGuiNET.ImGui.MenuItem("Item Count", "/rc itemcount", ItemCountOpen, ImGuiPanelHost.HasFace(ItemCountFace.Title)))
|
||||
ToggleItemCount();
|
||||
SafeImGui.SetItemTooltip(ItemCountTip);
|
||||
if (ImGuiNET.ImGui.MenuItem("Global Inventory", "/ginv", GlobalInventoryOpen))
|
||||
ToggleGlobalInventory();
|
||||
SafeImGui.SetItemTooltip(GlobalInventoryTip());
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
PopMenuStyle();
|
||||
}
|
||||
|
||||
// ── Header: burden, pyreals, count ──────────────────────────────────
|
||||
|
||||
private void Header(InventoryView view, float w)
|
||||
|
|
@ -239,11 +332,62 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
InventorySettingsStore.SetClassic(true);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Classic look (the retail inventory window)");
|
||||
|
||||
// Related panels (Mini Remote, RynthSort, Item Count, Global Inventory): four icons when the room
|
||||
// left of the Classic / Close buttons holds them, else one "more" menu, else none (the Character
|
||||
// menu has them all). The item count text gives way last. On Aelrynth the Vault button sits next
|
||||
// to the Classic button and takes its room first: it is never dropped
|
||||
// (UI/InventoryTitleLayout.InventoryHeaderLayout, tested in tools/BarDeclutterTests).
|
||||
float cw = ImGuiNET.ImGui.CalcTextSize(_countText).X;
|
||||
dl.AddText(new Vector2(tb.X - cw - 6, ty), Mute, _countText);
|
||||
float leftEnd = x + 20 + ImGuiNET.ImGui.CalcTextSize(view.PyrealText).X + 6;
|
||||
InventoryHeaderLayout hl = InventoryHeaderLayout.Compute(w, leftEnd - p.X, cw, VaultFeed.Available);
|
||||
Vector2 At(TitleSlot s) => new(p.X + s.X, p.Y + 1);
|
||||
var btn22 = new Vector2(InventoryHeaderLayout.Btn, InventoryHeaderLayout.Btn);
|
||||
if (hl.Plan.Extras == TitleExtrasMode.Icons)
|
||||
{
|
||||
if (IconButton("##inv_ginv", PhosphorIcons.GlobeHemisphereWest, At(hl.GInv), btn22,
|
||||
GlobalInventoryOpen ? Teal : Amber, BtnFill, font: UiFont.Ui11))
|
||||
ToggleGlobalInventory();
|
||||
SafeImGui.SetItemTooltip(GlobalInventoryTip());
|
||||
if (IconButton("##inv_itemcount", PhosphorIcons.Bag, At(hl.Count), btn22,
|
||||
ItemCountOpen ? Teal : Amber, BtnFill, font: UiFont.Ui11))
|
||||
ToggleItemCount();
|
||||
SafeImGui.SetItemTooltip(ItemCountTip);
|
||||
if (IconButton("##inv_rsort", PhosphorIcons.SortAscending, At(hl.Sort), btn22,
|
||||
RynthSortOpen ? Teal : Amber, BtnFill, font: UiFont.Ui11))
|
||||
ToggleRynthSort();
|
||||
SafeImGui.SetItemTooltip(RynthSortTip());
|
||||
if (IconButton("##inv_miniremote", PhosphorIcons.SquaresFour, At(hl.Remote), btn22,
|
||||
MiniRemoteOpen ? Teal : Amber, BtnFill, font: UiFont.Ui11))
|
||||
ToggleMiniRemote();
|
||||
SafeImGui.SetItemTooltip(MiniRemoteTip);
|
||||
}
|
||||
else if (hl.Plan.Extras == TitleExtrasMode.Menu)
|
||||
{
|
||||
if (IconButton("##inv_more", PhosphorIcons.DotsThree, At(hl.More), btn22,
|
||||
MiniRemoteOpen || RynthSortOpen || ItemCountOpen || GlobalInventoryOpen ? Teal : Amber, BtnFill, font: UiFont.Ui11))
|
||||
_openMore = true;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Mini Remote, RynthSort, Item Count, Global Inventory");
|
||||
}
|
||||
RelatedMenu();
|
||||
|
||||
// Vault (Aelrynth only): the grid shows the account vault instead of the packs.
|
||||
if (hl.Plan.Vault)
|
||||
{
|
||||
if (IconButton("##inv_vault_m", PhosphorIcons.TreasureChest, At(hl.Vault), btn22,
|
||||
_vaultOpen ? Teal : Amber, BtnFill, font: UiFont.Ui11))
|
||||
{
|
||||
_vaultOpen = !_vaultOpen;
|
||||
_vaultOpenedOnPack = _pack;
|
||||
if (_vaultOpen) VaultFeed.ViewOpened();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Your Aelrynth account vault");
|
||||
}
|
||||
|
||||
if (hl.Plan.ShowCount) dl.AddText(new Vector2(p.X + hl.CountX, ty), Mute, _countText);
|
||||
float countLeft = hl.Plan.ShowCount ? p.X + hl.CountX : p.X + hl.RightEdge;
|
||||
|
||||
// Drag surface: the empty part of the header, between the pyreals and the count.
|
||||
float dragFrom = x + 20 + ImGuiNET.ImGui.CalcTextSize(view.PyrealText).X + 6, dragTo = tb.X - cw - 10;
|
||||
float dragFrom = leftEnd, dragTo = countLeft - 4;
|
||||
if (dragTo > dragFrom)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(dragFrom, p.Y));
|
||||
|
|
@ -612,6 +756,109 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
// The pack showing when the Modern Vault opened (picking another pack closes the Vault).
|
||||
private uint _vaultOpenedOnPack;
|
||||
|
||||
/// <summary>
|
||||
/// The Modern look's Vault: the account vault's items in the grid's style, a caption with how full
|
||||
/// it is and Refresh. Read-only apart from right-click > Withdraw (VaultContextMenu).
|
||||
/// </summary>
|
||||
private void ModernVault(Vector2 pos, Vector2 size)
|
||||
{
|
||||
VaultSnapshot? snap = VaultFeed.Snapshot;
|
||||
VaultItem[] items = snap?.Items ?? Array.Empty<VaultItem>();
|
||||
var pdl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
const float CapH = 22;
|
||||
float ty = pos.Y + (CapH - ImGuiNET.ImGui.GetFontSize()) * 0.5f;
|
||||
pdl.AddText(new Vector2(pos.X + 4, ty), Text, VaultCaption(snap));
|
||||
if (IconButton("##vault_refresh_m", PhosphorIcons.ArrowsClockwise, new Vector2(pos.X + size.X - 22, pos.Y), new Vector2(22, 20),
|
||||
VaultFeed.Awaiting ? Teal : Amber, BtnFill, font: UiFont.Ui11))
|
||||
VaultFeed.RequestRefresh();
|
||||
ImGuiNET.ImGui.SetItemTooltip("Read the vault again");
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(pos.X, pos.Y + CapH));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ChildBg, PanelBg);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(3, 3));
|
||||
ImGuiNET.ImGui.BeginChild("##inv_vault_grid", new Vector2(size.X, Math.Max(30, size.Y - CapH)), ImGuiChildFlags.AlwaysUseWindowPadding);
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
|
||||
float avail = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||
int cols = Math.Max(1, (int)(avail / Cell));
|
||||
int rows = (items.Length + cols - 1) / cols;
|
||||
Vector2 o = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
if (items.Length == 0)
|
||||
{
|
||||
string empty = snap == null ? (VaultFeed.Awaiting ? "Reading the vault..." : VaultEmptyText) : "The vault is empty.";
|
||||
dl.AddText(o + new Vector2(4, 4), Mute, empty);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(avail, 20));
|
||||
}
|
||||
else
|
||||
{
|
||||
var content = new Vector2(cols * Cell, Math.Max(rows * Cell, 1));
|
||||
ImGuiNET.ImGui.InvisibleButton("##vault_cells_m", content, ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight);
|
||||
bool hovered = ImGuiNET.ImGui.IsItemHovered();
|
||||
Vector2 mouse = ImGuiNET.ImGui.GetMousePos();
|
||||
int hoverIdx = -1;
|
||||
if (hovered)
|
||||
{
|
||||
int c = (int)((mouse.X - o.X) / Cell), r = (int)((mouse.Y - o.Y) / Cell);
|
||||
if (c >= 0 && c < cols && r >= 0 && r < rows && r * cols + c < items.Length) hoverIdx = r * cols + c;
|
||||
}
|
||||
|
||||
// Visible rows only.
|
||||
Vector2 clipMin = ImGuiNET.ImGui.GetWindowPos(), clipMax = clipMin + ImGuiNET.ImGui.GetWindowSize();
|
||||
int firstRow = Math.Max(0, (int)((clipMin.Y - o.Y) / Cell));
|
||||
int lastRow = Math.Min(rows - 1, (int)((clipMax.Y - o.Y) / Cell));
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11)); // stack counts
|
||||
for (int r = firstRow; r <= lastRow; r++)
|
||||
{
|
||||
for (int c = 0; c < cols; c++)
|
||||
{
|
||||
int i = r * cols + c;
|
||||
if (i >= items.Length) break;
|
||||
VaultItem it = items[i];
|
||||
var cmin = new Vector2(o.X + c * Cell, o.Y + r * Cell);
|
||||
var cmax = cmin + new Vector2(Cell - 2, Cell - 2);
|
||||
dl.AddRectFilled(cmin, cmax, i == hoverIdx ? CellHot : CellBg, 3);
|
||||
Vector2 imin = cmin + new Vector2(2, 2);
|
||||
if (ScriptIcons.TryGetItem(it.Icon, it.Underlay, it.Overlay, it.Effects, it.ItemType, out IntPtr tex))
|
||||
{
|
||||
IconSampling.Begin(dl);
|
||||
dl.AddImage(tex, imin, imin + new Vector2(Icon, Icon));
|
||||
IconSampling.End(dl);
|
||||
}
|
||||
else
|
||||
dl.AddRectFilled(imin, imin + new Vector2(Icon, Icon), Placeholder, 2);
|
||||
if (it.Stack > 1)
|
||||
{
|
||||
string st = it.Stack.ToString(CultureInfo.InvariantCulture);
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(st);
|
||||
var tp = new Vector2(cmax.X - ts.X - 2, cmax.Y - ts.Y - 1);
|
||||
dl.AddText(tp + Vector2.One, StackShadow, st);
|
||||
dl.AddText(tp, StackCol, st);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
|
||||
if (hoverIdx >= 0)
|
||||
{
|
||||
VaultItem hot = items[hoverIdx];
|
||||
SafeImGui.SetTooltip(hot.Stack > 1 ? $"{hot.Name} ({hot.Stack:N0})" : hot.Name);
|
||||
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
_vaultCtx = hot;
|
||||
_openVaultCtx = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.EndChild();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
VaultContextMenu(); // in the panel's window, outside the child
|
||||
}
|
||||
|
||||
/// <summary>An item's icon (with underlay and overlay) from the shared icon cache, or a placeholder.</summary>
|
||||
private static void DrawItemIcon(ImDrawListPtr dl, uint objectId, Vector2 min, float size, uint tint = 0xFFFFFFFF)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,12 +82,23 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
foreach (var (groupName, idx) in groups)
|
||||
{
|
||||
if (groups.Count > 1) KindHeading(groupName, idx.Count, bw);
|
||||
foreach (int i in idx)
|
||||
for (int k = 0; k < idx.Count; k++)
|
||||
{
|
||||
int i = idx[k];
|
||||
ItemsPanel.WeaponEntry wpn = _data.Weapons[i];
|
||||
ImGuiNET.ImGui.PushID("w" + i);
|
||||
int r = Row(wpn.Name, wpn.Element, shown++, bw, _data.MissingIds.Contains(wpn.Id));
|
||||
int r = Row(wpn.Name, wpn.Element, shown++, bw, _data.MissingIds.Contains(wpn.Id), k > 0, k < idx.Count - 1);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
// Up / down inside its group: the order is RynthAi's preference (the buff wand, the
|
||||
// first weapon of a kind), and it couldn't be changed but by removing and re-adding.
|
||||
if (r == 3 || r == 4)
|
||||
{
|
||||
int j = idx[r == 3 ? k - 1 : k + 1];
|
||||
(_data.Weapons[i], _data.Weapons[j]) = (_data.Weapons[j], _data.Weapons[i]);
|
||||
Save();
|
||||
removed = true; // the indexes moved: draw the rest next frame
|
||||
break;
|
||||
}
|
||||
if (r == 1)
|
||||
{
|
||||
Vector2 at = ImGuiNET.ImGui.GetIO().MousePos;
|
||||
|
|
@ -121,8 +132,15 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
{
|
||||
ItemsPanel.ConsumableEntry c = _data.Consumables[i];
|
||||
ImGuiNET.ImGui.PushID("c" + i);
|
||||
int r = Row(c.Name, c.Type, i, bw, missing: false);
|
||||
int r = Row(c.Name, c.Type, i, bw, missing: false, canUp: i > 0, canDown: i < _data.Consumables.Count - 1);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
if (r == 3 || r == 4)
|
||||
{
|
||||
int j = r == 3 ? i - 1 : i + 1;
|
||||
(_data.Consumables[i], _data.Consumables[j]) = (_data.Consumables[j], _data.Consumables[i]);
|
||||
Save();
|
||||
break;
|
||||
}
|
||||
if (r == 1)
|
||||
{
|
||||
Vector2 at = ImGuiNET.ImGui.GetIO().MousePos;
|
||||
|
|
@ -248,18 +266,21 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
}
|
||||
|
||||
private const string MissingSuffix = " (missing)";
|
||||
// The up / down buttons' width in a row (two 20 px buttons and their gaps).
|
||||
private const float MoveW = 46;
|
||||
|
||||
/// <summary>
|
||||
/// Name | [value picker] | Del. Returns 1 when the picker was clicked, 2 for Del, else 0.
|
||||
/// Name | up | down | [value picker] | Del. Returns 1 when the picker was clicked, 2 for Del,
|
||||
/// 3 for up, 4 for down, else 0. Up / down are drawn dim and do nothing at the ends.
|
||||
/// <paramref name="missing"/>: the item isn't carried any more (amber, a warning icon,
|
||||
/// "(missing)" and a tooltip saying what to do).
|
||||
/// </summary>
|
||||
private static int Row(string name, string value, int index, float w, bool missing)
|
||||
private static int Row(string name, string value, int index, float w, bool missing, bool canUp = false, bool canDown = false)
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
dl.AddRectFilled(p, p + new Vector2(w, 24), index % 2 == 0 ? RowAlt : PanelBg);
|
||||
float nameW = w - 146;
|
||||
float nameW = w - 146 - MoveW;
|
||||
float ty = p.Y + (24 - ImGuiNET.ImGui.GetFontSize()) * 0.5f;
|
||||
dl.PushClipRect(p, p + new Vector2(nameW, 24), true);
|
||||
if (missing)
|
||||
|
|
@ -280,8 +301,14 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.SetTooltip("Not in your pack any more - select the item in your inventory and click\n"
|
||||
+ "Add Selected Weapon again, or remove this entry.");
|
||||
int result = 0;
|
||||
if (Button("##pick", value, new Vector2(p.X + nameW + 2, p.Y + 2), new Vector2(96, 20), Text, BtnFill)) result = 1;
|
||||
if (IconButton("##del", PhosphorIcons.Trash, new Vector2(p.X + nameW + 102, p.Y + 2), new Vector2(42, 20), Red, BtnFill)) result = 2;
|
||||
float bx = p.X + nameW + 2;
|
||||
if (IconButton("##up", PhosphorIcons.CaretUp, new Vector2(bx, p.Y + 2), new Vector2(20, 20), canUp ? Teal : Mute, BtnFill) && canUp) result = 3;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Move up");
|
||||
if (IconButton("##down", PhosphorIcons.CaretDown, new Vector2(bx + 22, p.Y + 2), new Vector2(20, 20), canDown ? Teal : Mute, BtnFill) && canDown) result = 4;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Move down");
|
||||
bx += MoveW;
|
||||
if (Button("##pick", value, new Vector2(bx, p.Y + 2), new Vector2(96, 20), Text, BtnFill)) result = 1;
|
||||
if (IconButton("##del", PhosphorIcons.Trash, new Vector2(bx + 100, p.Y + 2), new Vector2(42, 20), Red, BtnFill)) result = 2;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Remove");
|
||||
NextLine(p, 24);
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,13 @@
|
|||
// match name + class (default), name only, items like this
|
||||
// T11 "Include T11 attributes": also require the item's T11 tier,
|
||||
// grade, damage %, modifiers, slot special and Cast on Strike,
|
||||
// each at least this item's (any match; 2026-10-07)
|
||||
// each at least this item's (any match; 2026-10-07). With a
|
||||
// RynthAi that has it, the attribute checklist below replaces it.
|
||||
// attrs the attribute checklist (2026-10-18): every attribute the item
|
||||
// has, grouped (Item, Weapon / Armor, Ratings, Spells, Pet
|
||||
// essence, T11, Requirements); tick a row to require it, pick
|
||||
// >= / = / <= (spells: or better / exact / any tier), type a
|
||||
// value. "Items like this" pre-ticks its usual set.
|
||||
// action Keep, Keep # (with the count), Salvage, Sell, Read
|
||||
// name the rule's name (empty: RynthAi's default, "Keep Copper Pea")
|
||||
// preview the rule in words, where it goes in the list and why, notes
|
||||
|
|
@ -55,6 +61,13 @@ internal sealed class LootAddDialog
|
|||
private readonly byte[] _name = new byte[128];
|
||||
private int _keepEdit = 1;
|
||||
|
||||
// The attribute checklist: the rows the player changed (sent with every ask; the rest keep
|
||||
// RynthAi's defaults), each typed value's text box, and the box being typed in (a new
|
||||
// draft doesn't overwrite it).
|
||||
private readonly System.Collections.Generic.Dictionary<string, LootEditItemChoiceDto> _choices = new();
|
||||
private readonly System.Collections.Generic.Dictionary<string, byte[]> _valueBufs = new();
|
||||
private string _editingId = string.Empty;
|
||||
|
||||
// Seqs are unique across popups (the inventory's and the editor's share RynthAi's one draft):
|
||||
// a popup only takes an answer to something it asked.
|
||||
private static int s_seq;
|
||||
|
|
@ -94,6 +107,9 @@ internal sealed class LootAddDialog
|
|||
_keep = -1;
|
||||
_includeT11 = false;
|
||||
Array.Clear(_name);
|
||||
_choices.Clear();
|
||||
_valueBufs.Clear();
|
||||
_editingId = string.Empty;
|
||||
_draft = null;
|
||||
_adding = false;
|
||||
_addedAt = default;
|
||||
|
|
@ -119,6 +135,8 @@ internal sealed class LootAddDialog
|
|||
{
|
||||
ItemId = _itemId, Match = _match, Action = _action, KeepCount = _keep,
|
||||
RuleName = Utf8(_name).Trim(), ToOpenProfile = _toOpenProfile, IncludeT11 = _includeT11, Seq = _seq,
|
||||
// Null until the player changes a row: RynthAi's defaults (and its notes about them).
|
||||
Choices = _choices.Count == 0 ? null : new System.Collections.Generic.List<LootEditItemChoiceDto>(_choices.Values),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -198,13 +216,21 @@ internal sealed class LootAddDialog
|
|||
}
|
||||
}
|
||||
if (!ImGuiNET.ImGui.IsAnyItemActive() || first) _keepEdit = Math.Max(0, d.KeepCount);
|
||||
// Value boxes show what the rule uses now, except the one being typed in.
|
||||
foreach (LootEditItemAttributeDto a in d.Attributes)
|
||||
{
|
||||
if (!a.Editable || a.Id == _editingId) continue;
|
||||
if (!_valueBufs.TryGetValue(a.Id, out byte[]? buf)) _valueBufs[a.Id] = buf = new byte[32];
|
||||
WriteUtf8(buf, a.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The popup's contents; true when it should close.</summary>
|
||||
private bool Body()
|
||||
{
|
||||
const float w = 380;
|
||||
// Wider with the checklist (label, comparison, value on one line).
|
||||
float w = _draft?.AttributesSupported == true ? 440 : 380;
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
|
||||
ImGuiNET.ImGui.TextUnformatted(PhosphorIcons.Plus + " Add to loot profile");
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
|
|
@ -260,24 +286,31 @@ internal sealed class LootAddDialog
|
|||
if (ImGuiNET.ImGui.IsItemHovered()) SafeImGui.SetTooltip(MatchTips[i]);
|
||||
}
|
||||
|
||||
// T11 attributes. Shown for every item: a non-T11 item answers with a note saying so.
|
||||
bool t11 = _includeT11;
|
||||
if (ImGuiNET.ImGui.Checkbox("Include T11 attributes##la_t11", ref t11))
|
||||
if (d.AttributesSupported)
|
||||
{
|
||||
_includeT11 = t11;
|
||||
changed = true;
|
||||
changed |= DrawAttributes(d, w);
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip(
|
||||
"Also require this item's T11 tier (the server's stamped tier when it sends one), weapon grade,\n" +
|
||||
"damage %, gear grade, every modifier, slot special and Cast on Strike, each at least as good\n" +
|
||||
"as this one. Works with any match.\n" +
|
||||
"Not added: Can Wield (depends on your character), Zone Locked (depends on where it was assessed),\n" +
|
||||
"and property slots / Tainted (bag state, not quality).");
|
||||
if (!d.IsT11)
|
||||
else
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
ImGuiNET.ImGui.TextDisabled("(not a T11 item)");
|
||||
// An older RynthAi: the single T11 box. Shown for every item: a non-T11 item answers with a note saying so.
|
||||
bool t11 = _includeT11;
|
||||
if (ImGuiNET.ImGui.Checkbox("Include T11 attributes##la_t11", ref t11))
|
||||
{
|
||||
_includeT11 = t11;
|
||||
changed = true;
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip(
|
||||
"Also require this item's T11 tier (the server's stamped tier when it sends one), weapon grade,\n" +
|
||||
"damage %, gear grade, every modifier, slot special and Cast on Strike, each at least as good\n" +
|
||||
"as this one. Works with any match.\n" +
|
||||
"Not added: Can Wield (depends on your character), Zone Locked (depends on where it was assessed),\n" +
|
||||
"and property slots / Tainted (bag state, not quality).");
|
||||
if (!d.IsT11)
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
ImGuiNET.ImGui.TextDisabled("(not a T11 item)");
|
||||
}
|
||||
}
|
||||
|
||||
// Action.
|
||||
|
|
@ -370,6 +403,129 @@ internal sealed class LootAddDialog
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The attribute checklist: a scrolling list of the item's rows by group, each with a tick,
|
||||
/// its comparison and its value (typed, or the item's named value). A group header's
|
||||
/// "all" / "none" ticks its rows. True when a choice changed (the caller asks again).
|
||||
/// </summary>
|
||||
private bool DrawAttributes(LootEditItemDraftDto d, float w)
|
||||
{
|
||||
System.Collections.Generic.List<LootEditItemAttributeDto> rows = d.Attributes;
|
||||
ImGuiNET.ImGui.TextDisabled("Attributes:");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (rows.Count == 0)
|
||||
{
|
||||
ImGuiNET.ImGui.TextDisabled("none known yet (assess the item, then reopen)");
|
||||
return false;
|
||||
}
|
||||
int ticked = rows.FindAll(r => r.On).Count;
|
||||
SafeImGui.TextDisabled($"{ticked} of {rows.Count} required (tick what the rule needs)");
|
||||
|
||||
int groups = 0;
|
||||
string? last = null;
|
||||
foreach (LootEditItemAttributeDto r in rows)
|
||||
if (r.Group != last) { groups++; last = r.Group; }
|
||||
float lineH = ImGuiNET.ImGui.GetFrameHeightWithSpacing();
|
||||
float h = Math.Min(rows.Count * lineH + groups * lineH + 8, 300);
|
||||
|
||||
bool changed = false;
|
||||
const float opX = 230, valueX = 330;
|
||||
ImGuiNET.ImGui.BeginChild("##la_attrs", new Vector2(w, h), ImGuiChildFlags.Borders);
|
||||
string? group = null;
|
||||
foreach (LootEditItemAttributeDto r in rows)
|
||||
{
|
||||
if (r.Group != group)
|
||||
{
|
||||
group = r.Group;
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
|
||||
ImGuiNET.ImGui.TextUnformatted(group);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.SameLine(opX);
|
||||
if (ImGuiNET.ImGui.SmallButton("all##la_all_" + group)) changed |= TickGroup(rows, group, true);
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (ImGuiNET.ImGui.SmallButton("none##la_none_" + group)) changed |= TickGroup(rows, group, false);
|
||||
}
|
||||
|
||||
bool on = r.On;
|
||||
if (ImGuiNET.ImGui.Checkbox(r.Label + "##la_on_" + r.Id, ref on))
|
||||
{
|
||||
SetChoice(r, on: on);
|
||||
changed = true;
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemHovered() && r.Tip.Length > 0) SafeImGui.SetTooltip(r.Tip);
|
||||
|
||||
// The comparison: a picker when the row offers more than one.
|
||||
ImGuiNET.ImGui.SameLine(opX);
|
||||
if (r.Ops.Count > 1)
|
||||
{
|
||||
ImGuiNET.ImGui.SetNextItemWidth(90);
|
||||
if (ImGuiNET.ImGui.BeginCombo("##la_op_" + r.Id, LootAttrOps.Label(r.Op)))
|
||||
{
|
||||
foreach (int op in r.Ops)
|
||||
if (ImGuiNET.ImGui.Selectable(LootAttrOps.Label(op) + "##la_opv_" + r.Id + op.ToString(CultureInfo.InvariantCulture), op == r.Op) && op != r.Op)
|
||||
{
|
||||
SetChoice(r, op: op, on: true); // picking a comparison means "require it"
|
||||
changed = true;
|
||||
}
|
||||
ImGuiNET.ImGui.EndCombo();
|
||||
}
|
||||
}
|
||||
else
|
||||
SafeImGui.TextDisabled(LootAttrOps.Label(r.Op));
|
||||
|
||||
// The value: a box for numbers, the item's value (by name) for the rest.
|
||||
ImGuiNET.ImGui.SameLine(valueX);
|
||||
if (r.Editable)
|
||||
{
|
||||
if (!_valueBufs.TryGetValue(r.Id, out byte[]? buf))
|
||||
{
|
||||
_valueBufs[r.Id] = buf = new byte[32];
|
||||
WriteUtf8(buf, r.Value);
|
||||
}
|
||||
ImGuiNET.ImGui.SetNextItemWidth(w - valueX - 16);
|
||||
ImGuiNET.ImGui.InputText("##la_val_" + r.Id, buf, (uint)buf.Length, ImGuiInputTextFlags.CharsDecimal);
|
||||
if (ImGuiNET.ImGui.IsItemActive()) _editingId = r.Id;
|
||||
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
_editingId = string.Empty;
|
||||
SetChoice(r, value: Utf8(buf).Trim(), on: true); // typing a value means "require it"
|
||||
changed = true;
|
||||
}
|
||||
else if (_editingId == r.Id && !ImGuiNET.ImGui.IsItemActive())
|
||||
_editingId = string.Empty;
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("This item: " + r.ItemValue + ". Type another value to require that instead.");
|
||||
}
|
||||
else
|
||||
SafeImGui.TextDisabled(r.ItemValue);
|
||||
}
|
||||
ImGuiNET.ImGui.EndChild();
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>Ticks or clears every row of <paramref name="group"/>; true when one changed.</summary>
|
||||
private bool TickGroup(System.Collections.Generic.List<LootEditItemAttributeDto> rows, string group, bool on)
|
||||
{
|
||||
bool changed = false;
|
||||
foreach (LootEditItemAttributeDto r in rows)
|
||||
{
|
||||
if (r.Group != group || r.On == on) continue;
|
||||
SetChoice(r, on: on);
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>The player's choice for a row: its current state with the given parts changed.</summary>
|
||||
private void SetChoice(LootEditItemAttributeDto r, bool? on = null, int? op = null, string? value = null)
|
||||
{
|
||||
if (!_choices.TryGetValue(r.Id, out LootEditItemChoiceDto? c))
|
||||
_choices[r.Id] = c = new LootEditItemChoiceDto { Id = r.Id, On = r.On, Op = r.Op, Value = r.Editable && r.Value != r.ItemValue ? r.Value : string.Empty };
|
||||
if (on.HasValue) c.On = on.Value;
|
||||
if (op.HasValue) c.Op = op.Value;
|
||||
if (value != null) c.Value = value == r.ItemValue ? string.Empty : value;
|
||||
}
|
||||
|
||||
private bool CloseRow(float w)
|
||||
{
|
||||
Vector2 bp = ImGuiNET.ImGui.GetCursorScreenPos() + new Vector2(0, 4);
|
||||
|
|
|
|||
|
|
@ -123,6 +123,10 @@ internal sealed partial class MiniRemoteFace
|
|||
_remoteWindowSize = ImGuiNET.ImGui.GetWindowSize() / ImGuiPanelHost.PlacementScale();
|
||||
_section = next;
|
||||
_fitPending = true;
|
||||
// Non-Remote sections need the left rail (or they draw as an orphan body with no
|
||||
// hub tab bar). Rail-off is only for Remote + miniremote-window (Gear/Games/…).
|
||||
if (!IsRemote && !RailShown)
|
||||
PanelColumnStore.Set(RailKey, 1f);
|
||||
if (IsRemote)
|
||||
{
|
||||
// Back on the remote: RynthAi's asks again; the engine grid gets the size it had.
|
||||
|
|
@ -504,8 +508,17 @@ internal sealed partial class MiniRemoteFace
|
|||
ImGuiNET.ImGui.Separator();
|
||||
bool rail = RailShown;
|
||||
if (ImGuiNET.ImGui.MenuItem("Show the sections rail", "", rail))
|
||||
PanelColumnStore.Set(RailKey, rail ? 0f : 1f);
|
||||
SafeImGui.SetItemTooltip("The column of sections down the left. Hidden, RynthAi's remote shows its own tab bar again "
|
||||
+ "(Gear, Games and the other ILT tabs), and a section is picked here or with /rc miniremote section <name>.");
|
||||
{
|
||||
bool hide = rail;
|
||||
PanelColumnStore.Set(RailKey, hide ? 0f : 1f);
|
||||
// Hiding the rail only restores the Remote tab bar when we are on Remote
|
||||
// (Surface → miniremote-window). Off-Remote + rail off left Crafting/etc.
|
||||
// as a lone body in docked and undocked windows (2026-10-16).
|
||||
if (hide && !IsRemote)
|
||||
SelectSection(SectionCatalog.RemoteId);
|
||||
}
|
||||
SafeImGui.SetItemTooltip("The column of sections down the left. Hidden, the window returns to Remote so "
|
||||
+ "RynthAi's tab bar shows again (Pets, Crafting, Gear, Games, Vaulted), and a section is picked "
|
||||
+ "here or with /rc miniremote section <name> (that turns the rail back on).");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ using RynthCore.Engine.Compatibility;
|
|||
using RynthCore.Engine.Plugins;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using RynthCore.Engine.UI.ScriptWindows;
|
||||
using RynthCore.Engine.UI.Sections;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
|
@ -137,6 +138,11 @@ internal sealed partial class MiniRemoteFace : IImGuiPanel
|
|||
UI.Sections.SectionRegistry.Snapshot snap = UI.Sections.SectionRegistry.Current;
|
||||
TakeRequestedSection(snap);
|
||||
|
||||
// Safety: rail-off + non-Remote draws only that section's body (no hub tabs). Snap
|
||||
// back to Remote so undocked/docked Mini Remote keeps Pets/Crafting/Gear/Games/Vaulted.
|
||||
if (!RailShown && !IsRemote)
|
||||
SelectSection(SectionCatalog.RemoteId);
|
||||
|
||||
// The rail, then everything else to its right (the indent keeps each line there).
|
||||
float railW = RailShown ? DrawRail(snap, origin, size) : 0f;
|
||||
if (railW > 0)
|
||||
|
|
|
|||
|
|
@ -157,19 +157,21 @@ internal sealed class NavFace : IImGuiPanel
|
|||
|
||||
// Breadcrumbs | Route overlay (RynthAi's NavOverlaySettings; saved per character)
|
||||
p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (OverlayToggle("##crumbs", "Breadcrumbs", _data.TrackBreadcrumbs, p, half,
|
||||
"Record the trail you walk and draw it on the ground (/ra navtrail on|off).\nTurning it off hides the trail; /ra navtrail clear wipes it."))
|
||||
// Also on Settings > Navigation. The local settings copy takes the new value too, so a reach
|
||||
// save from this panel before the next settings fetch doesn't send the old one back.
|
||||
if (OverlayToggle("##crumbs", "Breadcrumbs", _data.TrackBreadcrumbs, p, half, SettingsSchema.BreadcrumbsTip))
|
||||
{
|
||||
bool on = !_data.TrackBreadcrumbs;
|
||||
NavCommands.Send(new NavCmd { Cmd = "setBreadcrumbs", On = on });
|
||||
_data.TrackBreadcrumbs = on;
|
||||
if (_settings?.TrackBreadcrumbs != null) _settings.TrackBreadcrumbs = on;
|
||||
}
|
||||
if (OverlayToggle("##routeovl", "Route overlay", _data.ShowRouteOverlay, new Vector2(p.X + half + 4, p.Y), half,
|
||||
"Draw the route in the world: waypoint rings and lines, waypoint labels and the guide line\nto the active waypoint (/ra navoverlay on|off). The waypoint HUD window is separate."))
|
||||
if (OverlayToggle("##routeovl", "Route overlay", _data.ShowRouteOverlay, new Vector2(p.X + half + 4, p.Y), half, SettingsSchema.RouteOverlayTip))
|
||||
{
|
||||
bool on = !_data.ShowRouteOverlay;
|
||||
NavCommands.Send(new NavCmd { Cmd = "setRouteOverlay", On = on });
|
||||
_data.ShowRouteOverlay = on;
|
||||
if (_settings?.ShowRouteOverlay != null) _settings.ShowRouteOverlay = on;
|
||||
}
|
||||
NextLine(p, 26);
|
||||
|
||||
|
|
|
|||
120
src/RynthCore.Engine/ImGui/Panels/OracleSkillsEmbed.cs
Normal file
120
src/RynthCore.Engine/ImGui/Panels/OracleSkillsEmbed.cs
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/OracleSkillsEmbed.cs
|
||||
// Bridges RynthOracle's Skills / Attributes / Progress tabs to the engine
|
||||
// SkillsFace body so raise/train/progression stay in one place under Oracle.
|
||||
// Oracle sets ActiveTab (`/rc oracle-skills <skills|attrs|progress|off>`) while
|
||||
// those tabs are selected; ScriptWindowFace for the Oracle window draws the
|
||||
// embed after the script tab strip.
|
||||
//
|
||||
// Idea and first version: Silentkelpie (RynthCore PR 6).
|
||||
//
|
||||
// Lifecycle (the part that must not leak): the embedded SkillsFace is "shown"
|
||||
// exactly once when it first draws, and "hidden" exactly once when it stops:
|
||||
// - Clear() (Oracle left the tabs: `/rc oracle-skills off`),
|
||||
// - the Oracle window closed / removed / its plugin unloaded (ScriptWindowFace
|
||||
// OnHidden, ScriptWindowRegistry removal and Reset on engine shutdown),
|
||||
// - a safety sweep: no draw for IdleMs (window collapsed, owner crashed).
|
||||
// Redraws while shown only refresh the idle clock (NoteDrawn). SkillsFace binds
|
||||
// its OnShown / OnHidden here; the callbacks go through a ShownLatch, so they
|
||||
// alternate no matter how often or from which thread these are called.
|
||||
//
|
||||
// Skills stays reachable without Oracle: TabsAvailable is true only while the
|
||||
// Oracle window is registered AND Oracle has announced itself by sending any
|
||||
// `/rc oracle-skills` (an older Oracle never does), so the standalone Skills bar
|
||||
// icon / panel stays for everyone who cannot reach the Oracle tabs.
|
||||
//
|
||||
// Pure of ImGui and the plugin registry, so tools/BarDeclutterTests compiles it.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
/// <summary>Which SkillsFace body Oracle wants drawn inside its window (-1 = none).</summary>
|
||||
internal static class OracleSkillsEmbed
|
||||
{
|
||||
/// <summary>0 = Skills, 1 = Attributes, 2 = Progress (ILT Progression). -1 = off.</summary>
|
||||
private static int _activeTab = -1;
|
||||
|
||||
/// <summary>1 once Oracle has sent a `/rc oracle-skills` (any argument) in this engine generation.</summary>
|
||||
private static int _announced;
|
||||
|
||||
private static long _lastDrawnMs;
|
||||
|
||||
private static Action? _onShown, _onHidden;
|
||||
|
||||
private static readonly ShownLatch Latch = new(
|
||||
static () => _onShown?.Invoke(),
|
||||
static () => _onHidden?.Invoke());
|
||||
|
||||
/// <summary>No draw for this long and the embed counts as hidden (Oracle collapsed, closed unseen, crashed).</summary>
|
||||
public const long IdleMs = 1000;
|
||||
|
||||
/// <summary>Oracle panel key prefix used by ScriptWindowRegistry ("script:…").</summary>
|
||||
public const string OraclePanelKeyFragment = "RynthOracle/Oracle";
|
||||
|
||||
public static int ActiveTab => Volatile.Read(ref _activeTab);
|
||||
|
||||
/// <summary>True between the first embed draw and the hide (Clear, window gone, idle).</summary>
|
||||
public static bool IsShown => Latch.IsShown;
|
||||
|
||||
/// <summary>SkillsFace hands over what to run on the shown / hidden edges. Once per engine generation.</summary>
|
||||
public static void Bind(Action shown, Action hidden)
|
||||
{
|
||||
_onShown = shown;
|
||||
_onHidden = hidden;
|
||||
}
|
||||
|
||||
/// <summary>The command saw `/rc oracle-skills` from the Oracle plugin: it has the tabs. Any thread.</summary>
|
||||
public static void Announce() => Volatile.Write(ref _announced, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Oracle Skills / Attributes / Progress tabs can be reached: the Oracle script window is
|
||||
/// registered and Oracle has announced the bridge. False for an Oracle without the tabs, or none.
|
||||
/// </summary>
|
||||
public static bool TabsAvailable(bool oracleWindowRegistered) =>
|
||||
oracleWindowRegistered && Volatile.Read(ref _announced) != 0;
|
||||
|
||||
/// <summary>Called from the Oracle plugin (pump/render) when a Skills-family tab is shown. Out of range = off.</summary>
|
||||
public static void SetActiveTab(int tab)
|
||||
{
|
||||
if (tab is < 0 or > 2) { Clear(); return; }
|
||||
Volatile.Write(ref _activeTab, tab);
|
||||
}
|
||||
|
||||
/// <summary>Clears the embed when Oracle leaves Skills / Attributes / Progress, and hides the face. Any thread.</summary>
|
||||
public static void Clear()
|
||||
{
|
||||
Volatile.Write(ref _activeTab, -1);
|
||||
Latch.Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The embed drew this frame (AC thread): keeps it shown. The face's OnShown runs on the first
|
||||
/// frame only. Ignored when the embed was cleared meanwhile.
|
||||
/// </summary>
|
||||
public static void NoteDrawn(long nowMs)
|
||||
{
|
||||
if (ActiveTab < 0) return;
|
||||
Volatile.Write(ref _lastDrawnMs, nowMs);
|
||||
Latch.Show();
|
||||
}
|
||||
|
||||
/// <summary>Once a frame (AC thread): hides an embed that stopped drawing for IdleMs.</summary>
|
||||
public static void Sweep(long nowMs)
|
||||
{
|
||||
if (!Latch.IsShown) return;
|
||||
if (nowMs - Volatile.Read(ref _lastDrawnMs) > IdleMs) Latch.Hide();
|
||||
}
|
||||
|
||||
/// <summary>Engine shutdown / reload: hide the face and forget the announcement.</summary>
|
||||
public static void Shutdown()
|
||||
{
|
||||
Clear();
|
||||
Volatile.Write(ref _announced, 0);
|
||||
}
|
||||
|
||||
public static bool IsOraclePanel(string panelKey) =>
|
||||
panelKey.Contains(OraclePanelKeyFragment, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
|
@ -1020,6 +1020,22 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
PanelRouter.Toggle(title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Character menu line that opens Skills (0), Attributes (1) or Progress (2): in RynthOracle when its tabs
|
||||
/// are there, else the standalone Skills panel on that tab. Checked while the place it opens is showing it.
|
||||
/// </summary>
|
||||
private static void SkillsMenuItem(string label, string command, int tab, string tooltip)
|
||||
{
|
||||
bool viaOracle = SkillsRouting.OracleTabsAvailable;
|
||||
if (!viaOracle && (tab != 0 || !ImGuiPanelHost.HasFace(SkillsFace.Title))) return; // standalone Skills has its own tab strip
|
||||
bool on = viaOracle
|
||||
? UI.ScriptWindows.ScriptWindowRegistry.IsOpen(OracleMainKey) && OracleSkillsEmbed.ActiveTab == tab
|
||||
: ImGuiPanelHost.IsOpen(SkillsFace.Title);
|
||||
if (ImGuiNET.ImGui.MenuItem(label, viaOracle ? SkillsRouting.OracleCommand(tab) : command, on))
|
||||
SkillsRouting.Open(tab);
|
||||
SafeImGui.SetItemTooltip(viaOracle ? "RynthOracle's " + label + " tab: " + tooltip : tooltip);
|
||||
}
|
||||
|
||||
// RynthOracle's script window keys (RynthOraclePlugin: UiWindow keys).
|
||||
private const string OracleMainKey = "RynthOracle/Oracle";
|
||||
private const string OracleTimersKey = "RynthOracle/QuestTimers";
|
||||
|
|
@ -1074,9 +1090,23 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
SafeImGui.SetItemTooltip(hasOracle
|
||||
? "RynthOracle's Fellowship tab: members, leader, open / locked, XP sharing and (Infinite Leaftide) the /fship commands."
|
||||
: "RynthOracle's Fellowship tab (RynthOracle isn't loaded).");
|
||||
PanelMenuItem(SkillsFace.Title, "/rc skills");
|
||||
// Skills / Attributes / Progress live under RynthOracle (raise/train + ILT planners) when Oracle
|
||||
// provides the tabs; otherwise these open the standalone Skills panel (SkillsRouting).
|
||||
SkillsMenuItem("Skills", "/rc skills", 0, "Raise and train skills.");
|
||||
SkillsMenuItem("Attributes", "/ro attrs", 1, "Attributes and vitals.");
|
||||
SkillsMenuItem("Progress", "/rc progression", 2, "Augmentation, Enlightenment and XP planners (Infinite Leaftide).");
|
||||
PanelMenuItem(InventoryFace.Title, "/rc inventory");
|
||||
PanelMenuItem(ItemCountFace.Title, "/rc itemcount");
|
||||
// RynthInventory's script window (same as /ginv and Inventory's GInv button).
|
||||
const string ginvKey = "RynthInventory/Main";
|
||||
bool hasGinv = UI.ScriptWindows.ScriptWindowRegistry.Has(ginvKey);
|
||||
if (ImGuiNET.ImGui.MenuItem("Global Inventory", "/ginv",
|
||||
hasGinv && UI.ScriptWindows.ScriptWindowRegistry.IsOpen(ginvKey), hasGinv))
|
||||
UI.ScriptWindows.ScriptWindowRegistry.PlayerSetVisible(ginvKey,
|
||||
!UI.ScriptWindows.ScriptWindowRegistry.IsOpen(ginvKey));
|
||||
SafeImGui.SetItemTooltip(hasGinv
|
||||
? "Every character's saved packs and storage (RynthInventory)."
|
||||
: "Global Inventory (RynthInventory isn't loaded).");
|
||||
PanelMenuItem(CharactersFace.Title, "/rc characters");
|
||||
|
||||
UI.ServerMenus.DrawImGuiMenu(separatorFirst: true);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,14 @@ internal sealed unsafe class ScriptWindowFace : IImGuiPanel
|
|||
public void OnShown() => NoteVisibility(visible: true);
|
||||
|
||||
/// <summary>Closed: as OnShown; a close the owner didn't ask for is the player's X unless the bar said otherwise.</summary>
|
||||
public void OnHidden() => NoteVisibility(visible: false);
|
||||
public void OnHidden()
|
||||
{
|
||||
// Leaving Oracle hides the Skills embed (its face's OnHidden runs once, releasing the
|
||||
// Progression subscription) so a later non-Oracle script window never inherits ActiveTab.
|
||||
if (OracleSkillsEmbed.IsOraclePanel(_window.PanelKey))
|
||||
OracleSkillsEmbed.Clear();
|
||||
NoteVisibility(visible: false);
|
||||
}
|
||||
|
||||
private void NoteVisibility(bool visible)
|
||||
{
|
||||
|
|
@ -60,6 +67,13 @@ internal sealed unsafe class ScriptWindowFace : IImGuiPanel
|
|||
ScriptWindowMetrics.Refresh();
|
||||
ReportGeometry();
|
||||
ScriptWindowReplay.Draw(_window);
|
||||
// Oracle Skills / Attributes / Progress: after the script tab strip, draw the
|
||||
// engine SkillsFace body (raise/train/progression) into the remaining space.
|
||||
if (OracleSkillsEmbed.IsOraclePanel(_window.PanelKey))
|
||||
{
|
||||
int tab = OracleSkillsEmbed.ActiveTab;
|
||||
if (tab >= 0) SkillsFace.DrawEmbedded(tab);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ internal sealed class SettingsRows
|
|||
}
|
||||
|
||||
// Label | [caption]; Click posts its own work (never runs plugin code on AC's thread).
|
||||
private static void ButtonRow(SettingRow row, float w)
|
||||
private void ButtonRow(SettingRow row, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
|
|
@ -252,7 +252,16 @@ internal sealed class SettingsRows
|
|||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.SameLine(Math.Max(ImGuiNET.ImGui.GetCursorPosX() + 8, w * 0.45f));
|
||||
if (ImGuiNET.ImGui.Button(row.ButtonText ?? row.Label))
|
||||
{
|
||||
// A settings edit is applied to this copy and saved like a typed value (the number
|
||||
// boxes re-sync from the copy next frame); Click, when also set, runs after.
|
||||
if (row.Edit != null)
|
||||
{
|
||||
row.Edit(_data);
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
row.Click?.Invoke();
|
||||
}
|
||||
Tooltip(row);
|
||||
}
|
||||
|
||||
|
|
|
|||
62
src/RynthCore.Engine/ImGui/Panels/ShownLatch.cs
Normal file
62
src/RynthCore.Engine/ImGui/Panels/ShownLatch.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/ShownLatch.cs
|
||||
// A shown / hidden pair that fires its callbacks once per transition.
|
||||
//
|
||||
// Show() runs the "shown" callback only when the latch is off; Hide() runs the
|
||||
// "hidden" callback only when it is on. Calling either twice in a row is a no-op,
|
||||
// so a face that wants to be "kept shown" every frame (Show) cannot re-run its
|
||||
// setup, and a hide that never had a show (or a second hide) cannot unbalance a
|
||||
// refcount like UiSource.Subscribe / Unsubscribe.
|
||||
//
|
||||
// Pure (no ImGui, no engine state). Any thread: the callbacks run under the
|
||||
// latch's own lock, so a Show and a Hide from two threads still alternate.
|
||||
// If the shown callback throws, the latch stays on, so the matching Hide runs.
|
||||
// Tests: tools/BarDeclutterTests.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal sealed class ShownLatch
|
||||
{
|
||||
private readonly object _gate = new();
|
||||
private readonly Action _shown;
|
||||
private readonly Action _hidden;
|
||||
private volatile bool _on;
|
||||
|
||||
public ShownLatch(Action shown, Action hidden)
|
||||
{
|
||||
_shown = shown;
|
||||
_hidden = hidden;
|
||||
}
|
||||
|
||||
/// <summary>True between a Show that ran its callback and the Hide that ends it.</summary>
|
||||
public bool IsShown => _on;
|
||||
|
||||
/// <summary>Turns the latch on. Returns true (and runs the callback) only on the off to on edge.</summary>
|
||||
public bool Show()
|
||||
{
|
||||
if (_on) return false;
|
||||
lock (_gate)
|
||||
{
|
||||
if (_on) return false;
|
||||
_on = true;
|
||||
_shown();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Turns the latch off. Returns true (and runs the callback) only on the on to off edge.</summary>
|
||||
public bool Hide()
|
||||
{
|
||||
if (!_on) return false;
|
||||
lock (_gate)
|
||||
{
|
||||
if (!_on) return false;
|
||||
_on = false;
|
||||
_hidden();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -595,11 +595,15 @@ internal sealed partial class SkillsFace
|
|||
SendProg("enltarget " + Math.Max(e.Level + 1, target).ToString(CultureInfo.InvariantCulture));
|
||||
foreach (string line in e.Plan) SafeImGui.BulletText(line);
|
||||
|
||||
DrawEnlCalculator(e, w);
|
||||
|
||||
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);
|
||||
if (!string.IsNullOrEmpty(e.Ecoins)) Label(e.Ecoins, Text);
|
||||
if (!string.IsNullOrEmpty(e.EcoinsLum)) Label(e.EcoinsLum, Dim);
|
||||
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (e.Blockers.Length == 0) Label("Client-side checks pass.", Green);
|
||||
|
|
@ -649,6 +653,171 @@ internal sealed partial class SkillsFace
|
|||
}
|
||||
}
|
||||
|
||||
// ── Enl calculator ──────────────────────────────────────────────────
|
||||
//
|
||||
// RynthILT's AppendEnlCalculatorJson (Silentkelpie's rynth PR 6 drew it first): per-level cost rows, still-need /
|
||||
// have materials and the 301-325 sigil craft chain. Read-only: it only draws the Progression snapshot already
|
||||
// subscribed by ProgressionShown, so it adds no subscription and no per-frame work beyond the table rows
|
||||
// (row text is formatted once per snapshot, in the DTOs). A snapshot without the fields (older RynthILT) has
|
||||
// empty arrays and nothing here is drawn.
|
||||
//
|
||||
// Width: the three tables are w - 16 wide inside the Indent(8) of DrawEnlPlanner, with a stretch label
|
||||
// column and narrow fixed number columns scaled down below the retail width (300); text in a cell wraps at
|
||||
// the cell instead of running off the panel. Level rows show a preview (12), "Show all" lists up to 100 in a
|
||||
// table that scrolls on its own.
|
||||
|
||||
private const float EnlRetailTableWidth = 284f; // retail panel width (300) - 16
|
||||
private bool _enlShowAllLevels;
|
||||
private string _enlToggleLabel = "";
|
||||
private int _enlToggleTotal = -1;
|
||||
private bool _enlToggleAll;
|
||||
|
||||
private void DrawEnlCalculator(EnlPlanner e, float w)
|
||||
{
|
||||
if (!e.HasCalculator) return;
|
||||
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
if (!ImGuiNET.ImGui.CollapsingHeader("Enl calculator##prog_enl_calc", ImGuiTreeNodeFlags.DefaultOpen))
|
||||
return;
|
||||
|
||||
float tw = Math.Max(120f, w - 16);
|
||||
float k = Math.Min(1f, tw / EnlRetailTableWidth); // fixed columns shrink on a narrower panel
|
||||
DrawEnlLevels(e.Levels, tw, k);
|
||||
DrawEnlMaterials(e.Materials, tw, k);
|
||||
DrawEnlChain(e, tw, k);
|
||||
}
|
||||
|
||||
private void DrawEnlLevels(EnlLevelRow[] rows, float tw, float k)
|
||||
{
|
||||
if (rows.Length == 0) return;
|
||||
bool canExpand = EnlCalculatorView.CanExpand(rows.Length);
|
||||
bool all = canExpand && _enlShowAllLevels;
|
||||
int shown = EnlCalculatorView.VisibleLevels(rows.Length, all);
|
||||
|
||||
ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp;
|
||||
var size = new Vector2(tw, 0);
|
||||
if (all)
|
||||
{
|
||||
// Own scroll area, a preview's worth of rows tall (+ header): the long list never pushes the panel.
|
||||
flags |= ImGuiTableFlags.ScrollY;
|
||||
size.Y = (ImGuiNET.ImGui.GetTextLineHeightWithSpacing() + 4f) * (EnlCalculatorView.PreviewLevels + 1);
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.PushTextWrapPos(0f); // wrap in the cell, not at the panel's wrap position
|
||||
try
|
||||
{
|
||||
if (ImGuiNET.ImGui.BeginTable("##enl_levels", 4, flags, size))
|
||||
{
|
||||
ImGuiNET.ImGui.TableSetupColumn("Enl", ImGuiTableColumnFlags.WidthFixed, 40 * k);
|
||||
ImGuiNET.ImGui.TableSetupColumn("Item", ImGuiTableColumnFlags.WidthFixed, 84 * k);
|
||||
ImGuiNET.ImGui.TableSetupColumn("Qty", ImGuiTableColumnFlags.WidthFixed, 44 * k);
|
||||
ImGuiNET.ImGui.TableSetupColumn("Lum");
|
||||
if (all) ImGuiNET.ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGuiNET.ImGui.TableHeadersRow();
|
||||
for (int i = 0; i < shown; i++)
|
||||
{
|
||||
EnlLevelRow row = rows[i];
|
||||
uint c = row.Ok ? Green : Amber;
|
||||
ImGuiNET.ImGui.TableNextRow();
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(row.LevelText, c);
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(row.Item, c);
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(row.CountText, c);
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(row.Lum, c);
|
||||
}
|
||||
ImGuiNET.ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
}
|
||||
|
||||
if (canExpand)
|
||||
{
|
||||
// The label is rebuilt only when the row count or the mode changes, not every frame.
|
||||
if (_enlToggleTotal != rows.Length || _enlToggleAll != all)
|
||||
{
|
||||
_enlToggleTotal = rows.Length;
|
||||
_enlToggleAll = all;
|
||||
_enlToggleLabel = (all ? "Show first " + EnlCalculatorView.PreviewLevels.ToString(CultureInfo.InvariantCulture)
|
||||
: "Show all " + Math.Min(rows.Length, EnlCalculatorView.MaxLevels).ToString(CultureInfo.InvariantCulture) + " steps")
|
||||
+ "##enl_lv_all";
|
||||
}
|
||||
if (ImGuiNET.ImGui.SmallButton(_enlToggleLabel)) _enlShowAllLevels = !all;
|
||||
}
|
||||
Label("Green = pack items and banked luminance still cover that step (simulated in order).", Dim);
|
||||
}
|
||||
|
||||
private static void DrawEnlMaterials(EnlMaterialRow[] rows, float tw, float k)
|
||||
{
|
||||
if (rows.Length == 0) return;
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
Label("Still need / have", Text);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(0f);
|
||||
try
|
||||
{
|
||||
if (ImGuiNET.ImGui.BeginTable("##enl_mats", 3,
|
||||
ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp, new Vector2(tw, 0)))
|
||||
{
|
||||
ImGuiNET.ImGui.TableSetupColumn("Material");
|
||||
ImGuiNET.ImGui.TableSetupColumn("Still need", ImGuiTableColumnFlags.WidthFixed, 72 * k);
|
||||
ImGuiNET.ImGui.TableSetupColumn("Have", ImGuiTableColumnFlags.WidthFixed, 72 * k);
|
||||
ImGuiNET.ImGui.TableHeadersRow();
|
||||
int n = Math.Min(rows.Length, EnlCalculatorView.MaxListRows);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
EnlMaterialRow m = rows[i];
|
||||
uint c = m.Ok ? Green : Amber;
|
||||
ImGuiNET.ImGui.TableNextRow();
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(m.Label, c);
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(m.Need, c);
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(m.Have, c);
|
||||
}
|
||||
ImGuiNET.ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawEnlChain(EnlPlanner e, float tw, float k)
|
||||
{
|
||||
EnlChainRow[] rows = e.Chain;
|
||||
if (rows.Length == 0) return;
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
Label("Sigil craft chain (301-325)", Text);
|
||||
if (!string.IsNullOrEmpty(e.ChainNote)) Label(e.ChainNote, Dim); // wraps at the panel's wrap position
|
||||
ImGuiNET.ImGui.PushTextWrapPos(0f);
|
||||
try
|
||||
{
|
||||
if (ImGuiNET.ImGui.BeginTable("##enl_chain", 3,
|
||||
ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp, new Vector2(tw, 0)))
|
||||
{
|
||||
ImGuiNET.ImGui.TableSetupColumn("Item");
|
||||
ImGuiNET.ImGui.TableSetupColumn("Need", ImGuiTableColumnFlags.WidthFixed, 72 * k);
|
||||
ImGuiNET.ImGui.TableSetupColumn("Have", ImGuiTableColumnFlags.WidthFixed, 72 * k);
|
||||
ImGuiNET.ImGui.TableHeadersRow();
|
||||
int n = Math.Min(rows.Length, EnlCalculatorView.MaxListRows);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
EnlChainRow r = rows[i];
|
||||
uint c = r.Ok ? Green : Amber;
|
||||
ImGuiNET.ImGui.TableNextRow();
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(r.DisplayLabel, c);
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(r.NeedText, c);
|
||||
ImGuiNET.ImGui.TableNextColumn(); Label(r.HaveText, c);
|
||||
}
|
||||
ImGuiNET.ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
// ── Confirm ─────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The Progression tab's Yes/No popup (outside the body child, like DrawConfirm).</summary>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
using RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
|
@ -186,7 +187,17 @@ internal sealed partial class SkillsFace : IImGuiPanel
|
|||
private long _masteryPendingUntilMs;
|
||||
private int _masteryPendingVersion;
|
||||
|
||||
public void OnShown()
|
||||
// Shown / hidden exactly once per visible stretch, however often the host (or the Oracle embed) asks:
|
||||
// the Progression subscription it takes in OnShownCore is given back in OnHiddenCore, once.
|
||||
private readonly ShownLatch _life;
|
||||
|
||||
public SkillsFace() => _life = new ShownLatch(OnShownCore, OnHiddenCore);
|
||||
|
||||
public void OnShown() => _life.Show();
|
||||
|
||||
public void OnHidden() => _life.Hide();
|
||||
|
||||
private void OnShownCore()
|
||||
{
|
||||
PlayerProgressHooks.Want();
|
||||
PlayerProgressHooks.RefreshSoon();
|
||||
|
|
@ -196,22 +207,85 @@ internal sealed partial class SkillsFace : IImGuiPanel
|
|||
ProgressionShown();
|
||||
}
|
||||
|
||||
public void OnHidden() => ProgressionHidden();
|
||||
private void OnHiddenCore() => ProgressionHidden();
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
int req = Interlocked.Exchange(ref _requestedTab, -1);
|
||||
if (req >= 0) _tab = req;
|
||||
PlayerProgressHooks.Want();
|
||||
Refresh();
|
||||
ApplyProgressionRequest();
|
||||
if (_tab == 2 && !ProgressionTabVisible) _tab = 0;
|
||||
|
||||
float w = Begin(out Vector2 origin, out Vector2 size);
|
||||
DrawBody(w, origin, size, showOwnTabs: true);
|
||||
End(origin, size);
|
||||
|
||||
_picker.Draw();
|
||||
DrawMulti();
|
||||
DrawConfirm();
|
||||
DrawProgressionConfirm();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Oracle-hosted body (the old Skills panel's tabs, without its frame or tab strip).
|
||||
/// Called each frame the Oracle window shows a Skills / Attributes / Progress tab.
|
||||
/// The first frame runs OnShown (via OracleSkillsEmbed's latch); OracleSkillsEmbed.Clear,
|
||||
/// the Oracle window closing and the idle sweep run OnHidden. AC thread.
|
||||
/// </summary>
|
||||
public static void DrawEmbedded(int tab)
|
||||
{
|
||||
if (_embed == null)
|
||||
{
|
||||
_embed = new SkillsFace();
|
||||
OracleSkillsEmbed.Bind(_embed.OnShown, _embed.OnHidden);
|
||||
}
|
||||
OracleSkillsEmbed.NoteDrawn(Environment.TickCount64);
|
||||
_embed.DrawHosted(tab);
|
||||
}
|
||||
|
||||
/// <summary>Selects Skills (0), Attributes (1) or Progress (2) on the next standalone Draw.</summary>
|
||||
public static void RequestTab(int tab)
|
||||
{
|
||||
tab = tab < 0 ? 0 : tab > 2 ? 2 : tab;
|
||||
Volatile.Write(ref _requestedTab, tab);
|
||||
}
|
||||
|
||||
private static int _requestedTab = -1;
|
||||
|
||||
/// <summary>Shared instance that draws inside Oracle (no separate Skills window).</summary>
|
||||
private static SkillsFace? _embed;
|
||||
|
||||
private void DrawHosted(int tab)
|
||||
{
|
||||
_tab = tab < 0 ? 0 : tab > 2 ? 2 : tab;
|
||||
PlayerProgressHooks.Want();
|
||||
Refresh();
|
||||
ApplyProgressionRequest();
|
||||
// Progress tab on a world without ILT: the tab stays selected and DrawProgression explains.
|
||||
|
||||
Vector2 avail = ImGuiNET.ImGui.GetContentRegionAvail();
|
||||
float w = Math.Max(40f, avail.X);
|
||||
Vector2 origin = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
DrawBody(w, origin, new Vector2(w, Math.Max(120f, avail.Y)), showOwnTabs: false);
|
||||
|
||||
_picker.Draw();
|
||||
DrawMulti();
|
||||
DrawConfirm();
|
||||
DrawProgressionConfirm();
|
||||
}
|
||||
|
||||
private void DrawBody(float w, Vector2 origin, Vector2 size, bool showOwnTabs)
|
||||
{
|
||||
DrawSummary(w);
|
||||
DrawTabs(w);
|
||||
if (showOwnTabs) DrawTabs(w);
|
||||
if (_tab == 0) DrawToolbar(w);
|
||||
if (_tab != 2) DrawColumnHeader(w, _tab == 0 ? "Skill" : "Attribute");
|
||||
|
||||
float bodyH = Math.Max(60, Remaining(origin, size) - GripOverlap());
|
||||
float bodyH = Math.Max(60, showOwnTabs
|
||||
? Remaining(origin, size) - GripOverlap()
|
||||
: size.Y - (ImGuiNET.ImGui.GetCursorScreenPos().Y - origin.Y));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ChildBg, PanelBg);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
||||
ImGuiNET.ImGui.BeginChild("##skills_body", new Vector2(w, bodyH));
|
||||
|
|
@ -230,12 +304,6 @@ internal sealed partial class SkillsFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.EndChild();
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
End(origin, size);
|
||||
|
||||
_picker.Draw();
|
||||
DrawMulti();
|
||||
DrawConfirm();
|
||||
DrawProgressionConfirm();
|
||||
}
|
||||
|
||||
// ── Data ────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
84
src/RynthCore.Engine/ImGui/Panels/SkillsRouting.cs
Normal file
84
src/RynthCore.Engine/ImGui/Panels/SkillsRouting.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/SkillsRouting.cs
|
||||
// Where "open Skills" goes. Skills / Attributes / Progress live under RynthOracle
|
||||
// when its tabs can be reached; otherwise the standalone Skills panel stays the
|
||||
// way in, so nobody loses Skills (bar icon, /rc skills, the Character menu).
|
||||
//
|
||||
// "Can be reached" = the Oracle script window is registered AND Oracle has
|
||||
// announced the bridge with `/rc oracle-skills` (OracleSkillsEmbed.TabsAvailable);
|
||||
// an Oracle without the tabs never announces, so it counts as absent.
|
||||
// ============================================================================
|
||||
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.ScriptWindows;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal static class SkillsRouting
|
||||
{
|
||||
/// <summary>Oracle's main script window (UiWindow "RynthOracle/Oracle").</summary>
|
||||
public const string OracleKey = OracleSkillsEmbed.OraclePanelKeyFragment;
|
||||
|
||||
/// <summary>Oracle provides the Skills / Attributes / Progress tabs now. Any thread.</summary>
|
||||
public static bool OracleTabsAvailable => OracleSkillsEmbed.TabsAvailable(ScriptWindowRegistry.Has(OracleKey));
|
||||
|
||||
/// <summary>The bar's Skills icon shows exactly when Oracle can't provide the tabs. Any thread.</summary>
|
||||
public static bool ShowSkillsBarIcon => !OracleTabsAvailable;
|
||||
|
||||
/// <summary>The Oracle command that selects a tab: skills, attrs or progress.</summary>
|
||||
public static string OracleCommand(int tab) => tab switch
|
||||
{
|
||||
1 => "/ro attrs",
|
||||
2 => "/ro progress",
|
||||
_ => "/ro skills",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Opens Skills (0), Attributes (1) or Progress (2): in Oracle when its tabs are there, else the
|
||||
/// standalone Skills panel on that tab. Returns false when neither exists (no ImGui layer).
|
||||
/// </summary>
|
||||
public static bool Open(int tab)
|
||||
{
|
||||
if (OracleTabsAvailable)
|
||||
{
|
||||
ServerMenus.Run(OracleCommand(tab));
|
||||
return true;
|
||||
}
|
||||
if (!ImGuiPanelHost.HasFace(SkillsFace.Title)) return false;
|
||||
if (tab == 2)
|
||||
{
|
||||
SkillsFace.ShowProgression();
|
||||
return true;
|
||||
}
|
||||
SkillsFace.RequestTab(tab);
|
||||
if (!ImGuiPanelHost.IsOpen(SkillsFace.Title)) PanelRouter.Toggle(SkillsFace.Title);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "/rc skills show|hide|toggle". With Oracle: show opens Oracle on Skills, hide closes Oracle only while
|
||||
/// it is showing a Skills-family tab, toggle closes it when it already shows Skills. Without: the panel.
|
||||
/// </summary>
|
||||
public static bool SetOpen(bool? show)
|
||||
{
|
||||
if (!OracleTabsAvailable)
|
||||
{
|
||||
if (!ImGuiPanelHost.HasFace(SkillsFace.Title)) return false;
|
||||
if (show == null || show.Value != ImGuiPanelHost.IsOpen(SkillsFace.Title))
|
||||
PanelRouter.Toggle(SkillsFace.Title);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool oracleOpen = ScriptWindowRegistry.IsOpen(OracleKey);
|
||||
int tab = OracleSkillsEmbed.ActiveTab;
|
||||
bool onSkills = oracleOpen && tab == 0;
|
||||
if (show == false || (show == null && onSkills))
|
||||
{
|
||||
if (oracleOpen && tab >= 0) ScriptWindowRegistry.PlayerSetVisible(OracleKey, false);
|
||||
return true;
|
||||
}
|
||||
if (show == true && onSkills) return true;
|
||||
ServerMenus.Run(OracleCommand(0));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue