Snapshot for release 2026.10.15.1 (internal 4b7e805)

This commit is contained in:
Tom Bohar 2026-10-15 09:27:14 -04:00
commit 8bb1c3aa23
71 changed files with 5546 additions and 837 deletions

View file

@ -65,11 +65,14 @@ internal sealed class ChatFace : IImGuiPanel
new PanelSpec(new Vector2(460, 300), new Vector2(260, 140), Background: 0, EdgeToEdge: true, GripInBody: true),
() => new ChatFace());
private static readonly uint TabActive = RynthTheme.Argb(0xFF264C59), TabAdd = RynthTheme.Argb(0xFF7AE09A),
InputBg = RynthTheme.Argb(0xFF0A121A), InputBorder = RynthTheme.Argb(0xFF264C59), InputActive = RynthTheme.Argb(0xFFFFD700),
SelBg = RynthTheme.Argb(0x663A6EA5), FlashBg = RynthTheme.Argb(0xE0264C59), TellBg = RynthTheme.Argb(0xFF0E2E3A),
private static readonly uint TabAdd = RynthTheme.Argb(0xFF7AE09A), InputActive = RynthTheme.Argb(0xFFFFD700),
SelBg = RynthTheme.Argb(0x663A6EA5), TellBg = RynthTheme.Argb(0xFF0E2E3A),
TsColor = RynthTheme.Argb(0xFF6F8397), MentionBg = RynthTheme.Argb(0x33FFC857),
BadgeBg = RynthTheme.Argb(0xFF1F6F7A), BadgeMention = RynthTheme.Argb(0xFFB8860B);
private static uint TabActive => RynthTheme.AccentFill;
private static uint InputBg => RynthTheme.BoxBg;
private static uint InputBorder => RynthTheme.AccentFill;
private static uint FlashBg => RynthTheme.WithAlpha(RynthTheme.AccentFill, 0xE0);
private const float StickThreshold = 24f;
// Visible lines for the current tab + search, with wrapped heights; _lay

View file

@ -37,8 +37,8 @@ internal sealed class ChatFiltersFace : IImGuiPanel
new PanelSpec(new Vector2(600, 460), new Vector2(440, 260), EdgeToEdge: true, GripInBody: true),
() => new ChatFiltersFace());
private static readonly uint AddBg = RynthTheme.Argb(0xFF264C59), CardBg = RynthTheme.Argb(0xFF0E1822),
FocusBorder = RynthTheme.Argb(0xFFFFD700);
private static readonly uint CardBg = RynthTheme.Argb(0xFF0E1822), FocusBorder = RynthTheme.Argb(0xFFFFD700);
private static uint AddBg => RynthTheme.AccentFill;
private sealed class Buffers
{

View file

@ -57,10 +57,15 @@ internal sealed class DamageDetailFace : IImGuiPanel
}
private static uint C(uint argb) => RynthTheme.Argb(argb);
private static readonly uint Teal = C(0xFF26D9E6), Gold = C(0xFFFFD16A), Dim = C(0xFFC8D4E0), White = C(0xFFF2F7FC),
EntryBg = C(0xFF16283A), EntryBorder = C(0xFF34587A), ToggleOn = C(0xFF33CC66), ToggleOff = C(0xFF4D4D4D),
BarBg = C(0xFF16222E), Good = C(0xFF33CC66), Mid = C(0xFFE8B333), Bad = C(0xFFE05A5A), DeleteBg = C(0xFF6E1E1E),
private static readonly uint Gold = C(0xFFFFD16A), ToggleOn = C(0xFF33CC66), ToggleOff = C(0xFF4D4D4D),
BarBg = C(0xFF16222E), Good = C(0xFF33CC66), Bad = C(0xFFE05A5A), DeleteBg = C(0xFF6E1E1E),
DeleteBorder = C(0xFFFF8A8A);
private static uint Teal => RynthTheme.Accent;
private static uint Dim => RynthTheme.MuteAlt;
private static uint White => RynthTheme.Text;
private static uint EntryBg => RynthTheme.Button;
private static uint EntryBorder => RynthTheme.Border;
private static uint Mid => RynthTheme.Highlight;
private MonsterDetail? _detail;
private long _seenVersion = -1, _seenRulesVersion = -1;

View file

@ -45,11 +45,17 @@ internal sealed class DamageFace : IImGuiPanel
() => new DamageFace());
// ── Palette (MonsterDamagePanel's, a little brighter) ───────────────
private static readonly uint Teal = C(0xFF26D9E6), Gold = C(0xFFFFD16A), Dim = C(0xFFC8D4E0),
White = C(0xFFF2F7FC), HeaderBg = C(0xFF121C26), PanelBg = C(0xF0081018), RowBg = C(0x40203040),
PickerBg = C(0xFF0A141E), PickSel = C(0xFF1A2E42), EntryBg = C(0xFF16283A), EntryBorder = C(0xFF34587A),
SearchBg = C(0xFF16222E), ToggleOn = C(0xFF33CC66), ToggleOff = C(0xFF4D4D4D), DeleteRed = C(0xFFFF8A8A),
FilterBg = C(0xFF203A52), TargetBg = C(0x5026D9E6), NearbyBg = C(0x3833CC66), NearbyBar = C(0xFF33CC66), ResetBg = C(0xFF5A2020), ResetBorder = C(0xFFFF8A8A), ClearBg = C(0xFF6E1E1E);
private static readonly uint Gold = C(0xFFFFD16A), HeaderBg = C(0xFF121C26), PanelBg = C(0xF0081018),
RowBg = C(0x40203040), PickerBg = C(0xFF0A141E), SearchBg = C(0xFF16222E), ToggleOn = C(0xFF33CC66),
ToggleOff = C(0xFF4D4D4D), DeleteRed = C(0xFFFF8A8A), FilterBg = C(0xFF203A52), NearbyBg = C(0x3833CC66),
NearbyBar = C(0xFF33CC66), ResetBg = C(0xFF5A2020), ResetBorder = C(0xFFFF8A8A), ClearBg = C(0xFF6E1E1E);
private static uint Teal => RynthTheme.Accent;
private static uint Dim => RynthTheme.MuteAlt;
private static uint White => RynthTheme.Text;
private static uint PickSel => RynthTheme.Selected;
private static uint EntryBg => RynthTheme.Button;
private static uint EntryBorder => RynthTheme.Border;
private static uint TargetBg => RynthTheme.WithAlpha(RynthTheme.Accent, 0x50);
private static uint C(uint argb) => RynthTheme.Argb(argb);
// Column widths (the Avalonia grid's) and their left edges.
@ -521,7 +527,7 @@ internal sealed class DamageFace : IImGuiPanel
if (all == null || count == 0)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 3));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), all == null
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), all == null
? " Monster rules not loaded yet." : " No name rules yet: add one below.");
}
else
@ -708,7 +714,7 @@ internal sealed class DamageFace : IImGuiPanel
bool filtering = _filterWid != 0 || _searchText.Length > 0;
bool anyData = _view.Rows.Exists(r => !r.IsDefault);
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), anyData && filtering
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), anyData && filtering
? " No monsters match the current filter."
: " No monsters yet: fight some and they show up here.");
}
@ -1006,16 +1012,16 @@ internal sealed class DamageFace : IImGuiPanel
Rule? view = RuleFor(name, out bool custom);
bool isDefault = name.Equals("Default", StringComparison.OrdinalIgnoreCase);
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), "Debuffs · " + name);
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), "Debuffs · " + name);
ImGuiNET.ImGui.PopFont();
if (view == null)
{
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), "Monster rules not loaded yet.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Monster rules not loaded yet.");
ImGuiNET.ImGui.EndPopup();
return;
}
ImGuiNET.ImGui.PushTextWrapPos(0);
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(custom || isDefault ? 0xFFFFD16A : 0xFFC8D4E0),
ImGuiNET.ImGui.TextColored((custom || isDefault ? RynthTheme.Vec(0xFFFFD16A) : RynthTheme.VecOf(RynthTheme.MuteAlt)),
isDefault ? "Every monster set to Default uses these." : custom ? "This monster's own debuffs." : "Following Default: a change here gives it its own.");
ImGuiNET.ImGui.PopTextWrapPos();
@ -1031,7 +1037,7 @@ internal sealed class DamageFace : IImGuiPanel
ImGuiNET.ImGui.SetItemTooltip(tip);
}
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), "Extra Vuln");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Extra Vuln");
ImGuiNET.ImGui.SameLine();
string ex = string.IsNullOrEmpty(view.ExVuln) ? "None" : view.ExVuln;
ImGuiNET.ImGui.SetNextItemWidth(ImGuiNET.ImGui.CalcTextSize("Lightning").X + 40);
@ -1048,7 +1054,7 @@ internal sealed class DamageFace : IImGuiPanel
ImGuiNET.ImGui.SetItemTooltip("A vulnerability of another element, on top of Vuln (which follows the attack's element).");
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), "Your own (comma separated):");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Your own (comma separated):");
ImGuiNET.ImGui.SetNextItemWidth(-1);
bool enter = ImGuiNET.ImGui.InputText("##db_custom", _customBuf, (uint)_customBuf.Length, ImGuiInputTextFlags.EnterReturnsTrue);
if (enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
@ -1316,9 +1322,9 @@ internal sealed class DamageFace : IImGuiPanel
if (ropen)
{
ImGuiNET.ImGui.PushTextWrapPos(0);
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), "Remove " + _removeName + "?");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), "Remove " + _removeName + "?");
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC),
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text),
"Its learned numbers and your settings for it (weapon, offhand, pet, HP) are deleted. It comes back if you meet it again.");
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
@ -1354,9 +1360,9 @@ internal sealed class DamageFace : IImGuiPanel
if (open)
{
ImGuiNET.ImGui.PushTextWrapPos(0);
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), "Reset ALL learned damage statistics?");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), "Reset ALL learned damage statistics?");
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC),
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text),
"Monster names and your settings (manual HP, weapon/offhand picks, debuffs) are KEPT — only the learned damage, crit, casts-to-kill, kills and HP are cleared. This cannot be undone.");
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));

View file

@ -1,25 +1,36 @@
// ============================================================================
// 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 RynthAi dashboard's slide-out drawers (Tom 2026-10-05: drawers on the
// dashboard's edges; only the vitals / target bars stay at its bottom). One
// tab per drawer, stacked down the dashboard's left or right edge; a click
// slides that drawer's panel out on its tab's side. One drawer is open per
// side, so a left and a right drawer can be out together.
//
// 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,
// Patrol and Mini Remote (RynthAiFace.Drawers.cs).
// Sides (2026-10-14): each drawer starts on a side (StartsRight) and a
// dashboard drawer can be moved to the other one from its tab's right-click
// (saved with the dashboard's state). The tabs never switch sides on their
// own any more; a panel with no room on its side stays on the screen over
// the dashboard instead.
//
// 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).
// The look: a closed tab is a button with its drawer's icon that peeks out a
// little on hover; the open tab joins its panel (same background, a teal
// edge, an accent bar against the dashboard), and the panel has a teal
// outline. Panels slide out with an ease-out.
//
// The mechanics live here (tabs, slide, side, placement, the windows); each
// drawer only draws its panel (DashboardDrawer.DrawPanel) and says how big it
// is. Drawers today: Ranges (RangesSlideOut.cs), Loaded files, Patrol, Mini
// Remote (RynthAiFace.Drawers.cs) and My settings (QuickSettingsDrawer.cs);
// RynthChat's Channels (ChatFace.cs) uses the same host.
//
// One top-level ImGui window per side, begun from inside the dashboard's Draw
// and placed against the dashboard's window every frame, so the drawers
// follow the dashboard (and go 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).
// ============================================================================
@ -31,7 +42,7 @@ 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>
/// <summary>One drawer on the dashboard's 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>
@ -43,7 +54,7 @@ internal abstract class DashboardDrawer
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>
/// <summary>The closed tab's tooltip; <paramref name="right"/>: the drawer is on the right.</summary>
public abstract string TabTooltip(bool right);
/// <summary>Panel size in pixels at text scale <paramref name="k"/>.</summary>
@ -60,10 +71,22 @@ internal abstract class DashboardDrawer
public abstract bool SavedOpen { get; }
public abstract void SaveOpen(bool open);
private string? _tabId, _hideTip;
/// <summary>The side the drawer starts on (false: left).</summary>
public virtual bool StartsRight => false;
/// <summary>The tab's right-click can move it to the other side (and the move is saved).</summary>
public virtual bool CanMove => false;
/// <summary>Moved to the side it doesn't start on.</summary>
public virtual bool Moved => false;
public virtual void SaveMoved(bool moved) { }
/// <summary>The side it is on now.</summary>
public bool OnRight => StartsRight != Moved;
private string? _tabId, _hideTip, _sideMenuId;
/// <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 + ".";
internal string SideMenuId => _sideMenuId ??= "##drawer_side_" + Key;
protected void Close() => Host?.Close(this);
@ -77,8 +100,11 @@ internal abstract class DashboardDrawer
// ── 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 static uint DTeal => RynthTheme.Accent;
protected static uint DMute => RynthTheme.TextMuted;
protected static uint DWhite => RynthTheme.Text;
protected static uint DBtnFill => RynthTheme.Button;
protected static uint DBtnBord => RynthTheme.Border;
protected const float Pad = 6, TitleH = 18;
/// <summary>Paints the panel's background and title row; returns the y under the title (pixels).</summary>
@ -86,7 +112,7 @@ internal abstract class DashboardDrawer
{
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);
dl.AddRect(origin, origin + new Vector2(panelW, panelH), DTeal, 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);
@ -108,19 +134,37 @@ internal abstract class DashboardDrawer
}
}
/// <summary>The tabs and the one open drawer beside the RynthAi dashboard.</summary>
/// <summary>A RynthAi dashboard drawer: movable to the other side, the side saved with the dashboard's state.</summary>
internal abstract class RynthAiDrawer : DashboardDrawer
{
public override bool CanMove => true;
public override bool Moved => RynthAiDashboardState.DrawerMoved(Key);
public override void SaveMoved(bool moved) => RynthAiDashboardState.SetDrawerMoved(Key, moved);
}
/// <summary>The tabs and the open drawers beside the RynthAi dashboard (one open per side).</summary>
internal sealed class DashboardDrawers
{
private readonly string WindowId; // "##rynthai_drawers" for the dashboard; the chat has its own
private const float SlideSeconds = 0.14f;
private readonly string[] _windowIds; // left, right ("##rynthai_drawers" for the dashboard; the chat has its own)
private const float SlideSeconds = 0.16f;
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 static uint Teal => RynthTheme.Accent;
private static uint Mute => RynthTheme.TextMuted;
private static uint White => RynthTheme.Text;
private static uint BtnFill => RynthTheme.Button;
private static uint BtnBord => RynthTheme.Border;
private static uint ShellBg => RynthTheme.Background;
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
/// <summary>One edge's drawers: which is open, which draws, how far it has slid.</summary>
private sealed class Side
{
public int Open = -1; // the drawer open (or opening); -1 none
public int Shown = -1; // the drawer whose panel draws (a closing one until it has slid in)
public float T; // slide position of Shown, 0 closed .. 1 open
}
private readonly Side[] _sides = { new(), new() };
private bool _loaded;
public DashboardDrawers(params DashboardDrawer[] drawers) : this("##rynthai_drawers", drawers) { }
@ -128,14 +172,20 @@ internal sealed class DashboardDrawers
/// <summary>A drawer set beside another panel (RynthChat's channels): its own window id.</summary>
public DashboardDrawers(string windowId, params DashboardDrawer[] drawers)
{
WindowId = windowId;
_windowIds = new[] { windowId, windowId + "_right" };
_drawers = drawers;
foreach (DashboardDrawer d in drawers) d.Host = this;
}
public bool IsOpen(DashboardDrawer d) => _open >= 0 && _drawers[_open] == d;
private Side SideOf(DashboardDrawer d) => _sides[d.OnRight ? 1 : 0];
/// <summary>Opens <paramref name="d"/> (closing the open one), or closes it when it is the open one.</summary>
public bool IsOpen(DashboardDrawer d)
{
Side s = SideOf(d);
return s.Open >= 0 && _drawers[s.Open] == d;
}
/// <summary>Opens <paramref name="d"/> (closing the one open on its side), or closes it when it is open.</summary>
public void Toggle(DashboardDrawer d)
{
if (IsOpen(d)) Close(d);
@ -146,25 +196,41 @@ internal sealed class DashboardDrawers
{
EnsureLoaded();
int i = Array.IndexOf(_drawers, d);
if (i < 0 || i == _open) return;
if (_open >= 0) _drawers[_open].SaveOpen(false);
_open = i;
Side s = SideOf(d);
if (i < 0 || i == s.Open) return;
if (s.Open >= 0) _drawers[s.Open].SaveOpen(false);
s.Open = i;
d.SaveOpen(true);
if (_shown != i)
if (s.Shown != i)
{
// Another drawer was out (or sliding in): this one slides out from closed.
_shown = i;
_t = 0f;
// Another drawer was out on this side (or sliding in): this one slides out from closed.
s.Shown = i;
s.T = 0f;
}
}
public void Close(DashboardDrawer d)
{
if (!IsOpen(d)) return;
_open = -1;
SideOf(d).Open = -1;
d.SaveOpen(false);
}
/// <summary>Moves <paramref name="d"/> to the other side; an open drawer opens again there.</summary>
public void Move(DashboardDrawer d)
{
if (!d.CanMove) return;
EnsureLoaded();
bool wasOpen = IsOpen(d);
int i = Array.IndexOf(_drawers, d);
Side from = SideOf(d);
if (wasOpen) from.Open = -1;
if (from.Shown == i) { from.Shown = -1; from.T = 0f; }
d.Update(false);
d.SaveMoved(!d.Moved);
if (wasOpen) { d.SaveOpen(false); Open(d); }
}
/// <summary>The dashboard closed: every drawer drops its subscriptions. AC thread.</summary>
public void Detach()
{
@ -175,19 +241,18 @@ internal sealed class DashboardDrawers
{
if (_loaded) return;
_loaded = true;
// The first drawer saved open wins (one at a time); any other saved open is closed.
// The first drawer saved open on each side wins (one per side); any other saved open is closed.
for (int i = 0; i < _drawers.Length; i++)
{
if (!_drawers[i].SavedOpen) continue;
if (_open < 0) _open = i;
Side s = SideOf(_drawers[i]);
if (s.Open < 0) { s.Open = i; s.Shown = i; s.T = 1f; }
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
/// Draws the tabs and the open drawers. 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()
@ -200,42 +265,51 @@ internal sealed class DashboardDrawers
}
EnsureLoaded();
Vector2 dashPos = ImGuiNET.ImGui.GetWindowPos(), dashSize = ImGuiNET.ImGui.GetWindowSize();
float k = MathF.Max(1f, ImGuiFonts.Get(UiFont.Dash11).FontSize / 11f);
DrawSide(0, dashPos, dashSize, k);
DrawSide(1, dashPos, dashSize, k);
}
private void DrawSide(int sideIdx, Vector2 dashPos, Vector2 dashSize, float k)
{
bool right = sideIdx == 1;
Side side = _sides[sideIdx];
int n = 0;
foreach (DashboardDrawer d in _drawers) if (d.OnRight == right) n++;
if (n == 0) { side.Open = side.Shown = -1; return; }
// Slide.
float target = _open >= 0 && _open == _shown ? 1f : 0f;
if (_t != target)
float target = side.Open >= 0 && side.Open == side.Shown ? 1f : 0f;
if (side.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);
side.T = target > side.T ? MathF.Min(1f, side.T + step) : MathF.Max(0f, side.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);
if (side.T <= 0f && side.Open < 0) side.Shown = -1;
float u = 1f - side.T;
float ease = 1f - u * u * u; // ease-out: quick to start, settling at the end
bool showing = side.Shown >= 0 && ease > 0.001f;
for (int i = 0; i < _drawers.Length; i++)
if (_drawers[i].OnRight == right) _drawers[i].Update(showing && i == side.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;
float tabW = 17 * k, tabGap = 3 * k, tabTop = 4 * k, peek = 3 * 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 tabH = MathF.Max(20 * k, MathF.Min(40 * k, (dashSize.Y - 2 * tabTop - (n - 1) * tabGap) / 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 panelW = showing ? _drawers[side.Shown].Width(k) : 0;
float panelH = showing ? _drawers[side.Shown].Height(k) : 0;
float shown = showing ? panelW * ease : 0;
float outer = MathF.Max(shown, peek); // room beyond the tabs: the panel, or a hovered tab's peek
float winX = right ? dashRight : dashPos.X - tabW - shown;
float winW = tabW + shown;
float dashRight = dashPos.X + dashSize.X;
float tabX = right ? dashRight : dashPos.X - tabW;
// Neither side has room (a very wide dashboard): keep it on the screen, over the dashboard.
float winX = right ? tabX : tabX - outer;
float winW = tabW + outer;
// No room on this side (the dashboard against the screen's edge): stay 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);
@ -255,36 +329,40 @@ internal sealed class DashboardDrawers
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);
bool visible = ImGuiNET.ImGui.Begin(_windowIds[sideIdx], WindowFlags);
ImGuiNET.ImGui.PopStyleVar(4);
try
{
if (visible)
if (!visible) return;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
try
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
try
if (showing)
{
if (showing)
// The panel's visible part; its content slides with the open edge.
float visX0 = right ? tabX + tabW : tabX - shown;
float contentX = right ? tabX + tabW + shown - panelW : tabX - shown;
Vector2 vMin = new(visX0, winY), vMax = new(visX0 + shown, winY + panelH);
DashboardDrawer d = _drawers[side.Shown];
ImGuiNET.ImGui.PushClipRect(vMin, vMax, true);
ImGuiNET.ImGui.PushID(d.Key);
try { d.DrawPanel(new Vector2(contentX, winY), panelW, panelH, k); }
finally
{
// 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();
}
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(); }
int slot = 0;
for (int i = 0; i < _drawers.Length; i++)
{
if (_drawers[i].OnRight != right) continue;
DrawTab(_drawers[i], new Vector2(tabX, tabY + slot * (tabH + tabGap)), new Vector2(tabW, tabH), right,
joined: showing && i == side.Shown && side.Open == i, canPeek: !showing, k);
slot++;
}
}
finally { ImGuiNET.ImGui.PopFont(); }
}
finally
{
@ -297,27 +375,66 @@ internal sealed class DashboardDrawers
| 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)
/// <param name="joined">The open drawer's tab, drawn as part of its panel.</param>
/// <param name="canPeek">No panel is out on this side, so a hovered tab may peek out.</param>
private void DrawTab(DashboardDrawer d, Vector2 pos, Vector2 size, bool right, bool joined, bool canPeek, float k)
{
bool open = IsOpen(d);
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.SetCursorScreenPos(pos);
bool clicked = ImGuiNET.ImGui.InvisibleButton(d.TabId, size);
bool clicked = ImGuiNET.ImGui.InvisibleButton(d.TabId, size, ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight)
&& ImGuiNET.ImGui.IsMouseReleased(ImGuiMouseButton.Left);
bool hot = ImGuiNET.ImGui.IsItemHovered();
bool rightClicked = d.CanMove && ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right);
// 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));
ImGuiNET.ImGui.SetTooltip(open ? d.HideTip : d.TabTooltip(right) + (d.CanMove ? MoveHint : ""));
if (clicked) Toggle(d);
if (rightClicked) ImGuiNET.ImGui.OpenPopup(d.SideMenuId);
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);
float edge = 2 * k; // the accent bar against the dashboard
if (joined)
{
// Part of the panel: its background, reaching over the panel's edge so there's no seam,
// a teal outline on the three other sides and an accent bar against the dashboard.
float over = 1.5f * k;
Vector2 a = right ? pos : pos - new Vector2(over, 0), b = right ? pos + size + new Vector2(over, 0) : pos + size;
dl.AddRectFilled(a, b, RynthTheme.RynthAiBackground);
float inner = right ? pos.X : pos.X + size.X;
float outerX = right ? pos.X + size.X + over : pos.X - over;
dl.AddLine(new Vector2(inner, pos.Y), new Vector2(outerX, pos.Y), Teal);
dl.AddLine(new Vector2(inner, pos.Y + size.Y - 1), new Vector2(outerX, pos.Y + size.Y - 1), Teal);
dl.AddRectFilled(new Vector2(right ? inner : inner - edge, pos.Y), new Vector2(right ? inner + edge : inner, pos.Y + size.Y), Teal);
PhosphorIcons.DrawCentered(dl, f10, d.Icon, pos, size, Teal);
}
else
{
// A hovered tab peeks out a little, as if it pulls.
float peek = canPeek && hot ? 2 * k : 0;
Vector2 p = pos + new Vector2(right ? peek : -peek, 0);
uint fill = ImGuiNET.ImGui.IsItemActive() ? FaceKit.Darken(BtnFill) : hot ? FaceKit.Lighten(BtnFill) : BtnFill;
ImDrawFlags corners = right ? ImDrawFlags.RoundCornersRight : ImDrawFlags.RoundCornersLeft;
dl.AddRectFilled(p, p + size, fill, 4 * k, corners);
dl.AddRect(p, p + size, open ? Teal : BtnBord, 4 * k, corners);
PhosphorIcons.DrawCentered(dl, f10, d.Icon, p, size, open ? Teal : hot ? White : Mute);
}
// Right-click: move the drawer to the other side.
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8 * k, 6 * k));
bool menu = ImGuiNET.ImGui.BeginPopup(d.SideMenuId);
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.PopStyleColor(2);
if (!menu) return;
try
{
if (ImGuiNET.ImGui.MenuItem(right ? PhosphorIcons.CaretLeft + " Move to the left side" : PhosphorIcons.CaretRight + " Move to the right side"))
Move(d);
}
finally { ImGuiNET.ImGui.EndPopup(); }
}
private const string MoveHint = "\nRight-click: move it to the other side of the dashboard.";
}

View file

@ -72,12 +72,13 @@ internal sealed class DungeonMapFace : IImGuiPanel
// ── Palette (the plugin map's colours, ARGB) ──────────────────────────
private const uint CanvasBgArgb = 0xFF0A121F, ToolbarBgArgb = 0xE00A121A;
private static readonly uint CanvasBorder = C(0xFF334D66), Wall = C(0xFF8CCCFF),
PlayerCol = C(0xFF33FF66), Portal = C(0xFFE673FF), PortalRing = C(0xB3FFBFFF), PortalLabel = C(0xFFFFE0FF),
Door = C(0xFFBF8C40), DoorRing = C(0xB3E6BF80), DoorLabel = C(0xFFF2D9A6),
Monster = C(0xFFFF4033), MonsterRing = C(0xB3FF8C80), Npc = C(0xFFFFD933), NpcRing = C(0xB3FFF28C),
CreatureLabel = C(0xFFFFE6E6), Hint = C(0xFF8FA3B8), ButtonBg = C(0xC0141F29), ButtonBorder = C(0xFF34587A),
private static readonly uint CanvasBorder = C(0xFF334D66), Wall = C(0xFF8CCCFF), PlayerCol = C(0xFF33FF66),
Portal = C(0xFFE673FF), PortalRing = C(0xB3FFBFFF), PortalLabel = C(0xFFFFE0FF), Door = C(0xFFBF8C40),
DoorRing = C(0xB3E6BF80), DoorLabel = C(0xFFF2D9A6), Monster = C(0xFFFF4033), MonsterRing = C(0xB3FF8C80),
Npc = C(0xFFFFD933), NpcRing = C(0xB3FFF28C), CreatureLabel = C(0xFFFFE6E6), Hint = C(0xFF8FA3B8),
FloorOn = C(0xFF2673B3), FloorHere = C(0xFF1AA64D);
private static uint ButtonBg => RynthTheme.WithAlpha(RynthTheme.Field, 0xC0);
private static uint ButtonBorder => RynthTheme.Border;
private const uint FillFlat = 0x662E8C38, FillUp = 0x668C1F14, FillDown = 0x661A8026, FillVisited = 0xB84D6B94;
// Route (ARGB, alpha scaled per floor).
private const uint RouteLegArgb = 0xD9FFA733, RoutePointArgb = 0xFFFFC266, RouteActiveArgb = 0xFFFFF04D,

View file

@ -20,10 +20,18 @@ internal static class FaceKit
{
private static uint C(uint argb) => RynthTheme.Argb(argb);
public static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Green = C(0xFF33CC66),
Red = C(0xFFE05A5A), Mute = C(0xFFC8D6E4), Text = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14),
PanelBg = C(0xFF141F29), RowAlt = C(0xFF101822), BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A),
Selected = C(0xFF1A2E42), StartBg = C(0xFF196119), StopBg = C(0xFF801919), DeleteBg = C(0xFF801A1A);
public static readonly uint Green = C(0xFF33CC66), Red = C(0xFFE05A5A), StartBg = C(0xFF196119),
StopBg = C(0xFF801919), DeleteBg = C(0xFF801A1A);
public static uint Teal => RynthTheme.Accent;
public static uint Amber => RynthTheme.Highlight;
public static uint Mute => RynthTheme.MuteAlt;
public static uint Text => RynthTheme.Text;
public static uint ShellBg => RynthTheme.Background;
public static uint PanelBg => RynthTheme.Field;
public static uint RowAlt => RynthTheme.RowAlt;
public static uint BtnFill => RynthTheme.Button;
public static uint BtnBord => RynthTheme.Border;
public static uint Selected => RynthTheme.Selected;
// ── Frame ────────────────────────────────────────────────────────────

View file

@ -26,10 +26,16 @@ internal sealed class HotkeysSettingsUi
{
public const string TabName = "Hotkeys";
private static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Mute = C(0xFFB8C8D8),
TextDim = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14), PanelBg = C(0xFF141F29), BtnFill = C(0xFF16283A),
BtnBord = C(0xFF34587A), ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455), TabActive = C(0xFF1A2E42),
Warn = C(0xFFFFB347);
private static readonly uint ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455), Warn = C(0xFFFFB347);
private static uint Teal => RynthTheme.Accent;
private static uint Amber => RynthTheme.Highlight;
private static uint Mute => RynthTheme.TextMuted;
private static uint TextDim => RynthTheme.Text;
private static uint ShellBg => RynthTheme.Background;
private static uint PanelBg => RynthTheme.Field;
private static uint BtnFill => RynthTheme.Button;
private static uint BtnBord => RynthTheme.Border;
private static uint TabActive => RynthTheme.Selected;
private static uint C(uint argb) => RynthTheme.Argb(argb);
private const string ChatCommandItem = "Chat command...";

View file

@ -58,9 +58,11 @@ internal sealed partial class InventoryFace : IImGuiPanel
private const float Cell = 38, Icon = 32, RowH = 24, PackRowH = 38, ZoneH = 30, StatusH = 20;
private const uint AllPacks = 0, WornPacks = 1; // pseudo pack ids (real ids are never 0 or 1)
private static readonly uint CellBg = RynthTheme.Argb(0xFF101822), CellHot = RynthTheme.Argb(0xFF1C3148),
CellSel = RynthTheme.Argb(0xFF26D9E6), StackCol = RynthTheme.Argb(0xFFFFFFFF), StackShadow = RynthTheme.Argb(0xE0000000),
DropHot = RynthTheme.Argb(0xFF1F5A3A), Placeholder = RynthTheme.Argb(0xFF1A2633);
private static readonly uint CellHot = RynthTheme.Argb(0xFF1C3148), StackCol = RynthTheme.Argb(0xFFFFFFFF),
StackShadow = RynthTheme.Argb(0xE0000000), DropHot = RynthTheme.Argb(0xFF1F5A3A),
Placeholder = RynthTheme.Argb(0xFF1A2633);
private static uint CellBg => RynthTheme.RowAlt;
private static uint CellSel => RynthTheme.Accent;
private static readonly string[] SortNames = { "Pack order", "Name", "Value", "Burden", "Type", "Stack" };
private static readonly string[] SortLabels = Array.ConvertAll(SortNames, n => PhosphorIcons.SortAscending + " " + n);

View file

@ -555,7 +555,7 @@ internal sealed class LuaFace : IImGuiPanel
ImGuiNET.ImGui.PushTextWrapPos(0);
string text = _data?.Console ?? string.Empty;
if (text.Length > 0) ImGuiNET.ImGui.TextUnformatted(text);
if (_note.Length > 0) ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFE8B333), "[panel] " + _note);
if (_note.Length > 0) ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Highlight), "[panel] " + _note);
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.PopFont();

View file

@ -0,0 +1,78 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/MapProjection.cs
// The World Map's geometry, with no ImGui in it (tools\WorldMapTilesTests checks it offline):
// map cells (x east, y north, one cell = 24 yards) to screen pixels and back, through the view
// centre, the zoom (pixels per cell) and a rotation.
//
// screen = centre + R(phi) * (dx * scale, -dy * scale), dx, dy = cell - view centre cell
// R(phi) = [cos -sin; sin cos] on a y-down screen (so a positive phi turns the map clockwise)
//
// Rotating with the player: heading is in degrees, 0 = east, 90 = north (AC), so the heading
// direction is (cos h, sin h) in the map; phi = heading - 90 degrees turns it to straight up.
// ============================================================================
using System;
using System.Numerics;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal readonly struct MapProjection
{
public readonly Vector2 Centre; // screen position of the view centre cell
public readonly double CentreX, CentreY; // the view centre, in cells
public readonly float Scale; // screen pixels per cell
public readonly float Cos, Sin; // of the rotation
public MapProjection(Vector2 centre, double centreX, double centreY, float scale, float phi)
{
Centre = centre; CentreX = centreX; CentreY = centreY; Scale = scale;
Cos = MathF.Cos(phi); Sin = MathF.Sin(phi);
}
public bool Turned => Sin != 0f;
/// <summary>The rotation that turns the way you face to up, for a heading in degrees (0 = east, 90 = north).</summary>
public static float PhiForHeading(float headingDegrees) => (headingDegrees - 90f) * MathF.PI / 180f;
public Vector2 Project(double cellX, double cellY)
{
float sx = (float)((cellX - CentreX) * Scale), sy = (float)(-(cellY - CentreY) * Scale);
return new Vector2(Centre.X + sx * Cos - sy * Sin, Centre.Y + sx * Sin + sy * Cos);
}
public void Unproject(Vector2 p, out double cellX, out double cellY) => Unproject(p, Scale, out cellX, out cellY);
public void Unproject(Vector2 p, float scale, out double cellX, out double cellY)
{
Vector2 d = p - Centre;
float ux = d.X * Cos + d.Y * Sin, uy = -d.X * Sin + d.Y * Cos;
cellX = CentreX + ux / scale;
cellY = CentreY - uy / scale;
}
/// <summary>A map direction (east, north) as a screen direction.</summary>
public Vector2 ScreenDir(float east, float north)
{
float sx = east, sy = -north;
return new Vector2(sx * Cos - sy * Sin, sx * Sin + sy * Cos);
}
/// <summary>
/// The view centre (cells) that keeps the cell under <paramref name="screenPoint"/> where it is
/// when the zoom changes from this projection's scale to <paramref name="newScale"/>.
/// </summary>
public (double X, double Y) CentreForZoomAbout(Vector2 screenPoint, float newScale)
{
Unproject(screenPoint, out double mx, out double my);
Vector2 d = screenPoint - Centre;
float ux = d.X * Cos + d.Y * Sin, uy = -d.X * Sin + d.Y * Cos;
return (mx - ux / newScale, my + uy / newScale);
}
/// <summary>The view centre (cells) after dragging the map by <paramref name="screenDelta"/> pixels.</summary>
public (double X, double Y) CentreAfterDrag(Vector2 screenDelta)
{
float ux = screenDelta.X * Cos + screenDelta.Y * Sin, uy = -screenDelta.X * Sin + screenDelta.Y * Cos;
return (CentreX - ux / Scale, CentreY + uy / Scale);
}
}

View file

@ -861,7 +861,7 @@ internal sealed partial class MetaFace
private static void Note(string text)
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), text);
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), text);
ImGuiNET.ImGui.PopFont();
}

View file

@ -61,10 +61,11 @@ namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed partial class MetaFace
{
// ── Rule text colours (MetaTone) and list lines ──────────────────────
private static readonly uint ToneLabel = C(0xFF8FA9C2), ToneCode = C(0xFF9CC8FF), ToneJoin = C(0xFF4FC3CF),
RowLine = C(0x7034587A), ColLine = C(0x5834587A), GuideLine = C(0x6034587A), CurrentHdr = C(0xFF0D2B36),
// Every other rule a clearly different shade (Tom, 2026-10-11: the old pair was hard to tell apart).
private static readonly uint ToneLabel = C(0xFF8FA9C2), ToneCode = C(0xFF9CC8FF), ToneJoin = C(0xFF4FC3CF), CurrentHdr = C(0xFF0D2B36), // Every other rule a clearly different shade (Tom, 2026-10-11: the old pair was hard to tell apart).
StripeA = C(0xFF121B25), StripeB = C(0xFF1C2B3A);
private static uint RowLine => RynthTheme.WithAlpha(RynthTheme.Border, 0x70);
private static uint ColLine => RynthTheme.WithAlpha(RynthTheme.Border, 0x58);
private static uint GuideLine => RynthTheme.WithAlpha(RynthTheme.Border, 0x60);
private static uint ToneColor(MetaTone tone) => tone switch
{
@ -310,7 +311,7 @@ internal sealed partial class MetaFace
if (_groups.Count == 0)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " No rules. Click New Rule to add one.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " No rules. Click New Rule to add one.");
return;
}

View file

@ -56,7 +56,7 @@ internal sealed partial class MetaFace
Separator(w);
if (sc == null)
{
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " This RynthAi has no Meta Manager (update RynthAi).");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " This RynthAi has no Meta Manager (update RynthAi).");
return;
}
@ -183,9 +183,9 @@ internal sealed partial class MetaFace
: sc.LastPollMs == 0 ? "Waiting for the first /myquests."
: $"{sc.QuestCount} quest timer(s), /myquests {Span(now - sc.LastPollMs)} ago.";
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(sc.ServerDisabled ? 0xFFE8B333 : 0xFFC8D6E4), Fit(poll, w));
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(sc.ServerDisabled ? RynthTheme.Highlight : RynthTheme.MuteAlt), Fit(poll, w));
if (sc.LastSwitch.Length > 0)
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6),
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent),
Fit($"Last: {sc.LastSwitch}{(sc.LastSwitchMs > 0 ? $", {Span(now - sc.LastSwitchMs)} ago" : "")}", w));
ImGuiNET.ImGui.PopFont();
}
@ -195,8 +195,8 @@ internal sealed partial class MetaFace
if (sc.Rules.Count == 0)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " No rules. New Rule: when a timer runs out, load a meta.");
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " The first due rule (top to bottom) wins.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " No rules. New Rule: when a timer runs out, load a meta.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " The first due rule (top to bottom) wins.");
return;
}
var dl = ImGuiNET.ImGui.GetWindowDrawList();
@ -367,7 +367,7 @@ internal sealed partial class MetaFace
ScheduleRuleDto r = _schedRule;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), _schedEdit == -1 ? "New rule" : $"Edit rule {_schedEdit + 1}");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), _schedEdit == -1 ? "New rule" : $"Edit rule {_schedEdit + 1}");
ImGuiNET.ImGui.PopFont();
FieldLabel("When:");
@ -436,7 +436,7 @@ internal sealed partial class MetaFace
if (_schedEdit >= 0)
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), "Saving re-arms the rule (clears fired / error).");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Saving re-arms the rule (clears fired / error).");
ImGuiNET.ImGui.PopFont();
}
ImGuiNET.ImGui.EndChild();

View file

@ -54,11 +54,18 @@ internal sealed partial class MetaFace : IImGuiPanel
() => new MetaFace());
// ── Palette (MetaPanel's, ARGB) ─────────────────────────────────────
private static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Green = C(0xFF33CC66),
Red = C(0xFFE04848), Mute = C(0xFFC8D6E4), TextDim = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14),
PanelBg = C(0xFF141F29), RowAlt = C(0xFF101822), BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A),
Fired = C(0xFF3A1212), BtnOn = C(0xFF0E2E3A), StateHdrA = C(0xFF0E1E30),
DelFill = C(0xFF7A1414), NewFill = C(0xFF0E2E1A), PickSel = C(0xFF1A2E42);
private static readonly uint Green = C(0xFF33CC66), Red = C(0xFFE04848), Fired = C(0xFF3A1212),
BtnOn = C(0xFF0E2E3A), StateHdrA = C(0xFF0E1E30), DelFill = C(0xFF7A1414), NewFill = C(0xFF0E2E1A);
private static uint Teal => RynthTheme.Accent;
private static uint Amber => RynthTheme.Highlight;
private static uint Mute => RynthTheme.MuteAlt;
private static uint TextDim => RynthTheme.Text;
private static uint ShellBg => RynthTheme.Background;
private static uint PanelBg => RynthTheme.Field;
private static uint RowAlt => RynthTheme.RowAlt;
private static uint BtnFill => RynthTheme.Button;
private static uint BtnBord => RynthTheme.Border;
private static uint PickSel => RynthTheme.Selected;
private static uint C(uint argb) => RynthTheme.Argb(argb);
private static uint Faded(uint abgr) => (abgr & 0x00FFFFFF) | ((abgr >> 25) << 24); // half alpha
@ -464,12 +471,12 @@ internal sealed partial class MetaFace : IImGuiPanel
ImGuiNET.ImGui.PopTextWrapPos();
}
if (_sourceStale)
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFE8B333), "The meta changed since you started editing. Revert loads it.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Highlight), "The meta changed since you started editing. Revert loads it.");
if (_editor == null || !CodeEditor.Available)
{
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFCC3333),
"The source editor needs the new cimgui.dll (a full RynthCore deploy). Use the Avalonia face meanwhile: /rc ui Meta avalonia");
"The source editor needs the new cimgui.dll (a full RynthCore deploy).");
return;
}
@ -987,7 +994,7 @@ internal sealed partial class MetaFace : IImGuiPanel
private static void FieldLabel(string text)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), text);
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), text);
}
private static void Separator(float w)

View file

@ -0,0 +1,70 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/MiniMapFace.cs
// The Mini Map: a small window with the same map as the World Map, following you and turned so the
// way you face is up (both switchable from the right-click menu), without a toolbar. The wheel
// zooms, a drag pans (Follow off), a double click comes back to you; right-click for Follow /
// Rotate / zoom / Go here / Open the World Map. Opened from the RynthNav panel's Mini button.
// Its zoom, Follow and Rotate are its own (WorldMapSettings.Mini); the layers are shared with the
// World Map's Show menu.
// ============================================================================
using System.Numerics;
using ImGuiNET;
using RynthCore.Engine.UI.Data;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed class MiniMapFace : IImGuiPanel
{
public const string Title = "Mini Map";
public static void Register()
{
ImGuiPanelHost.Register(Title,
new PanelSpec(new Vector2(290, 310), new Vector2(150, 150), EdgeToEdge: true, GripInBody: true, NoPopOut: true),
() => new MiniMapFace());
}
private readonly WorldMapView _view = new(mini: true);
private bool _charsSub;
public void OnShown() => WorldMapFeeds.Subscribe();
public void OnHidden()
{
WorldMapFeeds.Unsubscribe();
WorldMapFeeds.ReleaseCharacters(ref _charsSub);
}
public void Draw()
{
WorldMapFeeds.SyncCharacters(ref _charsSub);
Vector2 origin = ImGuiNET.ImGui.GetCursorScreenPos();
Vector2 size = ImGuiNET.ImGui.GetContentRegionAvail();
if (size.X < 40 || size.Y < 40) return;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
try
{
RynthNavStatus? st = UiSources.RynthNav.Current?.Value;
MapPlayer pl = WorldMapView.GatherPlayer(st, UiSources.Radar.Current?.Value);
CharacterRow[]? chars = WorldMapSettings.Characters ? UiSources.Characters.Current?.Value?.Rows : null;
_view.Blocked = null;
_view.Draw(origin + new Vector2(1, 1), origin + size - new Vector2(1, 1), pl, st, chars);
string tip = _view.HoverText;
if (tip.Length > 0)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(tip);
Vector2 a = origin + new Vector2(6, 6), b = a + ts + new Vector2(10, 6);
if (b.X < origin.X + size.X - 4)
{
dl.AddRectFilled(a, b, RynthTheme.Argb(0xD00A121A), 4);
dl.AddText(a + new Vector2(5, 3), FaceKit.Text, tip);
}
}
WorldMapSettings.FlushIfDue();
}
finally { ImGuiNET.ImGui.PopFont(); }
}
}

View file

@ -216,7 +216,7 @@ internal sealed class TrackerFace : IImGuiPanel
private static readonly Vector4 TitleColor = RynthTheme.Vec(0xFFE6B450);
private static readonly Vector4 LabelColor = RynthTheme.Vec(0xFF999999);
private static readonly uint ResetBg = RynthTheme.Argb(0xFF1A2E40);
private static readonly uint ResetBorder = RynthTheme.Argb(0xFF264C59);
private static uint ResetBorder => RynthTheme.AccentFill;
private int _opacity;
public void OnShown()

View file

@ -0,0 +1,200 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/QuickSettingsDrawer.cs
// The dashboard's My settings drawer (Tom 2026-10-14): the settings the player
// pinned, drawn with the Settings panel's own rows (SettingsRows.cs), so a
// setting changed here is the same setting, saved the same way.
//
// Pin from any setting's right-click (the Settings panel, the Patrol drawer,
// this drawer) or from the + button here, a searchable list of every setting
// that can be pinned (UI/QuickSettings.cs keeps the pins and their order).
// Here a row's right-click also moves it up or down. Starts on the
// dashboard's right edge; its tab's right-click moves it to the left.
// 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 class QuickSettingsDrawer : RynthAiDrawer
{
private readonly SettingsRows _rows = new();
private bool _sub;
private string _filter = string.Empty;
private const string AddPopupId = "##quick_add";
// Rows are drawn at the Settings panel's fixed sizes: about this tall each (pixels).
private const float RowH = 28, EmptyH = 70, MinBodyH = 60;
public override string Key => "quick";
public override string Icon => PhosphorIcons.SlidersHorizontal;
public override string Name => "My settings drawer";
public override bool StartsRight => true;
public override bool SavedOpen => RynthAiDashboardState.QuickOpen;
public override void SaveOpen(bool open) => RynthAiDashboardState.SetQuickOpen(open);
public override string TabTooltip(bool right) =>
"My settings: the settings you pinned, to change them without opening Settings.\n" +
"Pin one by right-clicking it in Settings, or with + in the drawer. Click to slide it out.";
public override float Width(float k) => 300 * k;
public override float Height(float k)
{
int pins = 0;
foreach (string key in QuickSettings.Pins)
if (QuickSettings.RowOf(key) != null) pins++;
float body = pins == 0 ? EmptyH : MathF.Max(MinBodyH, pins * RowH + 6);
float frame = (Pad + TitleH + 4 + Pad) * k;
float screen = ImGuiNET.ImGui.GetIO().DisplaySize.Y;
float max = screen > 1 ? MathF.Max(120 * k, screen - 8 * k) : 900 * k;
return MathF.Min(frame + body, max);
}
public override void Update(bool showing)
{
if (showing == _sub) return;
_sub = showing;
if (showing) { UiSources.Settings.Subscribe(); UiSources.Settings.RequestRefresh(); }
else UiSources.Settings.Unsubscribe();
}
public override void DrawPanel(Vector2 origin, float panelW, float panelH, float k)
{
float y = PanelFrame(origin, panelW, panelH, k, PhosphorIcons.SlidersHorizontal, "MY SETTINGS", null, "Hide My settings");
float x = origin.X + Pad * k, w = panelW - 2 * Pad * k;
// + beside the close button: pick settings to pin.
Vector2 btn = new(18 * k, 16 * k);
Vector2 addPos = new(x + w - 2 * btn.X - 3 * k, origin.Y + Pad * k + (TitleH * k - btn.Y) * 0.5f);
if (FaceKit.IconButton("##quick_plus", PhosphorIcons.Plus, addPos, btn, DTeal, DBtnFill, border: DBtnBord, font: UiFont.Dash10))
{
_filter = string.Empty;
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(addPos.X + btn.X, addPos.Y + btn.Y + 2 * k), ImGuiCond.Always, new Vector2(1, 0));
ImGuiNET.ImGui.OpenPopup(AddPopupId);
}
ImGuiNET.ImGui.SetItemTooltip("Pin or unpin settings");
AddPopup(k);
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x, y));
Vector2 size = new(w, MathF.Max(1, origin.Y + panelH - Pad * k - y));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
bool open = ImGuiNET.ImGui.BeginChild("##quick_body", size, ImGuiChildFlags.None, ImGuiWindowFlags.NoBackground);
ImGuiNET.ImGui.PopStyleVar();
try
{
if (!open) return;
_rows.Sync();
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 0));
try
{
float rw = ImGuiNET.ImGui.GetContentRegionAvail().X - 2 * k;
string[] pins = QuickSettings.Pins;
int drawn = 0;
for (int i = 0; i < pins.Length; i++)
{
SettingRow? row = QuickSettings.RowOf(pins[i]);
if (row == null) continue;
drawn++;
if (!row.IsVisible(_rows.Data)) continue;
ImGuiNET.ImGui.PushID(pins[i]);
_rows.DrawRow(row, rw, extraMenu: MoveItems);
ImGuiNET.ImGui.PopID();
}
if (drawn == 0)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, DMute);
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + rw);
ImGuiNET.ImGui.TextUnformatted("Pin the settings you change most. Right-click a setting in Settings (or in the Patrol drawer) " +
"and pick Pin to My settings, or click + above.");
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
}
}
finally
{
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.PopFont();
}
}
finally { ImGuiNET.ImGui.EndChild(); }
}
/// <summary>A pinned row's right-click, after Remove: Move up / Move down.</summary>
private static void MoveItems(string key)
{
string[] pins = QuickSettings.Pins;
int i = Array.IndexOf(pins, key);
if (ImGuiNET.ImGui.MenuItem(PhosphorIcons.CaretUp + " Move up", null, false, i > 0)) QuickSettings.Move(key, -1);
if (ImGuiNET.ImGui.MenuItem(PhosphorIcons.CaretDown + " Move down", null, false, i >= 0 && i < pins.Length - 1)) QuickSettings.Move(key, +1);
}
/// <summary>Every setting that can be pinned, by tab, with a search box; a click pins or unpins it.</summary>
private void AddPopup(float k)
{
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(320 * k, 420 * k));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, RynthTheme.Background);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, DTeal);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8 * k, 6 * k));
bool open = ImGuiNET.ImGui.BeginPopup(AddPopupId);
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.PopStyleColor(2);
if (!open) return;
try
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
ImGuiNET.ImGui.SetNextItemWidth(-1);
if (ImGuiNET.ImGui.IsWindowAppearing()) ImGuiNET.ImGui.SetKeyboardFocusHere();
ImGuiNET.ImGui.InputTextWithHint("##quick_search", "Search settings", ref _filter, 64);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.BeginChild("##quick_list", new Vector2(0, 0));
string filter = _filter.Trim();
foreach (SettingsTab tab in SettingsSchema.Tabs)
{
bool header = false;
string section = "";
foreach (SettingRow row in tab.Rows)
{
if (row.Kind == SettingKind.Section) { section = row.Label.Trim(); continue; }
string? key = QuickSettings.KeyOf(row);
if (key == null) continue;
string label = row.Label.Trim();
if (filter.Length > 0 && label.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0
&& section.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0
&& tab.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0)
continue;
if (!header)
{
header = true;
ImGuiNET.ImGui.Dummy(new Vector2(0, 3));
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Highlight), tab.Name);
}
bool pinned = QuickSettings.IsPinned(key);
ImGuiNET.ImGui.PushID(key);
// Stays open, so several can be pinned in one go; the section shows dimmed at the right.
if (ImGuiNET.ImGui.Selectable((pinned ? PhosphorIcons.Check : " ") + " " + label, pinned, ImGuiSelectableFlags.NoAutoClosePopups))
QuickSettings.SetPinned(key, !pinned);
if (row.Tooltip != null) ImGuiNET.ImGui.SetItemTooltip(row.Tooltip);
if (section.Length > 0)
{
Vector2 max = ImGuiNET.ImGui.GetItemRectMax(), min = ImGuiNET.ImGui.GetItemRectMin();
float sw = ImGuiNET.ImGui.CalcTextSize(section).X;
float sx = MathF.Max(min.X + ImGuiNET.ImGui.CalcTextSize(" " + label).X + 24, max.X - sw - 4);
if (sx + sw <= max.X)
ImGuiNET.ImGui.GetWindowDrawList().AddText(new Vector2(sx, min.Y), RynthTheme.Argb(0xFF6E8197), section);
}
ImGuiNET.ImGui.PopID();
}
}
ImGuiNET.ImGui.EndChild();
ImGuiNET.ImGui.PopFont();
}
finally { ImGuiNET.ImGui.EndPopup(); }
}
}

View file

@ -43,9 +43,10 @@ internal sealed class RadarFace : IImGuiPanel
// ── Palette (RadarPanel's, ARGB) ────────────────────────────────────
private const uint FrameOuterArgb = 0xFF0A0D14, CanvasBgArgb = 0xFF0A121A;
private static readonly uint FrameInner = C(0xFF9E853D), FrameAccent = C(0xFFE6C766),
Crosshair = C(0x994D6680), Cardinal = C(0xFFFFFFFF), CoordText = C(0xFFF2F8FF), Outline = C(0xF2000000),
PlayerCol = C(0xFF33FF66), ButtonBg = C(0xC0141F29), ButtonBorder = C(0xFF34587A);
private static readonly uint FrameInner = C(0xFF9E853D), FrameAccent = C(0xFFE6C766), Crosshair = C(0x994D6680),
Cardinal = C(0xFFFFFFFF), CoordText = C(0xFFF2F8FF), Outline = C(0xF2000000), PlayerCol = C(0xFF33FF66);
private static uint ButtonBg => RynthTheme.WithAlpha(RynthTheme.Field, 0xC0);
private static uint ButtonBorder => RynthTheme.Border;
// Marker colours per kind (RadarSettingsStore.KindColors, user-pickable), refreshed each frame.
private static readonly uint[] KindCols = new uint[RadarKind.Count];
private const uint WallUnseen = 0xFFFFFFFF, WallVisited = 0xFF4099FF, FloorFlat = 0x8C2E8C38,
@ -535,7 +536,7 @@ internal sealed class RadarFace : IImGuiPanel
private void SettingsWindow()
{
if (!_settingsOpen) return;
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.WindowBg, C(0xFF0A121A));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.WindowBg, RynthTheme.BoxBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, ButtonBorder);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 4f);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(10, 10));

View file

@ -46,12 +46,18 @@ using Rule = RynthCore.Engine.UI.Panels.MonstersPanel.Rule;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed class RangesSlideOut : DashboardDrawer
internal sealed class RangesSlideOut : RynthAiDrawer
{
// ── 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 readonly uint Gold = C(0xFFFFD16A);
private static uint Teal => RynthTheme.Accent;
private static uint TealSoft => RynthTheme.AccentFill;
private static uint Amber => RynthTheme.Highlight;
private static uint Mute => RynthTheme.TextMuted;
private static uint White => RynthTheme.Text;
private static uint BarBg => RynthTheme.Field;
private static uint BtnFill => RynthTheme.Button;
private static uint BtnBord => RynthTheme.Border;
private static uint C(uint argb) => RynthTheme.Argb(argb);
// ── Rows: (Settings row label, short label here) ────────────────────
@ -129,9 +135,8 @@ internal sealed class RangesSlideOut : DashboardDrawer
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 string TabTooltip(bool right) =>
"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);

View file

@ -33,7 +33,7 @@ namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed partial class RynthAiFace
{
/// <summary>Meta state, bot activity and the five file pickers.</summary>
private sealed class FilesDrawer : DashboardDrawer
private sealed class FilesDrawer : RynthAiDrawer
{
private readonly RynthAiFace _face;
public FilesDrawer(RynthAiFace face) => _face = face;
@ -51,7 +51,7 @@ internal sealed partial class RynthAiFace
"Profile: " + (v?.ProfileText ?? "Default") + "\nNav: " + (v?.NavText ?? "None") +
"\nLoot: " + (v?.LootText ?? "None") + "\nMeta: " + (v?.MetaText ?? "None") +
"\nBuffs: " + (v?.BuffText ?? "Built-in") +
(right ? "\n\nClick to slide them out (to the right: there's no room on the left)." : "\n\nClick to slide them out.");
"\n\nClick to slide them out.";
}
// The picker rows are the dashboard's own (Selector), so they take its size factor (_k);
@ -100,10 +100,14 @@ internal sealed partial class RynthAiFace
}
}
/// <summary>Hazard cells and saved routes (the Patrol launcher's right-click).</summary>
private sealed class PatrolDrawer : DashboardDrawer
/// <summary>The Dungeon Patrol settings, hazard cells and saved routes (the Patrol launcher's right-click).</summary>
private sealed class PatrolDrawer : RynthAiDrawer
{
private bool _sub;
// Settings > Navigation > Dungeon Patrol, drawn here too (2026-10-14).
private readonly SettingsRows _rows = new();
private static SettingRow[]? _settingRows;
private static SettingRow[] SettingRows => _settingRows ??= QuickSettings.SectionRows("Navigation", "Dungeon Patrol");
public override string Key => "patrol";
public override string Icon => PhosphorIcons.Footprints;
@ -111,19 +115,32 @@ internal sealed partial class RynthAiFace
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 string TabTooltip(bool right) =>
"Patrol: the Dungeon Patrol settings, this dungeon's hazard cells, recorded hazards and saved routes\n(also: right-click Patrol). Click to slide it out.";
public override float Width(float k) => 260 * k;
public override float Height(float k) => 320 * k;
public override float Width(float k) => 290 * k;
public override float Height(float k)
{
// Never taller than the screen: the body scrolls instead.
float screen = ImGuiNET.ImGui.GetIO().DisplaySize.Y;
return screen > 1 ? MathF.Min(500 * k, MathF.Max(200 * k, screen - 8 * k)) : 500 * 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();
if (showing)
{
UiSources.Patrol.Subscribe(); UiSources.Patrol.RequestRefresh();
UiSources.Settings.Subscribe(); UiSources.Settings.RequestRefresh();
}
else
{
UiSources.Patrol.Unsubscribe();
UiSources.Settings.Unsubscribe();
}
}
public override void DrawPanel(Vector2 origin, float panelW, float panelH, float k)
@ -141,6 +158,27 @@ internal sealed partial class RynthAiFace
{
if (open)
{
if (Mini(PhosphorIcons.Play + " Start patrol"))
RynthAiCommands.SendNavCommand("{\"Cmd\":\"dunPatrol\"}");
ImGuiNET.ImGui.SetItemTooltip("Start the Dungeon Patrol here (the same as left-clicking Patrol).");
// 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;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 0));
SettingRow[] rows = SettingRows;
for (int i = 0; i < rows.Length; i++)
{
if (!rows[i].IsVisible(_rows.Data)) continue;
ImGuiNET.ImGui.PushID(i);
_rows.DrawRow(rows[i], w);
ImGuiNET.ImGui.PopID();
}
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.PopFont();
PatrolInfo info = UiSources.Patrol.Current?.Value ?? new PatrolInfo();
PatrolBody(info, withTitle: false);
}
@ -150,7 +188,7 @@ internal sealed partial class RynthAiFace
}
/// <summary>RynthAi's Mini Remote, drawn by the plugin into this drawer (the Hub launcher's right-click).</summary>
private sealed class RemoteDrawer : DashboardDrawer
private sealed class RemoteDrawer : RynthAiDrawer
{
/// <summary>The plugin surface name, NUL-terminated for the export.</summary>
private static ReadOnlySpan<byte> Surface => "miniremote\0"u8;
@ -170,7 +208,7 @@ internal sealed partial class RynthAiFace
public override string TabTooltip(bool right) =>
"Mini Remote: session rates, attack target, summon, item slots, toggles, bank, rebuff, Translate.\n" +
"Its Options button picks the sections (also: right-click Hub). RynthILT's ILT tabs are in the Mini Remote window.\n" +
(right ? "Click to slide it out (to the right: there's no room on the left)." : "Click to slide it out.");
"Click to slide it out.";
public override float Width(float k) =>
Math.Clamp(_want.X > 0 ? _want.X : MinW * k, MinW * k, MaxW * k) + 2 * Pad * k;

View file

@ -3,24 +3,33 @@
// ImGui face of the RynthAi dashboard (docs/IMGUI_PARITY_PLAN.md §2.1),
// first laid out from the Avalonia face (UI/Panels/RynthAiPanel.cs), then
// made compact with Phosphor icons, after DrakBot's dashboard. Top to bottom:
// title row RYNTH | target, vitals, lock, opacity -/+,
// minimize, pop out
// title row RYNTH, running/stopped | target, vitals, lock, opacity -/+,
// minimize, pop out; a teal accent line along the top edge
// 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
// toggles (on: lit with a bar under the icon; off: dimmed),
// bot activity as a coloured label ... force rebuff. A
// toggle's right-click opens its settings (2026-10-14):
// Combat the Monsters panel, Buffing Settings > Buffing,
// Navigation the Nav panel, Looting the Loot Editor on the
// loot profile in use, Meta the Meta panel.
// launchers one row of icon buttons (names in tooltips; labels too
// when the panel is wide enough)
// footer FPS | version | uptime
// when the panel is wide enough); a button lights up while
// its window (or drawer) is open. Nav and Meta left the row
// for their toggles' right-click (2026-10-14).
// footer FPS (coloured by rate) | version | uptime
// bars player vitals, then the target (name + health), each
// 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, Patrol and Mini Remote
// (RynthAiFace.Drawers.cs). Everything that slides out goes
// left; only the bars stay at the bottom (Tom 2026-10-05).
// drawers tabs on the dashboard's edges (DashboardDrawers.cs), one
// open per side, windows of their own beside the dashboard:
// Ranges (RangesSlideOut.cs), Loaded files, Patrol and Mini
// Remote (RynthAiFace.Drawers.cs) on the left, My settings
// (QuickSettingsDrawer.cs) on the right; a tab's right-click
// moves its drawer to the other side. 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
@ -71,11 +80,18 @@ internal sealed partial class RynthAiFace : IImGuiPanel
private const float MinWidth = 280;
// ── Palette (RynthAiPanel's, ARGB) ─────────────────────────────────
private static readonly uint Teal = C(0xFF26D9E6), TealSoft = C(0xFF264C59), Amber = C(0xFFE8B333),
Green = C(0xFF40D973), Mute = C(0xFFB8C8D8), TextDim = C(0xFFF2F7FC), White = C(0xFFFFFFFF),
Hp = C(0xFFD93333), Mana = C(0xFF268CF2), ShellBg = C(0xFF0A0F14), BarBg = C(0xFF141F29),
BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A), MacroRun = C(0xFF1A5926), MacroStop = C(0xFF401F1F),
FrFill = C(0xFF47330A), SelectorBg = C(0xFF2D3847);
private static readonly uint Green = C(0xFF40D973), White = C(0xFFFFFFFF), Hp = C(0xFFD93333), Mana = C(0xFF268CF2),
MacroRun = C(0xFF1A5926), MacroStop = C(0xFF401F1F), FrFill = C(0xFF47330A), SelectorBg = C(0xFF2D3847),
Off = C(0xFF6E8197), Faint = C(0xFF5A7088), RunGlow = C(0x5540D973);
private static uint Teal => RynthTheme.Accent;
private static uint TealSoft => RynthTheme.AccentFill;
private static uint Amber => RynthTheme.Highlight;
private static uint Mute => RynthTheme.TextMuted;
private static uint TextDim => RynthTheme.Text;
private static uint ShellBg => RynthTheme.Background;
private static uint BarBg => RynthTheme.Field;
private static uint BtnFill => RynthTheme.Button;
private static uint BtnBord => RynthTheme.Border;
private static uint C(uint argb) => RynthTheme.Argb(argb);
private static readonly uint[] SegmentColors = BuildSegmentColors();
@ -118,7 +134,8 @@ internal sealed partial class RynthAiFace : IImGuiPanel
public RynthAiFace()
{
// Tab order top to bottom; the first one saved open wins at load.
_drawers = new DashboardDrawers(new RangesSlideOut(), new FilesDrawer(this), _patrol, _remote);
// Each side's in this order; My settings starts on the right.
_drawers = new DashboardDrawers(new RangesSlideOut(), new FilesDrawer(this), _patrol, _remote, new QuickSettingsDrawer());
}
public Vector2? MinSize
@ -155,7 +172,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
bool popped = ImGuiPopOuts.InPopOutFrame;
_view = view;
_raw = raw;
uint boxBg = (C(0xFF0A121A) & 0x00FFFFFF) | ((uint)(view?.PanelAlpha ?? 242) << 24);
uint boxBg = (RynthTheme.BoxBg & 0x00FFFFFF) | ((uint)(view?.PanelAlpha ?? 242) << 24);
// The host set the step these fonts are drawn at; the boxes take the same step's factor.
_k = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
// Enlarged: tooltips and menus opened from the dashboard at its size too. (At size 0 the
@ -168,6 +185,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
float x0 = start.X;
float width = ImGuiNET.ImGui.GetContentRegionAvail().X;
AccentLine();
TitleRow(raw, x0, width, minimized);
Gap(4);
// Popped out (no drawers there): the Profile/Nav/Loot/Meta pickers inline while expanded
@ -239,7 +257,15 @@ internal sealed partial class RynthAiFace : IImGuiPanel
_fitWidth = width;
}
// ── Title row: "R" + "YNTH" | chips (drag surface) ──────
/// <summary>A thin teal line along the window's top edge, inside its rounded corners.</summary>
private static void AccentLine()
{
Vector2 wp = ImGuiNET.ImGui.GetWindowPos(), ws = ImGuiNET.ImGui.GetWindowSize();
float r = RynthTheme.RynthAiRounding;
ImGuiNET.ImGui.GetWindowDrawList().AddRectFilled(new Vector2(wp.X + r, wp.Y), new Vector2(wp.X + ws.X - r, wp.Y + MathF.Max(1.5f, Px(2))), Teal);
}
// ── Title row: "R" + "YNTH", running | chips (drag surface) ──────
private void TitleRow(RynthAiSnapshot raw, float x0, float width, bool minimized)
{
@ -262,6 +288,19 @@ internal sealed partial class RynthAiFace : IImGuiPanel
dl.AddText(title, title.FontSize, new Vector2(x0, ty), Teal, "R");
float rw = CalcWidth(title, "R");
dl.AddText(title, title.FontSize, new Vector2(x0 + rw, ty), White, "YNTH");
// Running / stopped, at a glance: a dot and the word in a pill after the name.
{
ImFontPtr pf = ImGuiFonts.Get(UiFont.Dash9);
bool run = raw.MacroRunning;
string word = run ? "running" : "stopped";
float px = x0 + rw + CalcWidth(title, "YNTH") + Px(7);
float ph = pf.FontSize + Px(4), pw = Px(13) + CalcWidth(pf, word) + Px(6);
float py = y + (rowH - ph) * 0.5f;
uint col = run ? Green : Off;
dl.AddRect(new Vector2(px, py), new Vector2(px + pw, py + ph), run ? MacroRun : BtnBord, ph * 0.5f);
dl.AddCircleFilled(new Vector2(px + Px(7), py + ph * 0.5f), Px(2.5f), col);
dl.AddText(pf, pf.FontSize, new Vector2(px + Px(13), py + (ph - pf.FontSize) * 0.5f), col, word);
}
dl.PopClipRect();
float cx = x0 + width - chipsW;
@ -530,21 +569,29 @@ internal sealed partial class RynthAiFace : IImGuiPanel
// Macro start/stop: a square like the toggles, green with a Stop glyph while running.
{
bool on = raw.MacroRunning;
// Running: a soft green halo around the square.
if (on) dl.AddRect(new Vector2(x - Px(1.5f), y - Px(1.5f)), new Vector2(x + sq + Px(1.5f), y + sq + Px(1.5f)), RunGlow, round + Px(1.5f), ImDrawFlags.None, Px(2));
if (IconButton("##macro", new Vector2(x, y), square, on ? PhosphorIcons.Stop : PhosphorIcons.Play,
UiFont.Dash14, on ? MacroRun : BarBg, on ? White : Mute, on ? Green : BtnBord, round))
RynthAiCommands.ToggleMacro();
ImGuiNET.ImGui.SetItemTooltip(on ? "Macro running. Click to stop it." : "Macro stopped. Click to start it.");
x += sqStep + Px(6);
}
Toggle("##t_combat", PhosphorIcons.Sword, raw.CombatEnabled, 0, new Vector2(x, y), "Combat");
Toggle("##t_combat", PhosphorIcons.Sword, raw.CombatEnabled, 0, new Vector2(x, y), "Combat",
"the Monsters panel (weapons, spells and rules per monster)", PanelRouter.ToggleMonsters);
x += sqStep;
Toggle("##t_buff", PhosphorIcons.Sparkle, raw.BuffingEnabled, 1, new Vector2(x, y), "Buffing");
Toggle("##t_buff", PhosphorIcons.Sparkle, raw.BuffingEnabled, 1, new Vector2(x, y), "Buffing",
"the buffing settings", () => ShowSettingsTab("Buffing"));
x += sqStep;
Toggle("##t_nav", PhosphorIcons.SneakerMove, raw.NavigationEnabled, 2, new Vector2(x, y), "Navigation");
Toggle("##t_nav", PhosphorIcons.SneakerMove, raw.NavigationEnabled, 2, new Vector2(x, y), "Navigation",
"the Nav panel (routes)", () => PanelRouter.Toggle("Nav"));
x += sqStep;
Toggle("##t_loot", PhosphorIcons.Bag, raw.LootingEnabled, 3, new Vector2(x, y), "Looting");
string lootPath = raw.CurrentLootPath ?? string.Empty;
Toggle("##t_loot", PhosphorIcons.Bag, raw.LootingEnabled, 3, new Vector2(x, y), "Looting",
"the Loot Editor on the loot profile in use", () => LootEditorFace.ToggleFor(lootPath));
x += sqStep;
Toggle("##t_meta", PhosphorIcons.Code, raw.MetaEnabled, 4, new Vector2(x, y), "Meta (the macro rules)");
Toggle("##t_meta", PhosphorIcons.Code, raw.MetaEnabled, 4, new Vector2(x, y), "Meta (the macro rules)",
"the Meta panel", () => PanelRouter.Toggle("Meta"));
x += sqStep;
// RynthSort's auto-sort, when RynthSort is loaded and knows the character.
int sort = RynthSortWatch.State;
@ -581,9 +628,19 @@ internal sealed partial class RynthAiFace : IImGuiPanel
if (aRight - ax > Px(20))
{
string activity = view?.BotActivityText ?? "Idle";
float ay = y + (sq - af.FontSize) * 0.5f;
// A pill coloured by what the bot is doing, with its icon.
ActivityStyle(activity, out uint fg, out uint bg, out string icon);
float ph = MathF.Min(sq, af.FontSize + Px(6));
float py = y + (sq - ph) * 0.5f;
float iconW = icon.Length > 0 ? CalcWidth(af, icon) + Px(4) : 0;
float pw = MathF.Min(aRight - ax, Px(8) + iconW + CalcWidth(af, activity) + Px(8));
dl.PushClipRect(new Vector2(ax, y), new Vector2(aRight, y + sq), true);
dl.AddText(af, af.FontSize, new Vector2(ax, ay), Amber, activity);
dl.AddRectFilled(new Vector2(ax, py), new Vector2(ax + pw, py + ph), bg, ph * 0.5f);
float tx = ax + Px(8), ay = py + (ph - af.FontSize) * 0.5f;
if (icon.Length > 0) dl.AddText(af, af.FontSize, new Vector2(tx, ay), fg, icon);
dl.PushClipRect(new Vector2(ax, py), new Vector2(ax + pw - Px(6), py + ph), true);
dl.AddText(af, af.FontSize, new Vector2(tx + iconW, ay), fg, activity);
dl.PopClipRect();
dl.PopClipRect();
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(ax, y));
ImGuiNET.ImGui.InvisibleButton("##activity", new Vector2(aRight - ax, sq));
@ -603,11 +660,47 @@ internal sealed partial class RynthAiFace : IImGuiPanel
ImGuiNET.ImGui.Dummy(new Vector2(width, 0));
}
private void Toggle(string id, string icon, bool on, int subsystem, Vector2 pos, string name)
/// <summary>
/// A subsystem toggle: on is lit (teal, with a bar under the icon), off is dimmed so a subsystem
/// left off stands out. Right-click runs <paramref name="onRight"/>, which opens
/// <paramref name="rightWhat"/> (its settings).
/// </summary>
private void Toggle(string id, string icon, bool on, int subsystem, Vector2 pos, string name, string rightWhat, Action onRight)
{
if (IconButton(id, pos, new Vector2(Px(Square), Px(Square)), icon, UiFont.Dash14, on ? TealSoft : BarBg, on ? Teal : Mute, on ? Teal : BtnBord, Px(3)))
float sq = Px(Square);
if (IconButton(id, pos, new Vector2(sq, sq), icon, UiFont.Dash14, on ? TealSoft : BarBg, on ? Teal : Off, on ? Teal : BtnBord, Px(3)))
RynthAiCommands.SetSubsystemEnabled(subsystem, !on);
ImGuiNET.ImGui.SetItemTooltip(on ? name + " on. Click to turn it off." : name + " off. Click to turn it on.");
bool right = ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right);
ImGuiNET.ImGui.SetItemTooltip((on ? name + " on. Click to turn it off." : name + " off. Click to turn it on.") +
"\nRight-click: " + rightWhat + ".");
if (on)
ImGuiNET.ImGui.GetWindowDrawList().AddRectFilled(new Vector2(pos.X + Px(5), pos.Y + sq - Px(3.5f)),
new Vector2(pos.X + sq - Px(5), pos.Y + sq - Px(1.5f)), Teal, Px(1));
if (right) onRight();
}
/// <summary>Opens Settings (if closed) on tab <paramref name="tab"/>.</summary>
private static void ShowSettingsTab(string tab)
{
SettingsFace.RequestTab(tab);
if (!ImGuiPanelHost.IsOpen(SettingsFace.Title)) PanelRouter.Toggle(SettingsFace.Title);
}
/// <summary>The activity pill's colours and icon: red in a fight, gold looting, teal moving, and so on; grey idle.</summary>
private static void ActivityStyle(string activity, out uint fg, out uint bg, out string icon)
{
switch (activity)
{
case "Combat": fg = C(0xFFFF7A7A); bg = C(0xFF4A1A1A); icon = PhosphorIcons.Sword; break;
case "Looting":
case "Salvaging": fg = Amber; bg = FrFill; icon = PhosphorIcons.Bag; break;
case "Navigating": fg = Teal; bg = TealSoft; icon = PhosphorIcons.SneakerMove; break;
case "Buffing": fg = C(0xFFC2A8FF); bg = C(0xFF2E2350); icon = PhosphorIcons.Sparkle; break;
case "Healing": fg = C(0xFFFF8A8A); bg = C(0xFF4A1A1A); icon = PhosphorIcons.Heart; break;
case "Restoring mana": fg = C(0xFF6CB4FF); bg = C(0xFF15304D); icon = PhosphorIcons.Drop; break;
case "Restoring stamina": fg = Green; bg = C(0xFF173D24); icon = PhosphorIcons.Lightning; break;
default: fg = Mute; bg = C(0xFF1C2733); icon = ""; break;
}
}
// ── Launchers: one row of icon buttons ──────────────────────────────
@ -617,36 +710,36 @@ internal sealed partial class RynthAiFace : IImGuiPanel
private void Launchers(float x0, float width)
{
float y = ImGuiNET.ImGui.GetCursorScreenPos().Y;
const int buttons = 10;
// Nav and Meta left the row (2026-10-14): right-click the Navigation and Meta toggles.
const int buttons = 8;
float gap = Px(LauncherGap);
float bw = MathF.Floor((width - buttons * gap) / buttons);
// Short labels only when every button has room for its icon and label.
bool labels = bw >= Px(68);
float x = x0;
Launcher("##l_meta", PhosphorIcons.ListChecks, "Meta", "Meta: the macro rules", x, y, bw, labels, () => PanelRouter.Toggle("Meta"));
x += bw + gap;
Launcher("##l_lua", PhosphorIcons.FileCode, "Lua", "Lua scripts", x, y, bw, labels, () => PanelRouter.Toggle("Lua"));
Launcher("##l_lua", PhosphorIcons.FileCode, "Lua", "Lua scripts", x, y, bw, labels, () => PanelRouter.Toggle("Lua"),
ImGuiPanelHost.IsOpen("Lua"));
x += bw + gap;
// Monsters opens the Damage panel (the basic Monsters panel and its
// Simple/Advanced chip were retired 2026-10-01).
Launcher("##l_mon", PhosphorIcons.Skull, "Monsters", "Monsters: weapons, spells and rules per monster (the Damage panel)",
x, y, bw, labels, PanelRouter.ToggleMonsters);
x, y, bw, labels, PanelRouter.ToggleMonsters, ImGuiPanelHost.IsOpen(PanelRouter.Canonical("Monsters")));
x += bw + gap;
Launcher("##l_set", PhosphorIcons.Gear, "Settings", "Settings", x, y, bw, labels, () => PanelRouter.Toggle("Settings"));
x += bw + gap;
Launcher("##l_nav", PhosphorIcons.MapTrifold, "Nav", "Nav: routes", x, y, bw, labels, () => PanelRouter.Toggle("Nav"));
Launcher("##l_set", PhosphorIcons.Gear, "Settings", "Settings", x, y, bw, labels, () => PanelRouter.Toggle("Settings"),
ImGuiPanelHost.IsOpen(SettingsFace.Title));
x += bw + gap;
Launcher("##l_map", PhosphorIcons.MapPin, "Map", "Dungeon Map (shows while you're in a dungeon)", x, y, bw, labels,
() => PanelRouter.Toggle(DungeonMapFace.Title));
() => PanelRouter.Toggle(DungeonMapFace.Title), ImGuiPanelHost.IsOpen(DungeonMapFace.Title));
x += bw + gap;
Launcher("##l_items", PhosphorIcons.Backpack, "Items", "Items", x, y, bw, labels, () => PanelRouter.Toggle("Items"));
Launcher("##l_items", PhosphorIcons.Backpack, "Items", "Items", x, y, bw, labels, () => PanelRouter.Toggle("Items"),
ImGuiPanelHost.IsOpen("Items"));
x += bw + gap;
bool popped = ImGuiPopOuts.InPopOutFrame;
Launcher("##l_patrol", PhosphorIcons.Footprints, "Patrol",
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\"}"));
: "Patrol. Left-click: start dungeon patrol. Right-click: the Patrol drawer (patrol settings, hazards and routes).",
x, y, bw, labels, () => RynthAiCommands.SendNavCommand("{\"Cmd\":\"dunPatrol\"}"), !popped && _drawers.IsOpen(_patrol));
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
if (popped)
@ -663,7 +756,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
// on its Character tab (RynthILT's ILT tab; elsewhere the remote shows), Hub as it was left.
Launcher("##l_char", PhosphorIcons.User, "Char",
"Char. Left-click: the Mini Remote on its Character tab (ILT worlds). Right-click: Character windows (Spells, Quests, Pets, Skills, Inventory...), then Server: this server's plugin windows.",
x, y, bw, labels, () => ShowMiniRemoteTab("character"));
x, y, bw, labels, () => ShowMiniRemoteTab("character"), false);
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
ImGuiNET.ImGui.SetNextWindowPos(ImGuiNET.ImGui.GetItemRectMin(), ImGuiCond.Always, new Vector2(0, 1));
@ -677,7 +770,8 @@ internal sealed partial class RynthAiFace : IImGuiPanel
Launcher("##l_hub", PhosphorIcons.SquaresFour, "Hub",
popped ? "Hub. Left-click: the Mini Remote window (/rc miniremote). Right-click: open the Mini Remote window."
: "Hub. Left-click: the Mini Remote window (/rc miniremote). Right-click: the Mini Remote drawer (left), with its Options.",
x, y, bw, labels, () => PanelRouter.Toggle(MiniRemoteFace.Title));
x, y, bw, labels, () => PanelRouter.Toggle(MiniRemoteFace.Title),
ImGuiPanelHost.IsOpen(MiniRemoteFace.Title) || (!popped && _drawers.IsOpen(_remote)));
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
if (popped) ImGuiPanelHost.Open(MiniRemoteFace.Title);
@ -687,32 +781,37 @@ internal sealed partial class RynthAiFace : IImGuiPanel
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x0, y + Px(LauncherH)));
}
private void Launcher(string id, string icon, string label, string tooltip, float x, float y, float w, bool showLabel, Action? onClick)
/// <param name="lit">Its window (or drawer) is open: teal icon and outline, with a bar along the bottom.</param>
private void Launcher(string id, string icon, string label, string tooltip, float x, float y, float w, bool showLabel, Action? onClick, bool lit)
{
var pos = new Vector2(x, y);
float lh = Px(LauncherH);
var size = new Vector2(Math.Max(Px(10), w), lh);
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.SetCursorScreenPos(pos);
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size);
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size, ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight)
&& ImGuiNET.ImGui.IsMouseReleased(ImGuiMouseButton.Left);
ImGuiNET.ImGui.SetItemTooltip(tooltip);
uint fill = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : ImGuiNET.ImGui.IsItemHovered() ? Lighten(BtnFill) : BtnFill;
bool hot = ImGuiNET.ImGui.IsItemHovered();
uint fill = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : hot ? Lighten(BtnFill) : BtnFill;
uint fg = lit ? Teal : hot ? White : Mute;
dl.AddRectFilled(pos, pos + size, fill, Px(3));
dl.AddRect(pos, pos + size, BtnBord, Px(3));
dl.AddRect(pos, pos + size, lit ? Teal : BtnBord, Px(3));
if (lit) dl.AddRectFilled(new Vector2(pos.X + Px(3), pos.Y + lh - Px(2)), new Vector2(pos.X + size.X - Px(3), pos.Y + lh - Px(0.5f)), Teal);
ImFontPtr iconFont = ImGuiFonts.Get(UiFont.Dash14);
if (showLabel)
{
ImFontPtr f9 = ImGuiFonts.Get(UiFont.Dash9);
float iconBox = Px(16);
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos + new Vector2(Px(4), 0), new Vector2(iconBox, lh), Mute);
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos + new Vector2(Px(4), 0), new Vector2(iconBox, lh), fg);
dl.PushClipRect(pos, pos + size, true);
dl.AddText(f9, f9.FontSize, new Vector2(pos.X + Px(4) + iconBox + Px(4), pos.Y + (lh - f9.FontSize) * 0.5f), Mute, label);
dl.AddText(f9, f9.FontSize, new Vector2(pos.X + Px(4) + iconBox + Px(4), pos.Y + (lh - f9.FontSize) * 0.5f), fg, label);
dl.PopClipRect();
}
else
{
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos, size, Mute);
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos, size, fg);
}
if (clicked && onClick != null)
{
@ -767,7 +866,9 @@ internal sealed partial class RynthAiFace : IImGuiPanel
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Dash10);
float y = ImGuiNET.ImGui.GetCursorScreenPos().Y;
float fpsW = CalcWidth(f10, _fpsText), upW = CalcWidth(f10, _upText);
dl.AddText(f10, f10.FontSize, new Vector2(x0, y), Mute, _fpsText);
// FPS coloured by rate: green smooth, amber workable, red struggling.
uint fpsCol = fps <= 0 ? Mute : fps >= 45 ? Green : fps >= 25 ? Amber : C(0xFFFF6B6B);
dl.AddText(f10, f10.FontSize, new Vector2(x0, y), fpsCol, _fpsText);
dl.AddText(f10, f10.FontSize, new Vector2(x0 + width - upW, y), Mute, _upText);
// The version between them: centred when there's room, else after FPS, clipped short of the uptime.
@ -781,7 +882,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
float vx = x0 + (width - vw) * 0.5f;
if (vx < left || vx + vw > right) vx = left;
dl.PushClipRect(new Vector2(left, y), new Vector2(right, y + f10.FontSize + Px(2)), true);
dl.AddText(f10, f10.FontSize, new Vector2(vx, y), Mute, version);
dl.AddText(f10, f10.FontSize, new Vector2(vx, y), Faint, version);
dl.PopClipRect();
}
}
@ -971,14 +1072,14 @@ internal sealed partial class RynthAiFace : IImGuiPanel
if (withTitle)
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash11));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), PatrolTitle);
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), PatrolTitle);
ImGuiNET.ImGui.PopFont();
}
Section("THIS DUNGEON");
if (info.InDungeon)
{
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), $"0x{info.CurrentLandblock} · {info.CurrentHazards} hazard cell(s)");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), $"0x{info.CurrentLandblock} · {info.CurrentHazards} hazard cell(s)");
if (info.CurrentHazards > 0)
{
ImGuiNET.ImGui.SameLine();
@ -991,24 +1092,24 @@ internal sealed partial class RynthAiFace : IImGuiPanel
if (Mini("Unmark"))
RynthAiCommands.SendNavCommand("{\"Cmd\":\"unmarkHazardHere\"}", refreshPatrol: true);
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash9));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, RynthTheme.Vec(0xFFB8C8D8));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, RynthTheme.VecOf(RynthTheme.TextMuted));
ImGuiNET.ImGui.TextWrapped("Stand on the lava/acid, click Mark, then re-run Patrol.");
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.PopFont();
}
else
{
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "Not in a dungeon.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), "Not in a dungeon.");
}
Section($"RECORDED HAZARDS ({info.Dungeons.Length})");
if (info.Dungeons.Length == 0)
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "None recorded yet.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), "None recorded yet.");
for (int i = 0; i < info.Dungeons.Length; i++)
{
DungeonHazards d = info.Dungeons[i];
ImGuiNET.ImGui.PushID(i);
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), $"0x{d.Landblock} · {d.Cells} cell(s)");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), $"0x{d.Landblock} · {d.Cells} cell(s)");
ImGuiNET.ImGui.SameLine();
if (Mini("Clear"))
RynthAiCommands.SendNavCommand($"{{\"Cmd\":\"clearHazards\",\"NavName\":\"{d.Landblock}\"}}", refreshPatrol: true);
@ -1019,9 +1120,9 @@ internal sealed partial class RynthAiFace : IImGuiPanel
Section($"SAVED ROUTES ({info.Routes.Length})");
if (info.Routes.Length == 0)
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "No .nav routes saved.");
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), "No .nav routes saved.");
foreach (string name in info.Routes)
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), "• " + name);
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), "• " + name);
ImGuiNET.ImGui.PopFont();
}
@ -1033,7 +1134,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
{
ImGuiNET.ImGui.Dummy(new Vector2(0, Px(4)));
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash9));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), text);
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), text);
ImGuiNET.ImGui.PopFont();
}

View file

@ -51,8 +51,9 @@ internal sealed class RynthNavArrowFace : IImGuiPanel
/// <summary>The arrow turns with you: redraw popped out often enough to look smooth.</summary>
public int PopOutIdleHz => 20;
private static readonly uint Glass = RynthTheme.Argb(0xDC0A0F14), Ring = RynthTheme.Argb(0xFF1A2A39),
InputBg = RynthTheme.Argb(0xFF0E1822), Purple = RynthTheme.Argb(0xFFB48CF0), Done = Faded(Mute);
private static readonly uint Ring = RynthTheme.Argb(0xFF1A2A39), InputBg = RynthTheme.Argb(0xFF0E1822),
Purple = RynthTheme.Argb(0xFFB48CF0), Done = Faded(Mute);
private static uint Glass => RynthTheme.WithAlpha(RynthTheme.Background, 0xDC);
private const int MaxRouteRows = 8;

View file

@ -57,7 +57,8 @@ internal sealed class RynthNavFace : IImGuiPanel
}
private static readonly uint RunGreen = RynthTheme.Argb(0xFF40D973), Sep = RynthTheme.Argb(0xFF1A2A39),
RowHot = RynthTheme.Argb(0xFF16283A), Gold = RynthTheme.Argb(0xFFFFD24D), Purple = RynthTheme.Argb(0xFFBF4DFF);
Gold = RynthTheme.Argb(0xFFFFD24D), Purple = RynthTheme.Argb(0xFFBF4DFF);
private static uint RowHot => RynthTheme.Button;
private const int TabGo = 0, TabAtlas = 1, TabArrow = 2;
@ -127,6 +128,16 @@ internal sealed class RynthNavFace : IImGuiPanel
dl.AddText(big, big.FontSize, p + new Vector2(16, 1), Teal, "RynthNav");
float tw = ImGuiNET.ImGui.CalcTextSize("RynthNav").X * big.FontSize / ImGuiNET.ImGui.GetFontSize();
dl.AddText(p + new Vector2(24 + tw, 6), Mute, "go · atlas · arrow");
if (ImGuiPanelHost.HasFace(WorldMapFace.Title))
{
bool mapOpen = ImGuiPanelHost.IsOpen(WorldMapFace.Title), miniOpen = ImGuiPanelHost.IsOpen(MiniMapFace.Title);
if (Button("##rnav_worldmap", PhosphorIcons.GlobeHemisphereWest + " Map", new Vector2(p.X + w - 62, p.Y - 1), new Vector2(62, 22),
mapOpen ? Teal : Text, mapOpen ? Selected : BtnFill, border: mapOpen ? Teal : 0))
UI.PanelRouter.Toggle(WorldMapFace.Title);
if (Button("##rnav_minimap", "Mini", new Vector2(p.X + w - 62 - 4 - 40, p.Y - 1), new Vector2(40, 22),
miniOpen ? Teal : Text, miniOpen ? Selected : BtnFill, border: miniOpen ? Teal : 0))
UI.PanelRouter.Toggle(MiniMapFace.Title);
}
NextLine(p, 22);
DrawTabs(w);
DrawStatusLine(w);

View file

@ -4,14 +4,10 @@
//
// Draws SettingsSchema (UI/Data/SettingsData.cs), the same list the Avalonia
// face builds from, with that face's look: 150 px tab sidebar, "Advanced
// Settings > Tab" header, square toggle dots, - [value] + steppers (typed
// values commit on Enter or when the field loses focus, then clamp; bad
// input reverts), combo pickers, amber section headers, tooltips.
//
// Edits a private copy of the hub's settings and saves the whole copy
// (SettingsCommands.Save) on each change; a newer fetch replaces the copy
// only while no field here is being typed in. Rows that show or hide other
// rows need nothing special: visibility is re-evaluated every frame.
// Settings > Tab" header, then the tab's rows (SettingsRows.cs draws and
// edits them; right-click a row to pin it to the dashboard's My settings
// drawer). Rows that show or hide other rows need nothing special:
// visibility is re-evaluated every frame.
// ============================================================================
using System;
@ -33,30 +29,23 @@ internal sealed class SettingsFace : IImGuiPanel
() => new SettingsFace());
// ── Palette (SettingsPanel's, ARGB) ─────────────────────────────────
private static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Mute = C(0xFFB8C8D8),
TextDim = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14), PanelBg = C(0xFF141F29), BtnFill = C(0xFF16283A),
BtnBord = C(0xFF34587A), ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455), TabActive = C(0xFF1A2E42);
private static readonly uint ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455);
private static uint Teal => RynthTheme.Accent;
private static uint Amber => RynthTheme.Highlight;
private static uint Mute => RynthTheme.TextMuted;
private static uint TextDim => RynthTheme.Text;
private static uint ShellBg => RynthTheme.Background;
private static uint PanelBg => RynthTheme.Field;
private static uint BtnFill => RynthTheme.Button;
private static uint BtnBord => RynthTheme.Border;
private static uint TabActive => RynthTheme.Selected;
private static uint C(uint argb) => RynthTheme.Argb(argb);
private static readonly string[] Headers = BuildHeaders();
private RynthAiSettings _data = new();
private long _seenVersion = -1;
private int _tab;
private bool _editing;
// Typed-value buffers, one per numeric row (UTF-8, NUL-terminated).
private sealed class NumberEdit
{
public readonly byte[] Buffer = new byte[24];
public double Shown = double.NaN;
public bool Active; // the box had keyboard focus last frame
}
private readonly Dictionary<SettingRow, NumberEdit> _edits = new();
// Text rows being typed in (the saved value shows again once the box loses focus).
private readonly Dictionary<SettingRow, string> _textEdits = new();
// The Hotkeys tab (engine-side; not part of RynthAi's settings).
private readonly HotkeysSettingsUi _hotkeys = new();
// The rows (SettingsRows.cs: the edited copy, typed values, the hotkeys editor).
private readonly SettingsRows _rows = new();
// A tab asked for from outside (/rc hotkeys), taken on the next draw.
private static volatile string? _requestedTab;
@ -73,19 +62,13 @@ internal sealed class SettingsFace : IImGuiPanel
public void OnHidden()
{
UiSources.Settings.Unsubscribe();
_hotkeys.Leave();
_rows.LeaveHotkeys();
}
public void Draw()
{
// Take a newer fetch unless a value is being typed in.
var snap = UiSources.Settings.Current;
if (snap != null && snap.Version != _seenVersion && !_editing)
{
_seenVersion = snap.Version;
_data = snap.Value.Clone();
}
_editing = false;
_rows.Sync();
if (_requestedTab is { } wanted)
{
@ -176,7 +159,7 @@ internal sealed class SettingsFace : IImGuiPanel
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
if (_tab >= SettingsSchema.Tabs.Length) _tab = 0;
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), Headers[_tab]);
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), Headers[_tab]);
ImGuiNET.ImGui.PopFont();
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
Vector2 lp = ImGuiNET.ImGui.GetCursorScreenPos();
@ -184,13 +167,13 @@ internal sealed class SettingsFace : IImGuiPanel
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
SettingRow[] rows = SettingsSchema.Tabs[_tab].Rows;
if (SettingsSchema.Tabs[_tab].Name != HotkeysSettingsUi.TabName) _hotkeys.Leave();
if (SettingsSchema.Tabs[_tab].Name != HotkeysSettingsUi.TabName) _rows.LeaveHotkeys();
for (int i = 0; i < rows.Length; i++)
{
SettingRow row = rows[i];
if (!row.IsVisible(_data)) continue;
if (!row.IsVisible(_rows.Data)) continue;
ImGuiNET.ImGui.PushID(i);
DrawRow(row, w);
_rows.DrawRow(row, w);
ImGuiNET.ImGui.PopID();
}
@ -198,367 +181,6 @@ internal sealed class SettingsFace : IImGuiPanel
ImGuiNET.ImGui.EndChild();
}
private void DrawRow(SettingRow row, float w)
{
switch (row.Kind)
{
case SettingKind.Bool: BoolRow(row, w); break;
case SettingKind.Int:
case SettingKind.Float:
case SettingKind.Double: NumberRow(row, w); break;
case SettingKind.Combo: ComboRow(row, w); break;
case SettingKind.Section: Section(row.Label, w); break;
case SettingKind.Spacer: ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); break;
case SettingKind.Note: Note(row.Label, w); break;
case SettingKind.CraftingStatus: CraftingStatus(row); break;
case SettingKind.Button: ButtonRow(row, w); break;
case SettingKind.TraceCategories: TraceCategoriesRow(row, w); break;
case SettingKind.Text: TextRow(row, w); break;
case SettingKind.Status: StatusRow(row, w); break;
case SettingKind.Hotkeys: _editing |= _hotkeys.Draw(w); break;
}
}
// [All on] [All off], then a 3-column grid of square toggles, one per
// RynthAi trace category. Edits the copy's DiagCategories and saves like any other row.
private void TraceCategoriesRow(SettingRow row, float w)
{
var cats = TraceCategoryLevels.Parse(_data.DiagCategories);
if (cats.Count == 0)
{
Note("Waiting for RynthAi...", w);
return;
}
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
if (ImGuiNET.ImGui.Button("All on")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", true));
ImGuiNET.ImGui.SameLine(0, 6);
if (ImGuiNET.ImGui.Button("All off")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", false));
Tooltip(row);
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
var dl = ImGuiNET.ImGui.GetWindowDrawList();
float colW = Math.Max(80f, w / 3f);
int perRow = Math.Max(1, (int)(w / colW));
Vector2 start = ImGuiNET.ImGui.GetCursorScreenPos();
for (int i = 0; i < cats.Count; i++)
{
var (name, level) = cats[i];
bool on = level != TraceCategoryLevels.Off;
string label = TraceCategoryLevels.Label(name, level);
var p = start + new Vector2(i % perRow * colW, i / perRow * 18f);
ImGuiNET.ImGui.SetCursorScreenPos(p);
ImGuiNET.ImGui.PushID(name);
if (ImGuiNET.ImGui.InvisibleButton("##cat", new Vector2(colW - 4, 16)))
SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, name, !on));
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
ImGuiNET.ImGui.PopID();
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
dl.PushClipRect(p, p + new Vector2(colW - 4, 16), true);
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, label);
dl.PopClipRect();
}
int rowsUsed = (cats.Count + perRow - 1) / perRow;
ImGuiNET.ImGui.SetCursorScreenPos(start + new Vector2(0, rowsUsed * 18f));
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
}
private void SaveCategories(string levels)
{
_data.DiagCategories = levels;
SettingsCommands.Save(_data.Clone());
}
// Label, then a full-width box; the value commits on Enter or focus loss (like the number boxes).
private void TextRow(SettingRow row, float w)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
ImGuiNET.ImGui.TextUnformatted(row.Label);
ImGuiNET.ImGui.PopStyleColor();
Tooltip(row);
string saved = row.GetText?.Invoke(_data) ?? string.Empty;
string text = _textEdits.TryGetValue(row, out string? typing) ? typing : saved;
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(80, w - 4));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
bool enter = ImGuiNET.ImGui.InputTextWithHint("##text", row.Hint ?? string.Empty, ref text, 512u,
ImGuiInputTextFlags.EnterReturnsTrue);
bool active = ImGuiNET.ImGui.IsItemActive();
bool committed = enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit();
ImGuiNET.ImGui.PopStyleVar(2);
ImGuiNET.ImGui.PopStyleColor(3);
Tooltip(row);
_editing |= active;
if (committed)
{
_textEdits.Remove(row);
if (!string.Equals(text, saved, StringComparison.Ordinal))
{
row.SetText?.Invoke(_data, text);
SettingsCommands.Save(_data.Clone());
}
}
else if (active) _textEdits[row] = text;
else _textEdits.Remove(row);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
// RynthAi's one-line status (teal), wrapped to the column.
private void StatusRow(SettingRow row, float w)
{
string text = row.GetText?.Invoke(_data) ?? string.Empty;
if (text.Length == 0) return;
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Teal);
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
ImGuiNET.ImGui.TextUnformatted(text);
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
}
// Label | [caption]; Click posts its own work (never runs plugin code on AC's thread).
private static void ButtonRow(SettingRow row, float w)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
ImGuiNET.ImGui.AlignTextToFramePadding();
ImGuiNET.ImGui.TextUnformatted(row.Label);
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.SameLine(Math.Max(ImGuiNET.ImGui.GetCursorPosX() + 8, w * 0.45f));
if (ImGuiNET.ImGui.Button(row.ButtonText ?? row.Label))
row.Click?.Invoke();
Tooltip(row);
}
private void Changed(SettingRow row, double value)
{
row.Set!(_data, value);
SettingsCommands.Save(_data.Clone());
}
// Square dot + label; the whole row toggles.
private void BoolRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
bool on = row.Get!(_data) != 0;
float labelW = ImGuiNET.ImGui.CalcTextSize(row.Label).X;
if (ImGuiNET.ImGui.InvisibleButton("##b", new Vector2(Math.Min(w, 18 + labelW), 16)))
Changed(row, on ? 0 : 1);
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
Tooltip(row);
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
// Label | [-] [value] [+]; the value commits on Enter or focus loss.
private void NumberRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
bool isInt = row.Kind == SettingKind.Int;
float boxW = isInt ? 52 : 64, boxCol = isInt ? 56 : 68;
double value = Math.Clamp(row.Get!(_data), row.Min, row.Max);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
float right = p.X + w;
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
ImGuiNET.ImGui.InvisibleButton("##label", new Vector2(Math.Max(1, w - 40 - boxCol), 22));
Tooltip(row);
float plusX = right - 20, boxX = plusX - boxCol + (boxCol - boxW) * 0.5f, minusX = right - 20 - boxCol - 20;
if (StepButton("##minus", new Vector2(minusX + 1, p.Y + 1), PhosphorIcons.Minus))
Changed(row, Math.Clamp(value - row.Step, row.Min, row.Max));
// Typed value (amber on the panel colour).
NumberEdit edit = EditFor(row);
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(boxX, p.Y + 1));
ImGuiNET.ImGui.SetNextItemWidth(boxW);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(4, (20 - ImGuiNET.ImGui.GetFontSize()) * 0.5f));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
if (!edit.Active && edit.Shown != value)
WriteValue(edit, value, isInt);
ImGuiNET.ImGui.InputText("##v", edit.Buffer, (uint)edit.Buffer.Length,
ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.AutoSelectAll);
bool active = ImGuiNET.ImGui.IsItemActive();
edit.Active = active;
_editing |= active;
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
{
if (TryParse(edit.Buffer, out double typed))
{
double clamped = Math.Clamp(isInt ? Math.Round(typed) : typed, row.Min, row.Max);
Changed(row, clamped);
WriteValue(edit, clamped, isInt);
}
else WriteValue(edit, value, isInt); // bad input reverts
}
ImGuiNET.ImGui.PopStyleVar(3);
ImGuiNET.ImGui.PopStyleColor(3);
if (StepButton("##plus", new Vector2(plusX + 1, p.Y + 1), PhosphorIcons.Plus))
Changed(row, Math.Clamp(value + row.Step, row.Min, row.Max));
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
private NumberEdit EditFor(SettingRow row)
{
if (!_edits.TryGetValue(row, out NumberEdit? e))
_edits[row] = e = new NumberEdit();
return e;
}
private static void WriteValue(NumberEdit edit, double value, bool isInt)
{
string text = isInt ? ((long)Math.Round(value)).ToString(CultureInfo.InvariantCulture)
: value.ToString("G4", CultureInfo.InvariantCulture);
int n = Encoding.UTF8.GetBytes(text, 0, text.Length, edit.Buffer, 0);
edit.Buffer[Math.Min(n, edit.Buffer.Length - 1)] = 0;
edit.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);
}
// Label | [current item]; click opens a 220 px list with the current item highlighted.
private void ComboRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
string[] items = row.Items!;
int current = Math.Clamp((int)row.Get!(_data), 0, items.Length - 1);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Ui10);
const float btnW = 160;
var bp = new Vector2(p.X + w - btnW, p.Y + 1);
ImGuiNET.ImGui.SetCursorScreenPos(bp);
if (ImGuiNET.ImGui.InvisibleButton("##combo", new Vector2(btnW, 20)))
{
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(Math.Max(bp.X + btnW - 220, 0), bp.Y + 20));
ImGuiNET.ImGui.OpenPopup("##combo_list");
}
bool hot = ImGuiNET.ImGui.IsItemHovered();
Tooltip(row);
dl.AddRectFilled(bp, bp + new Vector2(btnW, 20), hot ? Lighten(BtnFill) : BtnFill);
dl.AddRect(bp, bp + new Vector2(btnW, 20), BtnBord);
dl.PushClipRect(bp, bp + new Vector2(btnW - 16, 20), true);
dl.AddText(f10, f10.FontSize, bp + new Vector2(4, (20 - f10.FontSize) * 0.5f), TextDim, items[current]);
dl.PopClipRect();
PhosphorIcons.DrawCentered(dl, f10, PhosphorIcons.CaretDown, bp + new Vector2(btnW - 16, 0), new Vector2(14, 20), Mute);
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.SetNextWindowSize(new Vector2(220, items.Length * 21 + 4));
bool open = ImGuiNET.ImGui.BeginPopup("##combo_list");
ImGuiNET.ImGui.PopStyleVar(2);
ImGuiNET.ImGui.PopStyleColor(2);
if (open)
{
var pdl = ImGuiNET.ImGui.GetWindowDrawList();
float iw = ImGuiNET.ImGui.GetContentRegionAvail().X;
for (int i = 0; i < items.Length; i++)
{
ImGuiNET.ImGui.PushID(i);
Vector2 ip = ImGuiNET.ImGui.GetCursorScreenPos();
bool picked = ImGuiNET.ImGui.InvisibleButton("##item", new Vector2(iw, 20));
bool ih = ImGuiNET.ImGui.IsItemHovered();
ImGuiNET.ImGui.PopID();
bool sel = i == current;
pdl.AddRectFilled(ip, ip + new Vector2(iw, 20), sel ? TabActive : ih ? Lighten(BtnFill) : BtnFill);
pdl.AddRect(ip, ip + new Vector2(iw, 20), BtnBord);
pdl.AddText(f10, f10.FontSize, ip + new Vector2(6, (20 - f10.FontSize) * 0.5f), sel ? Teal : TextDim, items[i]);
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
if (picked)
{
Changed(row, i);
ImGuiNET.ImGui.CloseCurrentPopup();
}
}
ImGuiNET.ImGui.EndPopup();
}
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
private static void Section(string text, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
ImFontPtr bold = ImGuiFonts.Get(UiFont.UiBold11);
float h = bold.FontSize + 4;
dl.AddRectFilled(p, p + new Vector2(w, h), TabActive);
dl.AddText(bold, bold.FontSize, p + new Vector2(4, 2), Amber, text);
ImGuiNET.ImGui.Dummy(new Vector2(w, h));
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
private static void Note(string text, float w)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
bool small = !text.StartsWith('(');
if (small) ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Mute);
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
ImGuiNET.ImGui.TextUnformatted(text);
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
if (small) ImGuiNET.ImGui.PopFont();
}
private void CraftingStatus(SettingRow row)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), row.Label);
ImGuiNET.ImGui.SameLine(0, 6);
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(_data.MissileCraftingActive ? 0xFFE8B333 : 0xFFB8C8D8), _data.MissileCraftingState);
ImGuiNET.ImGui.PopFont();
if (!string.IsNullOrEmpty(_data.MissileCraftingStatus))
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
ImGuiNET.ImGui.TextWrapped(_data.MissileCraftingStatus);
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.PopFont();
}
}
private static bool StepButton(string id, Vector2 pos, string glyph)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.SetCursorScreenPos(pos);
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(18, 20));
uint bg = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : ImGuiNET.ImGui.IsItemHovered() ? Lighten(BtnFill) : BtnFill;
dl.AddRectFilled(pos, pos + new Vector2(18, 20), bg);
dl.AddRect(pos, pos + new Vector2(18, 20), BtnBord);
PhosphorIcons.DrawCentered(dl, ImGuiFonts.Get(UiFont.Ui11), glyph, pos, new Vector2(18, 20), TextDim);
return clicked;
}
// Tab icons by tab name (SettingsSchema); a tab not listed shows its name alone.
private static readonly System.Collections.Generic.Dictionary<string, string> TabIcons = new()
{
@ -588,11 +210,6 @@ internal sealed class SettingsFace : IImGuiPanel
return label;
}
private static void Tooltip(SettingRow row)
{
if (row.Tooltip != null) ImGuiNET.ImGui.SetItemTooltip(row.Tooltip);
}
private static uint Lighten(uint abgr) => Scale(abgr, 1.25f, 12);
private static uint Darken(uint abgr) => Scale(abgr, 0.8f, 0);

View file

@ -0,0 +1,542 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/SettingsRows.cs
// Draws rows of the Settings schema (UI/Data/SettingsData.cs) with the
// Settings panel's look: square toggle dots, - [value] + steppers (typed
// values commit on Enter or when the field loses focus, then clamp; bad
// input reverts), combo pickers, amber section headers, tooltips. Moved out
// of SettingsFace (2026-10-14) so the dashboard's drawers draw the same rows:
// My settings (QuickSettingsDrawer.cs) and the Patrol drawer's settings.
//
// Each user keeps a private copy of the hub's settings and saves the whole
// copy (SettingsCommands.Save) on each change; a newer fetch replaces the
// copy only while none of its fields is being typed in (Sync, once a frame).
// The owner subscribes UiSources.Settings while it shows.
//
// Right-click a row: Pin to / Remove from My settings (UI/QuickSettings.cs),
// plus whatever the owner adds (the drawer's Move up / down).
// AC thread only.
// ============================================================================
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Numerics;
using System.Text;
using ImGuiNET;
using RynthCore.Engine.UI;
using RynthCore.Engine.UI.Data;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed class SettingsRows
{
// ── Palette (SettingsPanel's, ARGB) ─────────────────────────────────
private static readonly uint ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455);
private static uint Teal => RynthTheme.Accent;
private static uint Amber => RynthTheme.Highlight;
private static uint Mute => RynthTheme.TextMuted;
private static uint TextDim => RynthTheme.Text;
private static uint ShellBg => RynthTheme.Background;
private static uint PanelBg => RynthTheme.Field;
private static uint BtnFill => RynthTheme.Button;
private static uint BtnBord => RynthTheme.Border;
private static uint TabActive => RynthTheme.Selected;
private static uint C(uint argb) => RynthTheme.Argb(argb);
private RynthAiSettings _data = new();
private long _seenVersion = -1;
private bool _editing;
// Typed-value buffers, one per numeric row (UTF-8, NUL-terminated).
private sealed class NumberEdit
{
public readonly byte[] Buffer = new byte[24];
public double Shown = double.NaN;
public bool Active; // the box had keyboard focus last frame
}
private readonly Dictionary<SettingRow, NumberEdit> _edits = new();
// Text rows being typed in (the saved value shows again once the box loses focus).
private readonly Dictionary<SettingRow, string> _textEdits = new();
// The Hotkeys tab (engine-side; not part of RynthAi's settings).
private readonly HotkeysSettingsUi _hotkeys = new();
/// <summary>The copy being edited (the last fetch, plus this view's own changes).</summary>
public RynthAiSettings Data => _data;
/// <summary>Once a frame, before the rows: takes a newer fetch unless a value is being typed in.</summary>
public void Sync()
{
var snap = UiSources.Settings.Current;
if (snap != null && snap.Version != _seenVersion && !_editing)
{
_seenVersion = snap.Version;
_data = snap.Value.Clone();
}
_editing = false;
}
/// <summary>The hotkeys editor's tab was left (or the panel closed).</summary>
public void LeaveHotkeys() => _hotkeys.Leave();
/// <summary>
/// One row at the cursor, <paramref name="w"/> wide. The caller pushes an ID per row.
/// <paramref name="pinMenu"/>: right-click offers Pin to / Remove from My settings;
/// <paramref name="extraMenu"/> adds items to that menu (given the row's pin key).
/// </summary>
public void DrawRow(SettingRow row, float w, bool pinMenu = true, Action<string>? extraMenu = null)
{
Vector2 top = ImGuiNET.ImGui.GetCursorScreenPos();
DrawRowBody(row, w);
if (!pinMenu) return;
string? key = QuickSettings.KeyOf(row);
if (key == null) return;
Vector2 bottom = ImGuiNET.ImGui.GetCursorScreenPos();
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Right)
&& ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem)
&& ImGuiNET.ImGui.IsMouseHoveringRect(top, new Vector2(top.X + w, MathF.Max(bottom.Y, top.Y + 4))))
ImGuiNET.ImGui.OpenPopup("##pin_menu");
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8, 6));
bool open = ImGuiNET.ImGui.BeginPopup("##pin_menu");
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.PopStyleColor(2);
if (!open) return;
try
{
bool pinned = QuickSettings.IsPinned(key);
if (ImGuiNET.ImGui.MenuItem(pinned ? PhosphorIcons.X + " Remove from My settings" : PhosphorIcons.PushPin + " Pin to My settings"))
QuickSettings.SetPinned(key, !pinned);
ImGuiNET.ImGui.SetItemTooltip(pinned
? "Take it out of the My settings drawer on the dashboard (the setting itself doesn't change)."
: "Add it to the My settings drawer on the dashboard, for quick changes.");
extraMenu?.Invoke(key);
}
finally { ImGuiNET.ImGui.EndPopup(); }
}
private void DrawRowBody(SettingRow row, float w)
{
switch (row.Kind)
{
case SettingKind.Bool: BoolRow(row, w); break;
case SettingKind.Int:
case SettingKind.Float:
case SettingKind.Double: NumberRow(row, w); break;
case SettingKind.Combo: ComboRow(row, w); break;
case SettingKind.Section: Section(row.Label, w); break;
case SettingKind.Spacer: ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); break;
case SettingKind.Note: Note(row.Label, w); break;
case SettingKind.CraftingStatus: CraftingStatus(row); break;
case SettingKind.Button: ButtonRow(row, w); break;
case SettingKind.TraceCategories: TraceCategoriesRow(row, w); break;
case SettingKind.Text: TextRow(row, w); break;
case SettingKind.Status: StatusRow(row, w); break;
case SettingKind.Hotkeys: _editing |= _hotkeys.Draw(w); break;
case SettingKind.Color: ColorRow(row, w); break;
}
}
// [All on] [All off], then a 3-column grid of square toggles, one per
// RynthAi trace category. Edits the copy's DiagCategories and saves like any other row.
private void TraceCategoriesRow(SettingRow row, float w)
{
var cats = TraceCategoryLevels.Parse(_data.DiagCategories);
if (cats.Count == 0)
{
Note("Waiting for RynthAi...", w);
return;
}
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
if (ImGuiNET.ImGui.Button("All on")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", true));
ImGuiNET.ImGui.SameLine(0, 6);
if (ImGuiNET.ImGui.Button("All off")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", false));
Tooltip(row);
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
var dl = ImGuiNET.ImGui.GetWindowDrawList();
float colW = Math.Max(80f, w / 3f);
int perRow = Math.Max(1, (int)(w / colW));
Vector2 start = ImGuiNET.ImGui.GetCursorScreenPos();
for (int i = 0; i < cats.Count; i++)
{
var (name, level) = cats[i];
bool on = level != TraceCategoryLevels.Off;
string label = TraceCategoryLevels.Label(name, level);
var p = start + new Vector2(i % perRow * colW, i / perRow * 18f);
ImGuiNET.ImGui.SetCursorScreenPos(p);
ImGuiNET.ImGui.PushID(name);
if (ImGuiNET.ImGui.InvisibleButton("##cat", new Vector2(colW - 4, 16)))
SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, name, !on));
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
ImGuiNET.ImGui.PopID();
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
dl.PushClipRect(p, p + new Vector2(colW - 4, 16), true);
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, label);
dl.PopClipRect();
}
int rowsUsed = (cats.Count + perRow - 1) / perRow;
ImGuiNET.ImGui.SetCursorScreenPos(start + new Vector2(0, rowsUsed * 18f));
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
}
private void SaveCategories(string levels)
{
_data.DiagCategories = levels;
SettingsCommands.Save(_data.Clone());
}
// Label, then a full-width box; the value commits on Enter or focus loss (like the number boxes).
private void TextRow(SettingRow row, float w)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
ImGuiNET.ImGui.TextUnformatted(row.Label);
ImGuiNET.ImGui.PopStyleColor();
Tooltip(row);
string saved = row.GetText?.Invoke(_data) ?? string.Empty;
string text = _textEdits.TryGetValue(row, out string? typing) ? typing : saved;
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(80, w - 4));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
bool enter = ImGuiNET.ImGui.InputTextWithHint("##text", row.Hint ?? string.Empty, ref text, 512u,
ImGuiInputTextFlags.EnterReturnsTrue);
bool active = ImGuiNET.ImGui.IsItemActive();
bool committed = enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit();
ImGuiNET.ImGui.PopStyleVar(2);
ImGuiNET.ImGui.PopStyleColor(3);
Tooltip(row);
_editing |= active;
if (committed)
{
_textEdits.Remove(row);
if (!string.Equals(text, saved, StringComparison.Ordinal))
{
row.SetText?.Invoke(_data, text);
SettingsCommands.Save(_data.Clone());
}
}
else if (active) _textEdits[row] = text;
else _textEdits.Remove(row);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
// RynthAi's one-line status (teal), wrapped to the column.
private void StatusRow(SettingRow row, float w)
{
string text = row.GetText?.Invoke(_data) ?? string.Empty;
if (text.Length == 0) return;
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Teal);
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
ImGuiNET.ImGui.TextUnformatted(text);
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
}
// Label | [caption]; Click posts its own work (never runs plugin code on AC's thread).
private static void ButtonRow(SettingRow row, float w)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
ImGuiNET.ImGui.AlignTextToFramePadding();
ImGuiNET.ImGui.TextUnformatted(row.Label);
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.SameLine(Math.Max(ImGuiNET.ImGui.GetCursorPosX() + 8, w * 0.45f));
if (ImGuiNET.ImGui.Button(row.ButtonText ?? row.Label))
row.Click?.Invoke();
Tooltip(row);
}
private void Changed(SettingRow row, double value)
{
row.Set!(_data, value);
SettingsCommands.Save(_data.Clone());
}
// Square dot + label; the whole row toggles.
private void BoolRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
bool on = row.Get!(_data) != 0;
float labelW = ImGuiNET.ImGui.CalcTextSize(row.Label).X;
if (ImGuiNET.ImGui.InvisibleButton("##b", new Vector2(Math.Min(w, 18 + labelW), 16)))
Changed(row, on ? 0 : 1);
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
Tooltip(row);
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
// Label | [-] [value] [+]; the value commits on Enter or focus loss.
private void NumberRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
bool isInt = row.Kind == SettingKind.Int;
float boxW = isInt ? 52 : 64, boxCol = isInt ? 56 : 68;
double value = Math.Clamp(row.Get!(_data), row.Min, row.Max);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
float right = p.X + w;
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
ImGuiNET.ImGui.InvisibleButton("##label", new Vector2(Math.Max(1, w - 40 - boxCol), 22));
Tooltip(row);
float plusX = right - 20, boxX = plusX - boxCol + (boxCol - boxW) * 0.5f, minusX = right - 20 - boxCol - 20;
if (StepButton("##minus", new Vector2(minusX + 1, p.Y + 1), PhosphorIcons.Minus))
Changed(row, Math.Clamp(value - row.Step, row.Min, row.Max));
// Typed value (amber on the panel colour).
NumberEdit edit = EditFor(row);
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(boxX, p.Y + 1));
ImGuiNET.ImGui.SetNextItemWidth(boxW);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(4, (20 - ImGuiNET.ImGui.GetFontSize()) * 0.5f));
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
if (!edit.Active && edit.Shown != value)
WriteValue(edit, value, isInt);
ImGuiNET.ImGui.InputText("##v", edit.Buffer, (uint)edit.Buffer.Length,
ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.AutoSelectAll);
bool active = ImGuiNET.ImGui.IsItemActive();
edit.Active = active;
_editing |= active;
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
{
if (TryParse(edit.Buffer, out double typed))
{
double clamped = Math.Clamp(isInt ? Math.Round(typed) : typed, row.Min, row.Max);
Changed(row, clamped);
WriteValue(edit, clamped, isInt);
}
else WriteValue(edit, value, isInt); // bad input reverts
}
ImGuiNET.ImGui.PopStyleVar(3);
ImGuiNET.ImGui.PopStyleColor(3);
if (StepButton("##plus", new Vector2(plusX + 1, p.Y + 1), PhosphorIcons.Plus))
Changed(row, Math.Clamp(value + row.Step, row.Min, row.Max));
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
// Label | [swatch]; a click opens a colour picker. These are the theme's colours (engine-stored): each
// change applies at once and is saved by the theme, so the profile isn't saved for it.
private void ColorRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
const float swatchW = 52;
ImGuiNET.ImGui.InvisibleButton("##label", new Vector2(Math.Max(1, w - swatchW - 8), 22));
Tooltip(row);
uint argb = (uint)row.Get!(_data);
var col = new Vector4(((argb >> 16) & 0xFF) / 255f, ((argb >> 8) & 0xFF) / 255f, (argb & 0xFF) / 255f, 1f);
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X + w - swatchW, p.Y + 1));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
if (ImGuiNET.ImGui.ColorButton("##swatch", col, ImGuiColorEditFlags.NoAlpha | ImGuiColorEditFlags.NoTooltip, new Vector2(swatchW, 20)))
ImGuiNET.ImGui.OpenPopup("##picker");
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.SetItemTooltip("Click to pick a colour.");
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
bool open = ImGuiNET.ImGui.BeginPopup("##picker");
ImGuiNET.ImGui.PopStyleColor(2);
if (open)
{
var rgb = new Vector3(col.X, col.Y, col.Z);
ImGuiNET.ImGui.SetNextItemWidth(200);
if (ImGuiNET.ImGui.ColorPicker3("##pick", ref rgb, ImGuiColorEditFlags.NoAlpha | ImGuiColorEditFlags.NoSidePreview
| ImGuiColorEditFlags.PickerHueWheel | ImGuiColorEditFlags.DisplayHex))
{
uint packed = 0xFF000000 | ((uint)MathF.Round(Math.Clamp(rgb.X, 0f, 1f) * 255) << 16)
| ((uint)MathF.Round(Math.Clamp(rgb.Y, 0f, 1f) * 255) << 8) | (uint)MathF.Round(Math.Clamp(rgb.Z, 0f, 1f) * 255);
row.Set!(_data, packed);
}
ImGuiNET.ImGui.EndPopup();
}
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
private NumberEdit EditFor(SettingRow row)
{
if (!_edits.TryGetValue(row, out NumberEdit? e))
_edits[row] = e = new NumberEdit();
return e;
}
private static void WriteValue(NumberEdit edit, double value, bool isInt)
{
string text = isInt ? ((long)Math.Round(value)).ToString(CultureInfo.InvariantCulture)
: value.ToString("G4", CultureInfo.InvariantCulture);
int n = Encoding.UTF8.GetBytes(text, 0, text.Length, edit.Buffer, 0);
edit.Buffer[Math.Min(n, edit.Buffer.Length - 1)] = 0;
edit.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);
}
// Label | [current item]; click opens a 220 px list with the current item highlighted.
private void ComboRow(SettingRow row, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
string[] items = row.Items!;
int current = Math.Clamp((int)row.Get!(_data), 0, items.Length - 1);
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Ui10);
const float btnW = 160;
var bp = new Vector2(p.X + w - btnW, p.Y + 1);
ImGuiNET.ImGui.SetCursorScreenPos(bp);
if (ImGuiNET.ImGui.InvisibleButton("##combo", new Vector2(btnW, 20)))
{
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(Math.Max(bp.X + btnW - 220, 0), bp.Y + 20));
ImGuiNET.ImGui.OpenPopup("##combo_list");
}
bool hot = ImGuiNET.ImGui.IsItemHovered();
Tooltip(row);
dl.AddRectFilled(bp, bp + new Vector2(btnW, 20), hot ? Lighten(BtnFill) : BtnFill);
dl.AddRect(bp, bp + new Vector2(btnW, 20), BtnBord);
dl.PushClipRect(bp, bp + new Vector2(btnW - 16, 20), true);
dl.AddText(f10, f10.FontSize, bp + new Vector2(4, (20 - f10.FontSize) * 0.5f), TextDim, items[current]);
dl.PopClipRect();
PhosphorIcons.DrawCentered(dl, f10, PhosphorIcons.CaretDown, bp + new Vector2(btnW - 16, 0), new Vector2(14, 20), Mute);
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.SetNextWindowSize(new Vector2(220, items.Length * 21 + 4));
bool open = ImGuiNET.ImGui.BeginPopup("##combo_list");
ImGuiNET.ImGui.PopStyleVar(2);
ImGuiNET.ImGui.PopStyleColor(2);
if (open)
{
var pdl = ImGuiNET.ImGui.GetWindowDrawList();
float iw = ImGuiNET.ImGui.GetContentRegionAvail().X;
for (int i = 0; i < items.Length; i++)
{
ImGuiNET.ImGui.PushID(i);
Vector2 ip = ImGuiNET.ImGui.GetCursorScreenPos();
bool picked = ImGuiNET.ImGui.InvisibleButton("##item", new Vector2(iw, 20));
bool ih = ImGuiNET.ImGui.IsItemHovered();
ImGuiNET.ImGui.PopID();
bool sel = i == current;
pdl.AddRectFilled(ip, ip + new Vector2(iw, 20), sel ? TabActive : ih ? Lighten(BtnFill) : BtnFill);
pdl.AddRect(ip, ip + new Vector2(iw, 20), BtnBord);
pdl.AddText(f10, f10.FontSize, ip + new Vector2(6, (20 - f10.FontSize) * 0.5f), sel ? Teal : TextDim, items[i]);
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
if (picked)
{
Changed(row, i);
ImGuiNET.ImGui.CloseCurrentPopup();
}
}
ImGuiNET.ImGui.EndPopup();
}
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
private static void Section(string text, float w)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
ImFontPtr bold = ImGuiFonts.Get(UiFont.UiBold11);
float h = bold.FontSize + 4;
dl.AddRectFilled(p, p + new Vector2(w, h), TabActive);
dl.AddText(bold, bold.FontSize, p + new Vector2(4, 2), Amber, text);
ImGuiNET.ImGui.Dummy(new Vector2(w, h));
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
}
private static void Note(string text, float w)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
bool small = !text.StartsWith('(');
if (small) ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Mute);
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
ImGuiNET.ImGui.TextUnformatted(text);
ImGuiNET.ImGui.PopTextWrapPos();
ImGuiNET.ImGui.PopStyleColor();
if (small) ImGuiNET.ImGui.PopFont();
}
private void CraftingStatus(SettingRow row)
{
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), row.Label);
ImGuiNET.ImGui.SameLine(0, 6);
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(_data.MissileCraftingActive ? RynthTheme.Highlight : RynthTheme.TextMuted), _data.MissileCraftingState);
ImGuiNET.ImGui.PopFont();
if (!string.IsNullOrEmpty(_data.MissileCraftingStatus))
{
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
ImGuiNET.ImGui.TextWrapped(_data.MissileCraftingStatus);
ImGuiNET.ImGui.PopStyleColor();
ImGuiNET.ImGui.PopFont();
}
}
private static bool StepButton(string id, Vector2 pos, string glyph)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImGuiNET.ImGui.SetCursorScreenPos(pos);
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(18, 20));
uint bg = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : ImGuiNET.ImGui.IsItemHovered() ? Lighten(BtnFill) : BtnFill;
dl.AddRectFilled(pos, pos + new Vector2(18, 20), bg);
dl.AddRect(pos, pos + new Vector2(18, 20), BtnBord);
PhosphorIcons.DrawCentered(dl, ImGuiFonts.Get(UiFont.Ui11), glyph, pos, new Vector2(18, 20), TextDim);
return clicked;
}
private static void Tooltip(SettingRow row)
{
if (row.Tooltip != null) ImGuiNET.ImGui.SetItemTooltip(row.Tooltip);
}
private static uint Lighten(uint abgr) => Scale(abgr, 1.25f, 12);
private static uint Darken(uint abgr) => Scale(abgr, 0.8f, 0);
private static uint Scale(uint abgr, float k, int add)
{
uint a = abgr & 0xFF000000;
uint r = (uint)Math.Min(255, (int)((abgr & 0xFF) * k) + add);
uint g = (uint)Math.Min(255, (int)(((abgr >> 8) & 0xFF) * k) + add);
uint b = (uint)Math.Min(255, (int)(((abgr >> 16) & 0xFF) * k) + add);
return a | (b << 16) | (g << 8) | r;
}
}

View file

@ -58,8 +58,8 @@ internal sealed partial class SkillsFace : IImGuiPanel
// ── Palette (FaceKit's, plus the vitals') ────────────────────────────
private static readonly uint Mana = RynthTheme.Argb(0xFF4DA6FF), Dim = RynthTheme.Argb(0xFF7F8FA0),
ExpandedBg = RynthTheme.Argb(0xFF1A2E42), GroupBg = RynthTheme.Argb(0xFF0F1A24),
MasteryColor = RynthTheme.Argb(0xFFC9A2FF);
GroupBg = RynthTheme.Argb(0xFF0F1A24), MasteryColor = RynthTheme.Argb(0xFFC9A2FF);
private static uint ExpandedBg => RynthTheme.Selected;
private const float RowH = 24f, IconSize = 20f, ColBuffed = 46f, ColBase = 46f, ColCost = 76f, ColButton = 52f,
CaretW = 16f, MultiW = 190f;

View file

@ -0,0 +1,264 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/WorldMapFace.cs
// The World Map: an interactive map of Dereth, opened from the RynthNav panel's Map button.
// The map itself is WorldMapView (also the Mini Map's); this face is the toolbar around it:
// Follow keeps you centred (a drag, or Fit, turns it off; a double click on the map turns it on)
// Rotate turns the map so the way you face is up
// - + Fit zoom out / in / the whole world
// Show which kinds of place, and the labels / route / path / grid / characters / buildings layers
// Find a place by name (the Atlas's surface places, towns and dungeons first): Enter or a click
// centres on it, zooms in and rings it
// and, over the map's top-left, what is under the cursor: its coordinates, the place's name, and how
// far and which way it is from you.
// Settings (zoom, Follow, Rotate, the layers) last across sessions (WorldMapSettings).
// ============================================================================
using System;
using System.Collections.Generic;
using System.Numerics;
using ImGuiNET;
using RynthCore.Engine.UI.Data;
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
namespace RynthCore.Engine.ImGuiBackend.Panels;
/// <summary>The data both map faces draw from: subscribed while a face is open.</summary>
internal static class WorldMapFeeds
{
private static readonly string VectorPath = System.IO.Path.Combine(RynthCore.Install.RynthInstallPaths.CoreDir, "NavData", "worldmap.vec");
public static void Subscribe()
{
UiSources.RynthNav.Subscribe();
UiSources.RynthNav.RequestRefresh();
UiSources.Radar.Subscribe();
UiSources.Radar.RequestRefresh();
RynthNavAtlas.EnsureLoadedForNames();
WorldMapMaps.Refresh(); // finds which map pictures are installed and opens the one to use
WorldMapVectors.Open(VectorPath);
}
public static void Unsubscribe()
{
UiSources.RynthNav.Unsubscribe();
UiSources.Radar.Unsubscribe();
}
/// <summary>The characters feed (RynthNet) is polled only while the layer is on; each face keeps its own flag.</summary>
public static void SyncCharacters(ref bool subscribed)
{
bool want = WorldMapSettings.Characters;
if (want == subscribed) return;
subscribed = want;
if (want) { UiSources.Characters.Subscribe(); UiSources.Characters.RequestRefresh(); }
else UiSources.Characters.Unsubscribe();
}
public static void ReleaseCharacters(ref bool subscribed)
{
if (subscribed) UiSources.Characters.Unsubscribe();
subscribed = false;
}
}
internal sealed class WorldMapFace : IImGuiPanel
{
public const string Title = "World Map";
public static void Register()
{
WorldMapSettings.Load(); // engine init thread: the file read stays off AC's thread
ImGuiPanelHost.Register(Title,
new PanelSpec(new Vector2(680, 600), new Vector2(340, 280), EdgeToEdge: true, GripInBody: true, NoPopOut: true, OpenCentered: true),
() => new WorldMapFace());
MiniMapFace.Register();
}
private readonly WorldMapView _view = new(mini: false);
private bool _charsSub;
private readonly byte[] _find = new byte[64];
private string _findText = "";
private List<NavPlace> _found = new();
private bool _findOpen;
private Vector2 _findBoxMin, _findBoxMax;
public void OnShown() => WorldMapFeeds.Subscribe();
public void OnHidden()
{
WorldMapFeeds.Unsubscribe();
WorldMapFeeds.ReleaseCharacters(ref _charsSub);
_findOpen = false;
}
public void Draw()
{
WorldMapFeeds.SyncCharacters(ref _charsSub);
float w = Begin(out Vector2 origin, out Vector2 size);
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
try
{
RynthNavStatus? st = UiSources.RynthNav.Current?.Value;
RadarView? radar = UiSources.Radar.Current?.Value;
MapPlayer pl = WorldMapView.GatherPlayer(st, radar);
CharacterRow[]? chars = WorldMapSettings.Characters ? UiSources.Characters.Current?.Value?.Rows : null;
Vector2 barPos = ImGuiNET.ImGui.GetCursorScreenPos();
float canvasTop = DrawToolbar(barPos, w, pl.Known);
var canvasMin = new Vector2(origin.X + 1, canvasTop);
var canvasMax = new Vector2(origin.X + size.X - 1, origin.Y + size.Y - 1);
// The find dropdown covers part of the map: tell the map to ignore the mouse there.
(Vector2, Vector2)? drop = null;
if (_findOpen && _found.Count > 0)
{
var dmin = new Vector2(_findBoxMin.X, _findBoxMax.Y + 2);
drop = (dmin, dmin + new Vector2(Math.Max(_findBoxMax.X - _findBoxMin.X, 250f), _found.Count * 20 + 4));
}
_view.Blocked = drop;
_view.Draw(canvasMin, canvasMax, pl, st, chars);
// What's under the cursor, over the map's top-left.
string tip = _view.HoverText;
if (tip.Length > 0)
{
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(tip);
Vector2 a = canvasMin + new Vector2(8, 8), b = a + ts + new Vector2(12, 8);
if (b.X < canvasMax.X - 8)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
dl.AddRectFilled(a, b, RynthTheme.Argb(0xD00A121A), 4);
dl.AddText(a + new Vector2(6, 4), Text, tip);
}
}
DrawFindDropdown(drop);
WorldMapSettings.FlushIfDue();
}
finally
{
ImGuiNET.ImGui.PopFont();
End(origin, size);
}
}
// ── Toolbar ──────────────────────────────────────────────────────────
private float DrawToolbar(Vector2 pos, float width, bool canFollow)
{
float x = pos.X, y = pos.Y;
const float h = 22f;
bool follow = _view.Follow, rotate = _view.Rotate;
if (Button("##wm_follow", "Follow", new Vector2(x, y), new Vector2(54, h), follow ? Teal : Text, follow ? Selected : BtnFill,
enabled: canFollow, border: follow ? Teal : 0))
_view.Follow = !follow;
x += 58;
if (Button("##wm_rotate", "Rotate", new Vector2(x, y), new Vector2(52, h), rotate ? Teal : Text, rotate ? Selected : BtnFill,
enabled: canFollow, border: rotate ? Teal : 0))
_view.Rotate = !rotate;
x += 56;
if (Button("##wm_out", "-", new Vector2(x, y), new Vector2(24, h), Text, BtnFill)) _view.ZoomBy(1f / 1.5f);
x += 28;
if (Button("##wm_in", "+", new Vector2(x, y), new Vector2(24, h), Text, BtnFill)) _view.ZoomBy(1.5f);
x += 28;
if (Button("##wm_fit", "Fit", new Vector2(x, y), new Vector2(34, h), Text, BtnFill)) _view.FitWorld();
x += 38;
if (Button("##wm_show", "Show", new Vector2(x, y), new Vector2(46, h), Text, BtnFill)) ImGuiNET.ImGui.OpenPopup("##wm_show_pop");
var showMenuAt = new Vector2(x, y + h + 2);
x += 50;
ImGuiNET.ImGui.SetNextWindowPos(showMenuAt);
if (ImGuiNET.ImGui.BeginPopup("##wm_show_pop"))
{
// Which picture: the best installed, or one of the installed ones.
var installed = WorldMapMaps.Installed;
if (installed.Length > 0)
{
ImGuiNET.ImGui.TextDisabled("Map detail" + (WorldMapMaps.CurrentLabel.Length > 0 ? ": " + WorldMapMaps.CurrentLabel : ""));
if (ImGuiNET.ImGui.RadioButton("Best installed", WorldMapSettings.Detail.Length == 0)) { WorldMapSettings.Detail = ""; WorldMapSettings.MarkDirty(); WorldMapMaps.Apply(); }
foreach (var t in installed)
if (ImGuiNET.ImGui.RadioButton(t.Label, WorldMapSettings.Detail == t.Key)) { WorldMapSettings.Detail = t.Key; WorldMapSettings.MarkDirty(); WorldMapMaps.Apply(); }
ImGuiNET.ImGui.Separator();
}
for (int k = 0; k < (int)WorldMapView.Kind.Count; k++)
if (ImGuiNET.ImGui.Checkbox(WorldMapView.KindNames[k], ref WorldMapSettings.Show[k])) WorldMapSettings.MarkDirty();
ImGuiNET.ImGui.Separator();
if (ImGuiNET.ImGui.Checkbox("Labels", ref WorldMapSettings.Labels)) WorldMapSettings.MarkDirty();
if (ImGuiNET.ImGui.Checkbox("Route", ref WorldMapSettings.Route)) WorldMapSettings.MarkDirty();
if (ImGuiNET.ImGui.Checkbox("Walking path", ref WorldMapSettings.WalkPath)) WorldMapSettings.MarkDirty();
if (ImGuiNET.ImGui.Checkbox("Grid", ref WorldMapSettings.Grid)) WorldMapSettings.MarkDirty();
if (ImGuiNET.ImGui.Checkbox("Other characters", ref WorldMapSettings.Characters)) WorldMapSettings.MarkDirty();
if (ImGuiNET.ImGui.Checkbox("Buildings and roads", ref WorldMapSettings.Buildings)) WorldMapSettings.MarkDirty();
ImGuiNET.ImGui.EndPopup();
}
// Find: the rest of the row, at most 220 px.
float room = pos.X + width - x;
if (room >= 90)
{
float fw = Math.Min(room, 220f);
_findBoxMin = new Vector2(x, y);
_findBoxMax = new Vector2(x + fw, y + h);
bool enter = TextBox("##wm_findbox", _find, _findBoxMin, fw, "Find a place", out bool active, ImGuiInputTextFlags.EnterReturnsTrue);
string text = Utf8(_find).Trim();
if (text != _findText)
{
_findText = text;
_found = WorldMapView.Find(text, 8);
_findOpen = text.Length > 0;
}
else if (active && text.Length > 0) _findOpen = true;
if (active && ImGuiNET.ImGui.IsKeyPressed(ImGuiKey.Escape, false)) ClearFind();
if (enter && _found.Count > 0) PickFound(_found[0]);
else if (enter) ClearFind();
}
else _findBoxMin = _findBoxMax = new Vector2(x, y);
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(pos.X, y + 28));
return y + 28;
}
private void ClearFind()
{
Array.Clear(_find);
_findText = "";
_found = new List<NavPlace>();
_findOpen = false;
}
private void PickFound(NavPlace p)
{
float zoom = p.Type switch { "Town" => 3.5f, "Dungeon" => 5f, _ => 7f };
_view.Show(p.Name, p.Ns, p.Ew, zoom);
ClearFind();
}
/// <summary>The results under the find box. Drawn after the map, so its buttons win the mouse.</summary>
private void DrawFindDropdown((Vector2 Min, Vector2 Max)? drop)
{
if (drop is not { } d || !_findOpen || _found.Count == 0) return;
var dl = ImGuiNET.ImGui.GetWindowDrawList();
Vector2 mouse = ImGuiNET.ImGui.GetIO().MousePos;
bool inBox = mouse.X >= _findBoxMin.X && mouse.X <= _findBoxMax.X && mouse.Y >= _findBoxMin.Y && mouse.Y <= _findBoxMax.Y;
bool inDrop = mouse.X >= d.Min.X && mouse.X <= d.Max.X && mouse.Y >= d.Min.Y && mouse.Y <= d.Max.Y;
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left) && !inBox && !inDrop) { _findOpen = false; return; }
dl.AddRectFilled(d.Min, d.Max, ShellBg, 4);
dl.AddRect(d.Min, d.Max, Teal, 4);
NavPlace? pick = null;
for (int i = 0; i < _found.Count; i++)
{
NavPlace p = _found[i];
var rowMin = new Vector2(d.Min.X + 2, d.Min.Y + 2 + i * 20);
var rowSize = new Vector2(d.Max.X - d.Min.X - 4, 20);
ImGuiNET.ImGui.SetCursorScreenPos(rowMin);
bool clicked = ImGuiNET.ImGui.InvisibleButton("##wm_found" + i, rowSize);
if (ImGuiNET.ImGui.IsItemHovered()) dl.AddRectFilled(rowMin, rowMin + rowSize, Selected, 3);
dl.AddText(rowMin + new Vector2(6, 3), Text, p.Name);
string t = p.Type;
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(t);
dl.AddText(rowMin + new Vector2(rowSize.X - ts.X - 6, 3), Mute, t);
if (clicked) pick = p;
}
if (pick != null) PickFound(pick);
}
}

View file

@ -0,0 +1,110 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/WorldMapMaps.cs
// Which World Map picture to use. NavData and MapPacks can hold up to four, each a pyramid of tiles at its own
// resolution (RynthNav.Baker --map-world): worldmap-p64.rmap (Maximum, 64 px per cell), worldmap-p32.rmap (Extreme, 32), worldmap-ultra.rmap (16), worldmap-hd.rmap (8) and
// worldmap.rmap (Standard: the one everybody gets). The launcher offers the bigger ones as optional
// downloads, so a PC may have any of them: by default the best installed is used, and the Show menu's Detail
// list lets a player pick another that is installed. The choice is remembered (WorldMapSettings.Detail).
// The folder is scanned on a pool thread (no file access on AC's thread); a change of file is made by
// WorldMapTiles.Switch at the start of the next frame.
// ============================================================================
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using RynthCore.Engine.UI.Data;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal static class WorldMapMaps
{
internal readonly record struct Tier(string Key, string Label, string File);
/// <summary>Best first.</summary>
public static readonly Tier[] Tiers =
{
new("maximum", "Maximum", "worldmap-p64.rmap"),
new("extreme", "Extreme", "worldmap-p32.rmap"),
new("ultra", "Ultra", "worldmap-ultra.rmap"),
new("hd", "HD", "worldmap-hd.rmap"),
new("standard", "Standard", "worldmap.rmap"),
};
private static volatile Tier[] _installed = Array.Empty<Tier>();
private static volatile bool _scanned;
private static volatile Dictionary<string, string> _paths = new(); // tier key -> the file found
/// <summary>RynthNav's data folder: where the plugin says it is, else the default. Any thread.</summary>
public static string Dir
{
get
{
string dir = UiSources.RynthNav.Current?.Value?.NavDir ?? "";
return dir.Length > 0 && Path.IsPathFullyQualified(dir) ? dir.TrimEnd((char)92, (char)47) : Path.Combine(RynthCore.Install.RynthInstallPaths.CoreDir, "NavData");
}
}
/// <summary>Where the launcher puts the optional sizes: MapPacks, beside the NavData folder.</summary>
public static string PacksDir => Path.Combine(Path.GetDirectoryName(Dir) ?? Dir, "MapPacks");
/// <summary>The tiers found on the last scan, best first (empty until the first scan finishes).</summary>
public static Tier[] Installed => _installed;
public static bool Scanned => _scanned;
/// <summary>The file found for a tier (the NavData name when none was found, so a status can name it).</summary>
public static string PathOf(Tier t) => _paths.TryGetValue(t.Key, out string? p) ? p : Path.Combine(Dir, t.File);
/// <summary>The tier the setting calls for: that one if installed, else the best installed ("" and null when none).</summary>
public static Tier? Resolve(string preference)
{
Tier[] have = _installed;
if (have.Length == 0) return null;
foreach (Tier t in have) if (t.Key == preference) return t;
return have[0];
}
/// <summary>Scans the folder and (re)opens the chosen file, without touching AC's thread. Any thread.</summary>
public static void Refresh()
{
Task.Run(() =>
{
var found = new List<Tier>();
var paths = new Dictionary<string, string>();
string[] dirs = { PacksDir, Dir }; // a pack the launcher installed, else the one with the RynthNav data
foreach (Tier t in Tiers)
{
foreach (string d in dirs)
{
string f = Path.Combine(d, t.File);
try { if (File.Exists(f)) { found.Add(t); paths[t.Key] = f; break; } } catch { }
}
}
_paths = paths;
_installed = found.ToArray();
_scanned = true;
Apply();
});
}
/// <summary>Opens (or switches to) the file the current setting resolves to.</summary>
public static void Apply()
{
Tier? t = Resolve(WorldMapSettings.Detail);
// Nothing installed: ask for the Standard name, so the faces say "No world map file yet".
string path = t is Tier tier ? PathOf(tier) : PathOf(Tiers[^1]);
if (WorldMapTiles.CurrentPath.Length == 0) WorldMapTiles.Open(path);
else WorldMapTiles.Switch(path);
}
/// <summary>The label of the tier in use ("" until a file is open).</summary>
public static string CurrentLabel
{
get
{
string cur = WorldMapTiles.CurrentPath;
foreach (Tier t in Tiers) if (cur.EndsWith(t.File, StringComparison.OrdinalIgnoreCase)) return t.Label;
return "";
}
}
}

View file

@ -0,0 +1,121 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/WorldMapSettings.cs
// What the World Map and the Mini Map remember: each view's zoom, Follow and Rotate, and the layer
// switches they share (which kinds of place, labels, route, path, grid, other characters).
// Engine-wide, in %LOCALAPPDATA%\RynthCore\world_map_settings.txt, like dungeon_map_settings.txt.
// Zoom changes a lot (every wheel tick), so a change only marks the settings dirty; Draw calls
// FlushIfDue and the file is written (in the background) once nothing has changed for 1.5 s.
// ============================================================================
using System;
using System.Globalization;
using System.IO;
using System.Text;
using RynthCore.Engine.UI;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal static class WorldMapSettings
{
internal sealed class ViewState
{
public float Scale = 1.5f; // screen px per cell
public bool Follow = true, Rotate;
}
public static readonly ViewState Full = new() { Scale = 1.5f, Follow = true, Rotate = false };
public static readonly ViewState Mini = new() { Scale = 2.5f, Follow = true, Rotate = true };
/// <summary>Which kinds of place show (WorldMapView.Kind order).</summary>
public static readonly bool[] Show = { true, true, true, true, true, true, true, true };
/// <summary>Which map picture: a WorldMapMaps tier key ("ultra", "hd", "standard"), or "" for the best installed.</summary>
public static string Detail = "";
public static bool Labels = true, Route = true, WalkPath = true, Grid = true, Characters = true, Buildings = true;
private static readonly object Sync = new();
private static bool _loaded;
private static long _dirtyAtMs; // 0: nothing to write
private static string FilePath =>
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RynthCore", "world_map_settings.txt");
/// <summary>Reads the file once. Engine init thread or any pool thread (not AC's).</summary>
public static void Load()
{
lock (Sync)
{
if (_loaded) return;
_loaded = true;
try
{
if (!File.Exists(FilePath)) return;
foreach (string raw in File.ReadAllLines(FilePath))
{
string line = raw.Trim();
if (line.Length == 0 || line[0] == '#') continue;
int eq = line.IndexOf('=');
if (eq <= 0) continue;
string key = line[..eq].Trim(), val = line[(eq + 1)..].Trim();
bool on = val == "1";
switch (key)
{
case "full.scale": Full.Scale = ParseScale(val, Full.Scale); break;
case "full.follow": Full.Follow = on; break;
case "full.rotate": Full.Rotate = on; break;
case "mini.scale": Mini.Scale = ParseScale(val, Mini.Scale); break;
case "mini.follow": Mini.Follow = on; break;
case "mini.rotate": Mini.Rotate = on; break;
case "detail": Detail = val is "maximum" or "extreme" or "ultra" or "hd" or "standard" ? val : ""; break;
case "labels": Labels = on; break;
case "route": Route = on; break;
case "path": WalkPath = on; break;
case "grid": Grid = on; break;
case "characters": Characters = on; break;
case "buildings": Buildings = on; break;
default:
if (key.StartsWith("show.", StringComparison.Ordinal)
&& int.TryParse(key.AsSpan(5), NumberStyles.Integer, CultureInfo.InvariantCulture, out int k) && (uint)k < (uint)Show.Length)
Show[k] = on;
break;
}
}
}
catch { /* best-effort: the defaults are in place */ }
}
}
private static float ParseScale(string v, float fallback) =>
float.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out float f) && float.IsFinite(f) ? Math.Clamp(f, 0.12f, 14f) : fallback;
/// <summary>Something changed: the file is written when it has been quiet for a moment. Any thread.</summary>
public static void MarkDirty() => _dirtyAtMs = Math.Max(1, Environment.TickCount64);
/// <summary>AC's render thread, once a frame: writes the file if a change has settled.</summary>
public static void FlushIfDue()
{
long at = _dirtyAtMs;
if (at == 0 || Environment.TickCount64 - at < 1500) return;
_dirtyAtMs = 0;
var sb = new StringBuilder("# RynthCore world map settings - auto-generated, hand-edits OK.\n");
void Flag(string k, bool v) => sb.Append(k).Append('=').Append(v ? '1' : '0').Append('\n');
sb.Append(CultureInfo.InvariantCulture, $"full.scale={Full.Scale:0.###}\n"); Flag("full.follow", Full.Follow); Flag("full.rotate", Full.Rotate);
sb.Append(CultureInfo.InvariantCulture, $"mini.scale={Mini.Scale:0.###}\n"); Flag("mini.follow", Mini.Follow); Flag("mini.rotate", Mini.Rotate);
for (int i = 0; i < Show.Length; i++) Flag("show." + i, Show[i]);
sb.Append("detail=").Append(Detail).Append((char)10);
Flag("labels", Labels); Flag("route", Route); Flag("path", WalkPath); Flag("grid", Grid); Flag("characters", Characters); Flag("buildings", Buildings);
string text = sb.ToString();
UiBackgroundWriter.Enqueue("world map settings", () =>
{
lock (Sync)
{
try
{
string? dir = Path.GetDirectoryName(FilePath);
if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);
File.WriteAllText(FilePath, text);
}
catch { /* non-fatal */ }
}
});
}
}

View file

@ -0,0 +1,833 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/WorldMapView.cs
// The map itself, drawn into a rectangle by the World Map face (full: toolbar, find box) and the
// Mini Map face (a small follow-you view). One class so both look and behave the same.
//
// The picture is NavData\worldmap.rmap (WorldMapTiles; RynthNav.Baker --map --map-tiles renders it
// from client_cell_1.dat): a pyramid of 256 px tiles, so zooming in loads sharper tiles under the
// view and the coarser ones already loaded show meanwhile.
//
// On it (bottom to top): the tiles; a coordinate grid with edge labels; RynthNav's route (legs
// between its steps, a dashed jump for a portal / recall / Town Network step, the current step
// ringed) and the walking path it worked out; the Atlas's places (each kind from its own zoom,
// labels from a closer one, none that would overlap one already drawn); your other characters
// (RynthNet); a search highlight; the arrow's target; you (an arrow while RynthAi's radar feed
// gives a heading, a dot from RynthNav alone, dimmed at the last outdoor spot while indoors).
//
// Rotate turns the map so the way you face is up (the arrow points up, the compass shows north).
// Drag pans (and turns Follow off), the wheel zooms about the cursor. A click (full) or a right
// click (both) on the map or a place opens a menu: Go here, Route here, Arrow here, Copy
// coordinates (RynthNav's commands, RynthNavCommands).
//
// Coordinates: a "cell" is 24 yards, 10 per map degree: cell = degrees * 10 + 1019.5 on each axis
// (the same numbers as NavCoords). The map works in cell units; the picture is cells * PixelsPerCell.
// Screen = centre + R(phi) * (east, -north) * scale, phi = heading - 90 degrees when rotating.
//
// Data (subscribed by the faces while open): UiSources.RynthNav (position, route, arrow, path),
// UiSources.Radar (heading), UiSources.Characters (other characters, when that layer is on).
// ============================================================================
using System;
using System.Collections.Generic;
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;
/// <summary>Where you are, for the toolbar and the view: this frame's reading, with the last outdoor spot kept.</summary>
internal readonly struct MapPlayer
{
public MapPlayer(bool have, double ns, double ew, float heading, bool indoors, double lastNs, double lastEw)
{ Have = have; Ns = ns; Ew = ew; Heading = heading; Indoors = indoors; LastNs = lastNs; LastEw = lastEw; }
/// <summary>An outdoor position this frame.</summary>
public readonly bool Have;
public readonly double Ns, Ew;
public readonly float Heading; // degrees, 0 = east, 90 = north; NaN when only RynthNav's pose is known
public readonly bool Indoors;
public readonly double LastNs, LastEw; // the last outdoor spot (NaN: never outdoors this session)
public bool Known => Have || !double.IsNaN(LastNs);
public double ShowNs => Have ? Ns : LastNs;
public double ShowEw => Have ? Ew : LastEw;
}
internal sealed class WorldMapView
{
public enum Kind { Town, Landmark, Dungeon, Lifestone, Bindstone, Portal, Vendor, Npc, Count }
public static readonly string[] KindNames = { "Towns", "Landmarks", "Dungeons", "Lifestones", "Bindstones", "Portals", "Vendors", "NPCs" };
// ── Constants ────────────────────────────────────────────────────────
public const double Origin = 1019.5; // cell = degrees * 10 + Origin
public const float MinScale = 0.12f, MaxScale = 14f, AbsMaxScale = 160f; // screen px per cell
/// <summary>How far in the open map is worth zooming: a sharper map (more pixels per cell) allows more, up to 1.25x its own detail.</summary>
private static float MaxScaleNow => WorldMapTiles.IsOpen ? Math.Clamp(WorldMapTiles.PixelsPerCell * 1.25f, MaxScale, AbsMaxScale) : MaxScale;
private static readonly float[] ShowFrom = { 0f, 1.2f, 1.0f, 2.0f, 2.0f, 3.0f, 5.0f, 6.0f };
private static readonly float[] LabelFrom = { 0.45f, 3f, 2.5f, 5f, 5f, 6f, 8f, 10f };
private static readonly uint OceanBg = RynthTheme.Argb(0xFF1C4276);
private static readonly uint[] KindColour =
{
RynthTheme.Argb(0xFFFFD24D), RynthTheme.Argb(0xFFFFFFFF), RynthTheme.Argb(0xFFC77DFF), RynthTheme.Argb(0xFF5CE1E6),
RynthTheme.Argb(0xFF3DDC97), RynthTheme.Argb(0xFFFF6BD6), RynthTheme.Argb(0xFFFF9F43), RynthTheme.Argb(0xFFF2F2A0),
};
private static readonly uint LabelCol = RynthTheme.Argb(0xFFF4F7FA), LabelHalo = RynthTheme.Argb(0xE0000000),
RouteCol = RynthTheme.Argb(0xFFFFA733), RouteActive = RynthTheme.Argb(0xFFFFF04D), PathCol = RynthTheme.Argb(0xFF5AD2FF),
TargetCol = RynthTheme.Argb(0xFF4DD2FF), PlayerFill = RynthTheme.Argb(0xFF33FF66), PlayerEdge = RynthTheme.Argb(0xFF0A2A12),
CharCol = RynthTheme.Argb(0xFF6EA8FF), HintCol = RynthTheme.Argb(0xFF9FB3C8), BarBg = RynthTheme.Argb(0xE00A121A),
RoadCol = RynthTheme.Argb(0xFFE6CD78), RoadHalo = RynthTheme.Argb(0xB0301C08), BuildFill = RynthTheme.Argb(0xFF9A4B40),
BuildEdge = RynthTheme.Argb(0xFF2A1410), GridLine = RynthTheme.Argb(0x30FFFFFF), GridLabel = RynthTheme.Argb(0xC0DDE8F4), HighlightCol = RynthTheme.Argb(0xFFFFFFFF);
// ── Places (shared by every view; rebuilt when the Atlas reloads) ────
private readonly struct Mark
{
public Mark(float cx, float cy, string name, Kind kind, NavPlace place) { Cx = cx; Cy = cy; Name = name; Kind = kind; Place = place; }
public readonly float Cx, Cy;
public readonly string Name;
public readonly Kind Kind;
public readonly NavPlace Place;
}
private static Mark[]? _marks;
private static long _marksVersion = -1;
private static double _lastNs = double.NaN, _lastEw = double.NaN; // the last outdoor spot, shared by both views
public static double CellOf(double degrees) => degrees * 10.0 + Origin;
public static double DegreesOf(double cell) => (cell - Origin) / 10.0;
// ── This view ────────────────────────────────────────────────────────
public readonly bool Mini;
private readonly WorldMapSettings.ViewState _st;
private double _ccx = 1019.5, _ccy = 1019.5; // map cell at the canvas centre
private bool _fitNext, _centreNext;
private Vector2 _centre;
private float _phi; // the map's rotation this frame (radians)
private float _scale;
private MapProjection Proj => new(_centre, _ccx, _ccy, _scale, _phi);
public float Scale => _scale;
public bool Follow { get => _st.Follow; set { if (_st.Follow != value) { _st.Follow = value; WorldMapSettings.MarkDirty(); } } }
public bool Rotate { get => _st.Rotate; set { if (_st.Rotate != value) { _st.Rotate = value; WorldMapSettings.MarkDirty(); } } }
/// <summary>The line the toolbar shows for the point under the cursor ("" when none).</summary>
public string HoverText { get; private set; } = "";
/// <summary>A screen rectangle the face has covered (a dropdown): the map ignores the mouse inside it.</summary>
public (Vector2 Min, Vector2 Max)? Blocked;
// Interaction.
private bool _pressing, _pressMoved;
private int _hoverMark = -1, _hoverChar = -1;
private double _ctxNs, _ctxEw;
private string _ctxName = "";
private bool _openCtx;
private readonly string _ctxId;
private string _hiName = "";
private double _hiNs, _hiEw;
private long _hiUntilMs;
private readonly List<(Vector2 Min, Vector2 Max)> _labelRects = new(128);
private readonly List<(Vector2 Pos, int Index)> _drawn = new(256);
private readonly List<(Vector2 Pos, int Index)> _drawnChars = new(16);
private readonly List<(int Dist, int Col, int Row)> _tileOrder = new(128);
private CharacterRow[] _chars = Array.Empty<CharacterRow>();
public WorldMapView(bool mini)
{
Mini = mini;
_st = mini ? WorldMapSettings.Mini : WorldMapSettings.Full;
_scale = Math.Clamp(_st.Scale, MinScale, AbsMaxScale);
_ctxId = mini ? "##mm_ctx" : "##wm_ctx";
}
// ── Commands from the face ───────────────────────────────────────────
public void FitWorld() { _fitNext = true; }
public void ZoomBy(float k, Vector2? about = null)
{
float old = _scale;
float next = Math.Clamp(_scale * k, MinScale, MaxScaleNow);
if (next == old) return;
if (about is Vector2 m && !_st.Follow)
(_ccx, _ccy) = Proj.CentreForZoomAbout(m, next);
_scale = next;
_st.Scale = _scale;
WorldMapSettings.MarkDirty();
}
/// <summary>Centres on a map point (degrees), zooming in to at least <paramref name="minScale"/>, and rings it for a few seconds.</summary>
public void Show(string name, double ns, double ew, float minScale)
{
Follow = false;
_ccx = CellOf(ew); _ccy = CellOf(ns);
if (_scale < minScale) { _scale = Math.Min(minScale, MaxScaleNow); _st.Scale = _scale; WorldMapSettings.MarkDirty(); }
_hiName = name; _hiNs = ns; _hiEw = ew;
_hiUntilMs = Environment.TickCount64 + 6000;
}
// ── Projection (MapProjection) ───────────────────────────────────────
private Vector2 Project(double cx, double cy) => Proj.Project(cx, cy);
private Vector2 ProjectDeg(double ns, double ew) => Proj.Project(CellOf(ew), CellOf(ns));
private void Unproject(Vector2 p, out double cx, out double cy) => Proj.Unproject(p, out cx, out cy);
private Vector2 ScreenDir(float east, float north) => Proj.ScreenDir(east, north);
// ── Player ───────────────────────────────────────────────────────────
/// <summary>Reads where you are: the radar feed (heading), else RynthNav's pose. Indoors keeps the last outdoor spot.</summary>
public static MapPlayer GatherPlayer(RynthNavStatus? st, RadarView? radar)
{
double ns = double.NaN, ew = double.NaN;
float heading = float.NaN;
bool indoors = false;
if (radar != null)
{
indoors = radar.Live.IsIndoor;
if (!indoors && !double.IsNaN(radar.Live.Ns) && !double.IsNaN(radar.Live.Ew)) { ns = radar.Live.Ns; ew = radar.Live.Ew; heading = radar.Live.Player.Heading; }
}
if (double.IsNaN(ns) && st != null && st.HasPose)
{
indoors = indoors || st.Indoors;
if (!st.Indoors) { ns = st.NS; ew = st.EW; }
}
if (!double.IsNaN(ns)) { _lastNs = ns; _lastEw = ew; }
return new MapPlayer(!double.IsNaN(ns), ns, ew, heading, indoors, _lastNs, _lastEw);
}
// ── The frame ────────────────────────────────────────────────────────
/// <summary>Draws the map into the canvas and handles its input. AC's render thread, inside a face's Draw.</summary>
public void Draw(Vector2 canvasMin, Vector2 canvasMax, in MapPlayer pl, RynthNavStatus? st, CharacterRow[]? chars)
{
var dl = ImGuiNET.ImGui.GetWindowDrawList();
Vector2 csize = canvasMax - canvasMin;
if (csize.X < 40 || csize.Y < 40) return;
_centre = (canvasMin + canvasMax) * 0.5f;
_chars = chars ?? Array.Empty<CharacterRow>();
if (_fitNext)
{
_fitNext = false;
Follow = false; Rotate = false;
_scale = Math.Clamp(Math.Min(csize.X, csize.Y) / (float)WorldMapTiles.CellsHigh, MinScale, MaxScale);
_st.Scale = _scale;
_ccx = WorldMapTiles.CellsWide * 0.5; _ccy = WorldMapTiles.CellsHigh * 0.5;
WorldMapSettings.MarkDirty();
}
if (_scale > MaxScaleNow) { _scale = MaxScaleNow; _st.Scale = _scale; }
_phi = _st.Rotate && !float.IsNaN(pl.Heading) && pl.Have ? MapProjection.PhiForHeading(pl.Heading) : 0f;
if (_st.Follow && pl.Known) { _ccx = CellOf(pl.ShowEw); _ccy = CellOf(pl.ShowNs); }
dl.AddRectFilled(canvasMin, canvasMax, OceanBg);
dl.PushClipRect(canvasMin, canvasMax, true);
DrawTiles(dl, canvasMin, canvasMax);
_labelRects.Clear(); _drawn.Clear(); _drawnChars.Clear();
if (WorldMapSettings.Grid) DrawGrid(dl, canvasMin, canvasMax, _phi != 0f);
if (WorldMapSettings.Buildings) DrawVectors(dl, canvasMin, canvasMax);
if (WorldMapSettings.Route) DrawRoute(dl, st, pl);
DrawMarkers(dl, canvasMin, canvasMax);
if (WorldMapSettings.Characters) DrawCharacters(dl, canvasMin, canvasMax);
DrawHighlight(dl);
DrawTarget(dl, st);
DrawPlayer(dl, pl);
dl.PopClipRect();
dl.AddRect(canvasMin, canvasMax, BtnBord);
DrawScaleBar(dl, canvasMin, canvasMax);
DrawCompass(dl, canvasMax);
if (!WorldMapTiles.IsOpen || WorldMapTiles.Levels.Count == 0)
DrawCentred(dl, _centre, WorldMapTiles.Status.Length > 0 ? WorldMapTiles.Status : "Loading the map...");
else if (pl.Indoors && !pl.Have && pl.Known && _st.Follow)
DrawCentred(dl, new Vector2(_centre.X, canvasMin.Y + 20), "Indoors: the map shows where you went in.");
else if (!pl.Known && _st.Follow)
DrawCentred(dl, new Vector2(_centre.X, canvasMin.Y + 20), "Waiting for your position...");
Input(canvasMin, canvasMax, pl);
DrawContextMenu();
}
// ── Tiles ────────────────────────────────────────────────────────────
private void DrawTiles(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
{
var levels = WorldMapTiles.Levels;
if (!WorldMapTiles.IsOpen || levels.Count == 0) return;
int ppc0 = WorldMapTiles.PixelsPerCell, top = levels.Count - 1;
double cellsHigh = WorldMapTiles.CellsHigh;
// The map area in view: the canvas as it is, or (turned) the circle around it.
double halfW = (canvasMax.X - canvasMin.X) * 0.5, halfH = (canvasMax.Y - canvasMin.Y) * 0.5;
if (_phi != 0f) { halfW = halfH = Math.Sqrt(halfW * halfW + halfH * halfH); }
double cxMin = _ccx - halfW / _scale, cxMax = _ccx + halfW / _scale;
double cyMin = _ccy - halfH / _scale, cyMax = _ccy + halfH / _scale;
// The sharpest level whose pixels are at least as dense as the screen's; a coarser one if that is too many tiles.
int L = Math.Clamp((int)Math.Floor(Math.Log2(ppc0 / (double)_scale)), 0, top);
while (L < top && VisibleTiles(L, ppc0, cellsHigh, cxMin, cxMax, cyMin, cyMax) > 80) L++;
// Coarse to fine: the top level (always loaded) first, so whatever hasn't arrived shows blurry, not blank.
for (int lv = top; lv >= L; lv--)
DrawLevel(dl, lv, ppc0, cellsHigh, cxMin, cxMax, cyMin, cyMax, request: lv <= Math.Min(top, L + 1));
}
private static int VisibleTiles(int lv, int ppc0, double cellsHigh, double cxMin, double cxMax, double cyMin, double cyMax)
{
double cpt = WorldMapTiles.TileSize * (double)(1 << lv) / ppc0;
int cols = (int)Math.Floor(Math.Min(cxMax, WorldMapTiles.CellsWide) / cpt) - (int)Math.Floor(Math.Max(cxMin, 0) / cpt) + 1;
int rows = (int)Math.Floor((cellsHigh - Math.Max(cyMin, 0)) / cpt) - (int)Math.Floor((cellsHigh - Math.Min(cyMax, cellsHigh)) / cpt) + 1;
return Math.Max(cols, 0) * Math.Max(rows, 0);
}
private void DrawLevel(ImDrawListPtr dl, int lv, int ppc0, double cellsHigh, double cxMin, double cxMax, double cyMin, double cyMax, bool request)
{
var lvl = WorldMapTiles.Levels[lv];
double cpt = WorldMapTiles.TileSize * (double)(1 << lv) / ppc0;
int c0 = Math.Max(0, (int)Math.Floor(cxMin / cpt)), c1 = Math.Min(lvl.Cols - 1, (int)Math.Floor(cxMax / cpt));
int r0 = Math.Max(0, (int)Math.Floor((cellsHigh - cyMax) / cpt)), r1 = Math.Min(lvl.Rows - 1, (int)Math.Floor((cellsHigh - cyMin) / cpt));
if (c1 < c0 || r1 < r0) return;
// Centre-out, so the tiles you're looking at load first.
_tileOrder.Clear();
double ccol = _ccx / cpt, crow = (cellsHigh - _ccy) / cpt;
for (int r = r0; r <= r1; r++)
for (int c = c0; c <= c1; c++)
{
double dx = c + 0.5 - ccol, dy = r + 0.5 - crow;
_tileOrder.Add(((int)((dx * dx + dy * dy) * 1000), c, r));
}
_tileOrder.Sort(static (a, b) => a.Dist.CompareTo(b.Dist));
bool turned = _phi != 0f;
for (int i = _tileOrder.Count - 1; i >= 0; i--) // draw far to near; nothing overlaps within a level
{
var (_, c, r) = _tileOrder[i];
IntPtr tex;
if (!(request ? WorldMapTiles.TryGet(lv, c, r, out tex) : WorldMapTiles.Peek(lv, c, r, out tex))) continue;
double left = c * cpt, right = (c + 1) * cpt, topCell = cellsHigh - r * cpt, bottomCell = cellsHigh - (r + 1) * cpt;
if (!turned)
{
// Edges from the same formula for both neighbours, rounded to whole pixels: no seams, no gaps.
float x0 = MathF.Round(_centre.X + (float)((left - _ccx) * _scale)), x1 = MathF.Round(_centre.X + (float)((right - _ccx) * _scale));
float y0 = MathF.Round(_centre.Y - (float)((topCell - _ccy) * _scale)), y1 = MathF.Round(_centre.Y - (float)((bottomCell - _ccy) * _scale));
dl.AddImage(tex, new Vector2(x0, y0), new Vector2(x1, y1));
}
else
{
// Turned: a quad, grown by a pixel so neighbours overlap instead of showing a hairline.
Vector2 tl = Project(left, topCell), tr = Project(right, topCell), br = Project(right, bottomCell), bl = Project(left, bottomCell);
Vector2 mid = (tl + br) * 0.5f;
tl = Grow(tl, mid); tr = Grow(tr, mid); br = Grow(br, mid); bl = Grow(bl, mid);
dl.AddImageQuad(tex, tl, tr, br, bl, new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1));
}
}
}
private static Vector2 Grow(Vector2 p, Vector2 mid)
{
Vector2 d = p - mid;
float len = d.Length();
return len < 1f ? p : p + d / len * 0.8f;
}
// ── Grid ─────────────────────────────────────────────────────────────
private void DrawGrid(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax, bool turned)
{
float pxPerDeg = 10f * _scale;
float[] steps = { 50f, 20f, 10f, 5f, 2f, 1f, 0.5f, 0.2f, 0.1f, 0.05f };
float step = steps[0];
foreach (float s in steps) if (s * pxPerDeg >= 90f) step = s;
if (step * pxPerDeg < 40f) return;
double halfW = (canvasMax.X - canvasMin.X) * 0.5, halfH = (canvasMax.Y - canvasMin.Y) * 0.5;
double r = Math.Sqrt(halfW * halfW + halfH * halfH) / _scale; // cells, the circle around the canvas
double nsMin = DegreesOf(_ccy - r), nsMax = DegreesOf(_ccy + r), ewMin = DegreesOf(_ccx - r), ewMax = DegreesOf(_ccx + r);
string fmt = step >= 1f ? "0" : step >= 0.1f ? "0.0" : "0.00";
int lines = 0;
for (double ns = Math.Ceiling(nsMin / step) * step; ns <= nsMax && lines < 60; ns += step, lines++)
{
Vector2 a = ProjectDeg(ns, ewMin), b = ProjectDeg(ns, ewMax);
dl.AddLine(a, b, GridLine, 1f);
if (!turned) EdgeLabel(dl, new Vector2(canvasMin.X + 4, a.Y - 14), canvasMin, canvasMax, Fmt(ns, fmt, 'N', 'S'));
}
for (double ew = Math.Ceiling(ewMin / step) * step; ew <= ewMax && lines < 120; ew += step, lines++)
{
Vector2 a = ProjectDeg(nsMin, ew), b = ProjectDeg(nsMax, ew);
dl.AddLine(a, b, GridLine, 1f);
if (!turned) EdgeLabel(dl, new Vector2(a.X + 3, canvasMin.Y + 3), canvasMin, canvasMax, Fmt(ew, fmt, 'E', 'W'));
}
}
private static string Fmt(double v, string fmt, char pos, char neg) =>
Math.Abs(v).ToString(fmt, CultureInfo.InvariantCulture) + (v >= 0 ? pos : neg);
private static void EdgeLabel(ImDrawListPtr dl, Vector2 at, Vector2 min, Vector2 max, string text)
{
if (at.X < min.X || at.Y < min.Y || at.X > max.X - 30 || at.Y > max.Y - 14) return;
dl.AddText(at + new Vector2(1, 1), LabelHalo, text);
dl.AddText(at, GridLabel, text);
}
// ── Roads and buildings (WorldMapVectors) ────────────────────────────
private const float RoadsFrom = 1.5f, BuildingsFrom = 3f;
private readonly Vector2[] _poly = new Vector2[16];
private void DrawVectors(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
{
if (_scale < RoadsFrom) return;
if (WorldMapTiles.IsOpen && WorldMapTiles.PixelsPerCell >= 8) return; // HD and up have the roads and the real roofs in the picture
WorldMapVectors.Data? v = WorldMapVectors.Current;
if (v == null) return;
// The map area in view, in cells (the circle around the canvas when turned).
double halfW = (canvasMax.X - canvasMin.X) * 0.5, halfH = (canvasMax.Y - canvasMin.Y) * 0.5;
if (_phi != 0f) halfW = halfH = Math.Sqrt(halfW * halfW + halfH * halfH);
float xMin = (float)(_ccx - halfW / _scale) - 1, xMax = (float)(_ccx + halfW / _scale) + 1;
float yMin = (float)(_ccy - halfH / _scale) - 1, yMax = (float)(_ccy + halfH / _scale) + 1;
// Roads: a dark under-stroke and the road colour over it; wider as you zoom in.
float w = Math.Clamp(_scale * 0.4f, 1.5f, 6f);
ushort[] roads = v.Roads;
int visible = 0;
for (int i = 0; i + 3 < roads.Length && visible < 6000; i += 4)
{
float x0 = roads[i], y0 = roads[i + 1], x1 = roads[i + 2], y1 = roads[i + 3];
if ((x0 < xMin && x1 < xMin) || (x0 > xMax && x1 > xMax) || (y0 < yMin && y1 < yMin) || (y0 > yMax && y1 > yMax)) continue;
visible++;
Vector2 a = Project(x0, y0), b = Project(x1, y1);
dl.AddLine(a, b, RoadHalo, w + 1.5f);
}
visible = 0;
for (int i = 0; i + 3 < roads.Length && visible < 6000; i += 4)
{
float x0 = roads[i], y0 = roads[i + 1], x1 = roads[i + 2], y1 = roads[i + 3];
if ((x0 < xMin && x1 < xMin) || (x0 > xMax && x1 > xMax) || (y0 < yMin && y1 < yMin) || (y0 > yMax && y1 > yMax)) continue;
visible++;
dl.AddLine(Project(x0, y0), Project(x1, y1), RoadCol, w);
}
if (_scale < BuildingsFrom) return;
for (int i = 0; i < v.Buildings.Length; i++)
{
Vector4 bb = v.BuildingBounds[i];
if (bb.Z < xMin || bb.X > xMax || bb.W < yMin || bb.Y > yMax) continue;
Vector2[] pts = v.Buildings[i];
int n = Math.Min(pts.Length, _poly.Length);
if (n < 3) continue;
float area = 0;
for (int k = 0; k < n; k++)
{
Vector2 p = Project(pts[k].X, pts[k].Y);
_poly[k] = p;
}
for (int k = 0; k < n; k++) { Vector2 a = _poly[k], b = _poly[(k + 1) % n]; area += a.X * b.Y - b.X * a.Y; }
if (area < 0) Array.Reverse(_poly, 0, n); // ImGui wants one winding; the flip of y makes it vary
dl.AddConvexPolyFilled(ref _poly[0], n, BuildFill);
for (int k = 0; k < n; k++) dl.AddLine(_poly[k], _poly[(k + 1) % n], BuildEdge, 1.2f);
}
}
// ── Places ───────────────────────────────────────────────────────────
private static void EnsureMarks()
{
long v = RynthNavAtlas.Version;
if (_marks != null && v == _marksVersion) return;
var list = new List<Mark>(8192);
foreach (NavPlace p in RynthNavAtlas.Places)
{
if (!p.OnMap || double.IsNaN(p.Ns) || double.IsNaN(p.Ew)) continue;
Kind k;
switch (p.Type)
{
case "Town": k = Kind.Town; break;
case "Landmark": k = Kind.Landmark; break;
case "Dungeon": k = Kind.Dungeon; break;
case "Lifestone": k = Kind.Lifestone; break;
case "Bindstone": k = Kind.Bindstone; break;
case "Portal": k = Kind.Portal; break;
case "Vendor": k = Kind.Vendor; break;
case "NPC": k = Kind.Npc; break;
default: continue;
}
list.Add(new Mark((float)CellOf(p.Ew), (float)CellOf(p.Ns), p.Name, k, p));
}
_marks = list.ToArray();
_marksVersion = v;
}
/// <summary>The Atlas's surface places whose name has <paramref name="query"/> in it, towns and dungeons first. Any thread.</summary>
public static List<NavPlace> Find(string query, int max)
{
var res = new List<(int Rank, NavPlace Place)>();
if (query.Length == 0) return new List<NavPlace>();
foreach (NavPlace p in RynthNavAtlas.Places)
{
if (!p.OnMap || p.Name.Length == 0) continue;
int at = p.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase);
if (at < 0) continue;
int kind = p.Type switch { "Town" => 0, "Dungeon" => 1, "Landmark" => 2, "Lifestone" => 3, "Bindstone" => 3, "Portal" => 4, _ => 5 };
res.Add((kind * 1000 + (at == 0 ? 0 : 400) + Math.Min(p.Name.Length, 399), p));
}
res.Sort(static (a, b) => a.Rank.CompareTo(b.Rank));
var list = new List<NavPlace>(Math.Min(max, res.Count));
for (int i = 0; i < res.Count && list.Count < max; i++) list.Add(res[i].Place);
return list;
}
private void DrawMarkers(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
{
EnsureMarks();
Mark[]? marks = _marks;
if (marks == null) return;
float s = _scale;
// Towns first (they win a label overlap), then the rest in kind order.
for (int pass = 0; pass < (int)Kind.Count; pass++)
{
if (!WorldMapSettings.Show[pass] || s < ShowFrom[pass]) continue;
uint col = KindColour[pass];
float rad = pass == (int)Kind.Town ? 5f : pass is (int)Kind.Npc or (int)Kind.Vendor ? 2.5f : 3.5f;
bool label = WorldMapSettings.Labels && s >= LabelFrom[pass];
for (int i = 0; i < marks.Length; i++)
{
ref readonly Mark m = ref marks[i];
if ((int)m.Kind != pass) continue;
Vector2 pt = Project(m.Cx, m.Cy);
if (pt.X < canvasMin.X - 40 || pt.X > canvasMax.X + 40 || pt.Y < canvasMin.Y - 12 || pt.Y > canvasMax.Y + 12) continue;
_drawn.Add((pt, i));
bool hot = i == _hoverMark;
DrawMarkShape(dl, pt, m.Kind, col, hot ? rad + 1.5f : rad);
if (label || hot) DrawLabel(dl, pt, m.Name, rad, hot);
}
}
}
private static void DrawMarkShape(ImDrawListPtr dl, Vector2 p, Kind k, uint col, float r)
{
switch (k)
{
case Kind.Dungeon:
dl.AddQuadFilled(p + new Vector2(0, -r - 1), p + new Vector2(r + 1, 0), p + new Vector2(0, r + 1), p + new Vector2(-r - 1, 0), col);
dl.AddQuad(p + new Vector2(0, -r - 1), p + new Vector2(r + 1, 0), p + new Vector2(0, r + 1), p + new Vector2(-r - 1, 0), LabelHalo, 1f);
break;
case Kind.Town:
dl.AddCircleFilled(p, r + 1, LabelHalo);
dl.AddCircleFilled(p, r, col);
dl.AddCircleFilled(p, r - 2.5f, LabelHalo);
break;
default:
dl.AddCircleFilled(p, r + 1, LabelHalo);
dl.AddCircleFilled(p, r, col);
break;
}
}
private void DrawLabel(ImDrawListPtr dl, Vector2 pt, string text, float rad, bool force, uint? colour = null)
{
if (text.Length == 0) return;
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(text);
var min = new Vector2(pt.X + rad + 4, pt.Y - ts.Y * 0.5f);
var max = min + ts;
if (!force)
{
for (int i = 0; i < _labelRects.Count; i++)
{
var (a, b) = _labelRects[i];
if (min.X < b.X + 2 && max.X > a.X - 2 && min.Y < b.Y && max.Y > a.Y) return;
}
}
_labelRects.Add((min, max));
dl.AddText(min + new Vector2(1, 1), LabelHalo, text);
dl.AddText(min + new Vector2(-1, 1), LabelHalo, text);
dl.AddText(min, force ? Text : colour ?? LabelCol, text);
}
// ── Other characters (RynthNet) ──────────────────────────────────────
private void DrawCharacters(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
{
for (int i = 0; i < _chars.Length; i++)
{
CharacterRow c = _chars[i];
if (c.IsSelf || c.LoggedOut || !c.HasMap) continue;
Vector2 p = ProjectDeg(c.MapNs, c.MapEw);
if (p.X < canvasMin.X - 60 || p.X > canvasMax.X + 60 || p.Y < canvasMin.Y - 12 || p.Y > canvasMax.Y + 12) continue;
_drawnChars.Add((p, i));
uint col = c.Stale ? (CharCol & 0x00FFFFFF) | 0x80000000u : CharCol;
var tri = new[] { p + new Vector2(0, -6), p + new Vector2(5.5f, 4), p + new Vector2(-5.5f, 4) };
dl.AddTriangleFilled(tri[0], tri[1], tri[2], col);
dl.AddTriangle(tri[0], tri[1], tri[2], LabelHalo, 1.5f);
DrawLabel(dl, p, c.Name, 6f, i == _hoverChar, CharCol);
}
}
// ── Route, path, target, highlight, player ───────────────────────────
private void DrawRoute(ImDrawListPtr dl, RynthNavStatus? st, in MapPlayer pl)
{
if (st == null) return;
bool haveFrom = pl.Known;
// The walking path RynthNav worked out (when it sends one): a line under the route's dots, a segment per walk.
bool havePath = WorldMapSettings.WalkPath && st.PathSegments.Length > 0;
if (havePath)
{
foreach (float[] seg in st.PathSegments)
{
Vector2 prevP = ProjectDeg(seg[0], seg[1]);
for (int i = 2; i + 1 < seg.Length; i += 2)
{
Vector2 q = ProjectDeg(seg[i], seg[i + 1]);
dl.AddLine(prevP, q, LabelHalo, 4f);
dl.AddLine(prevP, q, PathCol, 2.5f);
prevP = q;
}
}
}
if (st.Route.Length > 0)
{
Vector2 prev = haveFrom ? ProjectDeg(pl.ShowNs, pl.ShowEw) : default;
bool havePrev = haveFrom;
for (int i = 0; i < st.Route.Length; i++)
{
RynthNavRouteStep step = st.Route[i];
bool jump = step.Kind is "recall" or "portal" or "town";
bool hasHere = step.Kind != "recall" && !(step.Ns == 0 && step.Ew == 0);
uint col = i == st.RouteIdx ? RouteActive : RouteCol;
if (hasHere)
{
Vector2 p = ProjectDeg(step.Ns, step.Ew);
if (havePrev && !havePath) dl.AddLine(prev, p, col, 2f); // straight legs only without a real path
DrawStepDot(dl, p, col, i == st.RouteIdx, jump);
prev = p; havePrev = true;
}
if (jump && step.HasLanding)
{
Vector2 q = ProjectDeg(step.LandNs, step.LandEw);
if (havePrev) DashedLine(dl, prev, q, col);
DrawStepDot(dl, q, col, false, false);
prev = q; havePrev = true;
}
}
}
}
private void DrawTarget(ImDrawListPtr dl, RynthNavStatus? st)
{
RynthNavArrow? ar = st?.Arrow;
if (ar == null || !ar.OnMap) return;
Vector2 t = ProjectDeg(ar.Ns, ar.Ew);
dl.AddCircle(t, 8f, LabelHalo, 24, 4f);
dl.AddCircle(t, 8f, TargetCol, 24, 2f);
dl.AddCircleFilled(t, 2.5f, TargetCol);
}
private void DrawHighlight(ImDrawListPtr dl)
{
long left = _hiUntilMs - Environment.TickCount64;
if (left <= 0) return;
Vector2 p = ProjectDeg(_hiNs, _hiEw);
float pulse = 10f + 5f * MathF.Sin(Environment.TickCount64 * 0.008f);
uint a = (uint)Math.Clamp(left / 6000f * 255f * 1.5f, 0, 255);
uint col = (HighlightCol & 0x00FFFFFF) | (a << 24);
dl.AddCircle(p, pulse + 1.5f, LabelHalo & 0x00FFFFFF | (a << 24), 28, 5f);
dl.AddCircle(p, pulse, col, 28, 2.5f);
if (_hiName.Length > 0) DrawLabel(dl, p, _hiName, pulse, true);
}
private static void DrawStepDot(ImDrawListPtr dl, Vector2 p, uint col, bool current, bool jump)
{
dl.AddCircleFilled(p, 4.5f, LabelHalo);
dl.AddCircleFilled(p, jump ? 3.5f : 3f, col);
if (current) dl.AddCircle(p, 8f, col, 20, 2f);
}
private static void DashedLine(ImDrawListPtr dl, Vector2 a, Vector2 b, uint col)
{
Vector2 d = b - a;
float len = d.Length();
if (len < 1f || len > 20000f) return;
Vector2 u = d / len;
for (float t = 0; t < len; t += 12f)
dl.AddLine(a + u * t, a + u * Math.Min(t + 6f, len), col, 2f);
}
private void DrawPlayer(ImDrawListPtr dl, in MapPlayer pl)
{
if (!pl.Known) return;
Vector2 p = ProjectDeg(pl.ShowNs, pl.ShowEw);
uint fill = pl.Have ? PlayerFill : (PlayerFill & 0x00FFFFFF) | 0x80000000u;
if (pl.Have && !float.IsNaN(pl.Heading))
{
float h = pl.Heading * MathF.PI / 180f; // AC: 0 = east, 90 = north
Vector2 fwd = ScreenDir(MathF.Cos(h), MathF.Sin(h));
var side = new Vector2(-fwd.Y, fwd.X);
Vector2 tip = p + fwd * 10f, l = p - fwd * 6f + side * 6f, r = p - fwd * 6f - side * 6f, back = p - fwd * 2.5f;
dl.AddTriangleFilled(tip, l, back, fill);
dl.AddTriangleFilled(tip, back, r, fill);
dl.AddTriangle(tip, l, r, PlayerEdge, 1.5f);
}
else
{
dl.AddCircleFilled(p, 6f, PlayerEdge);
dl.AddCircleFilled(p, 4.5f, fill);
}
if (pl.Indoors && !pl.Have) dl.AddCircle(p, 10f, fill, 24, 1.5f);
}
// ── Furniture ────────────────────────────────────────────────────────
private void DrawScaleBar(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
{
// A cell is 24 yards: pick the roundest length under ~140 px (90 on the mini map).
float limit = Mini ? 90f : 140f;
float[] yards = { 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000 };
float best = yards[0];
foreach (float y in yards) if (y / 24f * _scale <= limit) best = y;
float px = best / 24f * _scale;
var a = new Vector2(canvasMin.X + 12, canvasMax.Y - 14);
var b = new Vector2(a.X + px, a.Y);
dl.AddLine(a + new Vector2(1, 1), b + new Vector2(1, 1), LabelHalo, 3f);
dl.AddLine(a, b, LabelCol, 2f);
dl.AddLine(a + new Vector2(0, -4), a + new Vector2(0, 2), LabelCol, 2f);
dl.AddLine(b + new Vector2(0, -4), b + new Vector2(0, 2), LabelCol, 2f);
string t = best >= 1000 ? (best / 1000).ToString("0.#", CultureInfo.InvariantCulture) + " k yd" : best.ToString("0", CultureInfo.InvariantCulture) + " yd";
dl.AddText(a + new Vector2(1, -17), LabelHalo, t);
dl.AddText(a + new Vector2(0, -18), LabelCol, t);
}
private void DrawCompass(ImDrawListPtr dl, Vector2 canvasMax)
{
// A needle at north: straight up while the map is north-up, turning as it rotates.
var c = new Vector2(canvasMax.X - 20, canvasMax.Y - 26);
Vector2 n = ScreenDir(0, 1);
var side = new Vector2(-n.Y, n.X);
dl.AddCircleFilled(c, 12, BarBg);
dl.AddCircle(c, 12, BtnBord);
dl.AddTriangleFilled(c + n * 9f, c - n * 1f + side * 3.5f, c - n * 1f - side * 3.5f, LabelCol);
dl.AddTriangleFilled(c - n * 9f, c + n * 1f + side * 3.5f, c + n * 1f - side * 3.5f, RynthTheme.Argb(0xFF6C7C8C));
Vector2 ts = ImGuiNET.ImGui.CalcTextSize("N");
Vector2 lp = c + n * 17f - ts * 0.5f;
if (lp.Y > canvasMax.Y - 40) lp = c - n * 17f - ts * 0.5f;
dl.AddText(lp, LabelCol, "N");
}
private static void DrawCentred(ImDrawListPtr dl, Vector2 at, string text)
{
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(text);
Vector2 min = at - ts * 0.5f - new Vector2(8, 5), max = at + ts * 0.5f + new Vector2(8, 5);
dl.AddRectFilled(min, max, BarBg, 4);
dl.AddText(at - ts * 0.5f, HintCol, text);
}
// ── Input ────────────────────────────────────────────────────────────
private void Input(Vector2 canvasMin, Vector2 canvasMax, in MapPlayer pl)
{
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
ImGuiNET.ImGui.SetCursorScreenPos(canvasMin);
ImGuiNET.ImGui.InvisibleButton(Mini ? "##mm_canvas" : "##wm_canvas", Vector2.Max(canvasMax - canvasMin, new Vector2(1, 1)),
ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight);
Vector2 mouse = io.MousePos;
bool blocked = Blocked is { } b && mouse.X >= b.Min.X && mouse.X <= b.Max.X && mouse.Y >= b.Min.Y && mouse.Y <= b.Max.Y;
bool hovered = ImGuiNET.ImGui.IsItemHovered() && !blocked;
// Nearest drawn character or place within reach, else the map point under the cursor.
_hoverMark = -1; _hoverChar = -1;
if (hovered || _pressing)
{
float best = 11f * 11f;
foreach (var (pos, idx) in _drawnChars)
{
float dd = Vector2.DistanceSquared(pos, mouse);
if (dd < best) { best = dd; _hoverChar = idx; _hoverMark = -1; }
}
foreach (var (pos, idx) in _drawn)
{
float dd = Vector2.DistanceSquared(pos, mouse);
if (dd < best) { best = dd; _hoverMark = idx; _hoverChar = -1; }
}
}
HoverText = "";
if (hovered)
{
Unproject(mouse, out double hcx, out double hcy);
double hn = DegreesOf(hcy), he = DegreesOf(hcx);
string where = RynthNavStatus.Coord(hn, he);
string name = "";
if (_hoverChar >= 0 && _hoverChar < _chars.Length) { name = _chars[_hoverChar].Name + " (character)"; hn = _chars[_hoverChar].MapNs; he = _chars[_hoverChar].MapEw; where = RynthNavStatus.Coord(hn, he); }
else if (_hoverMark >= 0 && _marks != null && _hoverMark < _marks.Length) { Mark m = _marks[_hoverMark]; name = m.Name + " (" + m.Place.Type + ")"; hn = m.Place.Ns; he = m.Place.Ew; where = RynthNavStatus.Coord(hn, he); }
HoverText = (name.Length > 0 ? name + " " : "") + where + FromYou(pl, hn, he);
}
if (hovered && ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { _pressing = true; _pressMoved = false; }
if (hovered && ImGuiNET.ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left) && pl.Known) { Follow = true; _pressing = false; }
if (_pressing && ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left) && ImGuiNET.ImGui.IsMouseDragging(ImGuiMouseButton.Left, 4f))
{
_pressMoved = true;
Vector2 d = io.MouseDelta;
if (float.IsFinite(d.X) && float.IsFinite(d.Y) && d != Vector2.Zero)
{
Follow = false;
(_ccx, _ccy) = Proj.CentreAfterDrag(d);
}
}
if (_pressing && ImGuiNET.ImGui.IsMouseReleased(ImGuiMouseButton.Left))
{
if (!_pressMoved && hovered && !Mini) OpenMenuAt(mouse);
_pressing = false;
}
if (!ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left)) _pressing = false;
if (hovered && ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Right)) OpenMenuAt(mouse);
if (hovered)
{
float wheel = io.MouseWheel;
if (float.IsFinite(wheel) && wheel != 0f) ZoomBy(MathF.Pow(1.25f, wheel), mouse);
}
}
/// <summary>" · 1.2 k yd NNE" from you to a point, or "".</summary>
private static string FromYou(in MapPlayer pl, double ns, double ew)
{
if (!pl.Known) return "";
double dn = ns - pl.ShowNs, de = ew - pl.ShowEw;
double yards = Math.Sqrt(dn * dn + de * de) * 240.0;
if (yards < 5) return " · here";
double bearing = Math.Atan2(de, dn) * 180.0 / Math.PI;
if (bearing < 0) bearing += 360.0;
string dist = yards >= 1000 ? (yards / 1000).ToString("0.0", CultureInfo.InvariantCulture) + " k yd" : ((int)yards).ToString(CultureInfo.InvariantCulture) + " yd";
return " · " + dist + " " + RynthNavAtlas.CompassPoint(bearing);
}
private void OpenMenuAt(Vector2 mouse)
{
if (_hoverChar >= 0 && _hoverChar < _chars.Length)
{
CharacterRow c = _chars[_hoverChar];
_ctxNs = Math.Round(c.MapNs, 2); _ctxEw = Math.Round(c.MapEw, 2); _ctxName = c.Name;
}
else if (_hoverMark >= 0 && _marks != null && _hoverMark < _marks.Length)
{
Mark m = _marks[_hoverMark];
_ctxNs = m.Place.Ns; _ctxEw = m.Place.Ew; _ctxName = m.Name;
}
else
{
Unproject(mouse, out double cx, out double cy);
_ctxNs = Math.Round(DegreesOf(cy), 2);
_ctxEw = Math.Round(DegreesOf(cx), 2);
_ctxName = "";
}
_openCtx = true;
}
private void DrawContextMenu()
{
if (_openCtx) { ImGuiNET.ImGui.OpenPopup(_ctxId); _openCtx = false; }
if (!ImGuiNET.ImGui.BeginPopup(_ctxId)) return;
string where = _ctxName.Length > 0 ? _ctxName : "Map point";
ImGuiNET.ImGui.TextColored(new Vector4(1f, 0.82f, 0.3f, 1f), where);
ImGuiNET.ImGui.TextDisabled(RynthNavStatus.Coord(_ctxNs, _ctxEw));
ImGuiNET.ImGui.Separator();
if (ImGuiNET.ImGui.Selectable("Go here")) RynthNavCommands.Go(where, _ctxNs, _ctxEw);
if (ImGuiNET.ImGui.Selectable("Route here")) RynthNavCommands.Route(where, _ctxNs, _ctxEw);
if (ImGuiNET.ImGui.Selectable("Arrow here")) RynthNavCommands.Arrow(where, _ctxNs, _ctxEw);
if (ImGuiNET.ImGui.Selectable("Copy coordinates")) ImGuiNET.ImGui.SetClipboardText(RynthNavStatus.CommandCoord(_ctxNs, _ctxEw));
if (Mini)
{
ImGuiNET.ImGui.Separator();
bool follow = Follow, rotate = Rotate;
if (ImGuiNET.ImGui.Checkbox("Follow me", ref follow)) Follow = follow;
if (ImGuiNET.ImGui.Checkbox("Rotate with me", ref rotate)) Rotate = rotate;
if (ImGuiNET.ImGui.Selectable("Zoom in")) ZoomBy(1.5f);
if (ImGuiNET.ImGui.Selectable("Zoom out")) ZoomBy(1f / 1.5f);
if (ImGuiNET.ImGui.Selectable("Open the World Map")) UI.PanelRouter.Toggle(WorldMapFace.Title);
}
ImGuiNET.ImGui.EndPopup();
}
}