Snapshot for release 2026.10.23.1 (internal 4204305)

This commit is contained in:
Tom Bohar 2026-10-23 16:34:00 -04:00
commit 539a7a3e64
69 changed files with 5385 additions and 107 deletions

View file

@ -58,6 +58,9 @@ internal sealed class ChatFace : IImGuiPanel
private readonly DashboardDrawers _drawers;
private bool _openTabsPopup;
/// <summary>/rc ui channels: the channels drawer opens or closes on the next draw, as its button does.</summary>
public static volatile bool ToggleChannelsRequested;
public ChatFace()
{
_channels = new ChannelsDrawer(this);
@ -1101,6 +1104,12 @@ internal sealed class ChatFace : IImGuiPanel
private void DrawPopups()
{
if (ToggleChannelsRequested)
{
ToggleChannelsRequested = false;
if (ImGuiPopOuts.InPopOutFrame) _openTabsPopup = true;
else _drawers.Toggle(_channels);
}
if (_openSettings)
{
_openSettings = false;

View file

@ -201,12 +201,7 @@ internal sealed class ClassicDashboard
ImGuiPanelHost.DragWindowWithLastItem();
SafeImGui.SetItemTooltip("Drag to move. Right-click: size. Ctrl+wheel: bigger or smaller.");
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right)) ImGuiNET.ImGui.OpenPopup(SizePopupId);
if (ImGuiNET.ImGui.IsItemHovered())
{
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
if (io.KeyCtrl && io.MouseWheel != 0f)
PanelTextScale.SetForWindow(RynthAiFace.Title, PanelTextScale.Get(RynthAiFace.Title) + (io.MouseWheel > 0f ? 1 : -1));
}
// Ctrl+wheel: the panel host steps its size (over any panel).
// "RynthAi" in gold, then the profile and what the bot is doing.
float tx = o.X + Px(10);

View file

@ -204,7 +204,7 @@ internal sealed class ClassicTuningTab : IClassicTab
case SettingKind.Int:
case SettingKind.Float:
case SettingKind.Double: return NumberRow(row, w);
case SettingKind.Combo when row.Items is { Length: > 0 }: ComboRow(ctx, row, w); return false;
case SettingKind.Combo when row.CurrentItems.Length > 0: ComboRow(ctx, row, w); return false;
default:
// The special rows (buttons, hotkeys, colours, server picker, status): the Settings panel's drawing.
_rows.DrawRow(row, w);
@ -296,7 +296,7 @@ internal sealed class ClassicTuningTab : IClassicTab
private void ComboRow(ClassicContext ctx, SettingRow row, float w)
{
RynthAiSettings data = _rows.Data;
string[] items = row.Items!;
string[] items = row.CurrentItems;
int cur = row.Get != null ? Math.Clamp((int)Math.Round(row.Get(data)), 0, items.Length - 1) : 0;
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
float rh = Px(22), ddW = Math.Min(Px(170), w * 0.55f);

View file

@ -373,7 +373,10 @@ internal sealed partial class MiniRemoteFace : IImGuiPanel
if (ready && io.KeyCtrl && io.MouseWheel != 0
&& ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows)
&& ImGuiNET.ImGui.IsMouseHoveringRect(start, start + new Vector2(w, shownH)))
{
ResizeSlots(io.MouseWheel > 0 ? SlotSizeStep : -SlotSizeStep);
io.MouseWheel = 0f; // the boxes took it: not the panel's size too
}
if (clicked >= 0 && ready) Click(data, items, clicked);
else if (clicked >= 0) ShowMessage(ItemHudStore.Loaded ? "Waiting for your character..." : "Loading...", Amber);

View file

@ -11,6 +11,10 @@
// (ImGuiStackGuard): whatever the plugin left open (colours, style vars, fonts,
// IDs, groups, child windows, tables...) is ended and popped there, so the
// panels drawn after it start clean; logged once per window, then counted.
// A "fitHeight" window (v90) takes the height the plugin's draw asks for
// (wantHeight) as its minimum and is fitted to it whenever it changes and the
// mouse is up (a frameless window's empty rows would still catch clicks meant
// for the game); a text size change scales its width along with its fonts.
// docs/PLUGIN_WINDOWS.md. AC's render thread.
// ============================================================================
@ -18,6 +22,7 @@ using System;
using System.Numerics;
using System.Text;
using RynthCore.Engine.Plugins;
using RynthCore.Engine.UI;
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
namespace RynthCore.Engine.ImGuiBackend.Panels;
@ -32,20 +37,37 @@ internal sealed class PluginWindowFace : IImGuiPanel
private long _failedAtMs = -1;
private const long RetryMs = 5000;
public PluginWindowFace(string plugin, string surface, string title)
// "fitHeight" (v90): the content height the plugin asked for (logical units; 0 = not known
// yet), and the text size factor and width (logical) the window was last fitted at.
private readonly bool _fitHeight;
private readonly float _minWidth;
private float _contentHeight, _fitK, _fitWidth;
public PluginWindowFace(string plugin, string surface, string title, bool fitHeight = false, float minWidth = 0f)
{
_plugin = plugin;
_title = title;
_surface = Encoding.UTF8.GetBytes(surface + "\0");
_idScope = "##pw_" + surface;
_fitHeight = fitHeight;
_minWidth = minWidth;
}
/// <summary>A fitHeight window's minimum: its minimum width at its text size, and the content's height.</summary>
public Vector2? MinSize => _fitHeight && _contentHeight > 0f
? new Vector2(_minWidth * TextFactor(), _contentHeight)
: null;
/// <summary>The panel's text size factor at the size its fonts are baked for.</summary>
private float TextFactor() => PanelTextScale.Factor(ImGuiFonts.BakedStepNear(PanelTextScale.Get(_title)));
public void Draw()
{
Vector2 start = ImGuiNET.ImGui.GetCursorScreenPos();
Vector2 avail = ImGuiNET.ImGui.GetContentRegionAvail();
long now = Environment.TickCount64;
int result = PluginManager.EmbedFailed;
Vector2 want = Vector2.Zero;
if (_failedAtMs < 0 || now - _failedAtMs >= RetryMs)
{
// Two stack records: the body's base (where a recovery goes back to: the panel host
@ -57,7 +79,7 @@ internal sealed class PluginWindowFace : IImGuiPanel
ImGuiNET.ImGui.PushID(_idScope);
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
ImGuiStackGuard.Mark given = guarded ? ImGuiStackGuard.Take() : default;
try { result = PluginManager.RenderEmbed(_plugin, _surface, avail, out _); }
try { result = PluginManager.RenderEmbed(_plugin, _surface, avail, out want); }
finally
{
ImGuiStackGuard.Mark after = default;
@ -78,7 +100,11 @@ internal sealed class PluginWindowFace : IImGuiPanel
else if (result == PluginManager.EmbedDrawn) _failedAtMs = -1;
else if (_failedAtMs >= 0) { _failedAtMs = now; result = PluginManager.EmbedFailed; } // still off since the throw
}
if (result == PluginManager.EmbedDrawn) return;
if (result == PluginManager.EmbedDrawn)
{
if (_fitHeight) Fit(want.Y, avail.X);
return;
}
ImGuiNET.ImGui.SetCursorScreenPos(start + new Vector2(6, 6));
Label(result switch
@ -89,6 +115,39 @@ internal sealed class PluginWindowFace : IImGuiPanel
}, Mute);
}
/// <summary>
/// fitHeight: keeps the window as tall as the content the plugin drew (<paramref name="wantPx"/>,
/// client px) and scales its width with a text size change. Docked only (popped out, the OS window
/// is the player's to size); never while the mouse is down, so a drag or a resize isn't fought.
/// </summary>
private void Fit(float wantPx, float widthPx)
{
if (wantPx <= 0f || ImGuiPopOuts.InPopOutFrame) return;
float place = Math.Max(0.01f, ImGuiPanelHost.PlacementScale());
float height = MathF.Ceiling(wantPx / place);
float width = widthPx / place;
float k = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
float shownHeight = ImGuiNET.ImGui.GetWindowHeight() / place;
bool mouseUp = !ImGuiNET.ImGui.IsMouseDown(ImGuiNET.ImGuiMouseButton.Left);
_contentHeight = height;
if (_fitK > 0f && MathF.Abs(k - _fitK) > 0.001f)
{
// A text size change: the width from the one it had at the old size.
width = MathF.Max(_fitWidth * (k / _fitK), _minWidth * k);
float screenW = ImGuiNET.ImGui.GetIO().DisplaySize.X / place;
if (screenW > 1f) width = MathF.Min(width, screenW);
ImGuiPanelHost.RequestSize(_title, new Vector2(width, height));
// Clamped to the screen at the new size: near the right or bottom edge it moves in.
ImGuiPanelHost.RequestPos(_title, ImGuiNET.ImGui.GetWindowPos() / place);
}
else if (mouseUp && MathF.Abs(shownHeight - height) > 0.5f)
{
ImGuiPanelHost.RequestSize(_title, new Vector2(width, height));
}
_fitK = k;
_fitWidth = width;
}
// Unbalanced draws by plugin + surface: logged the first time, then every RepeatEvery-th.
private static readonly System.Collections.Generic.Dictionary<string, int> Unbalanced = new(StringComparer.Ordinal);
private const int RepeatEvery = 1000;

View file

@ -78,16 +78,34 @@ internal sealed class QuickSettingsDrawer : RynthAiDrawer
ImGuiNET.ImGui.OpenPopup(AddPopupId);
}
ImGuiNET.ImGui.SetItemTooltip("Pin or unpin settings");
DrawBody(x, y, w, MathF.Max(1, origin.Y + panelH - Pad * k - y), k, openPicker: false);
}
/// <summary>
/// The pinned rows at (<paramref name="x"/>, <paramref name="y"/>) in a <paramref name="w"/> x
/// <paramref name="h"/> child that scrolls (RynthAi's own dashboard window draws the frame and the
/// + button: <paramref name="openPicker"/> opens the pin list at the mouse, SettingsDrawerBodies).
/// Returns the rows' height (pixels).
/// </summary>
public float DrawBody(float x, float y, float w, float h, float k, bool openPicker)
{
if (openPicker)
{
_filter = string.Empty;
ImGuiNET.ImGui.SetNextWindowPos(ImGuiNET.ImGui.GetMousePos() + new Vector2(0, 8 * k), ImGuiCond.Always, new Vector2(1, 0));
ImGuiNET.ImGui.OpenPopup(AddPopupId);
}
AddPopup(k);
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x, y));
Vector2 size = new(w, MathF.Max(1, origin.Y + panelH - Pad * k - y));
Vector2 size = new(w, MathF.Max(1, h));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
bool open = ImGuiNET.ImGui.BeginChild("##quick_body", size, ImGuiChildFlags.None, ImGuiWindowFlags.NoBackground);
ImGuiNET.ImGui.PopStyleVar();
float contentH = EmptyH * k;
try
{
if (!open) return;
if (!open) return contentH;
_rows.Sync();
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 0));
@ -116,6 +134,8 @@ internal sealed class QuickSettingsDrawer : RynthAiDrawer
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
}
// What the rows took (unscrolled), for a host that fits its height to them.
contentH = ImGuiNET.ImGui.GetCursorPosY() + 2 * k; // content space: the scroll is in it
}
finally
{
@ -124,6 +144,7 @@ internal sealed class QuickSettingsDrawer : RynthAiDrawer
}
}
finally { ImGuiNET.ImGui.EndChild(); }
return contentH;
}
/// <summary>A pinned row's right-click, after Remove: Move up / Move down.</summary>

View file

@ -158,10 +158,18 @@ internal sealed class RangesSlideOut : RynthAiDrawer
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;
DrawBody(origin.X + Pad * k, y, panelW - 2 * Pad * k, k);
}
/// <summary>The body's height under the title row (pixels): RynthAi's own dashboard window draws the frame (SettingsDrawerBodies).</summary>
public static float BodyHeight(float k) => (3 * LineH + 6 + 3 + Math.Max(1, Rows.Length) * (RowH + RowGap)) * k;
/// <summary>The selected monster and the range rows at (<paramref name="x"/>, <paramref name="y"/>), <paramref name="w"/> wide.</summary>
public void DrawBody(float x, float y, float w, float k)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Dash10);
MonsterBlock(dl, x, y, w, k);

View file

@ -100,8 +100,14 @@ internal sealed partial class RynthAiFace
}
}
/// <summary>The Dungeon Patrol settings, hazard cells and saved routes (the Patrol launcher's right-click).</summary>
private sealed class PatrolDrawer : RynthAiDrawer
/// <summary>The size factor the static helpers (Px) draw at, for a drawer body drawn outside the face (SettingsDrawerBodies).</summary>
internal static void UseScale(float k) => _k = k;
/// <summary>
/// The Dungeon Patrol settings, hazard cells and saved routes (the Patrol launcher's right-click).
/// Internal: RynthAi's own dashboard window shows its body too (SettingsDrawerBodies).
/// </summary>
internal sealed class PatrolDrawer : RynthAiDrawer
{
private bool _sub;
// Settings > Navigation > Dungeon Patrol, drawn here too (2026-10-14).
@ -147,13 +153,24 @@ internal sealed partial class RynthAiFace
{
float y = PanelFrame(origin, panelW, panelH, k, PhosphorIcons.Footprints, "PATROL & ROUTES", null, "Hide the patrol drawer");
float x = origin.X + Pad * k;
DrawBody(x, y, panelW - 2 * Pad * k, MathF.Max(1, origin.Y + panelH - Pad * k - y), k);
}
/// <summary>
/// Start patrol, the settings and the lists in a <paramref name="w"/> x <paramref name="h"/> child at
/// (<paramref name="x"/>, <paramref name="y"/>) that scrolls. Returns what they took (pixels), for a
/// host that fits its height to them (RynthAi's own dashboard window, SettingsDrawerBodies).
/// </summary>
public float DrawBody(float x, float y, float w, float h, float 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));
Vector2 size = new(w, MathF.Max(1, h));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
bool open = ImGuiNET.ImGui.BeginChild("##patrol_body", size, ImGuiChildFlags.None, ImGuiWindowFlags.NoBackground);
ImGuiNET.ImGui.PopStyleVar();
float contentH = 200 * k;
try
{
if (open)
@ -165,7 +182,7 @@ internal sealed partial class RynthAiFace
// The settings, with the Settings panel's rows (right-click one to pin it to My settings).
Section("SETTINGS");
_rows.Sync();
float w = ImGuiNET.ImGui.GetContentRegionAvail().X - 2 * k;
float rw = ImGuiNET.ImGui.GetContentRegionAvail().X - 2 * k;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 0));
SettingRow[] rows = SettingRows;
@ -173,7 +190,7 @@ internal sealed partial class RynthAiFace
{
if (!rows[i].IsVisible(_rows.Data)) continue;
ImGuiNET.ImGui.PushID(i);
_rows.DrawRow(rows[i], w);
_rows.DrawRow(rows[i], rw);
ImGuiNET.ImGui.PopID();
}
ImGuiNET.ImGui.PopStyleVar();
@ -181,9 +198,11 @@ internal sealed partial class RynthAiFace
PatrolInfo info = UiSources.Patrol.Current?.Value ?? new PatrolInfo();
PatrolBody(info, withTitle: false);
contentH = ImGuiNET.ImGui.GetCursorPosY() + 2 * k; // content space: the scroll is in it
}
}
finally { ImGuiNET.ImGui.EndChild(); }
return contentH;
}
}

View file

@ -410,9 +410,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
if (ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem)
&& ImGuiNET.ImGui.IsMouseHoveringRect(new Vector2(x0, y), new Vector2(x0 + width, y + rowH), false))
{
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
if (io.KeyCtrl && io.MouseWheel != 0f)
PanelTextScale.SetForWindow(Title, PanelTextScale.Get(Title) + (io.MouseWheel > 0f ? 1 : -1));
// Ctrl+wheel: the panel host steps its size (over any panel).
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Right))
ImGuiNET.ImGui.OpenPopup(SizePopupId);
}

View file

@ -0,0 +1,112 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/SettingsDrawerBodies.cs
// The dashboard drawers that show Settings rows, drawn into RynthAi's own
// dashboard window (2026-10-21, plugin API v90 RenderSettingsDrawer). RynthAi
// draws its dashboard itself now, its drawers' tabs and frames included, but
// three drawers show the Settings panel's rows, and the Settings panel is still
// RynthCore's: until it moves to RynthAi, RynthAi's drawer windows ask for
// these bodies here (the frame and the title row are RynthAi's):
// ranges the selected monster and the key ranges (RangesSlideOut.cs)
// patrol Start patrol, the Dungeon Patrol settings, this dungeon's hazard
// cells, the recorded hazards and the saved routes (the Patrol
// drawer, RynthAiFace.Drawers.cs)
// pinned My settings, the rows the player pinned (QuickSettingsDrawer.cs)
// Each is the same drawer the engine's own dashboard shows, so a value changed
// here is saved the same way and a pin made here is the same pin. A drawer
// that wasn't drawn in a frame drops its hub subscriptions (EndFrame).
//
// AC thread only (inside RynthAi's window, and EndFrame after the panels).
// ============================================================================
using System;
using System.Numerics;
using RynthCore.Engine.UI;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal static class SettingsDrawerBodies
{
private static RangesSlideOut? _ranges;
private static RynthAiFace.PatrolDrawer? _patrol;
private static QuickSettingsDrawer? _pinned;
// The frame each was last drawn in (EndFrame counts frames).
private static long _frame, _rangesDrawn = -1, _patrolDrawn = -1, _pinnedDrawn = -1;
/// <summary>
/// Draws <paramref name="key"/>'s body at the cursor, <paramref name="width"/> pixels wide, in at most
/// <paramref name="room"/> pixels of height (0: as tall as it wants); <paramref name="openPicker"/>:
/// open My settings' list of settings to pin. Returns the height it wants (pixels), or -1 for a key
/// that isn't one of these.
/// </summary>
public static float Draw(string key, float width, float room, bool openPicker)
{
Vector2 at = ImGuiNET.ImGui.GetCursorScreenPos();
float w = MathF.Max(1, width);
float k = MathF.Max(1f, ImGuiFonts.Get(UiFont.Dash11).FontSize / 11f);
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
try
{
switch (key)
{
case "ranges":
{
_ranges ??= new RangesSlideOut();
_rangesDrawn = _frame;
_ranges.Update(true);
float h = RangesSlideOut.BodyHeight(k);
ImGuiNET.ImGui.PushID("##sdb_ranges");
try { _ranges.DrawBody(at.X, at.Y, w, k); }
finally { ImGuiNET.ImGui.PopID(); }
ImGuiNET.ImGui.SetCursorScreenPos(at);
ImGuiNET.ImGui.Dummy(new Vector2(w, h));
return h;
}
case "patrol":
{
_patrol ??= new RynthAiFace.PatrolDrawer();
_patrolDrawn = _frame;
_patrol.Update(true);
RynthAiFace.UseScale(k);
float h = room > 0 ? room : 400 * k;
float want;
ImGuiNET.ImGui.PushID("##sdb_patrol");
try { want = _patrol.DrawBody(at.X, at.Y, w, h, k); }
finally { ImGuiNET.ImGui.PopID(); }
ImGuiNET.ImGui.SetCursorScreenPos(at);
ImGuiNET.ImGui.Dummy(new Vector2(w, h));
return want;
}
case "pinned":
{
_pinned ??= new QuickSettingsDrawer();
_pinnedDrawn = _frame;
_pinned.Update(true);
float h = room > 0 ? room : 120 * k;
float want;
ImGuiNET.ImGui.PushID("##sdb_pinned");
try { want = _pinned.DrawBody(at.X, at.Y, w, h, k, openPicker); }
finally { ImGuiNET.ImGui.PopID(); }
ImGuiNET.ImGui.SetCursorScreenPos(at);
ImGuiNET.ImGui.Dummy(new Vector2(w, h));
return want;
}
default:
return -1f;
}
}
finally
{
ImGuiNET.ImGui.PopFont();
}
}
/// <summary>After the panels each frame: a body that wasn't drawn this frame lets its hub sources go.</summary>
public static void EndFrame()
{
if (_ranges != null && _rangesDrawn != _frame) _ranges.Update(false);
if (_patrol != null && _patrolDrawn != _frame) _patrol.Update(false);
if (_pinned != null && _pinnedDrawn != _frame) _pinned.Update(false);
_frame++;
}
}

View file

@ -416,7 +416,8 @@ internal sealed class SettingsRows
private void ComboRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
string[] items = row.Items!;
string[] items = row.CurrentItems;
if (items.Length == 0) return;
int current = Math.Clamp((int)row.Get!(_data), 0, items.Length - 1);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();