RynthCore as of 2026-11-08 (internal 9297e93): release 2026.11.8.1
This commit is contained in:
parent
418d80bafb
commit
c68204f160
99 changed files with 5032 additions and 185 deletions
|
|
@ -540,8 +540,20 @@ internal static unsafe class DX9Backend
|
|||
if (!_initialized) return;
|
||||
ImDrawData* dd = drawData.NativePtr;
|
||||
if (dd == null) return;
|
||||
RenderLists((ImDrawList**)dd->CmdLists.Data, dd->CmdListsCount, dd->TotalVtxCount, dd->DisplayPos, dd->DisplaySize,
|
||||
pDevice, midFrame: false);
|
||||
ImDrawList** lists = (ImDrawList**)dd->CmdLists.Data;
|
||||
int count = dd->CmdListsCount;
|
||||
// Windows drawn under AC's UI (UnderUiLayer, a plugin window's "layer": "underUi") were presented
|
||||
// at AC's UI pass: left out here, the rest keep their order.
|
||||
if (UnderUiLayer.HasWindowLists && count > 0 && count <= 512)
|
||||
{
|
||||
ImDrawList** kept = stackalloc ImDrawList*[count];
|
||||
int n = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
if (!UnderUiLayer.IsWindowList(lists[i])) kept[n++] = lists[i];
|
||||
RenderLists(kept, n, dd->TotalVtxCount, dd->DisplayPos, dd->DisplaySize, pDevice, midFrame: false);
|
||||
return;
|
||||
}
|
||||
RenderLists(lists, count, dd->TotalVtxCount, dd->DisplayPos, dd->DisplaySize, pDevice, midFrame: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -998,9 +998,14 @@ internal static class EngineFrameController
|
|||
// A docked click-through panel under the cursor that zooms with the wheel (the radar's
|
||||
// "Mouse wheel still zooms"): the wheel is its own, clicks and moves still the game's.
|
||||
Win32Backend.UpdateCaptureFlags(io.WantCaptureMouse || Hud.MonsterHud.WantsMouse, typing,
|
||||
mouseMovesToGame: !io.WantCaptureMouse && Hud.MonsterHud.MouseMovesToGame,
|
||||
// An under-UI panel only hovered: the same (ImGuiPanelHost.UnderUiHovered).
|
||||
mouseMovesToGame: (!io.WantCaptureMouse && Hud.MonsterHud.MouseMovesToGame)
|
||||
|| (PanelsLive && ImGuiPanelHost.UnderUiHovered),
|
||||
wheelToUi: !io.WantCaptureMouse && PanelsLive && ImGuiPanelHost.WheelWanted);
|
||||
Compatibility.AcMouseOver.Tick(); // /rc acmouse watch, when on
|
||||
// A RynthCore window's move or resize spot: retail's window-control cursor (RetailCursors).
|
||||
RetailCursors.Update(ImGuiNET.ImGui.GetMouseCursor(),
|
||||
Win32Backend.UiCaptureEnabled && (io.WantCaptureMouse || (PanelsLive && ImGuiPanelHost.UnderUiHovered)));
|
||||
// The UI is released (Insert): no text box keeps the keyboard. Keys are not
|
||||
// gated by the toggle any more (Win32Backend.UpdateCaptureFlags), so the edit
|
||||
// ends instead and the next keys go to the game.
|
||||
|
|
|
|||
|
|
@ -88,7 +88,11 @@ internal sealed record PanelSpec(
|
|||
PanelCorner OpenCorner = PanelCorner.None,
|
||||
// The panel draws its own content at any size (a plugin window's "scale": "draw", v90): Ctrl+wheel
|
||||
// steps its draw size (PanelDrawScale, 30-250%) instead of its text size.
|
||||
bool DrawScale = false);
|
||||
bool DrawScale = false,
|
||||
// Drawn under AC's own UI, like a native AC window (a plugin window's "layer": "underUi",
|
||||
// 2026-11-07): built in the normal frame, presented at AC's UI pass (UnderUiLayer), and
|
||||
// click-through wherever an AC window covers the cursor (AcMouseOver). Docked only.
|
||||
bool UnderUi = false);
|
||||
|
||||
/// <summary>An ImGui panel face. One instance per open; dropped on close.</summary>
|
||||
internal interface IImGuiPanel
|
||||
|
|
@ -594,6 +598,12 @@ internal static class ImGuiPanelHost
|
|||
/// </summary>
|
||||
public static bool WheelWanted { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The last DrawAll: an under-UI panel (PanelSpec.UnderUi) is only hovered (no button held), so the
|
||||
/// mouse moves still go to AC and its own mouse-over stays current (EngineFrameController). AC thread.
|
||||
/// </summary>
|
||||
public static bool UnderUiHovered { get; private set; }
|
||||
|
||||
// ── Frame (AC thread) ──────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -608,6 +618,7 @@ internal static class ImGuiPanelHost
|
|||
int drawn = 0;
|
||||
_frameScale = uiScale;
|
||||
WheelWanted = false;
|
||||
UnderUiHovered = false;
|
||||
float placeScale = PlacementScale();
|
||||
ApplyFaceChanges(placeScale); // plugin windows taking over (or giving back) engine panels
|
||||
ApplyLayoutSwitch(placeScale); // another character's panel layout (UI/PanelLayout)
|
||||
|
|
@ -725,25 +736,43 @@ internal static class ImGuiPanelHost
|
|||
OpenSavedOpen();
|
||||
}
|
||||
|
||||
/// <summary>Opens the engine panels the panel store has saved open (ImGui or Both docked face). AC thread.</summary>
|
||||
/// <summary>
|
||||
/// Opens the engine panels and plugin windows the panel store has saved open (ImGui or Both docked
|
||||
/// face). AC thread.
|
||||
/// </summary>
|
||||
private static void OpenSavedOpen()
|
||||
{
|
||||
List<string> titles = new();
|
||||
// Script windows (dynamic) open when their owner says so, not from the saved state.
|
||||
// Script windows (dynamic) open when their owner says so, not from the saved state. Plugin
|
||||
// windows (dynamic too) follow it like engine panels (2026-11-05): one registered before the
|
||||
// character's layout was in use (a hot reload, a name that came late, a relogin) decided its
|
||||
// open state from the layout before, and opened here it comes back as this layout left it.
|
||||
lock (Sync)
|
||||
foreach (Entry e in Entries.Values)
|
||||
if (!e.Dynamic) titles.Add(e.Title);
|
||||
if (PanelLayoutPolicy.FollowsSavedOpenState(KindOf(e))) titles.Add(e.Title);
|
||||
foreach (string title in titles)
|
||||
{
|
||||
if (!PanelStateStore.TryGetPanel(title, out PanelStateStore.PanelEntry saved)) continue;
|
||||
if (!saved.Open) continue;
|
||||
PanelFace face = PanelRouter.ResolveDockedFace(title);
|
||||
if (face is not (PanelFace.ImGui or PanelFace.Both)) continue;
|
||||
// Saved popped out: it reopens popped out (Apply reads the saved entry).
|
||||
Open(title);
|
||||
OpenSaved(title);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Opens a panel saved open, when its docked face is ImGui (or Both). AC thread.</summary>
|
||||
private static void OpenSaved(string title)
|
||||
{
|
||||
PanelFace face = PanelRouter.ResolveDockedFace(title);
|
||||
if (face is not (PanelFace.ImGui or PanelFace.Both)) return;
|
||||
// Saved popped out: it reopens popped out (Apply reads the saved entry).
|
||||
Open(title);
|
||||
}
|
||||
|
||||
/// <summary>An engine panel, a plugin's window (UI/Sections/PluginWindows) or a script window. AC thread.</summary>
|
||||
private static WindowKind KindOf(Entry e) =>
|
||||
!e.Dynamic ? WindowKind.EnginePanel
|
||||
: !e.PendingRemoval && UI.Sections.PluginWindows.IsHosted(e.Title) ? WindowKind.PluginWindow
|
||||
: WindowKind.ScriptWindow;
|
||||
|
||||
// ── Panel layout per character (UI/PanelLayout) ───────────────────────
|
||||
|
||||
private static volatile bool _layoutSwitched;
|
||||
|
|
@ -756,9 +785,12 @@ internal static class ImGuiPanelHost
|
|||
|
||||
/// <summary>
|
||||
/// After a layout switch: each shown panel is placed from the new layout (docked spot and size, popped
|
||||
/// out or not, and where); an engine panel the layout has saved closed closes, without saving over
|
||||
/// it; engine panels it has saved open open. Plugin and script windows stay open (their owners
|
||||
/// out or not, and where); an engine panel or plugin window the layout has saved closed closes,
|
||||
/// without saving over it; the ones it has saved open open. Script windows stay open (their owners
|
||||
/// decide that) and move. Nothing shown (a hot reload, the first login): only the opening. AC thread.
|
||||
/// (Plugin windows follow the layout's open state since 2026-11-05: they register from the plugins'
|
||||
/// manifests seconds after a login, and one registered while the store held another layout kept
|
||||
/// that layout's open state for the whole session.)
|
||||
/// </summary>
|
||||
private static void ApplyLayoutSwitch(float placeScale)
|
||||
{
|
||||
|
|
@ -769,12 +801,17 @@ internal static class ImGuiPanelHost
|
|||
lock (Sync) order = DrawOrder;
|
||||
foreach (Entry e in order)
|
||||
{
|
||||
if (!e.Shown) continue;
|
||||
bool has = PanelStateStore.TryGetPanel(e.Title, out PanelStateStore.PanelEntry saved);
|
||||
if (!e.Dynamic && remember && has && !saved.Open)
|
||||
switch (PanelLayoutPolicy.StepAtSwitch(KindOf(e), e.Shown, remember, has, saved.Open))
|
||||
{
|
||||
CloseQuietly(e);
|
||||
continue;
|
||||
case SwitchStep.Leave:
|
||||
continue;
|
||||
case SwitchStep.Open:
|
||||
OpenSaved(e.Title); // queued; applied by this DrawAll, placed from the new layout
|
||||
continue;
|
||||
case SwitchStep.Close:
|
||||
CloseQuietly(e);
|
||||
continue;
|
||||
}
|
||||
if (e.Popped)
|
||||
{
|
||||
|
|
@ -787,7 +824,6 @@ internal static class ImGuiPanelHost
|
|||
else if (!has)
|
||||
Persist(e, open: true, placeScale); // new to this layout: saved here, so it reopens here
|
||||
}
|
||||
if (remember) OpenSavedOpen(); // queued; applied by this DrawAll (an open one is skipped)
|
||||
RynthLog.UI("ImGuiPanelHost: the open panels took their places from the panel layout now in use.");
|
||||
}
|
||||
|
||||
|
|
@ -1183,10 +1219,25 @@ internal static class ImGuiPanelHost
|
|||
bool clickThrough = false;
|
||||
// Popped out, a panel is always interactive (like the Avalonia pop-out was).
|
||||
if (!popped) try { clickThrough = entry.Instance?.ClickThrough ?? false; } catch { }
|
||||
// Under AC's UI: where an AC window covers the cursor the click is AC's (unless a press that
|
||||
// began on this panel is still held, so a drag over an AC window isn't dropped).
|
||||
bool underUi = spec.UnderUi && !popped;
|
||||
if (underUi && !clickThrough && !ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left)
|
||||
&& Compatibility.AcMouseOver.Current() == Compatibility.AcMouseTarget.AcWindow)
|
||||
clickThrough = true;
|
||||
if (clickThrough) flags |= ImGuiWindowFlags.NoInputs;
|
||||
|
||||
bool childOpen = false;
|
||||
ImGuiNET.ImGui.Begin(entry.WindowId, flags);
|
||||
if (underUi)
|
||||
{
|
||||
UnderUiLayer.AddWindowList(ImGuiNET.ImGui.GetWindowDrawList());
|
||||
// Only hovered: the mouse moves still reach AC, so its own mouse-over follows the cursor
|
||||
// onto an AC window covering this one (as the nameplates do, MonsterHud.MouseMovesToGame).
|
||||
if (!clickThrough && !ImGuiNET.ImGui.IsAnyMouseDown()
|
||||
&& ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows))
|
||||
UnderUiHovered = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
ImGuiNET.ImGui.PopStyleVar(3); // the frame's own vars; the body gets normal padding
|
||||
|
|
@ -1263,6 +1314,7 @@ internal static class ImGuiPanelHost
|
|||
if (clickThrough) bodyFlags |= ImGuiWindowFlags.NoInputs;
|
||||
childOpen = ImGuiNET.ImGui.BeginChild("##body", bodySize, ImGuiChildFlags.AlwaysUseWindowPadding, bodyFlags);
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
if (underUi && childOpen) UnderUiLayer.AddWindowList(ImGuiNET.ImGui.GetWindowDrawList());
|
||||
|
||||
if (childOpen)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,11 +15,36 @@ internal enum DebuffKind : byte
|
|||
Imperil, MagicYield, Defense, Attributes, Vitals, Movement, Skills, Dot, Other,
|
||||
}
|
||||
|
||||
/// <summary>One icon: the kind, when its soonest entry expires, that entry's full length, and how many categories it merges.</summary>
|
||||
/// <summary>
|
||||
/// One icon: the kind, when its soonest entry expires, that entry's full length, how many categories it
|
||||
/// merges, and (2026-11-07, for the hover tooltip) the spell heading each merged category, up to
|
||||
/// <see cref="MaxSpells"/> (Stack can be higher: the tooltip says how many more).
|
||||
/// </summary>
|
||||
internal struct DebuffIcon
|
||||
{
|
||||
public const int MaxSpells = 4;
|
||||
|
||||
public DebuffKind Kind;
|
||||
public long Expiry; // Stopwatch ticks
|
||||
public float Duration; // seconds, of the entry expiring first
|
||||
public int Stack;
|
||||
public uint Spell0, Spell1, Spell2, Spell3;
|
||||
public int SpellCount; // ids held (<= MaxSpells)
|
||||
|
||||
/// <summary>Adds a spell id (0 and repeats are skipped; past MaxSpells it is only counted by Stack).</summary>
|
||||
public void AddSpell(uint id)
|
||||
{
|
||||
if (id == 0 || SpellCount >= MaxSpells) return;
|
||||
for (int i = 0; i < SpellCount; i++) if (SpellAt(i) == id) return;
|
||||
switch (SpellCount)
|
||||
{
|
||||
case 0: Spell0 = id; break;
|
||||
case 1: Spell1 = id; break;
|
||||
case 2: Spell2 = id; break;
|
||||
default: Spell3 = id; break;
|
||||
}
|
||||
SpellCount++;
|
||||
}
|
||||
|
||||
public readonly uint SpellAt(int i) => i switch { 0 => Spell0, 1 => Spell1, 2 => Spell2, 3 => Spell3, _ => 0 };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,19 +14,84 @@
|
|||
// the plate's scale x its own "Debuff icon size" setting (monster plates and
|
||||
// your plate apart, neither tied to a text size); the stack digit and "+N"
|
||||
// scale the plate's small text by it. At 100 % the row is exactly as before.
|
||||
// Hover tooltips (2026-11-07): a row painted with tips on notes the icon
|
||||
// under the cursor (the last row painted wins: it is on top); after every
|
||||
// plate is painted, MonsterHud.Draw calls ShowHoverTip, which names the
|
||||
// kind, what it does, its spells and when the first ends (DebuffTip), the
|
||||
// "+N" count, or what the "debuffed by others" marker means. No tip while an
|
||||
// ImGui panel has the mouse, the Insert UI toggle is off, the plate is
|
||||
// fading, or (rows drawn under AC's windows) one of AC's windows covers it.
|
||||
// Render thread only. Engine-owned statics.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
/// <summary>Whose row it is, for the hover tooltip (Off: no tooltip).</summary>
|
||||
internal enum DebuffRowTips : byte { Off, Monster, Self }
|
||||
|
||||
internal static class DebuffIconRow
|
||||
{
|
||||
private enum Hit : byte { None, Icon, More, Others }
|
||||
|
||||
private readonly record struct TipKey(Hit Hit, DebuffKind Kind, uint S0, uint S1, uint S2, uint S3, int Stack, int Secs, DebuffRowTips Row, int More);
|
||||
|
||||
// The icon under the cursor this frame (BeginHover clears it; the topmost row painted wins).
|
||||
private static Hit _hit;
|
||||
private static DebuffIcon _hitIcon;
|
||||
private static int _hitMore;
|
||||
private static DebuffRowTips _hitRow;
|
||||
private static bool _hitUnderUi;
|
||||
// The last tooltip built, kept while the cursor stays on the same icon and second.
|
||||
private static TipKey _tipKey;
|
||||
private static string _tipText = "";
|
||||
private static readonly List<string> TipNames = new(DebuffIcon.MaxSpells);
|
||||
|
||||
/// <summary>Start of a HUD frame: nothing hovered yet.</summary>
|
||||
internal static void BeginHover() => _hit = Hit.None;
|
||||
|
||||
/// <summary>
|
||||
/// End of a HUD frame (inside the ImGui frame): the tooltip of the icon the cursor is on, if any.
|
||||
/// A row drawn under AC's windows gets none where one of AC's windows covers the cursor.
|
||||
/// </summary>
|
||||
internal static void ShowHoverTip(long now)
|
||||
{
|
||||
if (_hit == Hit.None) return;
|
||||
if (_hitUnderUi && MonsterHud.AcWindowCoversCursor()) return;
|
||||
int secs = _hit == Hit.Icon ? (int)Math.Ceiling((_hitIcon.Expiry - now) / (double)Stopwatch.Frequency) : 0;
|
||||
var key = new TipKey(_hit, _hitIcon.Kind, _hitIcon.Spell0, _hitIcon.Spell1, _hitIcon.Spell2, _hitIcon.Spell3,
|
||||
_hitIcon.Stack, secs, _hitRow, _hitMore);
|
||||
if (key != _tipKey || _tipText.Length == 0)
|
||||
{
|
||||
_tipKey = key;
|
||||
_tipText = _hit switch
|
||||
{
|
||||
Hit.Others => DebuffTip.Others,
|
||||
Hit.More => DebuffTip.More(_hitMore),
|
||||
_ => IconTip(in _hitIcon, secs, _hitRow),
|
||||
};
|
||||
}
|
||||
SafeImGui.SetTooltip(_tipText);
|
||||
}
|
||||
|
||||
private static string IconTip(in DebuffIcon ic, int secs, DebuffRowTips row)
|
||||
{
|
||||
TipNames.Clear();
|
||||
for (int i = 0; i < ic.SpellCount; i++)
|
||||
if (PortalSpellTable.TryGetById(ic.SpellAt(i), out DebuffSpell s) && s.Name.Length > 0)
|
||||
TipNames.Add(s.Name);
|
||||
return DebuffTip.Text(ic.Kind, TipNames, ic.Stack, secs, estimated: row == DebuffRowTips.Monster, self: row == DebuffRowTips.Self);
|
||||
}
|
||||
|
||||
private static bool Inside(Vector2 m, Vector2 p0, Vector2 p1) => m.X >= p0.X && m.X <= p1.X && m.Y >= p0.Y && m.Y <= p1.Y;
|
||||
|
||||
/// <summary>Icons per row; more shows "+N" (the last slot makes room for it).</summary>
|
||||
internal const int MaxIcons = 5;
|
||||
/// <summary>Icons blink in their last seconds.</summary>
|
||||
|
|
@ -66,12 +131,23 @@ internal static class DebuffIconRow
|
|||
/// <paramref name="row"/> holds every length (the plate's scale x its icon size setting);
|
||||
/// <paramref name="smallFont"/>/<paramref name="smallSize"/> are the plate's small text, which the
|
||||
/// stack digit and "+N" scale by the icon size; <paramref name="overflowKey"/>/<paramref name="overflowText"/>
|
||||
/// cache the "+N" string per row. <paramref name="now"/> is Stopwatch ticks.
|
||||
/// cache the "+N" string per row. <paramref name="now"/> is Stopwatch ticks. <paramref name="tips"/>:
|
||||
/// whose row, for the hover tooltip (Off: none); <paramref name="underUi"/>: drawn under AC's windows.
|
||||
/// </summary>
|
||||
internal static void Paint(ImDrawListPtr dl, DebuffIcon[] icons, int count, bool others, in DebuffRowMetrics row,
|
||||
ImFontPtr smallFont, float smallSize, ref int overflowKey, ref string overflowText,
|
||||
float cx, float top, float a, long now)
|
||||
float cx, float top, float a, long now, DebuffRowTips tips = DebuffRowTips.Off, bool underUi = false)
|
||||
{
|
||||
// Hover: only a settled plate, with the UI toggle on and no ImGui panel holding the mouse.
|
||||
Vector2 mouse = default;
|
||||
bool hover = false;
|
||||
if (tips != DebuffRowTips.Off && a >= 0.25f && Win32Backend.IsUiCaptureEnabled())
|
||||
{
|
||||
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
|
||||
hover = !io.WantCaptureMouse;
|
||||
mouse = io.MousePos;
|
||||
}
|
||||
|
||||
float sz = row.Icon, gap = row.Gap;
|
||||
int shown = Prepare(icons.Length, count, in row, ref smallFont, ref smallSize, ref overflowKey, ref overflowText,
|
||||
out int overflow, out string more, out float moreTextW);
|
||||
|
|
@ -110,6 +186,9 @@ internal static class DebuffIconRow
|
|||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i1.X, ly + lineH), MonsterHud.Mul(MonsterHud.Outline, a * 0.8f));
|
||||
if (frac > 0f)
|
||||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i0.X + MathF.Max(1f, sz * frac), ly + lineH), MonsterHud.Mul(tint, a * blink));
|
||||
// The icon and its countdown line, with the gap to the next icon split between them (no dead spots).
|
||||
if (hover && Inside(mouse, i0 - new Vector2(gap * 0.5f, 0f), new Vector2(i1.X + gap * 0.5f, ly + lineH)))
|
||||
Note(Hit.Icon, in ic, 0, tips, underUi);
|
||||
x += sz + gap;
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +197,8 @@ internal static class DebuffIconRow
|
|||
var mp = new Vector2(x, MathF.Round(top + (sz - smallSize) * 0.5f));
|
||||
MonsterHud.OutlinedText(dl, smallFont, smallSize, mp, a, more);
|
||||
dl.AddText(smallFont, smallSize, mp, MonsterHud.Mul(MonsterHud.DimText, a), more);
|
||||
if (hover && Inside(mouse, new Vector2(x, top), new Vector2(x + moreW, top + sz)))
|
||||
Note(Hit.More, default, overflow, tips, underUi);
|
||||
x += moreW + gap;
|
||||
}
|
||||
|
||||
|
|
@ -126,9 +207,20 @@ internal static class DebuffIconRow
|
|||
var i0 = new Vector2(x, top);
|
||||
dl.AddRectFilled(i0, i0 + new Vector2(sz, sz), MonsterHud.Mul(IconBack, a * 0.8f), row.Round);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, PhosphorIcons.UsersThree, i0, new Vector2(sz, sz), MonsterHud.Mul(OthersTint, a * 0.8f));
|
||||
if (hover && Inside(mouse, i0, i0 + new Vector2(sz, sz)))
|
||||
Note(Hit.Others, default, 0, tips, underUi);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Note(Hit hit, in DebuffIcon icon, int more, DebuffRowTips row, bool underUi)
|
||||
{
|
||||
_hit = hit;
|
||||
_hitIcon = icon;
|
||||
_hitMore = more;
|
||||
_hitRow = row;
|
||||
_hitUnderUi = underUi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The row's width as <see cref="Paint"/> lays it out (same arguments): the plates' layout uses it so
|
||||
/// their box (crowding, clicks, the screen clamp) holds an enlarged row.
|
||||
|
|
|
|||
106
src/RynthCore.Engine/ImGui/MonsterHud/DebuffTip.cs
Normal file
106
src/RynthCore.Engine/ImGui/MonsterHud/DebuffTip.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/DebuffTip.cs
|
||||
// The words of the debuff icons' hover tooltip (2026-11-07), on the monster
|
||||
// plates and your own plate: what the kind is, what it does, the spells
|
||||
// behind the icon and when the first of them ends. DebuffIconRow finds the
|
||||
// icon under the cursor and shows the text.
|
||||
// Plain text, no engine dependencies (the offline tests compile it in).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
internal static class DebuffTip
|
||||
{
|
||||
/// <summary>The kind's name, the tooltip's first line.</summary>
|
||||
internal static string Title(DebuffKind kind) => kind switch
|
||||
{
|
||||
DebuffKind.VulnFire => "Fire vulnerability",
|
||||
DebuffKind.VulnCold => "Cold vulnerability",
|
||||
DebuffKind.VulnLightning => "Lightning vulnerability",
|
||||
DebuffKind.VulnAcid => "Acid vulnerability",
|
||||
DebuffKind.VulnSlash => "Slashing vulnerability",
|
||||
DebuffKind.VulnPierce => "Piercing vulnerability",
|
||||
DebuffKind.VulnBludgeon => "Bludgeoning vulnerability",
|
||||
DebuffKind.Imperil => "Imperil",
|
||||
DebuffKind.MagicYield => "Magic Yield",
|
||||
DebuffKind.Defense => "Defense lowered",
|
||||
DebuffKind.Attributes => "Attributes lowered",
|
||||
DebuffKind.Vitals => "Vitals lowered",
|
||||
DebuffKind.Movement => "Slowed",
|
||||
DebuffKind.Skills => "Skills lowered",
|
||||
DebuffKind.Dot => "Damage over time",
|
||||
_ => "Debuff",
|
||||
};
|
||||
|
||||
/// <summary>What it does, on a monster (<paramref name="self"/> false) or on you.</summary>
|
||||
internal static string Effect(DebuffKind kind, bool self)
|
||||
{
|
||||
string who = self ? "You take" : "Takes";
|
||||
return kind switch
|
||||
{
|
||||
DebuffKind.VulnFire => $"{who} more fire damage.",
|
||||
DebuffKind.VulnCold => $"{who} more cold damage.",
|
||||
DebuffKind.VulnLightning => $"{who} more lightning damage.",
|
||||
DebuffKind.VulnAcid => $"{who} more acid damage.",
|
||||
DebuffKind.VulnSlash => $"{who} more slashing damage.",
|
||||
DebuffKind.VulnPierce => $"{who} more piercing damage.",
|
||||
DebuffKind.VulnBludgeon => $"{who} more bludgeoning damage.",
|
||||
DebuffKind.Imperil => self ? "Your armor is lowered: physical hits land harder." : "Armor lowered: physical hits land harder.",
|
||||
DebuffKind.MagicYield => self ? "Your magic defense is lowered: spells land on you more often." : "Magic defense lowered: spells land more often.",
|
||||
DebuffKind.Defense => self ? "Your melee or missile defense is lowered: attacks hit you more often." : "Melee or missile defense lowered: attacks hit more often.",
|
||||
DebuffKind.Attributes => "Strength, Endurance, Quickness, Coordination, Focus or Self lowered.",
|
||||
DebuffKind.Vitals => "Maximum health, stamina or mana, or how fast they come back, lowered.",
|
||||
DebuffKind.Movement => "Run speed lowered.",
|
||||
DebuffKind.Skills => self ? "One or more of your skills lowered." : "One or more skills lowered.",
|
||||
DebuffKind.Dot => $"{who} damage every few seconds.",
|
||||
_ => self ? "A harmful spell on you." : "A harmful spell of yours on it.",
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An icon's tooltip. <paramref name="spells"/> are the names known (the icon holds up to
|
||||
/// DebuffIcon.MaxSpells; <paramref name="stack"/> counts every category it merges).
|
||||
/// <paramref name="estimated"/>: the end is worked out from the spell's length (the monster
|
||||
/// plates), not read from the server (your plate).
|
||||
/// </summary>
|
||||
internal static string Text(DebuffKind kind, IReadOnlyList<string> spells, int stack, double remainingSec,
|
||||
bool estimated, bool self)
|
||||
{
|
||||
var sb = new StringBuilder(160);
|
||||
sb.Append(Title(kind)).Append('\n').Append(Effect(kind, self));
|
||||
foreach (string s in spells)
|
||||
if (s.Length > 0) sb.Append("\n ").Append(s);
|
||||
int more = Math.Max(stack, spells.Count) - spells.Count;
|
||||
if (more > 0 && spells.Count > 0)
|
||||
sb.Append("\n and ").Append(more.ToString(CultureInfo.InvariantCulture)).Append(" more");
|
||||
if (remainingSec > 0)
|
||||
{
|
||||
sb.Append('\n').Append(stack > 1 ? "First one ends in " : "Ends in ");
|
||||
if (estimated) sb.Append("about ");
|
||||
sb.Append(Time(remainingSec));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>The "debuffed by others" marker's tooltip (monster plates only).</summary>
|
||||
internal const string Others =
|
||||
"Debuffed by someone else\nIts last appraisal showed attributes or vitals lowered that your own spells don't explain.";
|
||||
|
||||
/// <summary>The "+N" tooltip.</summary>
|
||||
internal static string More(int n) =>
|
||||
n == 1 ? "1 more debuff than fits in the row." : $"{n.ToString(CultureInfo.InvariantCulture)} more debuffs than fit in the row.";
|
||||
|
||||
/// <summary>"42 s", "1:05", "1:02:03".</summary>
|
||||
internal static string Time(double sec)
|
||||
{
|
||||
int s = (int)Math.Ceiling(Math.Max(0, sec));
|
||||
if (s < 60) return s.ToString(CultureInfo.InvariantCulture) + " s";
|
||||
if (s < 3600) return $"{s / 60}:{s % 60:00}";
|
||||
return $"{s / 3600}:{s / 60 % 60:00}:{s % 60:00}";
|
||||
}
|
||||
}
|
||||
|
|
@ -41,6 +41,10 @@
|
|||
// position is read (main thread, a handful of objects) and projected with
|
||||
// the engine's camera capture (GameMatrixCapture), so plates stick to
|
||||
// moving monsters without the 10 Hz snapshot's stepping.
|
||||
// Behind walls (2026-11-04, report R-20261105-020337-67aa; PlateSight): the
|
||||
// scan skips objects AC's cell lists rule out from the camera's cell, and
|
||||
// each frame a plate whose room AC didn't draw (or, seen from inside, an
|
||||
// outdoor object no drawn doorway covers) is hidden and takes no click.
|
||||
//
|
||||
// World -> screen: AC transforms geometry on the CPU; GameMatrixCapture
|
||||
// rebuilds the view from SmartBox's camera frame and hooks SetTransform for
|
||||
|
|
@ -121,6 +125,7 @@ internal static class MonsterHud
|
|||
public bool Chosen; // in the latest snapshot
|
||||
public bool Gone; // live position read failed (despawned / died)
|
||||
public bool OnScreen;
|
||||
public bool Hidden; // behind walls this frame (PlateSight): fades out, takes no click
|
||||
public bool Appeared; // became visible this frame: layout snaps instead of easing
|
||||
public float Alpha; // smoothed, 0..1
|
||||
public float Scale = 1f; // smoothed
|
||||
|
|
@ -324,6 +329,7 @@ internal static class MonsterHud
|
|||
PlateDebuffs.Clear();
|
||||
CombatText.Clear();
|
||||
PlayerPlate.Reset();
|
||||
PlateSight.Reset();
|
||||
Classes.Clear();
|
||||
_playerId = 0;
|
||||
}
|
||||
|
|
@ -387,6 +393,11 @@ internal static class MonsterHud
|
|||
float portalD2 = portalD * portalD;
|
||||
float portalTargetD2 = MathF.Max(portalD2, 100f * 100f); // and a selected portal
|
||||
bool targetIsPortal = false;
|
||||
// Behind walls (2026-11-04, report R-20261105-020337-67aa): objects the cell lists already rule
|
||||
// out (another room, another building, outdoors from a dungeon) are no candidates, so the
|
||||
// hidden NPCs of a town don't use up the caps; DrawPlates asks AC's draw stamps each frame.
|
||||
bool walls = MonsterHudSettings.HideBehindWalls;
|
||||
if (walls) PlateSight.Refresh(pCell);
|
||||
|
||||
int pass = ++_classPass;
|
||||
Candidates.Clear();
|
||||
|
|
@ -442,6 +453,7 @@ internal static class MonsterHud
|
|||
|
||||
if (!ClientObjectHooks.TryGetSnapshotPosition(id, out uint cell, out float x, out float y, out float z)) continue;
|
||||
if (!TryOffset(pCell, cell, out float ox, out float oy)) continue;
|
||||
if (walls && !PlateSight.ShowCoarse(cell)) continue;
|
||||
float dx = x + ox - px, dy = y + oy - py, dz = z - pz;
|
||||
float d2 = dx * dx + dy * dy + dz * dz;
|
||||
if (portal)
|
||||
|
|
@ -797,6 +809,7 @@ internal static class MonsterHud
|
|||
/// </summary>
|
||||
public static void Draw(float uiScale, bool worldVisible = true)
|
||||
{
|
||||
DebuffIconRow.BeginHover();
|
||||
if (!_hasContent) { ResetClick(); PlayerPlate.DropDrag(); return; }
|
||||
try
|
||||
{
|
||||
|
|
@ -809,6 +822,8 @@ internal static class MonsterHud
|
|||
}
|
||||
// The player plate fixed on screen: ImGui's background list (the normal UI pass), not the layer above.
|
||||
PlayerPlate.DrawScreen(ref f);
|
||||
// The debuff icon under the cursor (any plate's): its tooltip.
|
||||
DebuffIconRow.ShowHoverTip(f.Now);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -902,6 +917,9 @@ internal static class MonsterHud
|
|||
float kScale = 1f - MathF.Exp(-dt * 10f);
|
||||
float kBar = 1f - MathF.Exp(-dt * 14f);
|
||||
uint target = ClientHelperHooks.GetSelectedItemId();
|
||||
// Behind walls (2026-11-04, report R-20261105-020337-67aa): AC's draw stamp, sampled once a frame.
|
||||
bool walls = MonsterHudSettings.HideBehindWalls;
|
||||
if (walls) PlateSight.BeginFrame(f.PlayerCell);
|
||||
|
||||
DrawOrder.Clear();
|
||||
Evict.Clear();
|
||||
|
|
@ -937,9 +955,13 @@ internal static class MonsterHud
|
|||
p.IsAttacker = !label && MonsterHudData.AttackedRecently(p.Name, AttackerMemorySec);
|
||||
|
||||
p.OnScreen = false;
|
||||
bool headFront = false;
|
||||
Vector2 headPx = default; // where the head projects, before Keep on screen pins it
|
||||
if (p.HasWorld && GameMatrixCapture.WorldToScreen(p.LastWx, p.LastWy, p.LastWz, out float sx, out float sy))
|
||||
{
|
||||
sx *= f.MapX; sy *= f.MapY;
|
||||
headFront = true;
|
||||
headPx = new Vector2(sx, sy);
|
||||
const float margin = 60f;
|
||||
if (MonsterHudSettings.KeepOnScreen)
|
||||
{
|
||||
|
|
@ -964,7 +986,11 @@ internal static class MonsterHud
|
|||
float maxD = !label ? monsterMaxD : p.Kind == RadarKind.Portal ? portalMaxD : labelMaxD;
|
||||
float t = maxD > 1f ? Math.Clamp(p.Distance / maxD, 0f, 1f) : 0f;
|
||||
float distFade = fade ? 1f - 0.55f * SmoothStep(0.45f, 1f, t) : 1f;
|
||||
bool show = p.OnScreen && (p.Chosen || p.IsTarget) && !p.Gone;
|
||||
// An object the player can't see because of walls: no plate (it fades as one leaving the
|
||||
// screen does) and, from this frame, no click (PlateClick skips it). Asked only for a plate that would draw.
|
||||
p.Hidden = walls && p.OnScreen && (p.Chosen || p.IsTarget) && !p.Gone &&
|
||||
!PlateSight.Show(ref f, p.Id, p.LastCell, headFront, headPx, p.LastWx, p.LastZ, p.LastWz);
|
||||
bool show = p.OnScreen && !p.Hidden && (p.Chosen || p.IsTarget) && !p.Gone;
|
||||
float alphaTarget = show ? opacity * (p.IsTarget ? 1f : distFade) : 0f;
|
||||
bool wasVisible = p.Alpha > 0.01f;
|
||||
p.Appeared = !wasVisible;
|
||||
|
|
@ -1013,6 +1039,7 @@ internal static class MonsterHud
|
|||
PlateClick(f.UiScale, f.UnderUi);
|
||||
|
||||
// ── Paint: farthest first, nearest (and the target) on top ──
|
||||
_paintUnderUi = f.UnderUi;
|
||||
for (int i = DrawOrder.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Plate p = DrawOrder[i];
|
||||
|
|
@ -1213,7 +1240,7 @@ internal static class MonsterHud
|
|||
Vector2 m = io.MousePos;
|
||||
foreach (Plate p in DrawOrder)
|
||||
{
|
||||
if (p.Gone || p.Alpha < 0.25f) continue; // fading in or out: not a target yet
|
||||
if (p.Gone || p.Hidden || p.Alpha < 0.25f) continue; // fading in or out (or behind walls): not a target
|
||||
Vector4 r = RectAt(p, p.Nudge, uiScale);
|
||||
if (m.X < r.X || m.X > r.Z || m.Y < r.Y || m.Y > r.W) continue;
|
||||
_hoverId = p.Id;
|
||||
|
|
@ -1251,6 +1278,14 @@ internal static class MonsterHud
|
|||
}
|
||||
|
||||
private static int _leftToAcLogged;
|
||||
private static bool _paintUnderUi; // this frame's plates are on the layer under AC's windows
|
||||
|
||||
/// <summary>
|
||||
/// One of AC's windows is under the cursor (the debuff tooltips of rows drawn under AC's UI skip it).
|
||||
/// Same rule as the plate click, without its log line. AC's UI state unreadable: false.
|
||||
/// </summary>
|
||||
internal static bool AcWindowCoversCursor() =>
|
||||
!AcMouseOverRules.UnderUiOverlayMayTakeClick(AcMouseOver.Read().Target);
|
||||
|
||||
/// <summary>AC's own UI has one of its windows under the cursor (not the 3D world). AC's main thread.</summary>
|
||||
private static bool AcWindowUnderCursor()
|
||||
|
|
@ -1352,7 +1387,8 @@ internal static class MonsterHud
|
|||
// Under the bar: the debuff icons.
|
||||
if (icons)
|
||||
DebuffIconRow.Paint(dl, p.Icons, p.IconCount, p.Others, in p.Row, p.SmallFont, p.SmallSize,
|
||||
ref p.OverflowKey, ref p.OverflowString, cx, iconTop, a, now);
|
||||
ref p.OverflowKey, ref p.OverflowString, cx, iconTop, a, now,
|
||||
p.Gone || p.Hidden ? DebuffRowTips.Off : DebuffRowTips.Monster, _paintUnderUi);
|
||||
|
||||
// ── Name line: [level badge] Name ──
|
||||
if (p.NameW > 0 || p.BadgeW > 0)
|
||||
|
|
@ -1757,6 +1793,7 @@ internal static class MonsterHud
|
|||
$"({HealthProbe.ProbeCount} quer{(HealthProbe.ProbeCount == 1 ? "y" : "ies")} sent).",
|
||||
PlateDebuffs.Describe(),
|
||||
PlayerPlate.Describe() + " " + CombatText.Describe(),
|
||||
PlateSight.Describe(),
|
||||
AcMouseOver.Describe(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@
|
|||
// Both run on AC's main thread today; the lock keeps them safe if a caller
|
||||
// ever moves. Bounded: a full table is cleared wholesale (advisory data).
|
||||
// Engine-owned statics only (collectible with the engine generation).
|
||||
//
|
||||
// Plugin API v93 (2026-11-07) reads it from plugin threads too:
|
||||
// TryGetServerHealth hands out the last SERVER reading (probe replies
|
||||
// included, CleaveHealth estimates never) and its age, under the same lock.
|
||||
// Compiled into tools/CleaveGhostTests (with a stand-in HudFeed).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
|
@ -24,9 +29,11 @@ namespace RynthCore.Engine.ImGuiBackend.Hud;
|
|||
|
||||
/// <summary>Last health observation for one object. <paramref name="Prev"/>: the ratio before it
|
||||
/// (-1 = first). <paramref name="Estimated"/>: worked out from a hit (CleaveHealth), not sent by the server.
|
||||
/// <paramref name="ServerTicks"/>: when the server last sent this object's health (0 = never; estimates keep it).</summary>
|
||||
/// <paramref name="ServerTicks"/>: when the server last sent this object's health (0 = never; estimates keep it).
|
||||
/// <paramref name="ServerRatio"/>: the ratio the server last sent (-1 = never; an estimate keeps it, so it stays
|
||||
/// the server's number while <paramref name="Ratio"/> shows the estimate).</summary>
|
||||
internal readonly record struct HealthObservation(float Ratio, uint Current, uint Max, long Ticks, float Prev = -1f, bool Estimated = false,
|
||||
long ServerTicks = 0);
|
||||
long ServerTicks = 0, float ServerRatio = -1f);
|
||||
|
||||
internal static class MonsterHudData
|
||||
{
|
||||
|
|
@ -61,7 +68,8 @@ internal static class MonsterHudData
|
|||
if (Health.Count >= MaxHealthEntries && !Health.ContainsKey(id))
|
||||
Health.Clear();
|
||||
long serverTicks = estimated ? (had ? prev.ServerTicks : 0) : now;
|
||||
Health[id] = new HealthObservation(ratio, current, max, now, before, estimated, serverTicks);
|
||||
float serverRatio = estimated ? (had ? prev.ServerRatio : -1f) : ratio;
|
||||
Health[id] = new HealthObservation(ratio, current, max, now, before, estimated, serverTicks, serverRatio);
|
||||
}
|
||||
// An estimate never kills (CleaveHealth keeps it above 0) and the server correcting one
|
||||
// isn't a heal: the combat text sees an estimate's successor as a first observation.
|
||||
|
|
@ -76,6 +84,33 @@ internal static class MonsterHudData
|
|||
return Health.TryGetValue(id, out h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plugin API v93 GetMonsterHealth: the last health ratio the SERVER sent for <paramref name="id"/>
|
||||
/// (0x01C0 UpdateHealth, the HUD's own probe replies included; QueryHealthResponse; appraisal) and
|
||||
/// how many ms ago (saturates at uint.MaxValue). Never an estimate (CleaveHealth): an id the server
|
||||
/// never sent health for is false. Read-only, any thread (the table's lock), no game calls.
|
||||
/// </summary>
|
||||
public static bool TryGetServerHealth(uint id, out float ratio, out uint ageMs)
|
||||
=> TryGetServerHealth(id, Stopwatch.GetTimestamp(), out ratio, out ageMs);
|
||||
|
||||
/// <summary><see cref="TryGetServerHealth(uint, out float, out uint)"/> at <paramref name="nowTicks"/>
|
||||
/// (Stopwatch ticks; tests pass their own).</summary>
|
||||
public static bool TryGetServerHealth(uint id, long nowTicks, out float ratio, out uint ageMs)
|
||||
{
|
||||
ratio = -1f;
|
||||
ageMs = uint.MaxValue;
|
||||
if (id == 0) return false;
|
||||
HealthObservation h;
|
||||
lock (Sync)
|
||||
if (!Health.TryGetValue(id, out h)) return false;
|
||||
if (h.ServerTicks == 0 || h.ServerRatio < 0f) return false;
|
||||
long ticks = Math.Max(0, nowTicks - h.ServerTicks);
|
||||
double ms = ticks * 1000.0 / Stopwatch.Frequency;
|
||||
ratio = h.ServerRatio;
|
||||
ageMs = ms >= uint.MaxValue ? uint.MaxValue : (uint)ms;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>A monster named <paramref name="name"/> hit the player. Any thread.</summary>
|
||||
public static void RecordAttacker(string? name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ internal static class MonsterHudSettings
|
|||
/// <summary>A left-click on a monster plate selects that monster in game.</summary>
|
||||
public static bool ClickToSelect = true;
|
||||
/// <summary>
|
||||
/// "Hide behind walls" (2026-11-04, report R-20261105-020337-67aa): no plate or label (and no click) for
|
||||
/// an object the player can't see because of building or dungeon walls (PlateSight). Off: every object
|
||||
/// in range gets one, as before.
|
||||
/// </summary>
|
||||
public static bool HideBehindWalls = true;
|
||||
/// <summary>
|
||||
/// "Refresh others' health" (2026-10-31): the server streams health only for the selected / queried
|
||||
/// monster, so the HUD asks for the other plates' health itself, one monster per HealthRefreshSec
|
||||
/// (HealthProbe). Off: only the selected / queried monster's plate is live.
|
||||
|
|
@ -233,6 +239,7 @@ internal static class MonsterHudSettings
|
|||
case "scale": if (TryF(val, out float s)) Scale = Math.Clamp(s, MinScale, MaxScale); break;
|
||||
case "opacity": if (TryF(val, out float o)) Opacity = Math.Clamp(o, MinOpacity, MaxOpacity); break;
|
||||
case "clickSelect": ClickToSelect = val == "1"; break;
|
||||
case "hideBehindWalls": HideBehindWalls = val == "1"; break;
|
||||
case "refreshOthersHealth": RefreshOthersHealth = val == "1"; break;
|
||||
case "healthRefreshSec":
|
||||
if (TryF(val, out float hr)) HealthRefreshSec = Math.Clamp(hr, HealthProbe.MinIntervalSec, HealthProbe.MaxIntervalSec);
|
||||
|
|
@ -357,6 +364,7 @@ internal static class MonsterHudSettings
|
|||
sw.WriteLine(FormattableString.Invariant($"opacity={Opacity:0.##}"));
|
||||
sw.WriteLine(FormattableString.Invariant($"heightLift={HeightLift:0.##}"));
|
||||
sw.WriteLine($"clickSelect={B(ClickToSelect)}");
|
||||
sw.WriteLine($"hideBehindWalls={B(HideBehindWalls)}");
|
||||
sw.WriteLine($"refreshOthersHealth={B(RefreshOthersHealth)}");
|
||||
sw.WriteLine(FormattableString.Invariant($"healthRefreshSec={HealthRefreshSec:0.##}"));
|
||||
sw.WriteLine($"npcNames={B(NpcNames)}");
|
||||
|
|
@ -417,7 +425,7 @@ internal static class MonsterHudSettings
|
|||
{
|
||||
Enabled = true; MaxDistance = 35f; MaxPlates = 20; Filter = PlateFilter.All;
|
||||
ShowNames = true; ShowHpNumbers = true; ShowDistance = false; ShowLevel = true; ShowWeakness = true;
|
||||
FadeWithDistance = true; Scale = 1.0f; Opacity = 0.9f; HeightLift = 0f; ClickToSelect = true;
|
||||
FadeWithDistance = true; Scale = 1.0f; Opacity = 0.9f; HeightLift = 0f; ClickToSelect = true; HideBehindWalls = true;
|
||||
RefreshOthersHealth = true; HealthRefreshSec = HealthProbe.DefaultIntervalSec;
|
||||
ShowDebuffs = true; ShowOthersDebuff = true;
|
||||
NpcNames = true; NpcMaxDistance = 30f; MaxNpcLabels = 15; PlayerNames = false; PlayerBars = false;
|
||||
|
|
@ -484,7 +492,7 @@ internal static class MonsterHudSettings
|
|||
$"RynthVision nameplates: monsters {(Enabled ? "ON" : "OFF")} ({(Filter == PlateFilter.Engaged ? "engaged only" : "all monsters")}, " +
|
||||
$"{MaxDistance:0}yd, max {MaxPlates}, scale {Scale:0.##}, opacity {Opacity:0.##}, lift {HeightLift:0.#}m; " +
|
||||
$"names {OnOff(ShowNames)}, hp {OnOff(ShowHpNumbers)}, level {OnOff(ShowLevel)}, weak {OnOff(ShowWeakness)}, " +
|
||||
$"distance {OnOff(ShowDistance)}, fade {OnOff(FadeWithDistance)}, click to select {OnOff(ClickToSelect)}, " +
|
||||
$"distance {OnOff(ShowDistance)}, fade {OnOff(FadeWithDistance)}, click to select {OnOff(ClickToSelect)}, hide behind walls {OnOff(HideBehindWalls)}, " +
|
||||
$"refresh others' health {(RefreshOthersHealth ? $"every {HealthRefreshSec:0.0#} s" : "off")}), debuffs {OnOff(ShowDebuffs)} (others {OnOff(ShowOthersDebuff)}); " +
|
||||
$"NPC names {OnOff(NpcNames)} ({NpcMaxDistance:0}yd, max {MaxNpcLabels}), player names {OnOff(PlayerNames)} (bars {OnOff(PlayerBars)}), " +
|
||||
$"portal names {OnOff(PortalNames)} ({PortalMaxDistance:0}yd); " +
|
||||
|
|
|
|||
|
|
@ -212,6 +212,10 @@ internal static class MonsterHudSettingsUi
|
|||
changed |= SliderF("Scale", ref MonsterHudSettings.Scale, MonsterHudSettings.MinScale, MonsterHudSettings.MaxScale, "%.2f", w);
|
||||
changed |= Toggle("Keep on screen", ref MonsterHudSettings.KeepOnScreen,
|
||||
"When the camera closes in (walls), plates and numbers stay pinned to the screen edge instead of leaving it. Chat: /rv plates onscreen.");
|
||||
changed |= Toggle("Hide behind walls", ref MonsterHudSettings.HideBehindWalls,
|
||||
"No plate or name (and no click) for monsters, NPCs, players and portals you can't see because of building " +
|
||||
"or dungeon walls: in another room, another building, or outdoors where no doorway shows them. " +
|
||||
"Off: everything in range gets one. Chat: /rv plates walls.");
|
||||
changed |= SliderF("Opacity", ref MonsterHudSettings.Opacity, MonsterHudSettings.MinOpacity, MonsterHudSettings.MaxOpacity, "%.2f", w);
|
||||
changed |= SliderF("Height lift (m)", ref MonsterHudSettings.HeightLift, MonsterHudSettings.MinLift, MonsterHudSettings.MaxLift, "%.1f", w);
|
||||
changed |= Toggle("Fade and shrink with distance", ref MonsterHudSettings.FadeWithDistance, null);
|
||||
|
|
|
|||
|
|
@ -406,6 +406,7 @@ internal static class PlateDebuffs
|
|||
{
|
||||
if (dst[i].Kind != e.Kind) continue;
|
||||
dst[i].Stack++;
|
||||
dst[i].AddSpell(e.SpellId);
|
||||
if (e.Expiry < dst[i].Expiry) { dst[i].Expiry = e.Expiry; dst[i].Duration = e.Duration; }
|
||||
break;
|
||||
}
|
||||
|
|
@ -413,7 +414,10 @@ internal static class PlateDebuffs
|
|||
}
|
||||
seen |= 1UL << k;
|
||||
if (n < dst.Length)
|
||||
{
|
||||
dst[n] = new DebuffIcon { Kind = e.Kind, Expiry = e.Expiry, Duration = e.Duration, Stack = 1 };
|
||||
dst[n].AddSpell(e.SpellId);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
// Stable order on the plate: by kind.
|
||||
|
|
|
|||
354
src/RynthCore.Engine/ImGui/MonsterHud/PlateSight.cs
Normal file
354
src/RynthCore.Engine/ImGui/MonsterHud/PlateSight.cs
Normal file
|
|
@ -0,0 +1,354 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/PlateSight.cs
|
||||
// "Behind walls" for the nameplates (2026-11-04, problem report
|
||||
// R-20261105-020337-67aa, Conquest, indoors in a town shop: "NPC and Mob
|
||||
// labels show up through walls. When in a town I find it hard to even click
|
||||
// on interface items and buying things because my mouse wants to click on the
|
||||
// labels of the NPC's."). A plate or label for an object the player can't see
|
||||
// because of building or dungeon walls no longer draws, and so never takes a
|
||||
// click; MonsterHudSettings.HideBehindWalls (default on) turns it off.
|
||||
//
|
||||
// Where the answers come from (AC memory: Compatibility/AcCellSight.cs; the
|
||||
// rules: PlateSightRules.cs):
|
||||
// - The viewer: the cell AC renders from (the camera's), its seen_outside
|
||||
// flag and its visible-cell list. Read when the scan or the frame asks;
|
||||
// the list (and the doorways below) is cached until the viewer changes
|
||||
// cell.
|
||||
// - Per frame: the render device's draw stamp, sampled once a frame. An
|
||||
// EnvCell whose stamp is newer than the sample taken two frames ago was
|
||||
// drawn by AC in the last frame or two, through the portals from the viewer.
|
||||
// - Per plate, per frame: the object's own cell (its CPhysicsObj's cell) and
|
||||
// that cell's stamp and seen_outside.
|
||||
// - The doorways: the portals to the outside of the cells the viewer can see,
|
||||
// cached as landblock-local polygons; each frame those of cells AC drew are
|
||||
// projected to screen rects (only while the viewer is indoors and an outdoor
|
||||
// object asks). A doorway partly behind the camera counts as the whole screen.
|
||||
// The 4 Hz scan (MonsterHud.Snapshot) skips objects the cell lists already rule
|
||||
// out, so a town's hidden NPCs no longer use up the label cap; the frame check
|
||||
// (MonsterHud.DrawPlates) does the rest. A plate that goes out of sight fades
|
||||
// out as one leaving the screen does, and takes no click from the first frame.
|
||||
//
|
||||
// Cost: one viewer read per scan and per frame, one cell read per drawn plate,
|
||||
// the cached doorways projected while they matter (a handful of points); the
|
||||
// visible-cell list and the doorway polygons are read again only when the
|
||||
// viewer changes cell (or, while some visible rooms weren't reachable yet,
|
||||
// twice a second). Anything unreadable shows the plate (today's behaviour) and
|
||||
// is logged once.
|
||||
//
|
||||
// AC's main thread only. Unload-safe: engine-owned statics, no hooks.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
using RynthCore.Engine.D3D9;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
internal static class PlateSight
|
||||
{
|
||||
private const int MaxVisible = 1024; // AcCellSight's cap on a visible-cell list
|
||||
private const int MaxRooms = 96; // rooms walked for doorways
|
||||
private const int MaxDoorwayRects = 24;
|
||||
private static readonly long RebuildIncompleteTicks = Stopwatch.Frequency / 2;
|
||||
private static readonly long RebuildAnywayTicks = Stopwatch.Frequency * 5;
|
||||
private const float DoorwayMarginPx = 6f;
|
||||
|
||||
// ── The viewer (refreshed by the scan and every frame) ───────────────
|
||||
private static uint _viewerCell, _playerCell;
|
||||
private static IntPtr _viewerPtr;
|
||||
private static SightFact _viewerSeesOutside;
|
||||
|
||||
// ── Cached for one viewer cell ───────────────────────────────────────
|
||||
private static uint _cacheCell;
|
||||
private static IntPtr _cachePtr;
|
||||
private static long _cacheTicks;
|
||||
private static bool _cacheIncomplete;
|
||||
private static readonly uint[] Visible = new uint[MaxVisible];
|
||||
private static int _visibleCount = -1; // -1: the list couldn't be read
|
||||
private struct Doorway { public IntPtr Cell; public uint CellId; public Vector3[] World; }
|
||||
private static readonly List<Doorway> Doorways = new(16);
|
||||
private static bool _doorwaysKnown;
|
||||
private static readonly List<AcCellSight.PortalRead> PortalWork = new(16);
|
||||
private static readonly Queue<(IntPtr Cell, uint Id)> RoomQueue = new(32);
|
||||
private static readonly HashSet<uint> RoomSeen = new();
|
||||
|
||||
// ── Per frame ────────────────────────────────────────────────────────
|
||||
private static uint _stampPrev1, _stampPrev2; // the device stamp one and two frames ago
|
||||
private static int _stampSamples; // consecutive good samples (2+: _since is usable)
|
||||
private static uint _since;
|
||||
private static bool _stampsOk;
|
||||
private static int _frame;
|
||||
private static int _rectsFrame = -1;
|
||||
private static readonly List<Vector4> Rects = new(MaxDoorwayRects);
|
||||
private static SightFact _rectsState; // Unknown: the doorways couldn't be worked out this frame
|
||||
private static int _doorwaysDrawn;
|
||||
private static int _hiddenThisFrame, _hiddenLastFrame;
|
||||
|
||||
private static int _hideLogged, _viewerFailLogged;
|
||||
|
||||
/// <summary>The plates in the last frame that were out of sight (diagnostics).</summary>
|
||||
public static int HiddenCount => _hiddenLastFrame;
|
||||
|
||||
/// <summary>Drops every cache (logout, character switch). The next read starts again.</summary>
|
||||
public static void Reset()
|
||||
{
|
||||
_viewerCell = _playerCell = 0;
|
||||
_viewerPtr = IntPtr.Zero;
|
||||
_viewerSeesOutside = SightFact.Unknown;
|
||||
_cacheCell = 0;
|
||||
_cachePtr = IntPtr.Zero;
|
||||
_visibleCount = -1;
|
||||
Doorways.Clear();
|
||||
_doorwaysKnown = false;
|
||||
_stampSamples = 0;
|
||||
_stampsOk = false;
|
||||
_rectsFrame = -1;
|
||||
_hiddenThisFrame = _hiddenLastFrame = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the viewer (camera) cell and, when it changed, its visible-cell list and doorways.
|
||||
/// <paramref name="playerCell"/>: the player's own cell. AC's main thread.
|
||||
/// </summary>
|
||||
public static void Refresh(uint playerCell)
|
||||
{
|
||||
_playerCell = playerCell;
|
||||
if (!AcCellSight.TryGetViewer(out uint cell, out IntPtr ptr))
|
||||
{
|
||||
// No SmartBox viewer: the player's own cell stands in (no lists, no doorways from it).
|
||||
if (_viewerFailLogged == 0)
|
||||
{
|
||||
_viewerFailLogged = 1;
|
||||
RynthLog.UI("MonsterHud: can't read AC's viewer cell - plates behind walls go by your own cell only.");
|
||||
}
|
||||
cell = playerCell;
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
_viewerCell = cell;
|
||||
_viewerPtr = ptr;
|
||||
bool? outside = PlateSightRules.IsIndoor(cell) ? AcCellSight.SeesOutside(ptr, cell) : true;
|
||||
_viewerSeesOutside = outside == null ? SightFact.Unknown : outside.Value ? SightFact.Yes : SightFact.No;
|
||||
|
||||
long now = Stopwatch.GetTimestamp();
|
||||
bool rebuild = cell != _cacheCell || ptr != _cachePtr ||
|
||||
(_cacheIncomplete && now - _cacheTicks >= RebuildIncompleteTicks) ||
|
||||
(PlateSightRules.IsIndoor(cell) && now - _cacheTicks >= RebuildAnywayTicks);
|
||||
if (rebuild) Rebuild(cell, ptr, now);
|
||||
}
|
||||
|
||||
private static void Rebuild(uint cell, IntPtr ptr, long now)
|
||||
{
|
||||
_cacheCell = cell;
|
||||
_cachePtr = ptr;
|
||||
_cacheTicks = now;
|
||||
_cacheIncomplete = false;
|
||||
Doorways.Clear();
|
||||
_rectsFrame = -1;
|
||||
if (!PlateSightRules.IsIndoor(cell))
|
||||
{
|
||||
// Outdoors: no list and no doorways are needed.
|
||||
_visibleCount = 0;
|
||||
_doorwaysKnown = true;
|
||||
return;
|
||||
}
|
||||
_visibleCount = ptr == IntPtr.Zero ? -1 : AcCellSight.ReadVisibleCells(ptr, cell, Visible);
|
||||
if (_viewerSeesOutside == SightFact.No)
|
||||
{
|
||||
// A dungeon: AC draws nothing outdoors from here, so there are no doorways to look through.
|
||||
_doorwaysKnown = true;
|
||||
return;
|
||||
}
|
||||
_doorwaysKnown = ptr != IntPtr.Zero && _visibleCount >= 0 && WalkRooms(cell, ptr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The doorways to the outside of the viewer's room and of every room it can see that AC's
|
||||
/// portal walk has reached (the portal's other-cell pointer is filled as AC walks into it).
|
||||
/// </summary>
|
||||
private static bool WalkRooms(uint cell, IntPtr ptr)
|
||||
{
|
||||
RoomQueue.Clear();
|
||||
RoomSeen.Clear();
|
||||
RoomQueue.Enqueue((ptr, cell));
|
||||
RoomSeen.Add(cell);
|
||||
int rooms = 0;
|
||||
while (RoomQueue.Count > 0 && rooms < MaxRooms)
|
||||
{
|
||||
(IntPtr c, uint id) = RoomQueue.Dequeue();
|
||||
rooms++;
|
||||
PortalWork.Clear();
|
||||
if (!AcCellSight.ReadPortals(c, id, PortalWork))
|
||||
{
|
||||
if (id == cell) return false; // the viewer's own room unreadable: no doorway answer
|
||||
_cacheIncomplete = true;
|
||||
continue;
|
||||
}
|
||||
foreach (AcCellSight.PortalRead pr in PortalWork)
|
||||
{
|
||||
if (pr.OtherId == AcCellSight.OutdoorsId)
|
||||
{
|
||||
if (pr.World != null) Doorways.Add(new Doorway { Cell = c, CellId = id, World = pr.World });
|
||||
else return false; // a doorway we can't place: no doorway answer (plates show)
|
||||
continue;
|
||||
}
|
||||
if (!RoomSeen.Add(pr.OtherId) || !InVisible(pr.OtherId)) continue;
|
||||
if (pr.OtherCell == IntPtr.Zero || !AcCellSight.IsCell(pr.OtherCell, pr.OtherId))
|
||||
{
|
||||
_cacheIncomplete = true; // AC hasn't walked in yet: look again shortly
|
||||
continue;
|
||||
}
|
||||
RoomQueue.Enqueue((pr.OtherCell, pr.OtherId));
|
||||
}
|
||||
}
|
||||
if (RoomQueue.Count > 0) _cacheIncomplete = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool InVisible(uint cell)
|
||||
{
|
||||
for (int i = 0; i < _visibleCount; i++)
|
||||
if (Visible[i] == cell) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<uint> VisibleSpan => _visibleCount > 0 ? Visible.AsSpan(0, _visibleCount) : ReadOnlySpan<uint>.Empty;
|
||||
|
||||
/// <summary>The scan's question for an object in <paramref name="objectCell"/>: the cell lists only.</summary>
|
||||
public static bool ShowCoarse(uint objectCell) =>
|
||||
PlateSightRules.ShowCoarse(_viewerCell, _playerCell, _viewerSeesOutside, VisibleSpan, _visibleCount >= 0, objectCell);
|
||||
|
||||
/// <summary>Once a frame, before the plates ask: the viewer and the draw stamp.</summary>
|
||||
public static void BeginFrame(uint playerCell)
|
||||
{
|
||||
_frame++;
|
||||
_hiddenLastFrame = _hiddenThisFrame;
|
||||
_hiddenThisFrame = 0;
|
||||
Refresh(playerCell);
|
||||
if (AcCellSight.TryReadFrameStamp(out uint stamp))
|
||||
{
|
||||
_since = _stampPrev2;
|
||||
_stampsOk = _stampSamples >= 2;
|
||||
_stampPrev2 = _stampPrev1;
|
||||
_stampPrev1 = stamp;
|
||||
if (_stampSamples < 2) _stampSamples++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_stampSamples = 0;
|
||||
_stampsOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does this object's plate or label show this frame? <paramref name="objectCell"/>: its live cell.
|
||||
/// <paramref name="headFront"/>: the head point is in front of the camera, at <paramref name="head"/>
|
||||
/// (ImGui pixels, not pinned); <paramref name="feetWx"/>.. the feet in the projection's frame
|
||||
/// (D3D axes, as Plate.LastW*).
|
||||
/// </summary>
|
||||
public static bool Show(ref MonsterHud.Frame f, uint id, uint objectCell, bool headFront, Vector2 head,
|
||||
float feetWx, float feetWy, float feetWz)
|
||||
{
|
||||
bool feetFront = GameMatrixCapture.WorldToScreen(feetWx, feetWy, feetWz, out float fsx, out float fsy);
|
||||
var feet = new Vector2(fsx * f.MapX, fsy * f.MapY);
|
||||
bool onScreen = (headFront && Inside(ref f, head)) || (feetFront && Inside(ref f, feet));
|
||||
|
||||
var q = new SightQuery
|
||||
{
|
||||
ViewerCell = _viewerCell, PlayerCell = _playerCell, ViewerSeesOutside = _viewerSeesOutside,
|
||||
ViewerVisible = VisibleSpan, VisibleKnown = _visibleCount >= 0,
|
||||
ObjectCell = objectCell, OnScreen = onScreen,
|
||||
};
|
||||
bool viewerIndoor = PlateSightRules.IsIndoor(_viewerCell);
|
||||
if (PlateSightRules.IsIndoor(objectCell) && objectCell != _viewerCell && objectCell != _playerCell)
|
||||
{
|
||||
// The object's room: AC's draw stamp on it, and whether it sees outside.
|
||||
if (ClientObjectHooks.TryGetObjectCell(id, out IntPtr cell, out uint cellId) && cellId == objectCell && cell != IntPtr.Zero)
|
||||
{
|
||||
if (_stampsOk && AcCellSight.TryReadDrawStamp(cell, cellId, out uint st))
|
||||
q.ObjectCellDrawn = PlateSightRules.DrawnSince(st, _since) ? SightFact.Yes : SightFact.No;
|
||||
bool? so = AcCellSight.SeesOutside(cell, cellId);
|
||||
q.ObjectSeesOutside = so == null ? SightFact.Unknown : so.Value ? SightFact.Yes : SightFact.No;
|
||||
}
|
||||
}
|
||||
else if (!PlateSightRules.IsIndoor(objectCell) && viewerIndoor && onScreen && _viewerSeesOutside != SightFact.No)
|
||||
{
|
||||
q.InDoorway = InDoorway(ref f, headFront ? head : feet, feetFront ? feet : head);
|
||||
}
|
||||
|
||||
bool show = PlateSightRules.Show(in q);
|
||||
if (!show)
|
||||
{
|
||||
_hiddenThisFrame++;
|
||||
if (_hideLogged < 3)
|
||||
{
|
||||
_hideLogged++;
|
||||
RynthLog.UI($"MonsterHud: a plate is behind walls - hidden (viewer cell 0x{_viewerCell:X8}, sees outside {_viewerSeesOutside}, " +
|
||||
$"object cell 0x{objectCell:X8}, on screen {onScreen}, drawn {q.ObjectCellDrawn}, doorway {q.InDoorway}, " +
|
||||
$"{_visibleCount} visible cells, {Doorways.Count} doorways).");
|
||||
}
|
||||
}
|
||||
return show;
|
||||
}
|
||||
|
||||
private static bool Inside(ref MonsterHud.Frame f, Vector2 p) =>
|
||||
p.X >= 0f && p.Y >= 0f && p.X <= f.Display.X && p.Y <= f.Display.Y;
|
||||
|
||||
/// <summary>An outdoor object seen from inside: does a doorway AC drew cover its head-to-feet line on screen?</summary>
|
||||
private static SightFact InDoorway(ref MonsterHud.Frame f, Vector2 a, Vector2 b)
|
||||
{
|
||||
if (_rectsFrame != _frame) BuildRects(ref f);
|
||||
if (_rectsState != SightFact.Yes) return SightFact.Unknown;
|
||||
float x0 = MathF.Min(a.X, b.X), x1 = MathF.Max(a.X, b.X), y0 = MathF.Min(a.Y, b.Y), y1 = MathF.Max(a.Y, b.Y);
|
||||
float margin = DoorwayMarginPx * f.UiScale;
|
||||
foreach (Vector4 r in Rects)
|
||||
if (PlateSightRules.Overlaps(x0, y0, x1, y1, r.X, r.Y, r.Z, r.W, margin)) return SightFact.Yes;
|
||||
return SightFact.No;
|
||||
}
|
||||
|
||||
/// <summary>This frame's screen rects of the doorways to the outside in rooms AC drew.</summary>
|
||||
private static void BuildRects(ref MonsterHud.Frame f)
|
||||
{
|
||||
_rectsFrame = _frame;
|
||||
Rects.Clear();
|
||||
_doorwaysDrawn = 0;
|
||||
if (!_stampsOk || !_doorwaysKnown) { _rectsState = SightFact.Unknown; return; }
|
||||
var full = new Vector4(0f, 0f, f.Display.X, f.Display.Y);
|
||||
foreach (Doorway d in Doorways)
|
||||
{
|
||||
if (!AcCellSight.TryReadDrawStamp(d.Cell, d.CellId, out uint st)) { _rectsState = SightFact.Unknown; return; }
|
||||
if (!PlateSightRules.DrawnSince(st, _since)) continue; // AC didn't draw that room: its doorway isn't in view
|
||||
_doorwaysDrawn++;
|
||||
if (!MonsterHud.TryOffset(f.FrameCell, d.CellId, out float ox, out float oy)) continue;
|
||||
int front = 0, behind = 0;
|
||||
float x0 = float.MaxValue, y0 = float.MaxValue, x1 = float.MinValue, y1 = float.MinValue;
|
||||
foreach (Vector3 v in d.World)
|
||||
{
|
||||
if (!GameMatrixCapture.WorldToScreen(v.X + ox, v.Z, v.Y + oy, out float sx, out float sy)) { behind++; continue; }
|
||||
front++;
|
||||
sx *= f.MapX; sy *= f.MapY;
|
||||
x0 = MathF.Min(x0, sx); x1 = MathF.Max(x1, sx);
|
||||
y0 = MathF.Min(y0, sy); y1 = MathF.Max(y1, sy);
|
||||
}
|
||||
if (front == 0) continue; // wholly behind the camera
|
||||
Vector4 r = behind > 0 ? full : new Vector4(x0, y0, x1, y1); // straddling the camera: anywhere
|
||||
if (Rects.Count < MaxDoorwayRects) Rects.Add(r);
|
||||
else { Rects[0] = full; break; } // too many to keep apart: the whole screen
|
||||
}
|
||||
_rectsState = SightFact.Yes;
|
||||
}
|
||||
|
||||
/// <summary>One line for "/rv plates status".</summary>
|
||||
public static string Describe()
|
||||
{
|
||||
bool indoor = PlateSightRules.IsIndoor(_viewerCell);
|
||||
return $"Behind walls: {(MonsterHudSettings.HideBehindWalls ? "hidden" : "shown (setting off)")}; " +
|
||||
$"viewer cell 0x{_viewerCell:X8} ({(_viewerCell == 0 ? "unknown" : indoor ? "indoors" : "outdoors")}, sees outside {_viewerSeesOutside}), " +
|
||||
$"{(_visibleCount < 0 ? "visible cells unreadable" : $"{_visibleCount} visible cells")}, " +
|
||||
$"{(_doorwaysKnown ? $"{Doorways.Count} doorways ({_doorwaysDrawn} drawn)" : "doorways unknown")}" +
|
||||
$"{(_cacheIncomplete ? ", some rooms not reached yet" : "")}; " +
|
||||
$"{AcCellSight.Status}{(_stampsOk ? "" : " (no stamp window yet)")}; {_hiddenLastFrame} out of sight last frame.";
|
||||
}
|
||||
}
|
||||
116
src/RynthCore.Engine/ImGui/MonsterHud/PlateSightRules.cs
Normal file
116
src/RynthCore.Engine/ImGui/MonsterHud/PlateSightRules.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/PlateSightRules.cs
|
||||
// The pure half of PlateSight (2026-11-04, problem report
|
||||
// R-20261105-020337-67aa: "NPC and Mob labels show up through walls", and in a
|
||||
// town the labels caught the clicks meant for the shop): given what was read
|
||||
// out of AC's cells, can the player see this object, or is it behind building
|
||||
// or dungeon walls? No AC memory, no engine state: tools/PlateSightTests
|
||||
// compiles this file in and checks every case offline.
|
||||
//
|
||||
// Cells: an id's low word is the cell in its landblock; 0x0001-0x0040 are the
|
||||
// outdoor land cells, 0x0100 and up the EnvCells (dungeon and building rooms).
|
||||
// "The viewer" is the cell AC renders from (the camera's; SmartBox's viewer
|
||||
// cell), which is what decides what is on screen.
|
||||
//
|
||||
// Order of the answers, best first (AcCellSight.cs has the evidence):
|
||||
// 1. AC's own draw stamps: an EnvCell AC drew this frame is on screen through
|
||||
// the portals from the viewer; one it didn't draw is behind walls. Used only
|
||||
// for objects that project onto the screen: AC also skips cells outside the
|
||||
// view, and a plate pinned to the screen edge ("Keep on screen") must not
|
||||
// vanish just because its room is off to the side.
|
||||
// 2. AC's doorways: from inside, an outdoor object counts only where a doorway
|
||||
// to the outside that AC drew covers it on screen.
|
||||
// 3. The cell lists: from an EnvCell, only its visible-cell list (and itself)
|
||||
// can ever be drawn, and the outdoors only when it sees outside; from
|
||||
// outdoors, an EnvCell that doesn't see outside (a dungeon, a sealed room)
|
||||
// can't be seen.
|
||||
// Anything unknown keeps today's behaviour: the plate shows.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
/// <summary>A yes / no that may not be known.</summary>
|
||||
internal enum SightFact : byte { Unknown, No, Yes }
|
||||
|
||||
/// <summary>What is known about one object this frame (or this scan, with less filled in).</summary>
|
||||
internal ref struct SightQuery
|
||||
{
|
||||
/// <summary>The cell AC renders from (0: unknown).</summary>
|
||||
public uint ViewerCell;
|
||||
/// <summary>The player's own cell (0: unknown); objects in it always count.</summary>
|
||||
public uint PlayerCell;
|
||||
/// <summary>The viewer cell's seen_outside (outdoors: Yes).</summary>
|
||||
public SightFact ViewerSeesOutside;
|
||||
/// <summary>The viewer cell's visible-cell list; only read when <see cref="VisibleKnown"/>.</summary>
|
||||
public ReadOnlySpan<uint> ViewerVisible;
|
||||
public bool VisibleKnown;
|
||||
|
||||
/// <summary>The object's cell (0: unknown).</summary>
|
||||
public uint ObjectCell;
|
||||
/// <summary>The object's head or feet projects inside the screen (not only pinned to its edge).</summary>
|
||||
public bool OnScreen;
|
||||
/// <summary>AC drew the object's EnvCell in the last frames (Unknown: no stamps, no cell pointer).</summary>
|
||||
public SightFact ObjectCellDrawn;
|
||||
/// <summary>The object's EnvCell sees outside (Unknown: not read).</summary>
|
||||
public SightFact ObjectSeesOutside;
|
||||
/// <summary>An outdoor object seen from inside: a doorway AC drew covers it on screen (Unknown: not worked out).</summary>
|
||||
public SightFact InDoorway;
|
||||
}
|
||||
|
||||
internal static class PlateSightRules
|
||||
{
|
||||
/// <summary>A cell id is an EnvCell (dungeon / building room): low word 0x0100 and up.</summary>
|
||||
public static bool IsIndoor(uint cellId) => (cellId & 0xFFFF) >= 0x0100;
|
||||
|
||||
/// <summary>Does the plate or label for this object show?</summary>
|
||||
public static bool Show(in SightQuery q)
|
||||
{
|
||||
// Nothing to go on: today's behaviour.
|
||||
if ((q.ViewerCell >> 16) == 0 || (q.ObjectCell >> 16) == 0) return true;
|
||||
if (q.ObjectCell == q.ViewerCell || q.ObjectCell == q.PlayerCell) return true;
|
||||
|
||||
bool viewerIndoor = IsIndoor(q.ViewerCell);
|
||||
if (IsIndoor(q.ObjectCell))
|
||||
{
|
||||
// 1. AC drew the object's room this frame, or it didn't.
|
||||
if (q.OnScreen && q.ObjectCellDrawn != SightFact.Unknown) return q.ObjectCellDrawn == SightFact.Yes;
|
||||
// 3. The cell lists.
|
||||
if (viewerIndoor) return !q.VisibleKnown || Contains(q.ViewerVisible, q.ObjectCell);
|
||||
return q.ObjectSeesOutside != SightFact.No;
|
||||
}
|
||||
|
||||
// An outdoor object.
|
||||
if (!viewerIndoor) return true; // both outdoors: no change (no terrain or building occlusion)
|
||||
if (q.ViewerSeesOutside == SightFact.No) return false; // a dungeon: AC draws nothing outdoors from here
|
||||
if (q.OnScreen && q.InDoorway != SightFact.Unknown) return q.InDoorway == SightFact.Yes;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The 4 Hz scan's question: the cell lists only (no frame, no screen).</summary>
|
||||
public static bool ShowCoarse(uint viewerCell, uint playerCell, SightFact viewerSeesOutside, ReadOnlySpan<uint> viewerVisible,
|
||||
bool visibleKnown, uint objectCell)
|
||||
{
|
||||
var q = new SightQuery
|
||||
{
|
||||
ViewerCell = viewerCell, PlayerCell = playerCell, ViewerSeesOutside = viewerSeesOutside,
|
||||
ViewerVisible = viewerVisible, VisibleKnown = visibleKnown, ObjectCell = objectCell,
|
||||
};
|
||||
return Show(in q);
|
||||
}
|
||||
|
||||
/// <summary>A stamp written at or after the sample <paramref name="since"/> was taken (wraps).</summary>
|
||||
public static bool DrawnSince(uint cellStamp, uint since) => unchecked((int)(cellStamp - since)) > 0;
|
||||
|
||||
/// <summary>Two screen rects (x0, y0, x1, y1) overlap, the second grown by <paramref name="margin"/>.</summary>
|
||||
public static bool Overlaps(float ax0, float ay0, float ax1, float ay1, float bx0, float by0, float bx1, float by1, float margin) =>
|
||||
ax0 <= bx1 + margin && ax1 >= bx0 - margin && ay0 <= by1 + margin && ay1 >= by0 - margin;
|
||||
|
||||
private static bool Contains(ReadOnlySpan<uint> cells, uint cell)
|
||||
{
|
||||
foreach (uint c in cells)
|
||||
if (c == cell) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ internal static class PlayerPlate
|
|||
left = l.M.ClampLeft(left, f.Display.X);
|
||||
y = l.M.ClampTop(y, f.Display.Y);
|
||||
}
|
||||
float top = Paint(f.Dl, ref l, MathF.Round(left), MathF.Round(y), f.Now);
|
||||
float top = Paint(f.Dl, ref l, MathF.Round(left), MathF.Round(y), f.Now, f.UnderUi);
|
||||
// Gain text floats above the plate when it's over the head, else above the head itself.
|
||||
PlateTop = where == SelfPlatePosition.Above ? top : head.Y;
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ internal static class PlayerPlate
|
|||
dl.AddRectFilled(r0, r1, MonsterHud.Mul(hot ? 0x40000000u : 0x28000000u, a), 3f);
|
||||
dl.AddRect(r0, r1, MonsterHud.Mul(hot ? FrameHot : FrameCol, a), 3f, ImDrawFlags.None, hot ? 1.5f : 1f);
|
||||
}
|
||||
Paint(dl, ref l, left, y, f.Now);
|
||||
Paint(dl, ref l, left, y, f.Now, underUi: false);
|
||||
}
|
||||
|
||||
private static uint FrameCol => RynthTheme.WithAlpha(RynthTheme.Accent, 0xB0);
|
||||
|
|
@ -406,18 +406,21 @@ internal static class PlayerPlate
|
|||
|
||||
/// <summary>
|
||||
/// Paints the three bars (and the name over them, the debuff row under them) with the bars' top-left
|
||||
/// at (left, y); returns the plate's top. <paramref name="now"/> is Stopwatch ticks.
|
||||
/// at (left, y); returns the plate's top. <paramref name="now"/> is Stopwatch ticks; <paramref name="underUi"/>:
|
||||
/// <paramref name="dl"/> is the layer under AC's windows (the debuff tooltips then give way to them).
|
||||
/// </summary>
|
||||
private static float Paint(ImDrawListPtr dl, ref Layout l, float left, float y, long now)
|
||||
private static float Paint(ImDrawListPtr dl, ref Layout l, float left, float y, long now, bool underUi)
|
||||
{
|
||||
float a = Math.Clamp(_alpha, 0f, 1f);
|
||||
ref SelfPlateMetrics m = ref l.M;
|
||||
PaintOne(dl, ref _hp, ref l, left, y, a, HealthCol);
|
||||
PaintOne(dl, ref _st, ref l, left, y + m.BarH + m.Gap, a, StaminaCol);
|
||||
PaintOne(dl, ref _mn, ref l, left, y + 2 * (m.BarH + m.Gap), a, ManaCol);
|
||||
// No tooltip mid-drag: the drag owns the cursor.
|
||||
if (_iconCount > 0)
|
||||
DebuffIconRow.Paint(dl, _icons, _iconCount, others: false, in m.Row, l.IconText, l.IconTextSize,
|
||||
ref _overflowKey, ref _overflowText, left + m.BarW * 0.5f, y + m.RowTop, a, now);
|
||||
ref _overflowKey, ref _overflowText, left + m.BarW * 0.5f, y + m.RowTop, a, now,
|
||||
_dragging ? DebuffRowTips.Off : DebuffRowTips.Self, underUi);
|
||||
float top = y - 1f;
|
||||
if (MonsterHudSettings.SelfName)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
// - one icon per kind (DebuffKind); a kind merging several categories shows
|
||||
// their count and the soonest end, like the monster row;
|
||||
// - icons in kind order (the monster row's), as many as fit in dst; the
|
||||
// count returned includes the rest (the "+N").
|
||||
// count returned includes the rest (the "+N");
|
||||
// - each icon carries its categories' spell ids (the hover tooltip names them).
|
||||
// No engine dependencies beyond DebuffIcon.cs (the offline tests compile it).
|
||||
// ============================================================================
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ internal static class SelfDebuffs
|
|||
Span<double> catEnd = stackalloc double[MaxEntries];
|
||||
Span<float> catDur = stackalloc float[MaxEntries];
|
||||
Span<byte> catKind = stackalloc byte[MaxEntries];
|
||||
Span<uint> catSpell = stackalloc uint[MaxEntries];
|
||||
int cats = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
|
|
@ -82,6 +84,7 @@ internal static class SelfDebuffs
|
|||
catEnd[c] = end;
|
||||
catDur[c] = dur;
|
||||
catKind[c] = (byte)Math.Min((int)kind, KindCount - 1);
|
||||
catSpell[c] = id;
|
||||
}
|
||||
if (cats == 0) return 0;
|
||||
|
||||
|
|
@ -114,6 +117,12 @@ internal static class SelfDebuffs
|
|||
dst[count] = new DebuffIcon { Kind = (DebuffKind)k, Expiry = kindEnd[k], Duration = kindDur[k], Stack = kindStack[k] };
|
||||
count++;
|
||||
}
|
||||
|
||||
// 4. The hover tooltip's spell names: each category's spell on its kind's icon.
|
||||
int shown = Math.Min(count, dst.Length);
|
||||
for (int c = 0; c < cats; c++)
|
||||
for (int i = 0; i < shown; i++)
|
||||
if ((int)dst[i].Kind == catKind[c]) { dst[i].AddSpell(catSpell[c]); break; }
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
// The Classic look's Gear tab: RynthAi's Items lists (UiSources.Items, the
|
||||
// Items panel's source) in the retail style. Weapons with their element (a
|
||||
// drop-down; a weapon no longer carried shows "missing"), consumables with
|
||||
// their kind, a remove mark on each row; add the item selected in game as a
|
||||
// their kind, a remove mark on each row, a "No buff" gem on a shield row
|
||||
// (when RynthAi sends noBuff); add the item selected in game as a
|
||||
// weapon, a shield or a consumable; drop the missing ones; the shield and
|
||||
// mana-tap settings that ride the same list. Saved like the Items panel: the
|
||||
// whole payload (ItemsCommands.SetJson), older snapshots ignored after a save
|
||||
|
|
@ -176,6 +177,18 @@ internal sealed class ClassicGearTab : IClassicTab
|
|||
}
|
||||
SafeImGui.SetItemTooltip("The damage this weapon deals (picks it for monsters weak to it)");
|
||||
}
|
||||
else if (e.ShowsNoBuff)
|
||||
{
|
||||
// A shield has no element: its column is the "No buff" toggle (a RynthAi that sends noBuff).
|
||||
bool nb = e.NoBuff == true;
|
||||
if (Gem("##nobuff", "No buff", new Vector2(p.X + listW - xW - ddW - Px(2), p.Y), ddW, nb, 19))
|
||||
{
|
||||
e.NoBuff = !nb;
|
||||
Save();
|
||||
}
|
||||
SafeImGui.SetItemTooltip("Never buff this shield - for a shield that already carries its buffs.\n"
|
||||
+ "RynthAi then aims no armor spells at it, and its spells running low never start a rebuff.");
|
||||
}
|
||||
if (RemoveMark("##x", new Vector2(p.X + listW - xW, p.Y), rowH)) remove = i;
|
||||
SafeImGui.SetItemTooltip("Remove " + e.Name + " from the list");
|
||||
ImGuiNET.ImGui.PopID();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@
|
|||
// automatic.
|
||||
// Under a monster's row, when the plugin sends them (the row's "mstats",
|
||||
// UI/Data/DamageRowStats.cs, 2026-10-30): how often it evades and resists you
|
||||
// and you it since login, the full numbers on hover.
|
||||
// and you it since login, the full numbers on hover; "XP/kill" first when the
|
||||
// plugin counts XP ("xp"/"xk", 2026-11-08), then "corpse 2.1 s" when it times
|
||||
// the death animation ("cd"/"cn"), then "Hits taken: shield 11 avg (front 95%),
|
||||
// no shield 54 avg" when the plugin has learned its hits by shield and facing
|
||||
// ("h/d/m" + sf..nu, 2026-11-08; kept across logins, not since login).
|
||||
// Where the server plugin reports difficulty tiers: a tier chip after Reset stats
|
||||
// (DamageView.Tier) - which tier the numbers are for, and a picker; "~" marks an
|
||||
// HP estimated from tier 0's. Hidden elsewhere.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// current loot profile until it's out of keys."
|
||||
// Select the chest in the world, press Use selected as chest;
|
||||
// select the key in your pack, press Use selected as key; Start.
|
||||
// Chest re-lock wait (s): how long after the open the next key
|
||||
// goes on (RynthAi's setting, "/ra itemtool relock N").
|
||||
// Quick give Select an item in your pack (Use selected as item) and a player
|
||||
// or NPC in the world (Use selected as target), press Give: every
|
||||
// such item in your packs is handed over, one give at a time.
|
||||
|
|
@ -76,6 +78,8 @@ internal sealed class ItemToolFace : IImGuiPanel
|
|||
if (hit == 0) ItemToolCommands.Send("chest set");
|
||||
else if (hit == 1) ItemToolCommands.Send("chest key");
|
||||
|
||||
DrawRelockWait(c, w);
|
||||
|
||||
hit = StartStop("##chest_run", "Start", "Stop", ready && !c.Running, c.Running, w);
|
||||
if (hit == 0) ItemToolCommands.Send("chest start");
|
||||
else if (hit == 1) ItemToolCommands.Send("chest stop");
|
||||
|
|
@ -83,6 +87,44 @@ internal sealed class ItemToolFace : IImGuiPanel
|
|||
Wrapped(c.Status, c.Running ? Amber : Text, w);
|
||||
}
|
||||
|
||||
// The slider's value while it is dragged, and after the release until RynthAi reports it back
|
||||
// (the snapshot is 250 ms behind; without this the slider jumps back for a moment).
|
||||
private static int _relockEdit;
|
||||
private static bool _relockPending;
|
||||
private static long _relockSentAt;
|
||||
private const long RelockPendingMs = 2000;
|
||||
|
||||
/// <summary>
|
||||
/// "Chest re-lock wait (s)" (2026-11-05): how long after the chest was opened the next key goes on
|
||||
/// it. Sent on release as "relock N" (RynthAi clamps, saves it in the profile and answers in chat).
|
||||
/// Hidden for a RynthAi that predates it (no relockSec); greyed until the profile has loaded.
|
||||
/// </summary>
|
||||
private static void DrawRelockWait(ChestToolState c, float w)
|
||||
{
|
||||
if (c.RelockSec <= 0) return;
|
||||
int min = Math.Max(1, c.RelockMin), max = Math.Max(min, c.RelockMax);
|
||||
long now = Environment.TickCount64;
|
||||
if (_relockPending && (c.RelockSec == _relockEdit || now - _relockSentAt >= RelockPendingMs)) _relockPending = false;
|
||||
|
||||
Label("Chest re-lock wait (s)", Mute);
|
||||
int v = _relockPending ? _relockEdit : c.RelockSec;
|
||||
ImGuiNET.ImGui.BeginDisabled(!c.RelockReady);
|
||||
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(80, w - 4));
|
||||
ImGuiNET.ImGui.SliderInt("##chest_relock", ref v, min, max, "%d s", ImGuiSliderFlags.AlwaysClamp);
|
||||
if (ImGuiNET.ImGui.IsItemActive()) { _relockEdit = v; _relockPending = true; _relockSentAt = now; }
|
||||
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
_relockEdit = v;
|
||||
_relockPending = true;
|
||||
_relockSentAt = now;
|
||||
ItemToolCommands.Send("relock " + v.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
SafeImGui.SetItemTooltip(c.RelockReady
|
||||
? "How long after the chest was opened the next key goes on it (sooner when it reads locked again).\n125 s fits the usual 2-minute chest reset; a chest that resets sooner can use less.\nToo short costs nothing: the key is only tried again, never spent. Ctrl+click to type a value."
|
||||
: "Waiting for this character's settings profile to load.");
|
||||
ImGuiNET.ImGui.EndDisabled();
|
||||
}
|
||||
|
||||
// ── Quick give ──────────────────────────────────────────────────────
|
||||
|
||||
private static void DrawGive(GiveToolState g, float w)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
// and mana stone tapping (on/off, keep count, min max-mana to tap). A listed
|
||||
// weapon the character no longer carries (RynthAi's missingIds) shows in amber
|
||||
// with a warning icon and "(missing)", and says what to do in its tooltip.
|
||||
// A shield row (Action "Shield") from a RynthAi that sends noBuff shows a
|
||||
// "No buff" toggle in place of its element column: on = RynthAi never buffs
|
||||
// that shield. Weapon rows are unchanged.
|
||||
//
|
||||
// Edits change a private copy and save the whole payload (ItemsCommands,
|
||||
// pump thread). A newer snapshot replaces the copy; snapshots from before
|
||||
|
|
@ -91,8 +94,15 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
int i = idx[k];
|
||||
ItemsPanel.WeaponEntry wpn = _data.Weapons[i];
|
||||
ImGuiNET.ImGui.PushID("w" + i);
|
||||
int r = Row(wpn.Name, wpn.Element, shown++, bw, _data.MissingIds.Contains(wpn.Id), k > 0, k < idx.Count - 1);
|
||||
int r = Row(wpn.Name, wpn.Element, shown++, bw, _data.MissingIds.Contains(wpn.Id), k > 0, k < idx.Count - 1,
|
||||
wpn.ShowsNoBuff ? wpn.NoBuff : null);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
if (r == 5)
|
||||
{
|
||||
wpn.NoBuff = !(wpn.NoBuff ?? false);
|
||||
Save();
|
||||
continue;
|
||||
}
|
||||
// Up / down inside its group: the order is RynthAi's preference (the buff wand, the
|
||||
// first weapon of a kind), and it couldn't be changed but by removing and re-adding.
|
||||
if (r == 3 || r == 4)
|
||||
|
|
@ -273,13 +283,19 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
// The up / down buttons' width in a row (two 20 px buttons and their gaps).
|
||||
private const float MoveW = 46;
|
||||
|
||||
private const string NoBuffTip = "Never buff this shield - for a shield that already carries its buffs.\n"
|
||||
+ "RynthAi then aims no armor spells at it, and its spells running low never start a rebuff.";
|
||||
|
||||
/// <summary>
|
||||
/// Name | up | down | [value picker] | Del. Returns 1 when the picker was clicked, 2 for Del,
|
||||
/// 3 for up, 4 for down, else 0. Up / down are drawn dim and do nothing at the ends.
|
||||
/// <paramref name="missing"/>: the item isn't carried any more (amber, a warning icon,
|
||||
/// "(missing)" and a tooltip saying what to do).
|
||||
/// 3 for up, 4 for down, 5 for the "No buff" toggle, else 0. Up / down are drawn dim and do
|
||||
/// nothing at the ends. <paramref name="missing"/>: the item isn't carried any more (amber, a
|
||||
/// warning icon, "(missing)" and a tooltip saying what to do). <paramref name="noBuff"/>
|
||||
/// non-null (a shield row, RynthAi sending noBuff): the value column is the "No buff" toggle
|
||||
/// instead of the picker (a shield has no element; its column only said "Shield").
|
||||
/// </summary>
|
||||
private static int Row(string name, string value, int index, float w, bool missing, bool canUp = false, bool canDown = false)
|
||||
private static int Row(string name, string value, int index, float w, bool missing, bool canUp = false, bool canDown = false,
|
||||
bool? noBuff = null)
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
|
|
@ -311,7 +327,14 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
if (IconButton("##down", PhosphorIcons.CaretDown, new Vector2(bx + 22, p.Y + 2), new Vector2(20, 20), canDown ? Teal : Mute, BtnFill) && canDown) result = 4;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Move down");
|
||||
bx += MoveW;
|
||||
if (Button("##pick", value, new Vector2(bx, p.Y + 2), new Vector2(96, 20), Text, BtnFill)) result = 1;
|
||||
if (noBuff is bool nb)
|
||||
{
|
||||
// The tapping toggle's look: lit while the shield is left out of buffing.
|
||||
if (Button("##nobuff", (nb ? PhosphorIcons.CheckSquare : PhosphorIcons.Square) + " No buff", new Vector2(bx, p.Y + 2), new Vector2(96, 20),
|
||||
nb ? OnText : Mute, nb ? OnBg : BtnFill)) result = 5;
|
||||
ImGuiNET.ImGui.SetItemTooltip(NoBuffTip);
|
||||
}
|
||||
else if (Button("##pick", value, new Vector2(bx, p.Y + 2), new Vector2(96, 20), Text, BtnFill)) result = 1;
|
||||
if (IconButton("##del", PhosphorIcons.Trash, new Vector2(bx + 100, p.Y + 2), new Vector2(42, 20), Red, BtnFill)) result = 2;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Remove");
|
||||
NextLine(p, 24);
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ internal sealed class PluginWindowFace : IImGuiPanel
|
|||
}
|
||||
if (result == PluginManager.EmbedDrawn)
|
||||
{
|
||||
if (_fitHeight) Fit(want.Y, avail.X);
|
||||
if (_fitHeight) Fit(want.Y, avail.X, want.X);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -137,12 +137,23 @@ internal sealed class PluginWindowFace : IImGuiPanel
|
|||
/// client px) and scales its width with a text size change. Docked only (popped out, the OS window
|
||||
/// is the player's to size); never while the mouse is down, so a drag or a resize isn't fought.
|
||||
/// </summary>
|
||||
private void Fit(float wantPx, float widthPx)
|
||||
private void Fit(float wantPx, float widthPx, float wantWidthPx = 0f)
|
||||
{
|
||||
if (wantPx <= 0f || ImGuiPopOuts.InPopOutFrame) return;
|
||||
float place = Math.Max(0.01f, ImGuiPanelHost.PlacementScale());
|
||||
float height = MathF.Ceiling(wantPx / place);
|
||||
float width = widthPx / place;
|
||||
// A plugin that sizes its own width too (2026-11-07: RynthDreamWeave's retail Character panel, a
|
||||
// fixed design width at its text size) reports a width other than the one it was given: the window
|
||||
// takes it, as it takes the height. Every other plugin hands back the width it got: no change.
|
||||
if (wantWidthPx > 0f && MathF.Abs(wantWidthPx - widthPx) > 1f && ImGuiNET.ImGui.IsMouseDown(ImGuiNET.ImGuiMouseButton.Left) == false)
|
||||
{
|
||||
_contentHeight = height;
|
||||
_fitWidth = MathF.Ceiling(wantWidthPx / place);
|
||||
_fitK = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
|
||||
ImGuiPanelHost.RequestSize(_title, new Vector2(_fitWidth, height));
|
||||
return;
|
||||
}
|
||||
float k = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
|
||||
float shownHeight = ImGuiNET.ImGui.GetWindowHeight() / place;
|
||||
bool mouseUp = !ImGuiNET.ImGui.IsMouseDown(ImGuiNET.ImGuiMouseButton.Left);
|
||||
|
|
|
|||
37
src/RynthCore.Engine/ImGui/Panels/RadarDrag.cs
Normal file
37
src/RynthCore.Engine/ImGui/Panels/RadarDrag.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/RadarDrag.cs
|
||||
// Whether a press on the radar may move it (2026-11-04). Docked click-through
|
||||
// ("Docked click-through (dots still work; Ctrl for the rest)") gives the game
|
||||
// every click, except on a dot or the buttons: there the radar's window takes
|
||||
// input for that press (RadarFace._hot / _pressHot) so the dot can be hovered and
|
||||
// clicked to select. The surface under the dot is the same InvisibleButton that
|
||||
// drags the panel (ImGuiPanelHost.DragWindowWithLastItem), so holding on a dot
|
||||
// and moving the mouse moved the radar, Ctrl or not (Discord, 2026-11-02). Now a
|
||||
// press moves the radar only when click-through is off, Ctrl was held when the
|
||||
// press began, or the radar is popped out (always interactive there). It is
|
||||
// decided when the press begins and holds until the button is up, so Ctrl let go
|
||||
// or pressed mid-drag neither stops a move nor starts one.
|
||||
//
|
||||
// Pure (no ImGui), so tools\RadarSettingsTests links it.
|
||||
// ============================================================================
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal sealed class RadarDrag
|
||||
{
|
||||
private bool _moves = true;
|
||||
|
||||
/// <summary>A press with these settings may move the radar.</summary>
|
||||
public static bool PressMoves(bool clickThroughOn, bool ctrlHeld, bool poppedOut) =>
|
||||
!clickThroughOn || ctrlHeld || poppedOut;
|
||||
|
||||
/// <summary>
|
||||
/// Call once a frame right after the surface item: <paramref name="pressBegan"/> is the surface's
|
||||
/// IsItemActivated. Answers whether this press may move the radar (as decided when it began).
|
||||
/// </summary>
|
||||
public bool Update(bool pressBegan, bool clickThroughOn, bool ctrlHeld, bool poppedOut)
|
||||
{
|
||||
if (pressBegan) _moves = PressMoves(clickThroughOn, ctrlHeld, poppedOut);
|
||||
return _moves;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,8 @@
|
|||
// The object selected in game is highlighted (RadarSettingsStore.HighlightSelected, RadarSelection):
|
||||
// a ring in its own colour round its marker and the hover label beside it, or an arrow on the
|
||||
// edge when it is off the picture.
|
||||
// Range rings round you at RynthAi's Monster Range and Ring Range (RadarRangeRing; each has a box in
|
||||
// the settings), read from RynthAi's settings while one is on.
|
||||
//
|
||||
// Data: UiSources.Radar (RadarView, lookups precomputed). World geometry is
|
||||
// drawn without anti-aliasing (crisp tiling like the Avalonia face's aliased
|
||||
|
|
@ -71,6 +73,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
private bool _settingsSub; // subscribed to RynthAi's settings (the retail radar switch) while the window is open
|
||||
private bool? _hidePending; // the retail-radar switch as just set, until RynthAi's answer shows it
|
||||
private long _hidePendingAt;
|
||||
private bool _rangeSub; // subscribed to RynthAi's settings while a range ring is on
|
||||
|
||||
// The round radar (RadarSettingsStore.RoundRadar): this frame's circle, read by the drawing helpers.
|
||||
private static bool _round;
|
||||
|
|
@ -86,6 +89,8 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
// dot can always be hovered and clicked. A press that began on a dot keeps the panel interactive
|
||||
// until the button is released.
|
||||
private bool _hot, _pressHot, _downPrev;
|
||||
// Whether the current press on the surface may move the panel (off for a dot press under click-through).
|
||||
private readonly RadarDrag _drag = new();
|
||||
|
||||
public bool ClickThrough =>
|
||||
RadarSettingsStore.CtrlGatedClickThrough && !ImGuiNET.ImGui.GetIO().KeyCtrl && !_hot;
|
||||
|
|
@ -106,10 +111,19 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
{
|
||||
UiSources.Radar.Unsubscribe();
|
||||
if (_settingsSub) { UiSources.Settings.Unsubscribe(); _settingsSub = false; }
|
||||
if (_rangeSub) { UiSources.Settings.Unsubscribe(); _rangeSub = false; }
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
// The range rings need RynthAi's settings (Monster Range, Ring Range): polled only while one is on.
|
||||
bool wantRange = RadarSettingsStore.ShowMonsterRangeRing || RadarSettingsStore.ShowRingRangeRing;
|
||||
if (wantRange != _rangeSub)
|
||||
{
|
||||
if (wantRange) { UiSources.Settings.Subscribe(); UiSources.Settings.RequestRefresh(); }
|
||||
else UiSources.Settings.Unsubscribe();
|
||||
_rangeSub = wantRange;
|
||||
}
|
||||
bool clickThroughNow = ClickThrough; // what the host gave this frame's window (before UpdateHot moves _hot)
|
||||
_wheelHere = false;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
|
|
@ -216,7 +230,11 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
// ── Surface: drag moves the panel, a click on a dot selects, wheel zooms, right-click menu ──
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(origin);
|
||||
bool surfaceClicked = ImGuiNET.ImGui.InvisibleButton("##radar_surface", size);
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
// 2026-11-04: with docked click-through, a press on a dot only selects it; it never moves the
|
||||
// radar unless Ctrl was held when it began (RadarDrag; holding on a dot used to drag the panel).
|
||||
if (_drag.Update(ImGuiNET.ImGui.IsItemActivated(), RadarSettingsStore.CtrlGatedClickThrough,
|
||||
ImGuiNET.ImGui.GetIO().KeyCtrl, ImGuiPopOuts.InPopOutFrame))
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
UpdateHot(view, centre, worldMin, worldMax, gearPos, new Vector2(closePos.X + btn, closePos.Y + btn));
|
||||
if (view != null && RadarSettingsStore.ClickToSelect)
|
||||
MarkerInput(dl, view, centre, worldMin, worldMax, surfaceClicked);
|
||||
|
|
@ -310,6 +328,8 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
if (cur + 1 < count && cur >= 0) DrawLayer(dl, view, cur + 1, 0.30f, false, proj, rotate, clipMin, clipMax);
|
||||
if (cur >= 0) DrawLayer(dl, view, cur, 1.00f, true, proj, rotate, clipMin, clipMax);
|
||||
|
||||
DrawRangeRings(dl, centre, clipMin, clipMax, MathF.Max(0.5f, RadarSettingsStore.Zoom));
|
||||
|
||||
// Markers (shapes: RadarMarkerStyle). Corpses and items first, creatures on top.
|
||||
RadarMarkerStyle.FillColors(KindCols);
|
||||
MarkerStyleSettings markers = RadarSettingsStore.Markers;
|
||||
|
|
@ -350,6 +370,33 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
dl.AddLine(centre, tip, PlayerCol, 2);
|
||||
}
|
||||
|
||||
// ── Range rings ────────────────────────────────────────────────────────
|
||||
// Thin circles round you at RynthAi's Monster Range (warm white) and Ring Range (pale blue), over
|
||||
// the floors and under the markers, each on a faint dark line so it reads on the dark canvas and
|
||||
// on the world map alike. Nothing until RynthAi has sent its settings (UiSources.Settings).
|
||||
private static readonly uint MonsterRangeCol = C(0xB3FFE6B3), RingRangeCol = C(0xA680CCFF), RangeUnder = C(0x59000000);
|
||||
|
||||
private static void DrawRangeRings(ImDrawListPtr dl, Vector2 centre, Vector2 clipMin, Vector2 clipMax, float zoom)
|
||||
{
|
||||
bool monster = RadarSettingsStore.ShowMonsterRangeRing, ring = RadarSettingsStore.ShowRingRangeRing;
|
||||
if (!monster && !ring) return;
|
||||
RynthAiSettings? ra = UiSources.Settings.Current?.Value;
|
||||
if (ra == null) return;
|
||||
ImDrawListFlags saved = dl.Flags;
|
||||
dl.Flags = saved | ImDrawListFlags.AntiAliasedLines; // the world is drawn aliased; a circle looks ragged that way
|
||||
RoundMask? round = _round ? _mask : null;
|
||||
if (monster) RangeRing(dl, centre, clipMin, clipMax, round, RadarRangeRing.RadiusPx(ra.MonsterRange, zoom), MonsterRangeCol);
|
||||
if (ring) RangeRing(dl, centre, clipMin, clipMax, round, RadarRangeRing.RadiusPx(ra.RingRange, zoom), RingRangeCol);
|
||||
dl.Flags = saved;
|
||||
}
|
||||
|
||||
private static void RangeRing(ImDrawListPtr dl, Vector2 centre, Vector2 clipMin, Vector2 clipMax, RoundMask? round, float r, uint col)
|
||||
{
|
||||
if (!RadarRangeRing.Shows(r, centre, clipMin, clipMax, round)) return;
|
||||
dl.AddCircle(centre, r, RangeUnder, 0, 3f); // 0 segments: ImGui picks enough for the radius
|
||||
dl.AddCircle(centre, r, col, 0, 1.25f);
|
||||
}
|
||||
|
||||
// ── The selected object ────────────────────────────────────────────────
|
||||
// A ring in the selection colour round its marker (the marker drawn over everything, even when its
|
||||
// kind's box is off), and the hover label beside it; off the picture, an arrow on the edge pointing
|
||||
|
|
@ -521,7 +568,8 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
// ── Click-to-select ─────────────────────────────────────────────────────
|
||||
// Left-click a dot: that object is selected in game, as a click on it in the
|
||||
// 3D world would. A press that moves more than a few pixels is a drag (the
|
||||
// panel moves) and selects nothing. Hover shows the object's name and
|
||||
// panel moves; with docked click-through and no Ctrl it stays put, RadarDrag)
|
||||
// and selects nothing. Hover shows the object's name and
|
||||
// distance (and its last known health, when the engine has seen one).
|
||||
// RynthAi 2026-10-01 and later send each marker's object id, and the click
|
||||
// selects exactly that id. Older RynthAi builds send no id (Id = 0): then
|
||||
|
|
@ -864,6 +912,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
if (!WorldMapTiles.IsOpen && WorldMapTiles.Status.Length > 0)
|
||||
SafeImGui.TextDisabled(WorldMapTiles.Status);
|
||||
}
|
||||
changed |= RangeRingRows();
|
||||
RetailRadarRow();
|
||||
ImGuiNET.ImGui.Separator();
|
||||
changed |= KindRows();
|
||||
|
|
@ -879,6 +928,29 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
|
||||
private static bool Check(string label, ref bool value) => ImGuiNET.ImGui.Checkbox(label, ref value);
|
||||
|
||||
/// <summary>
|
||||
/// The range rings' boxes. Each label shows the range RynthAi has now (its Settings > Ranges set it);
|
||||
/// the boxes are the radar's own and save with the radar's settings. True when one changed.
|
||||
/// </summary>
|
||||
private static bool RangeRingRows()
|
||||
{
|
||||
RynthAiSettings? ra = UiSources.Settings.Current?.Value;
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
string Yards(int v) => ra == null ? "" : " (" + v.ToString(inv) + " yd)";
|
||||
bool changed = Check("Monster Range ring" + Yards(ra?.MonsterRange ?? 0) + "###mrring", ref RadarSettingsStore.ShowMonsterRangeRing);
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
ImGuiNET.ImGui.SetTooltip("A ring round you at RynthAi's Monster Range: monsters inside it are ones the bot will attack.\nIt follows the setting (Settings > Ranges). Measured along the ground; RynthAi counts height too,\nso a monster a floor up or down can be inside the ring and still out of range.");
|
||||
changed |= Check("Ring Range ring" + Yards(ra?.RingRange ?? 0) + "###rrring", ref RadarSettingsStore.ShowRingRangeRing);
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
ImGuiNET.ImGui.SetTooltip("A second, blue ring at RynthAi's Ring Range: how close monsters must be for its ring spells.");
|
||||
if (ra == null && (RadarSettingsStore.ShowMonsterRangeRing || RadarSettingsStore.ShowRingRangeRing))
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
ImGuiNET.ImGui.TextDisabled("(waiting for RynthAi)");
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Hide the retail radar": RynthAi's own SuppressRetailRadar setting (RynthAi pushes it to the engine every
|
||||
/// tick), the same switch as Settings > UI > Hide retail radar. This reads it from RynthAi's settings payload
|
||||
|
|
|
|||
47
src/RynthCore.Engine/ImGui/Panels/RadarRangeRing.cs
Normal file
47
src/RynthCore.Engine/ImGui/Panels/RadarRangeRing.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/RadarRangeRing.cs
|
||||
// The range rings round the player on the Radar (2026-11-06, player request): RynthAi's
|
||||
// Monster Range (how far away a monster can be for the bot to attack it) and, optionally,
|
||||
// its Ring Range (ring spells), drawn as circles at that many yards. The radar's world is
|
||||
// in yards (192 per landblock, the same units RynthAi measures in) and its zoom is pixels
|
||||
// per yard, so the ring's radius on the screen is range x zoom.
|
||||
//
|
||||
// Pure (no ImGui), so tools\RadarSettingsTests links it.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal static class RadarRangeRing
|
||||
{
|
||||
/// <summary>Rings smaller than this (px) aren't drawn: they would only blot out your own arrow.</summary>
|
||||
public const float MinRadiusPx = 4f;
|
||||
|
||||
/// <summary>
|
||||
/// The ring's radius in pixels for a range of <paramref name="yards"/> at the radar's
|
||||
/// <paramref name="zoom"/> (px per yard, at least 0.5 as the radar's projection keeps it).
|
||||
/// 0 for no range (0, negative or not a number).
|
||||
/// </summary>
|
||||
public static float RadiusPx(double yards, float zoom)
|
||||
{
|
||||
if (!(yards > 0) || !double.IsFinite(yards)) return 0f;
|
||||
float z = float.IsFinite(zoom) ? MathF.Max(0.5f, zoom) : 0.5f;
|
||||
return (float)yards * z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether any of a ring of <paramref name="radius"/> round <paramref name="centre"/> (the player)
|
||||
/// shows on the picture: not too small, and inside the circle for the round radar (the two share
|
||||
/// a centre), or reaching no further than the farthest corner of the square one.
|
||||
/// </summary>
|
||||
public static bool Shows(float radius, Vector2 centre, Vector2 min, Vector2 max, RoundMask? round)
|
||||
{
|
||||
if (!(radius >= MinRadiusPx)) return false;
|
||||
if (round is { } circle) return radius <= circle.Radius;
|
||||
float fx = MathF.Max(centre.X - min.X, max.X - centre.X);
|
||||
float fy = MathF.Max(centre.Y - min.Y, max.Y - centre.Y);
|
||||
return radius * radius <= fx * fx + fy * fy;
|
||||
}
|
||||
}
|
||||
|
|
@ -104,6 +104,7 @@ internal static unsafe class PhosphorIcons
|
|||
public const string MapTrifold = "\uE31A";
|
||||
public const string Minus = "\uE32A";
|
||||
public const string Monitor = "\uE32E";
|
||||
public const string Moon = "\uE330"; // baked for plugins: RynthDefective's Day/Night timer (2026-11-04)
|
||||
public const string NavigationArrow = "\uEADE";
|
||||
public const string Path = "\uE39C";
|
||||
public const string PencilSimple = "\uE3B4";
|
||||
|
|
@ -173,7 +174,8 @@ internal static unsafe class PhosphorIcons
|
|||
+ CastleTurret + ClockCounterClockwise + GlobeHemisphereWest + Path + Star + Target + User
|
||||
+ TextAa + Leaf + Keyboard
|
||||
+ PushPin + SlidersHorizontal + Wrench
|
||||
+ Scroll;
|
||||
+ Scroll
|
||||
+ Moon;
|
||||
|
||||
/// <summary>
|
||||
/// Draws <paramref name="glyph"/> (one icon) centred in the box at
|
||||
|
|
|
|||
170
src/RynthCore.Engine/ImGui/RetailCursors.cs
Normal file
170
src/RynthCore.Engine/ImGui/RetailCursors.cs
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/RetailCursors.cs
|
||||
// The retail window cursors for RynthCore's windows (2026-11-07, Tom: "on retail mouse
|
||||
// cursor changes when move/resize is going to happen"). AC's cursor is a Windows cursor:
|
||||
// UIElementManager::SetCursor (0x0045A910) makes one from a 0x06 picture
|
||||
// (Device::SetCursorFromImage -> CreateIconFromRenderSurface) and sets it as the game
|
||||
// window's class cursor (SetClassLong GCL_HCURSOR) and with SetCursor. ImGui's cursor
|
||||
// shapes (ImGui.SetMouseCursor: a panel's drag band, a resize edge or grip) never reached
|
||||
// it, so the cursor stayed AC's.
|
||||
//
|
||||
// Now, when the frame's ImGui cursor is a move or resize shape, the game window shows
|
||||
// retail's own window-control cursor for it (the pictures AC's windows use, read off the
|
||||
// dat as OpenAC's RetailCursorCatalog has them; 32x32, hotspot 16,16):
|
||||
// ResizeAll -> 0x06006119 (move) ResizeNS -> 0x06005E66
|
||||
// ResizeEW -> 0x06006128 ResizeNWSE -> 0x06006126 ResizeNESW -> 0x06006127
|
||||
// Win32Backend answers WM_SETCURSOR with it (AC's class cursor is left alone), and when the
|
||||
// shape goes back to the arrow AC's own cursor (its class cursor) is put back. Other shapes
|
||||
// (hand, text) keep AC's cursor, as before. The cursors are made once, from portal.dat.
|
||||
//
|
||||
// AC's main thread only (the ImGui frame and the window procedure both run on it).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI.ScriptWindows;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend;
|
||||
|
||||
internal static unsafe class RetailCursors
|
||||
{
|
||||
private const int Hotspot = 16;
|
||||
private static readonly (ImGuiMouseCursor Shape, uint Picture)[] Map =
|
||||
{
|
||||
(ImGuiMouseCursor.ResizeAll, 0x06006119u),
|
||||
(ImGuiMouseCursor.ResizeNS, 0x06005E66u),
|
||||
(ImGuiMouseCursor.ResizeEW, 0x06006128u),
|
||||
(ImGuiMouseCursor.ResizeNWSE, 0x06006126u),
|
||||
(ImGuiMouseCursor.ResizeNESW, 0x06006127u),
|
||||
};
|
||||
|
||||
private static readonly IntPtr[] Handles = new IntPtr[Map.Length];
|
||||
private static bool _made, _failedLogged;
|
||||
private static IntPtr _current;
|
||||
|
||||
/// <summary>The retail cursor wanted now, or zero (AC's own). Win32Backend's WM_SETCURSOR reads it.</summary>
|
||||
public static IntPtr Current => _current;
|
||||
|
||||
/// <summary>
|
||||
/// End of the ImGui frame: the shape ImGui asks for (<paramref name="shape"/>) while a RynthCore window has
|
||||
/// the mouse (<paramref name="overUi"/>). Sets the retail cursor at once when it changes, and gives AC's back.
|
||||
/// </summary>
|
||||
public static void Update(ImGuiMouseCursor shape, bool overUi)
|
||||
{
|
||||
IntPtr want = IntPtr.Zero;
|
||||
if (overUi)
|
||||
{
|
||||
int i = Array.FindIndex(Map, m => m.Shape == shape);
|
||||
if (i >= 0)
|
||||
{
|
||||
if (!_made) Make();
|
||||
want = Handles[i];
|
||||
}
|
||||
}
|
||||
if (want == _current) return;
|
||||
_current = want;
|
||||
try
|
||||
{
|
||||
if (want != IntPtr.Zero) SetCursor(want);
|
||||
else
|
||||
{
|
||||
IntPtr hwnd = Win32Backend.GameHwnd;
|
||||
IntPtr ac = hwnd != IntPtr.Zero ? (IntPtr)GetClassLongW(hwnd, GclHCursor) : IntPtr.Zero;
|
||||
if (ac != IntPtr.Zero) SetCursor(ac);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static void Make()
|
||||
{
|
||||
_made = true;
|
||||
try
|
||||
{
|
||||
string? path = AcDatFile.FindPortalDat();
|
||||
using AcDatFile? dat = path != null ? AcDatFile.Open(path, out _) : null;
|
||||
if (dat == null) { Log("client_portal.dat not found"); return; }
|
||||
int made = 0;
|
||||
for (int i = 0; i < Map.Length; i++)
|
||||
{
|
||||
AcIconImage? img = AcIconDecoder.Decode(dat, Map[i].Picture, AcIconDecoder.MaxUiSide);
|
||||
if (img == null) continue;
|
||||
Handles[i] = CreateCursor(img);
|
||||
if (Handles[i] != IntPtr.Zero) made++;
|
||||
}
|
||||
RynthLog.UI($"RetailCursors: {made} of {Map.Length} retail window cursors made.");
|
||||
}
|
||||
catch (Exception ex) { Log($"{ex.GetType().Name}: {ex.Message}"); }
|
||||
}
|
||||
|
||||
private static void Log(string why)
|
||||
{
|
||||
if (_failedLogged) return;
|
||||
_failedLogged = true;
|
||||
RynthLog.UI("RetailCursors: no retail window cursors (" + why + "); AC's cursor stays.");
|
||||
}
|
||||
|
||||
/// <summary>A Windows cursor from an RGBA picture (32-bit with alpha), hotspot in the middle as retail's.</summary>
|
||||
private static IntPtr CreateCursor(AcIconImage img)
|
||||
{
|
||||
int w = img.Width, h = img.Height;
|
||||
var bi = new BITMAPV5HEADER
|
||||
{
|
||||
bV5Size = (uint)sizeof(BITMAPV5HEADER), bV5Width = w, bV5Height = -h, bV5Planes = 1, bV5BitCount = 32,
|
||||
bV5Compression = 3 /* BI_BITFIELDS */, bV5RedMask = 0x00FF0000, bV5GreenMask = 0x0000FF00,
|
||||
bV5BlueMask = 0x000000FF, bV5AlphaMask = 0xFF000000,
|
||||
};
|
||||
IntPtr dc = GetDC(IntPtr.Zero);
|
||||
IntPtr color = CreateDIBSection(dc, ref bi, 0, out IntPtr bits, IntPtr.Zero, 0);
|
||||
ReleaseDC(IntPtr.Zero, dc);
|
||||
if (color == IntPtr.Zero || bits == IntPtr.Zero) return IntPtr.Zero;
|
||||
var dst = new Span<byte>((void*)bits, w * h * 4);
|
||||
byte[] src = img.Pixels;
|
||||
for (int p = 0; p < w * h; p++)
|
||||
{
|
||||
dst[p * 4 + 0] = src[p * 4 + 2]; // B
|
||||
dst[p * 4 + 1] = src[p * 4 + 1]; // G
|
||||
dst[p * 4 + 2] = src[p * 4 + 0]; // R
|
||||
dst[p * 4 + 3] = src[p * 4 + 3]; // A
|
||||
}
|
||||
IntPtr mask = CreateBitmap(w, h, 1, 1, IntPtr.Zero);
|
||||
var info = new ICONINFO { fIcon = false, xHotspot = Math.Min(Hotspot, w - 1), yHotspot = Math.Min(Hotspot, h - 1), hbmMask = mask, hbmColor = color };
|
||||
IntPtr cursor = CreateIconIndirect(ref info);
|
||||
DeleteObject(color);
|
||||
DeleteObject(mask);
|
||||
return cursor;
|
||||
}
|
||||
|
||||
private const int GclHCursor = -12;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct ICONINFO
|
||||
{
|
||||
[MarshalAs(UnmanagedType.Bool)] public bool fIcon;
|
||||
public int xHotspot, yHotspot;
|
||||
public IntPtr hbmMask, hbmColor;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct BITMAPV5HEADER
|
||||
{
|
||||
public uint bV5Size;
|
||||
public int bV5Width, bV5Height;
|
||||
public ushort bV5Planes, bV5BitCount;
|
||||
public uint bV5Compression, bV5SizeImage;
|
||||
public int bV5XPelsPerMeter, bV5YPelsPerMeter;
|
||||
public uint bV5ClrUsed, bV5ClrImportant, bV5RedMask, bV5GreenMask, bV5BlueMask, bV5AlphaMask, bV5CSType;
|
||||
public int e0, e1, e2, e3, e4, e5, e6, e7, e8; // CIEXYZTRIPLE
|
||||
public uint bV5GammaRed, bV5GammaGreen, bV5GammaBlue, bV5Intent, bV5ProfileData, bV5ProfileSize, bV5Reserved;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")] private static extern IntPtr SetCursor(IntPtr hCursor);
|
||||
[DllImport("user32.dll")] private static extern uint GetClassLongW(IntPtr hWnd, int nIndex);
|
||||
[DllImport("user32.dll")] private static extern IntPtr CreateIconIndirect(ref ICONINFO piconinfo);
|
||||
[DllImport("user32.dll")] private static extern IntPtr GetDC(IntPtr hWnd);
|
||||
[DllImport("user32.dll")] private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
[DllImport("gdi32.dll")] private static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPV5HEADER pbmi, uint usage, out IntPtr bits, IntPtr section, uint offset);
|
||||
[DllImport("gdi32.dll")] private static extern IntPtr CreateBitmap(int w, int h, uint planes, uint bitCount, IntPtr bits);
|
||||
[DllImport("gdi32.dll")] private static extern bool DeleteObject(IntPtr obj);
|
||||
}
|
||||
|
|
@ -18,7 +18,9 @@
|
|||
// The two meet only in two small queues under one lock.
|
||||
//
|
||||
// Bounded: at most 192 pictures, each at most 512 x 512 (the biggest the
|
||||
// inventory uses is its 300 x 362 background, ~0.4 MB). A picture that isn't
|
||||
// inventory uses is its 300 x 362 background, ~0.4 MB). A retail font's glyph
|
||||
// sheet (TryGetFontSheet, 2026-11-07) may be 2048 wide (Palatino 24's is 2048 x
|
||||
// 279, ~2.3 MB); only a plugin drawing retail text asks for them, a few at most. A picture that isn't
|
||||
// in the dat or doesn't decode is tried again after 30 s; until then the caller
|
||||
// draws its own stand-in (TryGet returns false).
|
||||
// ============================================================================
|
||||
|
|
@ -80,7 +82,30 @@ internal static class RetailSprites
|
|||
public static bool TryGet(uint textureId, out IntPtr texture)
|
||||
{
|
||||
texture = IntPtr.Zero;
|
||||
if (!AcIconDecoder.IsTextureId(textureId)) return false;
|
||||
return AcIconDecoder.IsTextureId(textureId) && TryGetKey(textureId, out texture);
|
||||
}
|
||||
|
||||
// A font's glyph sheet is keyed with this bit set, so it never shares a slot with the same
|
||||
// texture drawn as a picture (a sheet decodes white, its level as alpha).
|
||||
private const uint FontSheetBit = 0x80000000u;
|
||||
|
||||
/// <summary>
|
||||
/// A retail font's glyph sheet (its Font file's foreground or background surface, an A8
|
||||
/// 0x06 texture up to <see cref="AcIconDecoder.MaxFontSheetSide"/> wide) as a texture:
|
||||
/// white, the sheet's level as alpha, so ImGui's tint colours the text (2026-11-07, for
|
||||
/// plugins that draw the retail look with its own fonts). Otherwise as <see cref="TryGet"/>.
|
||||
/// AC's render thread.
|
||||
/// </summary>
|
||||
public static bool TryGetFontSheet(uint textureId, out IntPtr texture)
|
||||
{
|
||||
texture = IntPtr.Zero;
|
||||
return AcIconDecoder.IsTextureId(textureId) && TryGetKey(textureId | FontSheetBit, out texture);
|
||||
}
|
||||
|
||||
private static bool TryGetKey(uint key, out IntPtr texture)
|
||||
{
|
||||
texture = IntPtr.Zero;
|
||||
uint textureId = key;
|
||||
if (!Sprites.TryGetValue(textureId, out Sprite? sprite))
|
||||
{
|
||||
if (Sprites.Count >= MaxSprites) return false;
|
||||
|
|
@ -219,7 +244,12 @@ internal static class RetailSprites
|
|||
}
|
||||
|
||||
AcIconImage? image = null;
|
||||
try { image = dat == null ? null : AcIconDecoder.Decode(dat, r.Id, AcIconDecoder.MaxUiSide); }
|
||||
try
|
||||
{
|
||||
image = dat == null ? null
|
||||
: (r.Id & FontSheetBit) != 0 ? AcIconDecoder.DecodeFontSheet(dat, r.Id & ~FontSheetBit)
|
||||
: AcIconDecoder.Decode(dat, r.Id, AcIconDecoder.MaxUiSide);
|
||||
}
|
||||
catch { image = null; }
|
||||
lock (Sync)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,6 +26,16 @@
|
|||
// the ImGui panels - the same place RenderNav3D's fallback draws.
|
||||
// A list is presented at most once: no double draw.
|
||||
//
|
||||
// Windows under AC's UI (2026-11-07, PanelSpec.UnderUi: a plugin window's
|
||||
// "layer": "underUi", RynthDreamWeave's Skills panel): the panel host builds
|
||||
// the window as usual in the main frame and hands its draw lists (the window's
|
||||
// and its body child's) here. EndScene's draw leaves them out
|
||||
// (DX9Backend.RenderDrawData asks IsWindowList), and they are presented with
|
||||
// the plates, after them, at the next frame's UI pass. ImGui keeps a window's
|
||||
// draw list until the window's next Begin (the next EndScene, after that UI
|
||||
// pass), so no copy is needed. At the EndScene fallback the lists already hold
|
||||
// that frame's content: drawn without the lag, still under the panels.
|
||||
//
|
||||
// The plates are therefore one frame behind the frame they were built in -
|
||||
// the same lag the Nav3D markers have, since both project with the camera
|
||||
// GameMatrixCapture took at the previous EndScene - on both paths, so a frame
|
||||
|
|
@ -55,6 +65,33 @@ internal static unsafe class UnderUiLayer
|
|||
private static int _presenting; // a present is in flight (Shutdown waits for it)
|
||||
private static volatile bool _shutDown;
|
||||
|
||||
// Under-UI windows' draw lists (ImGui's own, owned by their windows): those of the frame being
|
||||
// built, and those to present this frame (built last frame). AC's render thread only.
|
||||
private static System.Collections.Generic.List<IntPtr> _winBuilding = new(), _winReady = new();
|
||||
private static Vector2 _winBuildingSize, _winReadySize;
|
||||
|
||||
/// <summary>
|
||||
/// Panel host, inside the main ImGui frame: a draw list of a window drawn under AC's UI. It is left
|
||||
/// out of EndScene's draw and presented at the next UI pass with the world overlays. AC's render thread.
|
||||
/// </summary>
|
||||
public static void AddWindowList(ImDrawListPtr list)
|
||||
{
|
||||
if (_shutDown || list.NativePtr == null) return;
|
||||
IntPtr p = (IntPtr)list.NativePtr;
|
||||
if (!_winBuilding.Contains(p)) _winBuilding.Add(p);
|
||||
_winBuildingSize = ImGuiNET.ImGui.GetIO().DisplaySize;
|
||||
}
|
||||
|
||||
/// <summary>True when any window draws under AC's UI (DX9Backend filters EndScene's lists then).</summary>
|
||||
public static bool HasWindowLists => _winBuilding.Count > 0 || _winReady.Count > 0;
|
||||
|
||||
/// <summary>
|
||||
/// DX9Backend.RenderDrawData: a list EndScene must leave out (an under-UI window's, this frame's or
|
||||
/// last frame's: a window's list pointer is the same every frame). AC's render thread.
|
||||
/// </summary>
|
||||
public static bool IsWindowList(ImDrawList* list)
|
||||
=> list != null && (_winBuilding.Contains((IntPtr)list) || _winReady.Contains((IntPtr)list));
|
||||
|
||||
/// <summary>True after <see cref="BeginBuild"/> returned a list this frame. AC's render thread.</summary>
|
||||
public static bool IsBuilding => _building != null;
|
||||
|
||||
|
|
@ -124,12 +161,31 @@ internal static unsafe class UnderUiLayer
|
|||
Interlocked.Exchange(ref _presenting, 1);
|
||||
try
|
||||
{
|
||||
if (_shutDown) return false;
|
||||
ImDrawList* list = _ready;
|
||||
if (list == null || _shutDown) return false;
|
||||
_presented = true;
|
||||
if (list->VtxBuffer.Size == 0) return false;
|
||||
DX9Backend.RenderDrawList(list, _readySize, device);
|
||||
return true;
|
||||
bool drew = false;
|
||||
if (list != null)
|
||||
{
|
||||
_presented = true;
|
||||
if (list->VtxBuffer.Size > 0)
|
||||
{
|
||||
DX9Backend.RenderDrawList(list, _readySize, device);
|
||||
drew = true;
|
||||
}
|
||||
}
|
||||
// The under-UI windows, over the plates (they are windows, the plates are the world's).
|
||||
if (_winReady.Count > 0)
|
||||
{
|
||||
_presented = true;
|
||||
foreach (IntPtr p in _winReady)
|
||||
{
|
||||
var w = (ImDrawList*)p;
|
||||
if (w->VtxBuffer.Size == 0) continue;
|
||||
DX9Backend.RenderDrawList(w, _winReadySize, device);
|
||||
drew = true;
|
||||
}
|
||||
}
|
||||
return drew;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -147,6 +203,10 @@ internal static unsafe class UnderUiLayer
|
|||
_readySize = _buildingSize;
|
||||
_building = null;
|
||||
_presented = false;
|
||||
(_winReady, _winBuilding) = (_winBuilding, _winReady);
|
||||
_winBuilding.Clear();
|
||||
if (_shutDown) _winReady.Clear();
|
||||
_winReadySize = _winBuildingSize;
|
||||
}
|
||||
|
||||
/// <summary>One line for /rc imgui diag.</summary>
|
||||
|
|
@ -164,6 +224,8 @@ internal static unsafe class UnderUiLayer
|
|||
_ready = null;
|
||||
_building = null;
|
||||
_listA = _listB = null;
|
||||
_winReady.Clear();
|
||||
_winBuilding.Clear();
|
||||
Thread.MemoryBarrier();
|
||||
var spin = new SpinWait();
|
||||
long deadline = Environment.TickCount64 + 200;
|
||||
|
|
|
|||
|
|
@ -134,6 +134,9 @@ internal static unsafe class Win32Backend
|
|||
private static bool IsExtendedKey(IntPtr lParam) => ((int)(long)lParam & 0x01000000) != 0;
|
||||
|
||||
// ─── Win32 P/Invoke ───────────────────────────────────────────────
|
||||
[DllImport("user32.dll", EntryPoint = "SetCursor")]
|
||||
private static extern IntPtr SetCursorNative(IntPtr hCursor);
|
||||
|
||||
// On x86, SetWindowLongPtr doesn't exist — use SetWindowLong
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true)]
|
||||
private static extern IntPtr SetWindowLong32(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
|
@ -881,6 +884,14 @@ internal static unsafe class Win32Backend
|
|||
if (IsRemoteClientMouse(hWnd, msg, lParam))
|
||||
return CallWindowProcA(_originalWndProc, hWnd, msg, wParam, lParam);
|
||||
|
||||
// A RynthCore window's move or resize spot under the mouse: retail's window-control cursor
|
||||
// (RetailCursors), in the client area only; AC's own cursor everywhere else.
|
||||
if (msg == WM_SETCURSOR && ((long)lParam & 0xFFFF) == 1 /* HTCLIENT */ && RetailCursors.Current != IntPtr.Zero)
|
||||
{
|
||||
SetCursorNative(RetailCursors.Current);
|
||||
return (IntPtr)1;
|
||||
}
|
||||
|
||||
// ── Chat capture: consume all key input for the chat TextBox ────
|
||||
// Game HWND keeps Win32 focus throughout; callbacks dispatch Text
|
||||
// updates to the panel on Avalonia's UI thread — no Avalonia focus needed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue