RynthCore as of 2026-10-05 (internal 0d3c210): dashboard slide-outs on the left (Ranges with the selected monster, Files, Patrol), fixed draggable vital bar, click an item to add a loot rule, loot rules by WCID, chat and loot editor typing no longer leaks into the game, title-bar text size, plugin API v76 (close container), plugin exception traces, plates drawn under the game UI (in testing), launcher account passwords encrypted with Windows DPAPI (in testing), release 2026.10.5.1

This commit is contained in:
Tom Bohar 2026-10-05 08:03:08 -04:00
commit c3e15480e5
50 changed files with 3315 additions and 490 deletions

View file

@ -0,0 +1,319 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/DashboardDrawers.cs
// The RynthAi dashboard's slide-out drawers (Tom 2026-10-05: every drawer on
// the dashboard's left edge; only the vitals / target bars stay at its
// bottom). One tab per drawer, stacked down the left edge; a click slides
// that drawer's panel out to the left (to the right when the dashboard sits
// too close to the screen's left edge for the widest drawer). One drawer is
// open at a time: opening one closes the other, so the panels never stack
// and the tabs never jump.
//
// The mechanics live here (tabs, slide, side, placement, the one window);
// each drawer only draws its panel (DashboardDrawer.DrawPanel) and says how
// big it is. Drawers today: Ranges (RangesSlideOut.cs), Loaded files and
// Patrol (RynthAiFace.Drawers.cs).
//
// A top-level ImGui window of its own, begun from inside the dashboard's Draw
// and placed against the dashboard's window every frame, so it follows the
// dashboard (and goes away with it). Each drawer's open/closed is saved with
// the dashboard's state (RynthAiDashboardState). Popped out the tabs are
// hidden: a popped-out dashboard is its own small window and the area around
// it lets clicks through to the game, so a drawer beside it couldn't be used
// (the dashboard falls back to its inline files block and patrol popup).
//
// AC thread only (inside the dashboard's Draw).
// ============================================================================
using System;
using System.Numerics;
using ImGuiNET;
using RynthCore.Engine.UI;
namespace RynthCore.Engine.ImGuiBackend.Panels;
/// <summary>One drawer on the dashboard's left edge: its tab's look and its panel.</summary>
internal abstract class DashboardDrawer
{
/// <summary>Set by the host: close this drawer from inside the panel (its close button).</summary>
public DashboardDrawers? Host { get; set; }
/// <summary>Unique among the drawers ("##drawer_tab_" + Key is the tab's id).</summary>
public abstract string Key { get; }
/// <summary>Phosphor glyph on the tab.</summary>
public abstract string Icon { get; }
/// <summary>Lower-case name for "Hide the …" tooltips.</summary>
public abstract string Name { get; }
/// <summary>The closed tab's tooltip; <paramref name="right"/>: it slides out to the right.</summary>
public abstract string TabTooltip(bool right);
/// <summary>Panel size in pixels at text scale <paramref name="k"/>.</summary>
public abstract float Width(float k);
public abstract float Height(float k);
/// <summary>Every frame before drawing: <paramref name="showing"/> while any of the panel is out (subscriptions, data).</summary>
public virtual void Update(bool showing) { }
/// <summary>Draws the whole panel at <paramref name="origin"/> (the host clips it to the part slid out).</summary>
public abstract void DrawPanel(Vector2 origin, float width, float height, float k);
/// <summary>The saved open/closed (RynthAiDashboardState).</summary>
public abstract bool SavedOpen { get; }
public abstract void SaveOpen(bool open);
private string? _tabId, _hideTip;
/// <summary>The tab's ImGui id and open tooltip (built once).</summary>
internal string TabId => _tabId ??= "##drawer_tab_" + Key;
internal string HideTip => _hideTip ??= "Hide the " + Name + ".";
protected void Close() => Host?.Close(this);
protected static float CalcWidth(ImFontPtr font, string text)
{
ImGuiNET.ImGui.PushFont(font);
float w = ImGuiNET.ImGui.CalcTextSize(text).X;
ImGuiNET.ImGui.PopFont();
return w;
}
// ── The shared panel frame: background, title row (icon + TITLE + note | close) ──
protected static readonly uint DTeal = RynthTheme.Argb(0xFF26D9E6), DMute = RynthTheme.Argb(0xFFB8C8D8),
DWhite = RynthTheme.Argb(0xFFF2F7FC), DBtnFill = RynthTheme.Argb(0xFF16283A), DBtnBord = RynthTheme.Argb(0xFF34587A);
protected const float Pad = 6, TitleH = 18;
/// <summary>Paints the panel's background and title row; returns the y under the title (pixels).</summary>
protected float PanelFrame(Vector2 origin, float panelW, float panelH, float k, string icon, string title, string? note, string closeTip)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
dl.AddRectFilled(origin, origin + new Vector2(panelW, panelH), RynthTheme.RynthAiBackground, RynthTheme.RynthAiRounding);
dl.AddRect(origin, origin + new Vector2(panelW, panelH), RynthTheme.RynthAiBorder, RynthTheme.RynthAiRounding);
float x = origin.X + Pad * k, w = panelW - 2 * Pad * k, y = origin.Y + Pad * k;
ImFontPtr f11 = ImGuiFonts.Get(UiFont.Dash11), f9 = ImGuiFonts.Get(UiFont.Dash9);
float th = TitleH * k;
float iconW = CalcWidth(f11, icon);
dl.AddText(f11, f11.FontSize, new Vector2(x, y + (th - f11.FontSize) * 0.5f), DTeal, icon);
dl.AddText(f11, f11.FontSize, new Vector2(x + iconW + 4 * k, y + (th - f11.FontSize) * 0.5f), DWhite, title);
if (note != null)
{
float tw = CalcWidth(f11, title);
dl.AddText(f9, f9.FontSize, new Vector2(x + iconW + 4 * k + tw + 4 * k, y + (th - f9.FontSize) * 0.5f + 1), DMute, note);
}
Vector2 closeSize = new(18 * k, 16 * k);
if (FaceKit.IconButton("##drawer_close", PhosphorIcons.X, new Vector2(x + w - closeSize.X, y + (th - closeSize.Y) * 0.5f),
closeSize, DMute, DBtnFill, border: DBtnBord, font: UiFont.Dash10))
Close();
ImGuiNET.ImGui.SetItemTooltip(closeTip);
return y + th + 4 * k;
}
}
/// <summary>The tabs and the one open drawer beside the RynthAi dashboard.</summary>
internal sealed class DashboardDrawers
{
private const string WindowId = "##rynthai_drawers";
private const float SlideSeconds = 0.14f;
private static readonly uint Teal = RynthTheme.Argb(0xFF26D9E6), Mute = RynthTheme.Argb(0xFFB8C8D8),
White = RynthTheme.Argb(0xFFF2F7FC), BtnFill = RynthTheme.Argb(0xFF16283A), BtnBord = RynthTheme.Argb(0xFF34587A);
private readonly DashboardDrawer[] _drawers;
private int _open = -1; // the drawer open (or opening); -1 none
private int _shown = -1; // the drawer whose panel draws (a closing one until it has slid in)
private float _t; // slide position of _shown, 0 closed .. 1 open
private bool _loaded;
public DashboardDrawers(params DashboardDrawer[] drawers)
{
_drawers = drawers;
foreach (DashboardDrawer d in drawers) d.Host = this;
}
public bool IsOpen(DashboardDrawer d) => _open >= 0 && _drawers[_open] == d;
/// <summary>Opens <paramref name="d"/> (closing the open one), or closes it when it is the open one.</summary>
public void Toggle(DashboardDrawer d)
{
if (IsOpen(d)) Close(d);
else Open(d);
}
public void Open(DashboardDrawer d)
{
EnsureLoaded();
int i = Array.IndexOf(_drawers, d);
if (i < 0 || i == _open) return;
if (_open >= 0) _drawers[_open].SaveOpen(false);
_open = i;
d.SaveOpen(true);
if (_shown != i)
{
// Another drawer was out (or sliding in): this one slides out from closed.
_shown = i;
_t = 0f;
}
}
public void Close(DashboardDrawer d)
{
if (!IsOpen(d)) return;
_open = -1;
d.SaveOpen(false);
}
/// <summary>The dashboard closed: every drawer drops its subscriptions. AC thread.</summary>
public void Detach()
{
foreach (DashboardDrawer d in _drawers) d.Update(false);
}
private void EnsureLoaded()
{
if (_loaded) return;
_loaded = true;
// The first drawer saved open wins (one at a time); any other saved open is closed.
for (int i = 0; i < _drawers.Length; i++)
{
if (!_drawers[i].SavedOpen) continue;
if (_open < 0) _open = i;
else _drawers[i].SaveOpen(false);
}
_shown = _open;
_t = _open >= 0 ? 1f : 0f;
}
/// <summary>
/// Draws the tabs and the open drawer. Call at the end of the dashboard's Draw, inside its
/// body child (whose rect is the dashboard's: the face is chromeless).
/// </summary>
public void Draw()
{
if (ImGuiPopOuts.InPopOutFrame)
{
// Popped out: no tabs (see the header). Nothing polled meanwhile.
Detach();
return;
}
EnsureLoaded();
// Slide.
float target = _open >= 0 && _open == _shown ? 1f : 0f;
if (_t != target)
{
float step = ImGuiNET.ImGui.GetIO().DeltaTime / SlideSeconds;
if (step <= 0 || float.IsNaN(step)) step = 1f;
_t = target > _t ? MathF.Min(1f, _t + step) : MathF.Max(0f, _t - step);
}
if (_t <= 0f && _open < 0) _shown = -1;
float ease = _t * _t * (3f - 2f * _t);
bool showing = _shown >= 0 && ease > 0.001f;
for (int i = 0; i < _drawers.Length; i++) _drawers[i].Update(showing && i == _shown);
// Geometry (pixels; k follows the dashboard's text size).
Vector2 dashPos = ImGuiNET.ImGui.GetWindowPos(), dashSize = ImGuiNET.ImGui.GetWindowSize();
Vector2 display = ImGuiNET.ImGui.GetIO().DisplaySize;
float k = MathF.Max(1f, ImGuiFonts.Get(UiFont.Dash11).FontSize / 11f);
int n = _drawers.Length;
float tabW = 14 * k, tabGap = 3 * k, tabTop = 4 * k;
// Tabs share the dashboard's height (40 tall at most, 20 at least: they may run past a minimized dashboard).
float tabH = MathF.Max(20 * k, MathF.Min(40 * k, (dashSize.Y - 2 * tabTop - (n - 1) * tabGap) / Math.Max(1, n)));
float tabsH = n * tabH + (n - 1) * tabGap;
float widest = 0;
foreach (DashboardDrawer d in _drawers) widest = MathF.Max(widest, d.Width(k));
float panelW = showing ? _drawers[_shown].Width(k) : widest;
float panelH = showing ? _drawers[_shown].Height(k) : 0;
float dashRight = dashPos.X + dashSize.X;
// Left unless there's no room there for the widest drawer and more on the right (so the tabs never switch sides
// as drawers open and close).
bool right = dashPos.X < tabW + widest && display.X - dashRight > dashPos.X;
float shown = showing ? panelW * ease : 0;
float winX = right ? dashRight : dashPos.X - tabW - shown;
float winW = tabW + shown;
float tabX = right ? dashRight : dashPos.X - tabW;
// Neither side has room (a very wide dashboard): keep it on the screen, over the dashboard.
float shift = 0;
if (winX < 0) shift = -winX;
else if (display.X > 1 && winX + winW > display.X) shift = display.X - (winX + winW);
winX += shift;
tabX += shift;
float winY = dashPos.Y;
float tabsBottom = tabTop + tabsH; // relative to the dashboard's top
float winH = showing ? MathF.Max(panelH, tabsBottom) : tabsBottom;
if (display.Y > 1 && winY + winH > display.Y) winY = MathF.Max(0, display.Y - winH);
float tabY = dashPos.Y + tabTop;
winH = MathF.Max(winH, tabY + tabsH - winY);
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(winX, winY), ImGuiCond.Always);
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(winW, winH), ImGuiCond.Always);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0f);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0f);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, Vector2.One);
bool visible = ImGuiNET.ImGui.Begin(WindowId, WindowFlags);
ImGuiNET.ImGui.PopStyleVar(4);
try
{
if (visible)
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
try
{
if (showing)
{
// The panel's visible part; its content slides with the open edge.
float visX0 = right ? tabX + tabW : winX;
float contentX = right ? tabX + tabW + shown - panelW : winX;
Vector2 vMin = new(visX0, winY), vMax = new(visX0 + shown, winY + panelH);
DashboardDrawer d = _drawers[_shown];
ImGuiNET.ImGui.PushClipRect(vMin, vMax, true);
ImGuiNET.ImGui.PushID(d.Key);
try { d.DrawPanel(new Vector2(contentX, winY), panelW, panelH, k); }
finally
{
ImGuiNET.ImGui.PopID();
ImGuiNET.ImGui.PopClipRect();
}
}
for (int i = 0; i < n; i++)
DrawTab(_drawers[i], new Vector2(tabX, tabY + i * (tabH + tabGap)), new Vector2(tabW, tabH), right, k);
}
finally { ImGuiNET.ImGui.PopFont(); }
}
}
finally
{
ImGuiNET.ImGui.End();
}
}
private const ImGuiWindowFlags WindowFlags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize
| ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse
| ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoDocking
| ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoNav;
private void DrawTab(DashboardDrawer d, Vector2 pos, Vector2 size, bool right, float k)
{
bool open = IsOpen(d);
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.SetCursorScreenPos(pos);
bool clicked = ImGuiNET.ImGui.InvisibleButton(d.TabId, size);
bool hot = ImGuiNET.ImGui.IsItemHovered();
// Like SetItemTooltip (same delay), but the closed tooltip is only built while it shows.
if (ImGuiNET.ImGui.IsItemHovered(ImGuiHoveredFlags.ForTooltip))
ImGuiNET.ImGui.SetTooltip(open ? d.HideTip : d.TabTooltip(right));
if (clicked) Toggle(d);
uint fill = ImGuiNET.ImGui.IsItemActive() ? FaceKit.Darken(BtnFill) : hot ? FaceKit.Lighten(BtnFill) : BtnFill;
ImDrawFlags corners = right ? ImDrawFlags.RoundCornersRight : ImDrawFlags.RoundCornersLeft;
dl.AddRectFilled(pos, pos + size, fill, 4 * k, corners);
dl.AddRect(pos, pos + size, open ? Teal : BtnBord, 4 * k, corners);
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Dash10);
float half = size.Y * 0.5f;
PhosphorIcons.DrawCentered(dl, f10, d.Icon, pos, new Vector2(size.X, half), open ? Teal : Mute);
// The caret points the way the drawer will move.
string caret = right == open ? PhosphorIcons.CaretLeft : PhosphorIcons.CaretRight;
PhosphorIcons.DrawCentered(dl, f10, caret, pos + new Vector2(0, half), new Vector2(size.X, half), hot ? White : Mute);
}
}

View file

@ -201,6 +201,7 @@ internal static class FaceKit
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 3f);
bool result = ImGuiNET.ImGui.InputText(id, buffer, (uint)buffer.Length, flags);
active = ImGuiNET.ImGui.IsItemActive();
if (active) ImGuiTextFocus.NoteActive(id); // keys stay out of AC from this frame on
ImGuiNET.ImGui.PopStyleVar(3);
ImGuiNET.ImGui.PopStyleColor(3);
if (buffer[0] == 0 && !active && hint.Length > 0)

View file

@ -102,6 +102,8 @@ internal sealed partial class InventoryFace : IImGuiPanel
private InventoryItem? _splitItem;
private int _splitAmount = 1;
private uint _splitTarget;
// "Add to loot profile..." (right-click): RynthAi builds the rule, the popup previews it.
private readonly LootAddDialog _lootAdd = new("##inv_lootadd");
// Status line cache.
private string _statusText = string.Empty;
@ -120,6 +122,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
InventoryModel.Hover(0);
InventoryModel.Unsubscribe();
_dragItem = _pressItem = null;
_lootAdd.Cancel();
}
// =====================================================================
@ -155,6 +158,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
DrawDragGhost();
ContextMenu(view);
SplitDialog(view);
_lootAdd.Draw();
_picker.Draw();
}
@ -883,6 +887,11 @@ internal sealed partial class InventoryFace : IImGuiPanel
if (target != null && it.Wielder == 0
&& ImGuiNET.ImGui.MenuItem(target.MenuLabel, "", false, idle && InventoryModel.GiveAvailable))
Act(InventoryActionKind.Give, it, target.Id, target.Name, 0);
ImGuiNET.ImGui.Separator();
if (ImGuiNET.ImGui.MenuItem("Add to loot profile..."))
_lootAdd.Open(it.Id, it.Name, toOpenProfile: false);
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip("Make a RynthAi loot rule for this item (preview first)");
if (!idle)
ImGuiNET.ImGui.TextDisabled("(an item action is waiting)");
}

View file

@ -0,0 +1,380 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/LootAddDialog.cs
// "Add to loot profile": the small popup that turns a clicked item into a
// loot rule (2026-10-04). Opened from the Inventory panel's right-click menu
// and from the Loot Editor's "Add selected item"; /ra loot add is the chat
// twin (no popup, defaults straight in).
//
// item its name and the profile the rule goes to
// match name + class (default), name only, items like this
// 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
// Add RynthAi inserts it, saves (old file kept as .bak) and reloads
//
// RynthAi builds the rule (LootSdk LootItemRules) and does the insert and the
// save; this face only posts item_preview / item_add / item_close through
// LootEditCommands and shows LootEditStateDto.ItemDraft. A face owns one of
// these and calls Draw once per frame outside any child window.
// ============================================================================
using System;
using System.Globalization;
using System.Numerics;
using ImGuiNET;
using RynthCore.Engine.UI.Data;
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed class LootAddDialog
{
private static readonly string[] MatchLabels = { "Name + class", "Name only", "Items like this" };
private static readonly string[] MatchTips =
{
"This exact item: its name and its kind (object class).",
"Anything with this exact name.",
"Its kind plus key properties: material, workmanship, slot, armor / damage, ratings and spells, at least as good as this one. No name.",
};
private static readonly int[] ActionIds =
{ LootEditVocabulary.Keep, LootEditVocabulary.KeepUpTo, LootEditVocabulary.Salvage, LootEditVocabulary.Sell, LootEditVocabulary.Read };
private static readonly string[] ActionLabels = { "Keep", "Keep #", "Salvage", "Sell", "Read" };
private readonly string _id;
private bool _open, _openRequested, _subscribed;
private uint _itemId;
private string _itemName = string.Empty;
private bool _toOpenProfile;
// What the popup asks for (0 / -1 = RynthAi's default).
private int _match, _action, _keep = -1;
private readonly byte[] _name = new byte[128];
private int _keepEdit = 1;
// 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;
private readonly System.Collections.Generic.HashSet<int> _mine = new();
private int _seq;
private DateTime _sentAt;
private long _seenVersion = -1;
private LootEditItemDraftDto? _draft;
private bool _adding;
private DateTime _addedAt;
private bool _justAdded;
/// <summary>True once after an add went through (the Loot Editor scrolls to the new rule).</summary>
public bool TakeAdded()
{
bool v = _justAdded;
_justAdded = false;
return v;
}
public LootAddDialog(string id) => _id = id;
public bool IsOpen => _open;
/// <summary>
/// Opens the popup for <paramref name="itemId"/> (0: the item selected in the
/// game, resolved once). <paramref name="toOpenProfile"/>: the rule goes to the
/// profile open in the Loot Editor, else to the one RynthAi loots with.
/// </summary>
public void Open(uint itemId, string itemName, bool toOpenProfile)
{
_itemId = itemId;
_itemName = itemName ?? string.Empty;
_toOpenProfile = toOpenProfile;
_match = 0;
_action = 0;
_keep = -1;
Array.Clear(_name);
_draft = null;
_adding = false;
_addedAt = default;
_mine.Clear();
if (!_subscribed)
{
UiSources.LootEdit.Subscribe();
_subscribed = true;
}
_openRequested = true;
Send("item_preview");
}
private void Send(string op)
{
_seq = System.Threading.Interlocked.Increment(ref s_seq);
_mine.Add(_seq);
_sentAt = DateTime.UtcNow;
LootEditCommands.Send(new LootEditCmd
{
Op = op,
Item = new LootEditItemRequestDto
{
ItemId = _itemId, Match = _match, Action = _action, KeepCount = _keep,
RuleName = Utf8(_name).Trim(), ToOpenProfile = _toOpenProfile, Seq = _seq,
},
});
}
/// <summary>The owning face was hidden: drop the popup (and its subscription and draft).</summary>
public void Cancel()
{
if (_open || _subscribed) Close();
_openRequested = false;
}
private void Close()
{
if (_open || _subscribed) LootEditCommands.Simple("item_close");
_open = false;
if (_subscribed)
{
UiSources.LootEdit.Unsubscribe();
_subscribed = false;
}
}
/// <summary>Once per frame, outside any child window.</summary>
public void Draw()
{
if (_openRequested)
{
_openRequested = false;
_open = true;
ImGuiNET.ImGui.SetNextWindowPos(ImGuiNET.ImGui.GetMousePos(), ImGuiCond.Always);
ImGuiNET.ImGui.OpenPopup(_id);
}
if (!_open) return;
TakeDraft();
PushStyle();
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(10, 8));
bool visible = ImGuiNET.ImGui.BeginPopup(_id, ImGuiWindowFlags.AlwaysAutoResize);
ImGuiNET.ImGui.PopStyleVar();
if (!visible)
{
PopStyle();
Close(); // clicked outside, or Esc
return;
}
try
{
if (Body()) ImGuiNET.ImGui.CloseCurrentPopup();
}
finally
{
ImGuiNET.ImGui.EndPopup();
PopStyle();
}
}
private void TakeDraft()
{
var snap = UiSources.LootEdit.Current;
if (snap == null || snap.Version == _seenVersion) return;
_seenVersion = snap.Version;
LootEditItemDraftDto? d = snap.Value.State?.ItemDraft;
if (d == null || !_mine.Contains(d.Seq) || (_draft != null && d.Seq < _draft.Seq)) return;
bool first = _draft == null;
_draft = d;
if (d.ItemId != 0) _itemId = d.ItemId; // the selected item, from now on by id
if (d.ItemName.Length > 0) _itemName = d.ItemName;
if (d.Seq == _seq)
{
if (_adding)
{
_adding = false;
if (d.Added)
{
_addedAt = DateTime.UtcNow;
_justAdded = true;
}
}
if (!ImGuiNET.ImGui.IsAnyItemActive() || first) _keepEdit = Math.Max(0, d.KeepCount);
}
}
/// <summary>The popup's contents; true when it should close.</summary>
private bool Body()
{
const float w = 380;
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
ImGuiNET.ImGui.TextUnformatted(PhosphorIcons.Plus + " Add to loot profile");
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.TextUnformatted(_itemName.Length > 0 ? _itemName : "the selected item");
ImGuiNET.ImGui.Separator();
LootEditItemDraftDto? d = _draft;
bool current = d != null && d.Seq == _seq;
if (d == null)
{
bool slow = (DateTime.UtcNow - _sentAt).TotalSeconds > 3;
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, slow ? Amber : Mute);
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
ImGuiNET.ImGui.TextUnformatted(slow
? "No answer from RynthAi. Is it loaded? (A RynthAi older than this feature doesn't answer; /ra loot add needs the new one too.)"
: "Building the rule...");
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
return CloseRow(w);
}
if (d.Added && _addedAt != default)
{
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Green);
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
ImGuiNET.ImGui.TextUnformatted(d.Message + (d.TargetInUse ? ". RynthAi loots with it now." : " (not the profile RynthAi loots with)."));
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
if ((DateTime.UtcNow - _addedAt).TotalSeconds > 2.5) return CloseNow();
return CloseRow(w);
}
// Where it goes.
if (d.TargetFile.Length > 0)
{
ImGuiNET.ImGui.TextDisabled("Profile:");
ImGuiNET.ImGui.SameLine();
ImGuiNET.ImGui.TextUnformatted(d.TargetFile + (d.TargetInUse ? " (in use)" : " (not the one RynthAi loots with)"));
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetTooltip(d.TargetPath);
}
bool changed = false;
// Match.
ImGuiNET.ImGui.TextDisabled("Match:");
for (int i = 0; i < MatchLabels.Length; i++)
{
ImGuiNET.ImGui.SameLine();
if (ImGuiNET.ImGui.RadioButton(MatchLabels[i] + "##m" + i.ToString(CultureInfo.InvariantCulture), d.Match == i) && d.Match != i)
{
_match = i;
changed = true;
}
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetTooltip(MatchTips[i]);
}
// Action.
ImGuiNET.ImGui.TextDisabled("Action:");
for (int i = 0; i < ActionIds.Length; i++)
{
ImGuiNET.ImGui.SameLine();
if (ImGuiNET.ImGui.RadioButton(ActionLabels[i] + "##a" + i.ToString(CultureInfo.InvariantCulture), d.Action == ActionIds[i]) && d.Action != ActionIds[i])
{
_action = ActionIds[i];
changed = true;
}
}
if (d.Action == LootEditVocabulary.KeepUpTo)
{
ImGuiNET.ImGui.TextDisabled("Keep up to:");
ImGuiNET.ImGui.SameLine();
ImGuiNET.ImGui.SetNextItemWidth(110);
ImGuiNET.ImGui.InputInt("##la_keep", ref _keepEdit, 1, 10);
_keepEdit = Math.Max(0, _keepEdit);
bool done = ImGuiNET.ImGui.IsItemDeactivatedAfterEdit() || (ImGuiNET.ImGui.IsItemEdited() && !ImGuiNET.ImGui.IsItemActive());
if (done && _keepEdit != d.KeepCount)
{
_keep = _keepEdit;
_action = LootEditVocabulary.KeepUpTo;
changed = true;
}
ImGuiNET.ImGui.SameLine();
ImGuiNET.ImGui.TextDisabled(d.Stackable ? "(counts stack sizes)" : "(items)");
}
// Name.
ImGuiNET.ImGui.TextDisabled("Name:");
ImGuiNET.ImGui.SameLine();
ImGuiNET.ImGui.SetNextItemWidth(w - 50);
ImGuiNET.ImGui.InputText("##la_name", _name, (uint)_name.Length);
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit()) changed = true;
if (Utf8(_name).Trim().Length == 0 && d.DefaultRuleName.Length > 0)
ImGuiNET.ImGui.TextDisabled("Left empty, the rule is named \"" + d.DefaultRuleName + "\".");
// Preview.
ImGuiNET.ImGui.Separator();
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, current ? Teal : Faded(Teal));
foreach (string line in d.Preview) ImGuiNET.ImGui.TextUnformatted(line);
ImGuiNET.ImGui.PopStyleColor();
if (d.OrderNote.Length > 0)
{
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Mute);
ImGuiNET.ImGui.TextUnformatted(d.OrderNote);
ImGuiNET.ImGui.PopStyleColor();
}
if (d.Notes.Count > 0)
{
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
foreach (string n in d.Notes) ImGuiNET.ImGui.TextUnformatted(n);
ImGuiNET.ImGui.PopStyleColor();
}
if (!d.Ok && d.Error.Length > 0)
{
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Red);
ImGuiNET.ImGui.TextUnformatted(d.Error);
ImGuiNET.ImGui.PopStyleColor();
}
ImGuiNET.ImGui.PopTextWrapPos();
if (changed)
{
Send("item_preview"); // Add waits for the answer (the preview shows faded until then)
current = false;
}
// Add / Cancel.
Vector2 bp = ImGuiNET.ImGui.GetCursorScreenPos() + new Vector2(0, 4);
bool canAdd = current && d.Ok && !_adding;
string addLabel = _adding ? "Adding..." : PhosphorIcons.Plus + " Add rule";
if (Button("##la_add", addLabel, bp, new Vector2(110, 24), canAdd ? Green : Mute, canAdd ? StartBg : BtnFill, canAdd))
{
_adding = true;
Send("item_add");
}
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip(d.InsertAt >= 0
? $"Insert at {d.InsertAt + 1} of {d.RuleCount + 1}, save {d.TargetFile} (old file kept as .bak) and reload it"
: "Add the rule");
if (Button("##la_cancel", "Cancel", bp + new Vector2(116, 0), new Vector2(80, 24), Text, BtnFill))
return CloseNow();
ImGuiNET.ImGui.SetCursorScreenPos(bp + new Vector2(0, 28));
ImGuiNET.ImGui.Dummy(new Vector2(w, 0));
return false;
}
private bool CloseRow(float w)
{
Vector2 bp = ImGuiNET.ImGui.GetCursorScreenPos() + new Vector2(0, 4);
bool close = Button("##la_close", "Close", bp, new Vector2(80, 24), Text, BtnFill);
ImGuiNET.ImGui.SetCursorScreenPos(bp + new Vector2(0, 28));
ImGuiNET.ImGui.Dummy(new Vector2(w, 0));
return close && CloseNow();
}
private bool CloseNow()
{
Close();
return true;
}
private static void PushStyle()
{
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, Teal);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Text);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, BtnFill);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, Lighten(BtnFill));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.CheckMark, Teal);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Separator, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.PopupRounding, 4f);
}
private static void PopStyle()
{
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.PopStyleColor(7);
}
}

View file

@ -120,6 +120,8 @@ internal sealed class LootEditorFace : IImGuiPanel
private const string OtherNumber = "Other number...";
private readonly Picker _picker = new("##loot_pick");
// "Add selected item": a rule for the item selected in the game, into the open profile.
private readonly LootAddDialog _lootAdd = new("##loot_additem");
// ── List ─────────────────────────────────────────────────────────────
@ -171,6 +173,7 @@ internal sealed class LootEditorFace : IImGuiPanel
{
UiSources.LootEdit.WantRule(-1);
UiSources.LootEdit.Unsubscribe();
_lootAdd.Cancel();
}
// =====================================================================
@ -202,6 +205,10 @@ internal sealed class LootEditorFace : IImGuiPanel
else RuleView(origin, size, w);
}
End(origin, size);
_lootAdd.Draw();
// An item rule added to the open profile: show it (the state already carries it and its Focus).
if (_lootAdd.TakeAdded() && _mode == Mode.List && _state != null && _state.Focus >= 0 && _state.Focus < _state.Rules.Count)
_scrollTo = _state.Focus;
_picker.Draw();
}
@ -708,6 +715,15 @@ internal sealed class LootEditorFace : IImGuiPanel
Expect(Await.OpenFocus);
}
ImGuiNET.ImGui.SetItemTooltip("Add a rule at the end and edit it");
string itemLabel = PhosphorIcons.Plus + " Add selected item";
float itemW = ButtonWidth(itemLabel) + 6;
bool canItem = s.Path.Length > 0 && !s.Dirty && (!s.ReadOnly || s.Format == "json");
if (Button("##add_item", itemLabel, new Vector2(p.X + addW + 6, p.Y), new Vector2(itemW, h), canItem ? Teal : Mute, BtnFill, canItem))
_lootAdd.Open(0, string.Empty, toOpenProfile: true);
ImGuiNET.ImGui.SetItemTooltip(canItem
? "A rule for the item selected in the game (click it first): preview, then add it here"
: s.Dirty ? "Save or discard your edits first" : "This profile is read-only here");
addW += itemW + 6;
MessageText(new Vector2(p.X + addW + 8, p.Y), p.X + w - grip - 4, h);
NextLine(p, h);
}

View file

@ -0,0 +1,501 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/RangesSlideOut.cs
// The RynthAi dashboard's "Ranges" drawer (a player request, Tom 2026-10-04):
// a small tab on the dashboard's left edge; clicking it slides a narrow panel
// out to the left (to the right when the dashboard sits too close to the
// screen's left edge for it). Top to bottom:
// title ruler + RANGES (yd) | close
// monster the selected creature: name, priority / damage type / weak
// to, weapon; Edit opens its Monster Detail page, the skull its
// row on the Damage panel (weapon, off hand, pet, debuffs).
// "Select a monster" with nothing selected; "Not a monster" for
// players, NPCs, pets and items (Edit off).
// ranges slider + number rows: Monster range, Nav point reach, Ring
// range, Approach range, Blast range (0 = off), Corpse range
// (max). Labels are short; min/max/step, tooltips and saving
// are the Settings panel's rows (SettingsSchema.Find).
// Values save exactly like the Settings face: a private copy of the hub's
// settings, the row's Set, SettingsCommands.Save of the whole copy (RynthAi
// saves it to the profile). A newer fetch replaces the copy while nothing here
// is typed in or dragged, so Settings > Ranges and this drawer follow each
// other. A slider saves when it's let go; a typed value on Enter or focus loss
// (clamped; bad input reverts). Number boxes are FaceKit.TextBox, so typing
// keeps keys out of AC (ImGuiTextFocus).
//
// One of the dashboard's left-edge drawers (DashboardDrawers.cs: the tab, the
// slide, the side, the window; one drawer open at a time). Open/closed is
// saved with the dashboard's state (RynthAiDashboardState.RangesOpen). Popped
// out the tabs are hidden (see DashboardDrawers); Settings > Ranges still
// works there.
//
// AC thread only (inside the dashboard's Draw). The selection is read once a
// frame while the drawer shows and resolved only when it changes; display
// strings are built when the selection or its data changes, not per frame.
// ============================================================================
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Numerics;
using System.Text;
using ImGuiNET;
using RynthCore.Engine.Compatibility;
using RynthCore.Engine.UI;
using RynthCore.Engine.UI.Data;
using Rule = RynthCore.Engine.UI.Panels.MonstersPanel.Rule;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed class RangesSlideOut : DashboardDrawer
{
// ── Palette (the dashboard's, ARGB) ────────────────────────────────
private static readonly uint Teal = C(0xFF26D9E6), TealSoft = C(0xFF264C59), Amber = C(0xFFE8B333),
Gold = C(0xFFFFD16A), Mute = C(0xFFB8C8D8), White = C(0xFFF2F7FC), BarBg = C(0xFF141F29),
BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A);
private static uint C(uint argb) => RynthTheme.Argb(argb);
// ── Rows: (Settings row label, short label here) ────────────────────
private static readonly (string Schema, string Short)[] Wanted =
{
("Monster Range", "Monster range"),
(SettingsSchema.NavPointReachLabel, "Nav point reach"),
("Ring Range", "Ring range"),
("Approach Range", "Approach range"),
("Blast Range (yd)", "Blast (0=off)"),
("Corpse Max (yd)", "Corpse range"),
};
private sealed class Row
{
public required SettingRow Setting;
public required string Label;
public required string Tip;
public required bool IsInt;
public readonly byte[] Buffer = new byte[24];
public double Shown = double.NaN;
public bool Typing, Dragging;
public double DragValue;
}
private static Row[]? _rows;
private static Row[] Rows => _rows ??= BuildRows();
private static Row[] BuildRows()
{
var list = new List<Row>(Wanted.Length);
foreach (var (schema, label) in Wanted)
{
SettingRow? s = SettingsSchema.Find(schema);
if (s?.Get == null || s.Set == null) continue; // renamed in the schema: leave it out
string tip = s.Tooltip ?? schema;
if (schema == "Corpse Max (yd)") tip = "Corpse Max on Settings > Ranges.\n" + tip;
list.Add(new Row { Setting = s, Label = label, Tip = tip, IsInt = s.Kind == SettingKind.Int });
}
return list.ToArray();
}
// ── State ────────────────────────────────────────────────────────────
private RynthAiSettings? _data;
private long _seenVersion = -1;
private bool _busy; // a row was typed in or dragged last frame
private bool _subSettings, _subMonster;
// The selection, resolved when it changes.
private enum SelKind { None, Unknown, Monster, NotMonster }
private uint _selId = uint.MaxValue;
private long _selSince, _selChecked;
private SelKind _kind = SelKind.None;
private string _selName = "";
private uint _selWcid;
private long _damageSeen = -1, _rulesSeen = -1;
private bool _factsDirty = true;
private string _facts1 = "", _facts2 = "", _factsTip = "";
private string _editTip = NoEditTip, _damageTip = NoDamageTip;
private const string NoEditTip = "Select a monster to edit its rule.";
private const string NoDamageTip = "Select a monster to see it on the Damage panel.";
private bool _factsGold;
private const uint TypeCreature = 0x10; // ITEM_TYPE TYPE_CREATURE
private const uint BfPlayer = 0x8; // PublicWeenieDesc BF_PLAYER
private const uint BfVendor = 0x200; // PublicWeenieDesc BF_VENDOR
private const uint PetOwnerIid = 44; // PropertyInstanceId PetOwner (summoned pets)
// ── Drawer ───────────────────────────────────────────────────────────
public override string Key => "ranges";
public override string Icon => PhosphorIcons.Ruler;
public override string Name => "ranges";
public override bool SavedOpen => RynthAiDashboardState.RangesOpen;
public override void SaveOpen(bool open) => RynthAiDashboardState.SetRangesOpen(open);
public override string TabTooltip(bool right) => right
? "Ranges: monster range, nav point reach and more, and the selected monster.\nClick to slide them out (to the right: there's no room on the left)."
: "Ranges: monster range, nav point reach and more, and the selected monster.\nClick to slide them out.";
public override float Width(float k) => 250 * k;
public override float Height(float k) => PanelHeight(k);
/// <summary>While the panel is out: the selection, the hub subscriptions, a newer settings fetch.</summary>
public override void Update(bool showing)
{
if (showing) ReadSelection();
SetSubscriptions(showing, showing && _kind == SelKind.Monster);
if (showing) TakeNewerSettings(force: false);
}
// ── Panel ────────────────────────────────────────────────────────────
private const float LineH = 15, RowH = 20, RowGap = 3;
private static float PanelHeight(float k) =>
(Pad + TitleH + 4 + 3 * LineH + 6 + 3 + Math.Max(1, Rows.Length) * (RowH + RowGap) + Pad) * k;
public override void DrawPanel(Vector2 origin, float panelW, float panelH, float k)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
// Title row: ruler + RANGES (yards) | close.
float y = PanelFrame(origin, panelW, panelH, k, PhosphorIcons.Ruler, "RANGES", "yards", "Hide the ranges");
float x = origin.X + Pad * k, w = panelW - 2 * Pad * k;
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Dash10);
MonsterBlock(dl, x, y, w, k);
y += 3 * LineH * k + 6 * k;
dl.AddLine(new Vector2(x, y), new Vector2(x + w, y), BtnBord);
y += 3 * k;
if (_data == null)
{
dl.AddText(f10, f10.FontSize, new Vector2(x, y + 4 * k), Mute,
UiSources.Settings.Current == null ? "Waiting for RynthAi…" : "Loading…");
_busy = false;
return;
}
bool busy = false;
Row[] rows = Rows;
float labelW = 0;
foreach (Row r in rows) labelW = MathF.Max(labelW, CalcWidth(f10, r.Label));
labelW += 6 * k;
for (int i = 0; i < rows.Length; i++)
{
ImGuiNET.ImGui.PushID(i);
busy |= NumberRow(rows[i], x, y, w, labelW, k);
ImGuiNET.ImGui.PopID();
y += (RowH + RowGap) * k;
}
_busy = busy;
}
// ── Number rows: label | slider | box ────────────────────────────────
/// <summary>Returns true while the row is typed in or dragged.</summary>
private bool NumberRow(Row r, float x, float y, float w, float labelW, float k)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
SettingRow s = r.Setting;
double value = Math.Clamp(s.Get!(_data!), s.Min, s.Max);
double shownValue = r.Dragging ? r.DragValue : value;
float h = RowH * k;
// Label (tooltip: the Settings row's).
float fs = ImGuiNET.ImGui.GetFontSize();
dl.AddText(new Vector2(x, y + (h - fs) * 0.5f), White, r.Label);
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x, y));
ImGuiNET.ImGui.InvisibleButton("##label", new Vector2(Math.Max(1, labelW - 2 * k), h));
ImGuiNET.ImGui.SetItemTooltip(r.Tip);
// Box at the right.
float boxW = 46 * k;
float boxX = x + w - boxW;
if (!r.Typing && r.Shown != shownValue) WriteValue(r, shownValue);
FaceKit.TextBox("##v", r.Buffer, new Vector2(boxX, y), boxW, "", out bool typing,
ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.AutoSelectAll, h);
r.Typing = typing;
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
{
if (TryParse(r.Buffer, out double typed))
{
double clamped = Math.Clamp(r.IsInt ? Math.Round(typed) : typed, s.Min, s.Max);
Changed(r, clamped);
}
else WriteValue(r, value); // bad input reverts
}
ImGuiNET.ImGui.SetItemTooltip(r.Tip);
// Slider between them: drag (or click) to pick, saved when let go.
float sx = x + labelW, sw = boxX - 6 * k - sx;
if (sw > 10 * k)
{
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(sx, y));
ImGuiNET.ImGui.InvisibleButton("##slider", new Vector2(sw, h));
bool active = ImGuiNET.ImGui.IsItemActive();
bool hot = active || ImGuiNET.ImGui.IsItemHovered();
float knobR = 5 * k;
float trackX0 = sx + knobR, trackX1 = sx + sw - knobR;
if (active && trackX1 > trackX0)
{
float f = Math.Clamp((ImGuiNET.ImGui.GetMousePos().X - trackX0) / (trackX1 - trackX0), 0f, 1f);
r.DragValue = Snap(s.Min + f * (s.Max - s.Min), s, r.IsInt);
r.Dragging = true;
shownValue = r.DragValue;
}
if (ImGuiNET.ImGui.IsItemDeactivated() && r.Dragging)
{
r.Dragging = false;
if (r.DragValue != value) Changed(r, r.DragValue);
}
ImGuiNET.ImGui.SetItemTooltip(r.Tip);
float cy = y + h * 0.5f;
float frac = s.Max > s.Min ? (float)((shownValue - s.Min) / (s.Max - s.Min)) : 0f;
float kx = trackX0 + (trackX1 - trackX0) * Math.Clamp(frac, 0f, 1f);
dl.AddRectFilled(new Vector2(trackX0, cy - 2 * k), new Vector2(trackX1, cy + 2 * k), BarBg, 2 * k);
dl.AddRect(new Vector2(trackX0, cy - 2 * k), new Vector2(trackX1, cy + 2 * k), BtnBord, 2 * k);
if (kx > trackX0) dl.AddRectFilled(new Vector2(trackX0, cy - 2 * k), new Vector2(kx, cy + 2 * k), TealSoft, 2 * k);
dl.AddCircleFilled(new Vector2(kx, cy), knobR, hot ? White : Teal);
}
return r.Typing || r.Dragging;
}
private static double Snap(double v, SettingRow s, bool isInt)
{
double step = s.Step > 0 ? s.Step : 1;
v = s.Min + Math.Round((v - s.Min) / step) * step;
v = isInt ? Math.Round(v) : Math.Round(v, 4);
return Math.Clamp(v, s.Min, s.Max);
}
/// <summary>Saves a new value the way the Settings face does (the row's Set, the whole payload).</summary>
private void Changed(Row r, double value)
{
TakeNewerSettings(force: true);
if (_data == null) return;
r.Setting.Set!(_data, value);
SettingsCommands.Save(_data.Clone());
WriteValue(r, value);
}
/// <summary>A newer fetch replaces the copy unless a row is in use (force: about to save anyway).</summary>
private void TakeNewerSettings(bool force)
{
var snap = UiSources.Settings.Current;
if (snap == null || snap.Version == _seenVersion || (_busy && !force)) return;
_seenVersion = snap.Version;
_data = snap.Value.Clone();
}
private static void WriteValue(Row r, double value)
{
string text = r.IsInt ? ((long)Math.Round(value)).ToString(CultureInfo.InvariantCulture)
: value.ToString("G4", CultureInfo.InvariantCulture);
int n = Encoding.UTF8.GetBytes(text, 0, text.Length, r.Buffer, 0);
r.Buffer[Math.Min(n, r.Buffer.Length - 1)] = 0;
r.Shown = value;
}
private static bool TryParse(byte[] buffer, out double value)
{
int len = Array.IndexOf(buffer, (byte)0);
if (len < 0) len = buffer.Length;
return double.TryParse(Encoding.UTF8.GetString(buffer, 0, len), NumberStyles.Float, CultureInfo.InvariantCulture, out value);
}
// ── Selected monster ─────────────────────────────────────────────────
private void MonsterBlock(ImDrawListPtr dl, float x, float y, float w, float k)
{
ImFontPtr f11 = ImGuiFonts.Get(UiFont.Dash11), f10 = ImGuiFonts.Get(UiFont.Dash10);
float lh = LineH * k;
bool monster = _kind == SelKind.Monster;
if (monster) BuildFacts();
// Buttons at the right of the name line: Edit (Monster Detail), Damage panel row.
Vector2 bsize = new(20 * k, lh);
float bx = x + w - 2 * bsize.X - 2 * k;
if (FaceKit.IconButton("##mon_edit", PhosphorIcons.PencilSimple, new Vector2(bx, y), bsize, monster ? Teal : Mute, BtnFill,
enabled: monster, border: BtnBord, font: UiFont.Dash10))
DamageDetailFace.Show(_selWcid, _selName);
ImGuiNET.ImGui.SetItemTooltip(monster ? _editTip : NoEditTip);
if (FaceKit.IconButton("##mon_damage", PhosphorIcons.Skull, new Vector2(bx + bsize.X + 2 * k, y), bsize, monster ? Teal : Mute, BtnFill,
enabled: monster, border: BtnBord, font: UiFont.Dash10))
{
if (!ImGuiPanelHost.IsOpen(DamageFace.Title)) PanelRouter.ToggleMonsters();
}
ImGuiNET.ImGui.SetItemTooltip(monster ? _damageTip : NoDamageTip);
// Name line.
string name; uint nameColor;
switch (_kind)
{
case SelKind.None: name = "Select a monster"; nameColor = Mute; break;
case SelKind.Unknown: name = _selName.Length > 0 ? _selName : "Reading…"; nameColor = Mute; break;
default: name = _selName.Length > 0 ? _selName : "(no name)"; nameColor = monster ? White : Mute; break;
}
float crossW = CalcWidth(f11, PhosphorIcons.Crosshair);
dl.AddText(f11, f11.FontSize, new Vector2(x, y + (lh - f11.FontSize) * 0.5f), monster ? Teal : Mute, PhosphorIcons.Crosshair);
dl.PushClipRect(new Vector2(x, y), new Vector2(bx - 4 * k, y + lh), true);
dl.AddText(f11, f11.FontSize, new Vector2(x + crossW + 4 * k, y + (lh - f11.FontSize) * 0.5f), nameColor, name);
dl.PopClipRect();
// Two fact lines (one tooltip over both).
float fy = y + lh;
string l1, l2;
uint c1 = Mute;
switch (_kind)
{
case SelKind.None: l1 = "Click one to see its rule here."; l2 = ""; break;
case SelKind.Unknown: l1 = ""; l2 = ""; break;
case SelKind.NotMonster: l1 = "Not a monster"; l2 = ""; c1 = Amber; break;
default: l1 = _facts1; l2 = _facts2; c1 = _factsGold ? Gold : Mute; break;
}
dl.PushClipRect(new Vector2(x, fy), new Vector2(x + w, fy + 2 * lh), true);
if (l1.Length > 0) dl.AddText(f10, f10.FontSize, new Vector2(x, fy + (lh - f10.FontSize) * 0.5f), c1, l1);
if (l2.Length > 0) dl.AddText(f10, f10.FontSize, new Vector2(x, fy + lh + (lh - f10.FontSize) * 0.5f), Mute, l2);
dl.PopClipRect();
if (monster && _factsTip.Length > 0)
{
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x, fy));
ImGuiNET.ImGui.InvisibleButton("##mon_facts", new Vector2(w, 2 * lh));
ImGuiNET.ImGui.SetItemTooltip(_factsTip);
}
}
/// <summary>Reads the selection (one read a frame) and classifies it when it changes.</summary>
private void ReadSelection()
{
uint sel = ClientHelperHooks.GetSelectedItemId();
long now = Environment.TickCount64;
if (sel == _selId && (_kind != SelKind.Unknown || now - _selChecked < 250)) return;
if (sel != _selId) { _selId = sel; _selSince = now; }
_selChecked = now;
_factsDirty = true;
_selWcid = 0;
if (sel == 0) { _kind = SelKind.None; _selName = ""; return; }
_selName = ClientObjectHooks.TryGetSnapshotName(sel, out string n) ? n : "";
SelKind kind = Classify(sel);
// Not in the snapshots a second on: something that isn't out in the world (an item).
if (kind == SelKind.Unknown && now - _selSince > 1000) kind = SelKind.NotMonster;
if (kind == SelKind.Monster)
{
ClientObjectHooks.TryGetObjectWcid(sel, out _selWcid); // 0: the rule alone (by name)
_editTip = "Edit " + _selName + ": its Monster Detail page (priority, damage type, shapes).\n" +
"On Default, a change there gives it a rule of its own.";
_damageTip = "Damage panel: " + _selName + "'s row (weapon, off hand, pet, debuffs).\n" +
"The selected monster is highlighted (and listed first with Nearby first on).";
}
_kind = kind;
}
private static SelKind Classify(uint id)
{
if (!ClientObjectHooks.TryGetSnapshotItemType(id, out uint type)) return SelKind.Unknown;
if ((type & TypeCreature) == 0) return SelKind.NotMonster;
if (!ClientObjectHooks.TryGetSnapshotPwdInfo(id, out uint bf, out _, out _)) return SelKind.Unknown;
if ((bf & (BfPlayer | BfVendor)) != 0) return SelKind.NotMonster;
if (ClientObjectHooks.TryGetObjectInstanceIdProperty(id, PetOwnerIid, out uint owner) && owner != 0) return SelKind.NotMonster;
if (!ClientObjectHooks.TryGetSnapshotAttackable(id, out bool attackable)) return SelKind.Unknown;
return attackable ? SelKind.Monster : SelKind.NotMonster; // not attackable: an NPC
}
/// <summary>Priority / damage type / weak to and the weapon, rebuilt when the monster or its data changes.</summary>
private void BuildFacts()
{
var dmg = UiSources.Damage.Current;
var rules = UiSources.MonsterRules.Current;
long dv = dmg?.Version ?? -1, rv = rules?.Version ?? -1;
if (!_factsDirty && dv == _damageSeen && rv == _rulesSeen) return;
_factsDirty = false;
_damageSeen = dv;
_rulesSeen = rv;
string name = _selName;
DamageRow? row = null;
if (dmg != null)
foreach (DamageRow r in dmg.Value.Rows)
if (!r.IsDefault && (_selWcid != 0 ? r.Wcid == _selWcid : r.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
{
row = r;
break;
}
var tip = new StringBuilder();
string prio = "?", dtype = "?";
_factsGold = false;
if (rules != null)
{
MonsterRulesSnapshot rs = rules.Value;
Rule? own = rs.FindRule(name);
Rule? cover = own == null ? DamageCommands.CoveringRule(rs.Parsed.Rules, name) : null;
Rule use = own ?? cover ?? rs.DefaultRule();
prio = use.Priority.ToString(CultureInfo.InvariantCulture);
dtype = string.IsNullOrEmpty(use.DamageType) ? "Auto" : use.DamageType;
_factsGold = own != null;
tip.Append("Priority ").Append(prio).Append(", damage type ").Append(dtype).Append(": ")
.Append(own != null ? "its own rule." : cover != null ? "the name rule \"" + cover.Name + "\"." : "Default (no rule of its own).")
.Append('\n');
}
else tip.Append("Monster rules loading…\n");
string weakTop = "";
if (row != null && row.Weak.Length > 0)
{
int comma = row.Weak.IndexOf(',');
string first = comma > 0 ? row.Weak.Substring(0, comma) : row.Weak;
int sp = first.IndexOf(' ');
weakTop = sp > 0 ? first.Substring(0, sp) : first;
tip.Append("Weak to: ").Append(row.Weak);
if (row.WeakSrc.Length > 0) tip.Append(" (").Append(row.WeakSrc).Append(')');
tip.Append('\n');
}
_facts1 = "Prio " + prio + " · " + dtype + (weakTop.Length > 0 ? " · weak " + weakTop : "");
if (row == null)
{
_facts2 = dmg == null ? "Loading…" : "Not on the Damage panel yet";
tip.Append(dmg == null ? "" : "Nothing learned about it yet: it joins the Damage panel once fought.\n");
}
else if (row.AssignedWid != 0)
{
string wname = row.AssignedWeapon.Length > 0 ? row.AssignedWeapon : "Weapon " + row.AssignedWid.ToString(CultureInfo.InvariantCulture);
_facts2 = "Weapon " + wname;
tip.Append("Weapon: ").Append(wname).Append(" (set for it).\n");
}
else
{
_facts2 = row.BestWid != 0 ? "Weapon Auto: " + row.BestWeapon : "Weapon Auto";
tip.Append("Weapon: Auto").Append(row.BestWid != 0 ? " (learned best: " + row.BestWeapon + ")" : "").Append(".\n");
}
tip.Append("Gold = its own rule. Edit opens Monster Detail; the skull, the Damage panel.");
_factsTip = tip.ToString();
}
// ── Hub subscriptions ────────────────────────────────────────────────
private void SetSubscriptions(bool settings, bool monster)
{
if (settings != _subSettings)
{
_subSettings = settings;
if (settings) { UiSources.Settings.Subscribe(); UiSources.Settings.RequestRefresh(); }
else UiSources.Settings.Unsubscribe();
}
if (monster != _subMonster)
{
_subMonster = monster;
if (monster)
{
UiSources.Damage.Subscribe();
UiSources.MonsterRules.Subscribe();
UiSources.Damage.RequestRefresh();
UiSources.MonsterRules.RequestRefresh();
}
else
{
UiSources.Damage.Unsubscribe();
UiSources.MonsterRules.Unsubscribe();
}
}
}
}

View file

@ -0,0 +1,139 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/RynthAiFace.Drawers.cs
// The RynthAi dashboard's left-edge drawers that draw with the dashboard's
// own helpers (DashboardDrawers.cs has the tabs and the slide; the Ranges
// drawer is RangesSlideOut.cs):
// Loaded files meta state and bot activity, then the Profile / Nav / Loot
// / Meta pickers and the Loot Editor button. Until
// 2026-10-05 this block folded out inside the dashboard
// (the caret on the control row); a popped-out dashboard
// still shows it inline that way (no drawers popped out).
// Patrol this dungeon's hazard cells (mark / unmark / clear), the
// recorded hazards and the saved routes. Was the Patrol
// launcher's right-click popup; right-click now opens this
// drawer (popped out: still the popup).
// AC thread only (inside the dashboard's Draw).
// ============================================================================
using System;
using System.Numerics;
using ImGuiNET;
using RynthCore.Engine.UI;
using RynthCore.Engine.UI.Data;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed partial class RynthAiFace
{
/// <summary>Meta state, bot activity and the four file pickers.</summary>
private sealed class FilesDrawer : DashboardDrawer
{
private readonly RynthAiFace _face;
public FilesDrawer(RynthAiFace face) => _face = face;
public override string Key => "files";
public override string Icon => PhosphorIcons.Files;
public override string Name => "loaded files";
public override bool SavedOpen => RynthAiDashboardState.FilesOpen;
public override void SaveOpen(bool open) => RynthAiDashboardState.SetFilesOpen(open);
public override string TabTooltip(bool right)
{
RynthAiView? v = _face._view;
return "Loaded files: the Profile, Nav, Loot and Meta pickers, meta state and bot activity.\n" +
"Profile: " + (v?.ProfileText ?? "Default") + "\nNav: " + (v?.NavText ?? "None") +
"\nLoot: " + (v?.LootText ?? "None") + "\nMeta: " + (v?.MetaText ?? "None") +
(right ? "\n\nClick to slide them out (to the right: there's no room on the left)." : "\n\nClick to slide them out.");
}
private const float LineH = 15, SelRow = 16, SelGap = 3;
public override float Width(float k) => 230 * k;
public override float Height(float k) =>
(Pad + TitleH + 4 + 2 * LineH + 6) * k + 4 * SelRow + 3 * SelGap + Pad * k;
public override void DrawPanel(Vector2 origin, float panelW, float panelH, float k)
{
float y = PanelFrame(origin, panelW, panelH, k, PhosphorIcons.Files, "LOADED FILES", null, "Hide the loaded files");
float x = origin.X + Pad * k, w = panelW - 2 * Pad * k;
RynthAiView? view = _face._view;
RynthAiSnapshot raw = _face._raw;
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Dash10);
float lh = LineH * k;
// Meta state / bot activity: label, then the value (amber) on the same line.
float labelW = MathF.Max(CalcWidth(f10, "Meta state:"), CalcWidth(f10, "Bot activity:")) + 6 * k;
InfoLine(dl, f10, x, y, w, lh, labelW, "Meta state:", view?.MetaStateText ?? "Default");
y += lh;
InfoLine(dl, f10, x, y, w, lh, labelW, "Bot activity:", view?.BotActivityText ?? "Idle");
y += lh + 6 * k;
_face.Selector(0, "Profile:", view?.ProfileText ?? "Default", raw.Profiles, raw.SelectedProfileIdx, 3, x, y, w, null);
y += SelRow + SelGap;
_face.Selector(1, "Nav:", view?.NavText ?? "None", raw.NavProfiles, raw.SelectedNavIdx, 0, x, y, w, null);
y += SelRow + SelGap;
_face.Selector(2, "Loot:", view?.LootText ?? "None", raw.LootProfiles, raw.SelectedLootIdx, 1, x, y, w, raw);
y += SelRow + SelGap;
_face.Selector(3, "Meta:", view?.MetaText ?? "None", raw.MetaProfiles, raw.SelectedMetaIdx, 2, x, y, w, null);
}
private static void InfoLine(ImDrawListPtr dl, ImFontPtr f, float x, float y, float w, float lh, float labelW, string label, string value)
{
float ty = y + (lh - f.FontSize) * 0.5f;
dl.AddText(f, f.FontSize, new Vector2(x, ty), Mute, label);
dl.PushClipRect(new Vector2(x + labelW, y), new Vector2(x + w, y + lh), true);
dl.AddText(f, f.FontSize, new Vector2(x + labelW, ty), Amber, value);
dl.PopClipRect();
}
}
/// <summary>Hazard cells and saved routes (the Patrol launcher's right-click).</summary>
private sealed class PatrolDrawer : DashboardDrawer
{
private bool _sub;
public override string Key => "patrol";
public override string Icon => PhosphorIcons.Footprints;
public override string Name => "patrol drawer";
public override bool SavedOpen => RynthAiDashboardState.PatrolOpen;
public override void SaveOpen(bool open) => RynthAiDashboardState.SetPatrolOpen(open);
public override string TabTooltip(bool right) => right
? "Patrol: this dungeon's hazard cells, recorded hazards and saved routes (also: right-click Patrol).\nClick to slide it out (to the right: there's no room on the left)."
: "Patrol: this dungeon's hazard cells, recorded hazards and saved routes (also: right-click Patrol).\nClick to slide it out.";
public override float Width(float k) => 260 * k;
public override float Height(float k) => 320 * k;
public override void Update(bool showing)
{
if (showing == _sub) return;
_sub = showing;
if (showing) { UiSources.Patrol.Subscribe(); UiSources.Patrol.RequestRefresh(); }
else UiSources.Patrol.Unsubscribe();
}
public override void DrawPanel(Vector2 origin, float panelW, float panelH, float k)
{
float y = PanelFrame(origin, panelW, panelH, k, PhosphorIcons.Footprints, "PATROL & ROUTES", null, "Hide the patrol drawer");
float x = origin.X + Pad * k;
// A scrolling child for the lists. A child window is clipped to its parent's clip rect,
// so the host's slide clip covers it too.
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x, y));
Vector2 size = new(panelW - 2 * Pad * k, MathF.Max(1, origin.Y + panelH - Pad * k - y));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
bool open = ImGuiNET.ImGui.BeginChild("##patrol_body", size, ImGuiChildFlags.None, ImGuiWindowFlags.NoBackground);
ImGuiNET.ImGui.PopStyleVar();
try
{
if (open)
{
PatrolInfo info = UiSources.Patrol.Current?.Value ?? new PatrolInfo();
PatrolBody(info, withTitle: false);
}
}
finally { ImGuiNET.ImGui.EndChild(); }
}
}
}

View file

@ -5,9 +5,10 @@
// made compact with Phosphor icons, after DrakBot's dashboard. Top to bottom:
// title row RYNTHAI DASHBOARD | target, vitals, lock, opacity -/+,
// minimize, pop out
// header grid macro RUNNING/STOPPED, meta state, bot activity | pickers
// control row (ON/OFF when minimized) combat, buffing, nav, looting and
// meta toggles ... force rebuff
// header grid popped out only: meta state, bot activity | pickers (docked,
// they are the Loaded files drawer)
// control row macro start/stop, combat, buffing, nav, looting and meta
// toggles, bot activity ... force rebuff
// launchers one row of icon buttons (names in tooltips; labels too
// when the panel is wide enough)
// footer FPS | version | uptime
@ -15,6 +16,11 @@
// toggled from the title row. Last on purpose, like DrakBot's
// target row: what comes and goes with a fight never moves
// the buttons above it.
// drawers tabs on the left edge (DashboardDrawers.cs), one open at a
// time, a window of their own beside the dashboard: Ranges
// (RangesSlideOut.cs), Loaded files and Patrol
// (RynthAiFace.Drawers.cs). Everything that slides out goes
// left; only the bars stay at the bottom (Tom 2026-10-05).
// Minimized keeps the title row, the control row and the bars. The window's
// minimum height is the content's, and toggling the bars or minimize fits the
// window to the content. Data: UiSources.RynthAi (a RynthAiView with every
@ -33,7 +39,7 @@ using RynthCore.Engine.UI.Data;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed class RynthAiFace : IImGuiPanel
internal sealed partial class RynthAiFace : IImGuiPanel
{
public const string Title = "RynthAi";
@ -67,6 +73,12 @@ internal sealed class RynthAiFace : IImGuiPanel
private int _fpsShown = -1;
private long _upShown = -1;
private bool _patrolOpen;
// The drawers on the dashboard's left edge (their own window, placed against this one).
private readonly DashboardDrawers _drawers;
private readonly PatrolDrawer _patrol = new();
// This frame's data, for the drawers.
private RynthAiView? _view;
private RynthAiSnapshot _raw = Empty;
// Picker toggle: ImGui closes a popup on the press outside it, so remember
// whether it was showing when the selector press began (a second click closes).
private readonly int[] _pickerShownFrame = { -10, -10, -10, -10 };
@ -75,11 +87,14 @@ internal sealed class RynthAiFace : IImGuiPanel
// frame: the window's minimum height. _fit: resize the window to it once.
private float _contentHeight;
private bool _fit;
// Files folded/open flipped: size the window to that mode's own remembered size.
private bool _modeFlip, _modeFlipApply;
private Vector2 _winLogical; // the window's size in logical units, last frame (docked only)
private const float GripRoom = 12;
public RynthAiFace()
{
// Tab order top to bottom; the first one saved open wins at load.
_drawers = new DashboardDrawers(new RangesSlideOut(), new FilesDrawer(this), _patrol);
}
public Vector2? MinSize => new Vector2(MinWidth, _contentHeight > 0 ? _contentHeight
: RynthAiDashboardState.Minimized ? 54 : 180);
@ -94,6 +109,7 @@ internal sealed class RynthAiFace : IImGuiPanel
{
UiSources.RynthAi.Unsubscribe();
if (_patrolOpen) { UiSources.Patrol.Unsubscribe(); _patrolOpen = false; }
_drawers.Detach();
}
public void Draw()
@ -101,6 +117,9 @@ internal sealed class RynthAiFace : IImGuiPanel
RynthAiView? view = UiSources.RynthAi.Current?.Value;
RynthAiSnapshot raw = view?.Raw ?? Empty;
bool minimized = RynthAiDashboardState.Minimized;
bool popped = ImGuiPopOuts.InPopOutFrame;
_view = view;
_raw = raw;
uint boxBg = (C(0xFF0A121A) & 0x00FFFFFF) | ((uint)(view?.PanelAlpha ?? 242) << 24);
Vector2 start = ImGuiNET.ImGui.GetCursorScreenPos();
@ -109,13 +128,14 @@ internal sealed class RynthAiFace : IImGuiPanel
TitleRow(raw, x0, width, minimized);
Gap(4);
// The Profile/Nav/Loot/Meta pickers only while expanded (the caret on the control row).
if (!minimized && RynthAiDashboardState.ShowFiles)
// Popped out (no drawers there): the Profile/Nav/Loot/Meta pickers inline while expanded
// (the caret on the control row). Docked they are the Loaded files drawer.
if (popped && !minimized && RynthAiDashboardState.FilesOpen)
{
HeaderGrid(view, raw, x0, width);
Gap(4);
}
ControlRow(view, raw, x0, width, minimized, boxBg);
ControlRow(view, raw, x0, width, minimized, popped, boxBg);
if (!minimized)
{
Gap(4);
@ -126,6 +146,8 @@ internal sealed class RynthAiFace : IImGuiPanel
Bars(view, raw, x0, width, boxBg);
PatrolPopup();
MeasureAndFit(start.Y);
// Last: a window of its own, placed against this one's rect (hidden popped out).
_drawers.Draw();
}
/// <summary>
@ -139,28 +161,6 @@ internal sealed class RynthAiFace : IImGuiPanel
float place = ImGuiPanelHost.PlacementScale();
// + room for the host's resize grip, which is painted over the body's bottom-right corner.
_contentHeight = MathF.Ceiling(px / place) + GripRoom;
if (!ImGuiPopOuts.InPopOutFrame)
{
if (_modeFlip)
{
// The flip happened mid-frame, so this frame measured the old layout: size next frame.
_modeFlip = false;
_modeFlipApply = true;
}
else if (_modeFlipApply)
{
_modeFlipApply = false;
_fit = false;
bool open = RynthAiDashboardState.ShowFiles;
bool known = RynthAiDashboardState.TryGetFilesModeSize(open, out float mw, out float mh);
float w = known ? mw : ImGuiNET.ImGui.GetWindowWidth() / place;
// Folded always shrinks to its one line; open comes back at the size it last had.
float h = open && known ? MathF.Max(mh, _contentHeight) : _contentHeight;
ImGuiPanelHost.RequestSize(Title, new Vector2(w, h));
return;
}
_winLogical = new Vector2(ImGuiNET.ImGui.GetWindowWidth() / place, ImGuiNET.ImGui.GetWindowHeight() / place);
}
if (_fit && !ImGuiPopOuts.InPopOutFrame)
{
_fit = false;
@ -272,11 +272,7 @@ internal sealed class RynthAiFace : IImGuiPanel
const float foldW = 18f;
Selector(0, "Profile:", view?.ProfileText ?? "Default", raw.Profiles, raw.SelectedProfileIdx, 3, rx, ry, rw - foldW - 2, null);
if (IconButton("##files_fold", new Vector2(rx + rw - foldW, ry), new Vector2(foldW, 16), PhosphorIcons.CaretUp, UiFont.Dash11, BtnFill, Mute, BtnBord, 2))
{
RynthAiDashboardState.SetFilesModeSize(true, _winLogical.X, _winLogical.Y);
RynthAiDashboardState.SetShowFiles(false);
_modeFlip = true;
}
RynthAiDashboardState.SetFilesOpen(false);
ImGuiNET.ImGui.SetItemTooltip("Fold the loaded files into one line");
ry += 16 + 3;
Selector(1, "Nav:", view?.NavText ?? "None", raw.NavProfiles, raw.SelectedNavIdx, 0, rx, ry, rw, null);
@ -394,7 +390,7 @@ internal sealed class RynthAiFace : IImGuiPanel
private const float Square = 24, SquareStep = 27, RowPad = 3;
private void ControlRow(RynthAiView? view, RynthAiSnapshot raw, float x0, float width, bool minimized, uint boxBg)
private void ControlRow(RynthAiView? view, RynthAiSnapshot raw, float x0, float width, bool minimized, bool popped, uint boxBg)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
float top = ImGuiNET.ImGui.GetCursorScreenPos().Y;
@ -423,19 +419,16 @@ internal sealed class RynthAiFace : IImGuiPanel
Toggle("##t_meta", PhosphorIcons.Code, raw.MetaEnabled, 4, new Vector2(x, y), "Meta (the macro rules)");
x += SquareStep;
// The pickers fold out from a caret left of FR (expanded mode, while folded away).
// Popped out: the pickers fold out from a caret left of FR (expanded mode, while folded away).
// Docked they are the Loaded files drawer on the left edge.
const float caretW = 16f;
bool caret = !minimized && !RynthAiDashboardState.ShowFiles;
bool caret = popped && !minimized && !RynthAiDashboardState.FilesOpen;
float frX = x0 + width - 5 - Square;
if (caret)
{
if (IconButton("##files_open", new Vector2(frX - 4 - caretW, y), new Vector2(caretW, Square), PhosphorIcons.CaretDown,
UiFont.Dash11, BtnFill, Teal, BtnBord, 2))
{
RynthAiDashboardState.SetFilesModeSize(false, _winLogical.X, _winLogical.Y);
RynthAiDashboardState.SetShowFiles(true);
_modeFlip = true;
}
RynthAiDashboardState.SetFilesOpen(true);
ImGuiNET.ImGui.SetItemTooltip("Profile: " + (view?.ProfileText ?? "Default") + "\nNav: " + (view?.NavText ?? "None") +
"\nLoot: " + (view?.LootText ?? "None") + "\nMeta: " + (view?.MetaText ?? "None") +
"\n\nClick to show the Profile, Nav, Loot and Meta pickers.");
@ -508,13 +501,20 @@ internal sealed class RynthAiFace : IImGuiPanel
x += bw + LauncherGap;
Launcher("##l_items", PhosphorIcons.Backpack, "Items", "Items", x, y, bw, labels, () => PanelRouter.Toggle("Items"));
x += bw + LauncherGap;
bool popped = ImGuiPopOuts.InPopOutFrame;
Launcher("##l_patrol", PhosphorIcons.Footprints, "Patrol",
"Patrol. Left-click: start dungeon patrol. Right-click: routes & recorded hazards.", x, y, bw, labels,
() => RynthAiCommands.SendNavCommand("{\"Cmd\":\"dunPatrol\"}"));
popped ? "Patrol. Left-click: start dungeon patrol. Right-click: routes & recorded hazards."
: "Patrol. Left-click: start dungeon patrol. Right-click: routes & recorded hazards (the Patrol drawer, left).",
x, y, bw, labels, () => RynthAiCommands.SendNavCommand("{\"Cmd\":\"dunPatrol\"}"));
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
ImGuiNET.ImGui.SetNextWindowPos(ImGuiNET.ImGui.GetItemRectMin(), ImGuiCond.Always, new Vector2(0, 1));
ImGuiNET.ImGui.OpenPopup("##patrol");
if (popped)
{
// Popped out there are no drawers: the popup, as before.
ImGuiNET.ImGui.SetNextWindowPos(ImGuiNET.ImGui.GetItemRectMin(), ImGuiCond.Always, new Vector2(0, 1));
ImGuiNET.ImGui.OpenPopup("##patrol");
}
else _drawers.Toggle(_patrol);
}
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x0, y + LauncherH));
@ -682,7 +682,7 @@ internal sealed class RynthAiFace : IImGuiPanel
dl.AddText(font, font.FontSize, new Vector2(x + 4 + CalcWidth(font, icon) + 3, ty), White, bar.Text ?? "");
}
// ── Patrol flyout (right-click Patrol) ────────────────────────────────
// ── Patrol popup (right-click Patrol, popped out; docked it's the Patrol drawer) ──
private void PatrolPopup()
{
@ -704,11 +704,20 @@ internal sealed class RynthAiFace : IImGuiPanel
var snap = UiSources.Patrol.Current;
PatrolInfo info = snap?.Value ?? new PatrolInfo();
PatrolBody(info, withTitle: true);
ImGuiNET.ImGui.EndPopup();
}
/// <summary>The patrol lists at the cursor (the popup's body and the Patrol drawer's).</summary>
private static void PatrolBody(PatrolInfo info, bool withTitle)
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash11));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), PhosphorIcons.Footprints + " PATROL & ROUTES");
ImGuiNET.ImGui.PopFont();
if (withTitle)
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash11));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), PatrolTitle);
ImGuiNET.ImGui.PopFont();
}
Section("THIS DUNGEON");
if (info.InDungeon)
@ -759,9 +768,9 @@ internal sealed class RynthAiFace : IImGuiPanel
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), "• " + name);
ImGuiNET.ImGui.PopFont();
ImGuiNET.ImGui.EndPopup();
}
private const string PatrolTitle = PhosphorIcons.Footprints + " PATROL & ROUTES";
private const string MarkHazardLabel = PhosphorIcons.Warning + " Mark cell as hazard";
private static void Section(string text)