Snapshot for release 2026.10.28.2 (internal 4a5e2d7)

This commit is contained in:
Tom Bohar 2026-10-28 19:47:17 -04:00
commit f9ae10d692
14 changed files with 1069 additions and 115 deletions

View file

@ -396,6 +396,13 @@ internal static class BusyCountHooks
public static void ResetSession()
{
_lastThisPtr = IntPtr.Zero;
// The next session's ClientUISystem starts at 0, and so does our copy (2026-10-28). Kept,
// a count left up by a logout mid-action stayed up for good: the watchdog can't clear it
// without the pointer, switches itself off, and is armed again only by a 0 -> 1 step, so
// GetBusyState answered "busy" until the client restarted (the item bar refused every use
// after a relog; RynthAi's waiting-on-the-server test reads the same count).
Interlocked.Exchange(ref _netBusyCount, 0);
Volatile.Write(ref _busyBecamePositiveTickMs, 0);
Volatile.Write(ref _realBusyPositiveTickMs, 0);
_realBusyNegativeSince = 0;
lock (_directLock)

View file

@ -1231,16 +1231,17 @@ internal static class RynthCoreChatCommands
/// <summary>
/// /rv plates (alias /rc plates): the RynthVision nameplates and combat text
/// (ImGui/MonsterHud). Alone it toggles the monster plates; on|off, all on|off,
/// self|debuffs|others|numbers|gains [sub] [on|off], all|engaged, dist|max|scale|
/// opacity|lift &lt;n&gt;, names|hp|level|weak|distance|fade|click [on|off], reset, status.
/// Every change is saved.
/// self|debuffs|others|numbers|gains [sub] [on|off], debuffs size / self debuffs size &lt;50-200&gt;,
/// all|engaged, dist|max|scale|opacity|lift &lt;n&gt;, names|hp|level|weak|distance|fade|click [on|off],
/// reset, status. Every change is saved.
/// </summary>
private static void HandlePlatesCommand(string args)
{
const string usage = "Usage: /rv plates [on|off] | all on|off | self [numbers|name|firstperson|lock] [on|off] | " +
"self fixed|follow|unlock|reset | " +
"debuffs [on|off] | others [on|off] | numbers [dealt|taken|heals|kills] [on|off] | " +
"gains [xp|lum|radiance] [on|off] | npcs [on|off] | npcs dist <yd>|max <n> | players [on|off] | all|engaged |dist <yd>|max <n>|scale <x>|opacity <x>|lift <m> | " +
const string usage = "Usage: /rv plates [on|off] | all on|off | self [numbers|name|firstperson|lock|debuffs] [on|off] | " +
"self fixed|follow|unlock|reset | self debuffs size <50-200%> | " +
"debuffs [on|off] | debuffs size <50-200%> | others [on|off] | numbers [dealt|taken|heals|kills] [on|off] | " +
"gains [xp|lum|radiance] [on|off] | npcs [on|off] | npcs dist <yd>|max <n> | players [on|off] | portals [on|off] | portals dist <yd> | " +
"all|engaged |dist <yd>|max <n>|scale <x>|opacity <x>|lift <m> | " +
"names|hp|level|weak|distance|fade|click [on|off] | reset | status | test";
if (!ImGuiBackend.Hud.HudFeed.VisionInstalled)
{
@ -1285,6 +1286,19 @@ internal static class RynthCoreChatCommands
case "numbers": case "text": S.SelfNumbers = Flag(subValue, S.SelfNumbers); break;
case "name": S.SelfName = Flag(subValue, S.SelfName); break;
case "firstperson": case "fp": S.SelfHideFirstPerson = Flag(subValue, S.SelfHideFirstPerson); break;
// "Debuffs on you": on|off, or its icon size ("self debuffs size 150").
case "debuffs": case "debuff":
if (subValue != null && subValue.Equals("size", StringComparison.OrdinalIgnoreCase))
{
if (!S.TryParseDebuffIconSize(parts.Length > 3 ? parts[3] : null, out int sdi))
{
Reply($"usage: /rv plates self debuffs size {S.MinDebuffIconSize}-{S.MaxDebuffIconSize} (percent; now {S.SelfDebuffIconSize}%)");
return;
}
S.SelfDebuffIconSize = sdi;
}
else S.SelfDebuffs = Flag(subValue, S.SelfDebuffs);
break;
// Placement: fixed on screen (drag it while unlocked) or following the character.
case "fixed": case "screen": S.SelfPlacement = ImGuiBackend.Hud.SelfPlacement.Fixed; break;
case "follow": case "world": S.SelfPlacement = ImGuiBackend.Hud.SelfPlacement.Follow; break;
@ -1318,7 +1332,18 @@ internal static class RynthCoreChatCommands
S.KeepOnScreen = Flag(value, S.KeepOnScreen); break;
case "debuffs":
case "debuff":
S.ShowDebuffs = Flag(value, S.ShowDebuffs); break;
if (sub == "size")
{
// The monster plates' icon size ("debuffs size 150"); your own row's is "self debuffs size".
if (!S.TryParseDebuffIconSize(subValue, out int mdi))
{
Reply($"usage: /rv plates debuffs size {S.MinDebuffIconSize}-{S.MaxDebuffIconSize} (percent; now {S.MonsterDebuffIconSize}%)");
return;
}
S.MonsterDebuffIconSize = mdi;
}
else S.ShowDebuffs = Flag(value, S.ShowDebuffs);
break;
case "others":
S.ShowOthersDebuff = Flag(value, S.ShowOthersDebuff); break;
case "numbers":
@ -1395,6 +1420,17 @@ internal static class RynthCoreChatCommands
default: Reply(usage); return;
}
break;
case "portals":
case "portal":
switch (sub)
{
case null: S.PortalNames = Flag(subValue, S.PortalNames); break;
case "dist": case "range":
if (!TryNum(subValue, out float pd)) { Reply("usage: /rv plates portals dist 5-120"); return; }
S.PortalMaxDistance = Math.Clamp(pd, S.MinPortalDistance, S.MaxPortalDistanceLimit); break;
default: Reply(usage); return;
}
break;
case "players":
S.PlayerNames = Flag(value, S.PlayerNames); break;
case "playerbars": S.PlayerBars = Flag(value, S.PlayerBars); break;

View file

@ -10,6 +10,10 @@
//
// Moved out of MonsterHud.PaintIcons unchanged (2026-10-27) so the player
// plate can draw the same row; the monster plates look exactly as before.
// Sizes (2026-10-28): every length comes from DebuffRowMetrics (PlateMetrics.cs),
// 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.
// Render thread only. Engine-owned statics.
// ============================================================================
@ -59,35 +63,24 @@ internal static class DebuffIconRow
/// The row centred on <paramref name="cx"/> with its top at <paramref name="top"/>:
/// <paramref name="count"/> kinds (may exceed <paramref name="icons"/>' length: the rest
/// show as "+N"), then the "debuffed by others" marker when <paramref name="others"/>.
/// <paramref name="sz"/> is the icon square, <paramref name="smallFont"/>/<paramref name="smallSize"/>
/// draw the stack digit and "+N"; <paramref name="overflowKey"/>/<paramref name="overflowText"/>
/// <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.
/// </summary>
internal static void Paint(ImDrawListPtr dl, DebuffIcon[] icons, int count, bool others, float sz,
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 k, float a, long now)
float cx, float top, float a, long now)
{
float gap = MathF.Max(2f, MathF.Round(2f * k));
int shown = count > icons.Length ? icons.Length - 1 : count;
int overflow = count - shown;
string more = "";
float moreW = 0f;
if (overflow > 0)
{
if (overflow != overflowKey)
{
overflowKey = overflow;
overflowText = "+" + overflow.ToString(CultureInfo.InvariantCulture);
}
more = overflowText;
moreW = MonsterHud.TextWidth(smallFont, smallSize, more) + 4f * k;
}
int slots = shown + (others ? 1 : 0);
float rowW = slots * sz + Math.Max(0, slots - 1) * gap + (overflow > 0 ? gap + moreW : 0f);
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);
float moreW = overflow > 0 ? row.MoreWidth(moreTextW) : 0f;
float rowW = row.Width(shown + (others ? 1 : 0), overflow > 0, moreTextW);
float x = MathF.Round(cx - rowW * 0.5f);
float glyphPx = MathF.Round(sz * 0.8f);
float glyphPx = row.Glyph;
ImFontPtr iconFont = ImGuiFonts.Sharp(glyphPx, bold: false); // the icons are merged into every bake
float lineH = MathF.Max(1f, MathF.Round(1.5f * k));
float lineH = row.LineH;
for (int i = 0; i < shown; i++)
{
@ -100,20 +93,20 @@ internal static class DebuffIconRow
var i0 = new Vector2(x, top);
var i1 = i0 + new Vector2(sz, sz);
dl.AddRectFilled(i0, i1, MonsterHud.Mul(IconBack, a), 2f * k);
dl.AddRect(i0, i1, MonsterHud.Mul(tint, a * 0.55f * blink), 2f * k, ImDrawFlags.None, 1f);
dl.AddRectFilled(i0, i1, MonsterHud.Mul(IconBack, a), row.Round);
dl.AddRect(i0, i1, MonsterHud.Mul(tint, a * 0.55f * blink), row.Round, ImDrawFlags.None, 1f);
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, KindGlyph[kind < KindGlyph.Length ? kind : KindGlyph.Length - 1],
i0, new Vector2(sz, sz), MonsterHud.Mul(tint, a * blink));
if (ic.Stack > 1 && ic.Stack < StackDigits.Length)
{
string digit = StackDigits[ic.Stack];
float ds = MathF.Round(smallSize * 0.85f);
var dp = new Vector2(i1.X - MonsterHud.TextWidth(smallFont, ds, digit) + 1f, i0.Y - 2f);
var dp = new Vector2(i1.X - MonsterHud.TextWidth(smallFont, ds, digit) + row.DigitDx, i0.Y - row.DigitDy);
MonsterHud.OutlinedText(dl, smallFont, ds, dp, a, digit);
dl.AddText(smallFont, ds, dp, MonsterHud.Mul(MonsterHud.HpText, a), digit);
}
// Countdown: a line under the icon that shrinks to nothing at expiry.
float ly = i1.Y + 1f;
float ly = i1.Y + row.LineGap;
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));
@ -131,8 +124,50 @@ internal static class DebuffIconRow
if (others)
{
var i0 = new Vector2(x, top);
dl.AddRectFilled(i0, i0 + new Vector2(sz, sz), MonsterHud.Mul(IconBack, a * 0.8f), 2f * k);
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));
}
}
/// <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.
/// </summary>
internal static float Width(int capacity, int count, bool others, in DebuffRowMetrics row,
ImFontPtr smallFont, float smallSize, ref int overflowKey, ref string overflowText)
{
int shown = Prepare(capacity, count, in row, ref smallFont, ref smallSize, ref overflowKey, ref overflowText,
out int overflow, out _, out float moreTextW);
return row.Width(shown + (others ? 1 : 0), overflow > 0, moreTextW);
}
/// <summary>
/// How many icons show (the last slot makes room for "+N" when more kinds than fit), the "+N" string and
/// its width, and the row's text (stack digit, "+N"): the plate's small text scaled by the icon size, from
/// the smallest bake at least that big (at 100 % the plate's own font and size, untouched).
/// </summary>
private static int Prepare(int capacity, int count, in DebuffRowMetrics row, ref ImFontPtr font, ref float size,
ref int overflowKey, ref string overflowText, out int overflow, out string more, out float moreTextW)
{
if (row.Scale != 1f)
{
size = row.TextSize(size);
font = ImGuiFonts.Sharp(size, bold: false);
}
int shown = count > capacity ? capacity - 1 : count;
overflow = count - shown;
more = "";
moreTextW = 0f;
if (overflow > 0)
{
if (overflow != overflowKey)
{
overflowKey = overflow;
overflowText = "+" + overflow.ToString(CultureInfo.InvariantCulture);
}
more = overflowText;
moreTextW = MonsterHud.TextWidth(font, size, more);
}
return shown;
}
}

View file

@ -33,8 +33,10 @@
// same scan picks the name-only labels: non-attackable creatures (NPCs,
// vendors; summoned pets skipped) within NpcMaxDistance, nearest first,
// capped at MaxNpcLabels apart from the plates (and players, if "Player
// names" is on). Each object is classified once (Classes). The same tick
// polls the player's XP / Luminance for the gain text.
// names" is on), and portals' names ("Portal names", 2026-10-28) within
// PortalMaxDistance, capped at MaxPortalLabels on their own. Each object
// is classified once (Classes, PlateClass: ITEM_TYPE creature / portal).
// The same tick polls the player's XP / Luminance for the gain text.
// Draw (inside the ImGui frame): every frame each chosen monster's LIVE
// position is read (main thread, a handful of objects) and projected with
// the engine's camera capture (GameMatrixCapture), so plates stick to
@ -72,7 +74,6 @@ internal static class MonsterHud
private const int SnapshotPeriodMs = 250; // monster list refresh (4 Hz)
private const double AttackerMemorySec = 20; // "hit you recently"
private const double HurtMemorySec = 60; // "hurt recently" (engaged filter)
private const uint TypeCreature = 0x10; // ITEM_TYPE TYPE_CREATURE
private const uint BfPlayer = 0x8; // PublicWeenieDesc BF_PLAYER
private const uint BfVendor = 0x200; // PublicWeenieDesc BF_VENDOR
private const uint PetOwnerIid = 44; // PropertyInstanceId PetOwner (summoned pets)
@ -143,7 +144,8 @@ internal static class MonsterHud
public bool Others; // "debuffed by others" marker
// Layout (this frame)
public float Width, Height, BarW, BarH, NameSize, SmallSize, BelowBar, IconSize;
public float Width, Height, BarW, BarH, NameSize, SmallSize, BelowBar;
public DebuffRowMetrics Row; // the debuff row's lengths (k x "Debuff icon size")
public ImFontPtr NameFont, SmallFont;
public float NameW, BadgeW;
@ -160,6 +162,9 @@ internal static class MonsterHud
private sealed record WeakTag(string Label, uint Color, string Icon);
private const float DefaultHeadHeight = 2.0f;
// Portals: the snapshot has no model height, so a fixed lift over the portal's origin (its foot)
// that clears the top of a standard swirl. "Height lift" in the settings adds to it, as to every plate.
private const float PortalLabelHeight = 3.5f;
// A player's health is only known from what the game happened to tell us; a reading older than this is not drawn.
private const long PlayerBarMemorySec = 90;
// A size from the table is the top of the model: a hand's width above it for the plate, within sane bounds.
@ -169,14 +174,16 @@ internal static class MonsterHud
private static readonly List<Plate> Placed = new(64);
private static readonly List<(uint Id, float D2)> Candidates = new(128);
private static readonly List<(uint Id, float D2)> LabelCandidates = new(64);
private static readonly List<(uint Id, float D2)> PortalCandidates = new(16);
private static readonly List<uint> Evict = new(16);
// What each live object is, worked out once per id (item type, BF_PLAYER, BF_VENDOR and
// PetOwner never change), so the 4 Hz scan skips non-creatures with one lookup and the
// PetOwner never change), so the 4 Hz scan skips other objects with one lookup and the
// monster pick no longer reads the bitfield live. Attackable is NOT cached: it is read
// from the snapshot every scan, as before. Entries not seen for a while are pruned.
private const byte ClsUnknown = 0, ClsOther = 1, ClsCreature = 2, ClsVendor = 3, ClsPlayer = 4, ClsPet = 5;
private const byte ClsCreatureNoPwd = 6; // a creature whose PWD isn't in the snapshot yet: never cached
private const byte ClsUnknown = PlateClass.Unknown, ClsOther = PlateClass.Other, ClsCreature = PlateClass.Creature,
ClsVendor = PlateClass.Vendor, ClsPlayer = PlateClass.Player, ClsPet = PlateClass.Pet, ClsPortal = PlateClass.Portal;
private const byte ClsCreatureNoPwd = PlateClass.CreatureNoPwd; // a creature whose PWD isn't in the snapshot yet: never cached
private struct ObjClass { public byte Cls; public int Seen; }
private static readonly Dictionary<uint, ObjClass> Classes = new(512);
private static readonly List<uint> ClassEvict = new(64);
@ -263,8 +270,9 @@ internal static class MonsterHud
// "the Drudge you hit" among them) when the plates themselves are off.
bool monsters = MonsterHudSettings.Enabled;
bool trackMonsters = monsters || MonsterHudSettings.Numbers;
// Name-only labels over NPCs (and, if asked, players): their own switches and cap.
bool track = trackMonsters || MonsterHudSettings.NpcNames || MonsterHudSettings.PlayerNames || MonsterHudSettings.PlayerBars;
// Name-only labels over NPCs (and, if asked, players) and over portals: their own switches and caps.
bool track = trackMonsters || MonsterHudSettings.NpcNames || MonsterHudSettings.PlayerNames || MonsterHudSettings.PlayerBars ||
MonsterHudSettings.PortalNames;
if (!track) ClearPlates();
SetDamageSubscription(monsters && MonsterHudSettings.ShowWeakness);
if (monsters && MonsterHudSettings.ShowDebuffs) PortalSpellTable.EnsureLoadQueued();
@ -369,10 +377,16 @@ internal static class MonsterHud
float npcD2 = npcD * npcD;
float npcTargetD2 = MathF.Max(npcD2, 100f * 100f); // a selected NPC keeps its name further out too
bool targetIsLabel = false;
bool portalNames = MonsterHudSettings.PortalNames;
float portalD = MonsterHudSettings.PortalMaxDistance;
float portalD2 = portalD * portalD;
float portalTargetD2 = MathF.Max(portalD2, 100f * 100f); // and a selected portal
bool targetIsPortal = false;
int pass = ++_classPass;
Candidates.Clear();
LabelCandidates.Clear();
PortalCandidates.Clear();
uint[] ids = ClientObjectHooks.LiveObjectIds;
for (int i = 0; i < ids.Length; i++)
{
@ -390,9 +404,15 @@ internal static class MonsterHud
}
if (cls == ClsOther || cls == ClsUnknown) continue;
// Monster plate (attackable creature) or name label (NPC / vendor, player)?
bool label;
if (cls == ClsPlayer)
// Monster plate (attackable creature), name label (NPC / vendor, player) or portal name?
bool label, portal = false;
if (cls == ClsPortal)
{
// A portal: its name only, from its own list and cap.
if (!portalNames) continue;
label = portal = true;
}
else if (cls == ClsPlayer)
{
// Players never get a monster plate (attackable in PK or not).
if (!playerNames) continue;
@ -419,7 +439,13 @@ internal static class MonsterHud
if (!TryOffset(pCell, cell, out float ox, out float oy)) continue;
float dx = x + ox - px, dy = y + oy - py, dz = z - pz;
float d2 = dx * dx + dy * dy + dz * dz;
if (label)
if (portal)
{
if (d2 > (id == target ? portalTargetD2 : portalD2)) continue;
PortalCandidates.Add((id, d2));
if (id == target) targetIsPortal = true;
}
else if (label)
{
if (d2 > (id == target ? npcTargetD2 : npcD2)) continue;
LabelCandidates.Add((id, d2));
@ -433,6 +459,7 @@ internal static class MonsterHud
}
Candidates.Sort(ByD2);
LabelCandidates.Sort(ByD2);
PortalCandidates.Sort(ByD2);
if ((pass & 63) == 0) PruneClasses(pass);
foreach (Plate p in Plates.Values) p.Chosen = false;
@ -493,6 +520,28 @@ internal static class MonsterHud
if (isTarget) targetIsLabel = false; // found: the cap applies again
}
// ── Portal names: their own cap, so a town's NPCs never push them out ──
int portalCap = MonsterHudSettings.MaxPortalLabels;
int portals = 0;
for (int i = 0; i < PortalCandidates.Count; i++)
{
uint id = PortalCandidates[i].Id;
bool isTarget = id == target;
if (portals >= portalCap && !isTarget)
{
if (!targetIsPortal) break;
continue; // keep scanning only to find the target
}
if (!ClientObjectHooks.TryGetSnapshotName(id, out string name) || name.Length == 0) continue;
Plate plate = GetPlate(id, RadarKind.Portal);
plate.WithBar = false;
if (name != plate.Name) plate.Name = name;
plate.HeadHeight = PortalLabelHeight;
portals++;
if (isTarget) targetIsPortal = false;
}
// Plates no longer chosen fade out in Draw and are evicted at zero alpha.
}
@ -511,14 +560,15 @@ internal static class MonsterHud
}
/// <summary>
/// What an object is, from the main-thread snapshots only (no AC call): not a creature,
/// a player, a summoned pet, a vendor or another creature. ClsUnknown / ClsCreatureNoPwd
/// when the snapshots don't have it yet (asked again next scan).
/// What an object is, from the main-thread snapshots only (no AC call): a portal, nothing
/// labelled, a player, a summoned pet, a vendor or another creature. ClsUnknown /
/// ClsCreatureNoPwd when the snapshots don't have it yet (asked again next scan).
/// </summary>
private static byte Classify(uint id)
{
if (!ClientObjectHooks.TryGetSnapshotItemType(id, out uint type)) return ClsUnknown;
if ((type & TypeCreature) == 0) return ClsOther;
byte byType = PlateClass.FromItemType(type);
if (byType != ClsCreature) return byType; // a portal, or nothing that gets a plate or a name
if (!ClientObjectHooks.TryGetSnapshotPwdInfo(id, out uint bf, out _, out _)) return ClsCreatureNoPwd;
if ((bf & BfPlayer) != 0) return ClsPlayer;
if (ClientObjectHooks.TryGetObjectInstanceIdProperty(id, PetOwnerIid, out uint owner) && owner != 0) return ClsPet;
@ -835,6 +885,7 @@ internal static class MonsterHud
{
float monsterMaxD = MonsterHudSettings.MaxDistance;
float labelMaxD = MonsterHudSettings.NpcMaxDistance;
float portalMaxD = MonsterHudSettings.PortalMaxDistance;
float opacity = MonsterHudSettings.Opacity;
float userScale = MonsterHudSettings.Scale;
float lift = MonsterHudSettings.HeightLift;
@ -905,7 +956,7 @@ internal static class MonsterHud
}
// ── Alpha / scale targets ──
float maxD = label ? labelMaxD : monsterMaxD;
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;
@ -1042,7 +1093,7 @@ internal static class MonsterHud
p.NameFont = ImGuiFonts.Sharp(p.NameSize, bold: true);
p.NameW = TextWidth(p.NameFont, p.NameSize, p.Name);
p.BadgeW = 0f;
p.IconSize = 0f;
p.Row = default;
if (p.HasBar)
{
// A thin bar under the name, at least the name's width.
@ -1077,9 +1128,10 @@ internal static class MonsterHud
p.BadgeW = MonsterHudSettings.ShowLevel && p.LevelText.Length > 0
? TextWidth(p.SmallFont, p.SmallSize, p.LevelText) + 8f * k : 0f;
// Debuff row under the bar: icon + countdown line.
p.IconSize = MathF.Round(13f * k);
float iconRow = p.IconCount > 0 || p.Others ? p.IconSize + MathF.Round(3f * k) + 3f : 0f;
// Debuff row under the bar: icon + countdown line, at its own size (not the text size).
p.Row = new DebuffRowMetrics(k, MonsterHudSettings.MonsterDebuffIconSize);
bool icons = p.IconCount > 0 || p.Others;
float iconRow = icons ? p.Row.Height : 0f;
p.BelowBar = iconRow + (p.IsTarget ? 9f * k : 3f * k);
float nameLine = p.NameW + (p.BadgeW > 0 ? p.BadgeW + 4f * k : 0f);
@ -1088,10 +1140,14 @@ internal static class MonsterHud
// inside the crowd-avoidance box, symmetric so the plate stays centred.
float side = (p.Weak != null || MonsterHudSettings.ShowDistance) ? 2f * 30f * k * text : 0f;
p.Width = MathF.Max(p.BarW + side, nameLine) + 8f * k;
// Icons made bigger than the default can be wider than the bar: the box (crowding, clicks) holds them.
if (icons && p.Row.Scale > 1f)
p.Width = p.Row.CoverWidth(p.Width, DebuffIconRow.Width(p.Icons.Length, p.IconCount, p.Others, in p.Row,
p.SmallFont, p.SmallSize, ref p.OverflowKey, ref p.OverflowString), 8f * k);
p.Height = nameH + p.BarH + p.BelowBar;
}
/// <summary>A name label's text size: players' or NPCs' (vendors count as NPCs).</summary>
/// <summary>A name label's text size: players' or NPCs' (vendors and portals go with NPCs).</summary>
private static float LabelTextSize(byte kind) =>
kind == RadarKind.Player ? MonsterHudSettings.PlayerTextSize : MonsterHudSettings.NpcTextSize;
@ -1223,8 +1279,8 @@ internal static class MonsterHud
var b1 = new Vector2(barR, barBottom);
float round = MathF.Max(1f, 2f * k);
bool icons = p.IconCount > 0 || p.Others;
float iconTop = barBottom + MathF.Round(3f * k);
float pointerTop = icons ? iconTop + p.IconSize + 3f + 2f * k : barBottom + 2f * k;
float iconTop = barBottom + p.Row.Above;
float pointerTop = icons ? iconTop + p.Row.Icon + p.Row.Below + 2f * k : barBottom + 2f * k;
// Crowd leader: a plate pushed up keeps a faint line down to its monster.
if (p.Nudge > 10f * uiScale)
@ -1290,8 +1346,8 @@ internal static class MonsterHud
// Under the bar: the debuff icons.
if (icons)
DebuffIconRow.Paint(dl, p.Icons, p.IconCount, p.Others, p.IconSize, p.SmallFont, p.SmallSize,
ref p.OverflowKey, ref p.OverflowString, cx, iconTop, k, a, now);
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);
// ── Name line: [level badge] Name ──
if (p.NameW > 0 || p.BadgeW > 0)
@ -1621,12 +1677,13 @@ internal static class MonsterHud
/// <summary>Chat lines for "/rv plates status": what the overlays see right now. AC's thread.</summary>
public static string[] DescribeLines()
{
int onScreen = 0, known = 0, labels = 0, labelsOnScreen = 0;
int onScreen = 0, known = 0, labels = 0, labelsOnScreen = 0, portals = 0;
foreach (Plate p in Plates.Values)
{
if (p.IsLabel)
{
labels++;
if (p.Kind == RadarKind.Portal) portals++;
if (p.OnScreen && p.Alpha > 0.01f) labelsOnScreen++;
continue;
}
@ -1636,7 +1693,7 @@ internal static class MonsterHud
return new[]
{
$"Nameplates: {Plates.Count - labels} tracked, {onScreen} on screen, {known} with health seen; " +
$"name labels {labels} ({labelsOnScreen} on screen), {Classes.Count} objects classified; " +
$"name labels {labels} ({labelsOnScreen} on screen, {portals} portals), {Classes.Count} objects classified; " +
$"camera {(GameMatrixCapture.HasCapturedFrame ? "captured" : "not captured")} " +
$"(frame lb 0x{GameMatrixCapture.FrameLandblock:X4}, viewport {GameMatrixCapture.ViewportWidth}x{GameMatrixCapture.ViewportHeight}); " +
$"weakness data {(_weakByWcid.Count + _weakByName.Count > 0 ? "loaded" : "none")}.",

View file

@ -58,6 +58,15 @@ internal static class MonsterHudSettings
public static bool PlayerNames = false;
/// <summary>A health bar under other players' names, for those whose health the client has been told (selected, fellowship).</summary>
public static bool PlayerBars = false;
/// <summary>
/// The name over portals (2026-10-28), in the radar's portal colour. On by default: portals are few and
/// the label is only the name. Their own distance and count, so NPC names never crowd them out.
/// </summary>
public static bool PortalNames = true;
public static float PortalMaxDistance = DefaultPortalDistance; // yards; portals are worth seeing from further than NPCs
public const float DefaultPortalDistance = 60f;
/// <summary>At most this many portal names (nearest first; a selected portal always keeps its own). Not a setting.</summary>
public const int MaxPortalLabels = 12;
// Debuff icons on the monster plates (PlateDebuffs).
public static bool ShowDebuffs = true;
@ -121,7 +130,7 @@ internal static class MonsterHudSettings
// NPC and player names are name-only labels (no bar), so they only have a text size.
/// <summary>Monster plates: the health bar's width and height, and their text (name, level, HP, weak-to, distance).</summary>
public static float MonsterBarWidth = 1.0f, MonsterBarHeight = 1.0f, MonsterTextSize = 1.0f;
/// <summary>Name labels over NPCs and vendors.</summary>
/// <summary>Name labels over NPCs and vendors, and over portals.</summary>
public static float NpcTextSize = 1.0f;
/// <summary>Name labels over other players.</summary>
public static float PlayerTextSize = 1.0f;
@ -130,12 +139,21 @@ internal static class MonsterHudSettings
public const float MinBarWidth = 0.5f, MaxBarWidth = 2.5f;
public const float MinBarHeight = 0.5f, MaxBarHeight = 3.0f;
public const float MinTextSize = 0.5f, MaxTextSize = 2.0f;
/// <summary>
/// "Debuff icon size" (2026-10-28), in percent of the icons' size before it existed (100 = unchanged), on
/// top of Look > Scale: the monster plates' row and your own plate's "Debuffs on you" row, each on its own
/// and apart from every text size. The icon, its glyph, countdown line, stack digit, "+N" and spacing all
/// follow it (DebuffRowMetrics).
/// </summary>
public static int MonsterDebuffIconSize = DefaultDebuffIconSize, SelfDebuffIconSize = DefaultDebuffIconSize;
public const int DefaultDebuffIconSize = 100, MinDebuffIconSize = 50, MaxDebuffIconSize = 200;
// ── Ranges (shared by the Settings face, the command and Load) ──────
public const float MinDistance = 5f, MaxDistanceLimit = 120f;
public const int MinPlates = 1, MaxPlatesLimit = 60;
public const float MinNpcDistance = 5f, MaxNpcDistanceLimit = 80f;
public const int MinNpcLabels = 1, MaxNpcLabelsLimit = 40;
public const float MinPortalDistance = 5f, MaxPortalDistanceLimit = 120f;
public const float MinScale = 0.6f, MaxScale = 2.0f;
public const float MinOpacity = 0.2f, MaxOpacity = 1.0f;
public const float MinLift = -1.5f, MaxLift = 3.0f;
@ -211,6 +229,8 @@ internal static class MonsterHudSettings
break;
case "playerNames": PlayerNames = val == "1"; break;
case "playerBars": PlayerBars = val == "1"; break;
case "portalNames": PortalNames = val == "1"; break;
case "portalDistance": if (TryF(val, out float pd)) PortalMaxDistance = Math.Clamp(pd, MinPortalDistance, MaxPortalDistanceLimit); break;
case "showDebuffs": ShowDebuffs = val == "1"; break;
case "showOthersDebuff": ShowOthersDebuff = val == "1"; break;
case "selfPlate": SelfPlate = val == "1"; break;
@ -250,12 +270,38 @@ internal static class MonsterHudSettings
case "selfBarWidth": if (TryF(val, out float sbw)) SelfBarWidth = Math.Clamp(sbw, MinBarWidth, MaxBarWidth); break;
case "selfBarHeight": if (TryF(val, out float sbh)) SelfBarHeight = Math.Clamp(sbh, MinBarHeight, MaxBarHeight); break;
case "selfTextSize": if (TryF(val, out float sts)) SelfTextSize = Math.Clamp(sts, MinTextSize, MaxTextSize); break;
case "monsterDebuffIconSize":
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int mdi))
MonsterDebuffIconSize = Math.Clamp(mdi, MinDebuffIconSize, MaxDebuffIconSize);
break;
case "selfDebuffIconSize":
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int sdi))
SelfDebuffIconSize = Math.Clamp(sdi, MinDebuffIconSize, MaxDebuffIconSize);
break;
}
}
}
private static bool TryF(string s, out float v) => float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out v);
/// <summary>
/// A typed debuff icon size (/rv plates debuffs size, /rv plates self debuffs size) as a percent in range:
/// "150", "150%", or a factor "1.5" / "1.5x" (up to 3 reads as a factor). False for junk.
/// </summary>
internal static bool TryParseDebuffIconSize(string? text, out int percent)
{
percent = DefaultDebuffIconSize;
if (string.IsNullOrWhiteSpace(text)) return false;
string t = text.Trim();
bool factor = false;
if (t.EndsWith('%')) t = t[..^1].TrimEnd();
else if (t.EndsWith('x') || t.EndsWith('X')) { t = t[..^1].TrimEnd(); factor = true; }
if (!TryF(t, out float v) || !float.IsFinite(v)) return false;
if (factor || v <= 3f) v *= 100f;
percent = (int)MathF.Round(Math.Clamp(v, MinDebuffIconSize, MaxDebuffIconSize));
return true;
}
/// <summary>Writes the settings in the background. Any thread.</summary>
public static void Save() => UiBackgroundWriter.Enqueue("nameplate settings", SaveNow);
@ -298,6 +344,8 @@ internal static class MonsterHudSettings
sw.WriteLine(FormattableString.Invariant($"npcMax={MaxNpcLabels}"));
sw.WriteLine($"playerNames={B(PlayerNames)}");
sw.WriteLine($"playerBars={B(PlayerBars)}");
sw.WriteLine($"portalNames={B(PortalNames)}");
sw.WriteLine(FormattableString.Invariant($"portalDistance={PortalMaxDistance:0.#}"));
sw.WriteLine($"showDebuffs={B(ShowDebuffs)}");
sw.WriteLine($"showOthersDebuff={B(ShowOthersDebuff)}");
sw.WriteLine($"selfPlate={B(SelfPlate)}");
@ -337,6 +385,8 @@ internal static class MonsterHudSettings
sw.WriteLine(FormattableString.Invariant($"selfBarWidth={SelfBarWidth:0.##}"));
sw.WriteLine(FormattableString.Invariant($"selfBarHeight={SelfBarHeight:0.##}"));
sw.WriteLine(FormattableString.Invariant($"selfTextSize={SelfTextSize:0.##}"));
sw.WriteLine(FormattableString.Invariant($"monsterDebuffIconSize={MonsterDebuffIconSize}"));
sw.WriteLine(FormattableString.Invariant($"selfDebuffIconSize={SelfDebuffIconSize}"));
}
private static string B(bool v) => v ? "1" : "0";
@ -349,6 +399,7 @@ internal static class MonsterHudSettings
FadeWithDistance = true; Scale = 1.0f; Opacity = 0.9f; HeightLift = 0f; ClickToSelect = true;
ShowDebuffs = true; ShowOthersDebuff = true;
NpcNames = true; NpcMaxDistance = 30f; MaxNpcLabels = 15; PlayerNames = false; PlayerBars = false;
PortalNames = true; PortalMaxDistance = DefaultPortalDistance;
SelfPlate = true; SelfNumbers = false; SelfName = false; SelfHideFirstPerson = true;
SelfPlacement = SelfPlacement.Fixed; SelfLocked = true; SelfFixedX = DefaultSelfFixedX; SelfFixedY = DefaultSelfFixedY;
SelfBarTrack = true; SelfBarChip = true; SelfTextOutline = true; SelfNumberBand = true; SelfDebuffs = true;
@ -360,7 +411,7 @@ internal static class MonsterHudSettings
Save();
}
/// <summary>Every plate type's bar and text size back to 1 (and saved). Render / chat thread.</summary>
/// <summary>Every plate type's bar and text size back to 1, the debuff icon sizes to 100 % (and saved). Render / chat thread.</summary>
public static void ResetSizes()
{
ResetSizesNoSave();
@ -372,6 +423,7 @@ internal static class MonsterHudSettings
MonsterBarWidth = 1.0f; MonsterBarHeight = 1.0f; MonsterTextSize = 1.0f;
NpcTextSize = 1.0f; PlayerTextSize = 1.0f;
SelfBarWidth = 1.0f; SelfBarHeight = 1.0f; SelfTextSize = 1.0f;
MonsterDebuffIconSize = DefaultDebuffIconSize; SelfDebuffIconSize = DefaultDebuffIconSize;
}
/// <summary>The fixed plate back to its default spot (and saved). Render / chat thread.</summary>
@ -401,7 +453,7 @@ internal static class MonsterHudSettings
/// <summary>Every master switch at once ("/rv plates all on|off").</summary>
public static void SetAll(bool on)
{
Enabled = on; ShowDebuffs = on; SelfPlate = on; Numbers = on; Gains = on; NpcNames = on;
Enabled = on; ShowDebuffs = on; SelfPlate = on; Numbers = on; Gains = on; NpcNames = on; PortalNames = on;
if (!on) { PlayerNames = false; PlayerBars = false; } // "all on" leaves player names and bars as chosen (off by default)
}
@ -411,16 +463,17 @@ internal static class MonsterHudSettings
$"{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)}), debuffs {OnOff(ShowDebuffs)} (others {OnOff(ShowOthersDebuff)}); " +
$"NPC names {OnOff(NpcNames)} ({NpcMaxDistance:0}yd, max {MaxNpcLabels}), player names {OnOff(PlayerNames)} (bars {OnOff(PlayerBars)}); " +
$"NPC names {OnOff(NpcNames)} ({NpcMaxDistance:0}yd, max {MaxNpcLabels}), player names {OnOff(PlayerNames)} (bars {OnOff(PlayerBars)}), " +
$"portal names {OnOff(PortalNames)} ({PortalMaxDistance:0}yd); " +
$"self {OnOff(SelfPlate)} ({(SelfPlacement == SelfPlacement.Fixed ? "fixed on screen, " + (SelfLocked ? "locked" : "unlocked") : "follows you, " + SelfPosition.ToString().ToLowerInvariant())}, " +
$"numbers {OnOff(SelfNumbers)}, name {OnOff(SelfName)}, hide in first person {OnOff(SelfHideFirstPerson)}, " +
$"debuffs on you {OnOff(SelfDebuffs)}, track {OnOff(SelfBarTrack)}, damage trail {OnOff(SelfBarChip)}, " +
$"text outline {OnOff(SelfTextOutline)}, number band {OnOff(SelfNumberBand)}); " +
$"combat text {OnOff(Numbers)} (dealt {OnOff(NumDealt)}, taken {OnOff(NumTaken)}, heals {OnOff(NumHeals)}, kills {OnOff(NumKills)}); " +
$"gains {OnOff(Gains)} (xp {OnOff(GainXp)}, lum {OnOff(GainLum)}, radiance {OnOff(GainRadiance)}); " +
$"sizes: monster bar {MonsterBarWidth:0.##}x{MonsterBarHeight:0.##} text {MonsterTextSize:0.##}, " +
$"NPC text {NpcTextSize:0.##}, player text {PlayerTextSize:0.##}, " +
$"your bars {SelfBarWidth:0.##}x{SelfBarHeight:0.##} text {SelfTextSize:0.##}.");
$"sizes: monster bar {MonsterBarWidth:0.##}x{MonsterBarHeight:0.##} text {MonsterTextSize:0.##} debuff icons {MonsterDebuffIconSize}%, " +
$"NPC and portal text {NpcTextSize:0.##}, player text {PlayerTextSize:0.##}, " +
$"your bars {SelfBarWidth:0.##}x{SelfBarHeight:0.##} text {SelfTextSize:0.##} debuff icons {SelfDebuffIconSize}%.");
private static string OnOff(bool v) => v ? "on" : "off";
}

View file

@ -1,7 +1,7 @@
// ============================================================================
// RynthCore.Engine - ImGui/MonsterHud/MonsterHudSettingsUi.cs
// The RynthVision overlay settings, drawn as two tabs of the Vision panel
// (Panels/VisionFace.cs): "Nameplates" (monster plates, NPC / player names,
// (Panels/VisionFace.cs): "Nameplates" (monster plates, NPC / player / portal names,
// debuff icons, your plate, look) and "Combat text" (numbers, kill burst, gains). Square toggle
// dots and amber section headers; sliders save when the drag ends. Values
// live engine-side in MonsterHudSettings. AC's render thread, inside the
@ -24,6 +24,11 @@ internal static class MonsterHudSettingsUi
private static uint BtnFill => RynthTheme.Button;
private static uint C(uint argb) => RynthTheme.Argb(argb);
private static readonly string PortalNamesTip =
"The portal's name above it, in the radar's portal colour (purple by default), at the NPC name size. " +
$"The nearest {MonsterHudSettings.MaxPortalLabels}, counted on their own so NPC names never crowd them out; " +
"click one to select the portal. Chat: /rv plates portals [on|off], /rv plates portals dist <yd>.";
private static bool Loading(float w)
{
if (MonsterHudSettings.Loaded) return false;
@ -79,7 +84,7 @@ internal static class MonsterHudSettingsUi
changed |= SizeSlider("Text size", ref MonsterHudSettings.MonsterTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
"The monster plate's text: name, level badge, HP numbers, weak-to pill and distance (1.00x = the default).");
Section("Names over NPCs and players", w);
Section("Names over NPCs, players and portals", w);
changed |= Toggle("NPC names", ref MonsterHudSettings.NpcNames,
"The name over vendors, quest givers, town criers and other NPCs: yellow, vendors gold (the radar's colours). " +
"Name only, no health bar; click one to select it. Chat: /rv plates npcs.");
@ -88,7 +93,7 @@ internal static class MonsterHudSettingsUi
changed |= SliderI("Max names", ref MonsterHudSettings.MaxNpcLabels,
MonsterHudSettings.MinNpcLabels, MonsterHudSettings.MaxNpcLabelsLimit, w);
changed |= SizeSlider("NPC name size", ref MonsterHudSettings.NpcTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
"Text size of the names over NPCs and vendors (1.00x = the default). Names have no bar.");
"Text size of the names over NPCs and vendors, and over portals (1.00x = the default). Names have no bar.");
changed |= Toggle("Player names", ref MonsterHudSettings.PlayerNames,
"The name over other players too (blue), within the same distance and count. Chat: /rv plates players.");
changed |= Toggle("Player health bars", ref MonsterHudSettings.PlayerBars,
@ -96,6 +101,9 @@ internal static class MonsterHudSettingsUi
"once you select them or they share it (fellowship), so a bar shows from then on; others keep just the name. Chat: /rv plates playerbars.");
changed |= SizeSlider("Player name size", ref MonsterHudSettings.PlayerTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
"Text size of the names over other players (1.00x = the default). Names have no bar.");
changed |= Toggle("Portal names", ref MonsterHudSettings.PortalNames, PortalNamesTip);
changed |= SliderF("Portal name distance (yd)", ref MonsterHudSettings.PortalMaxDistance,
MonsterHudSettings.MinPortalDistance, MonsterHudSettings.MaxPortalDistanceLimit, "%.0f", w);
Note("Names count apart from the monster plates, so they never push one out; the nearest win.", w);
Section("Debuffs", w);
@ -105,6 +113,11 @@ internal static class MonsterHudSettingsUi
changed |= Toggle("Debuffed by others", ref MonsterHudSettings.ShowOthersDebuff,
"A small marker when an appraisal shows a lowered attribute or vital that none of your own debuffs explains. " +
"It only updates when the monster is appraised (your combat target is appraised often).", sub: true);
changed |= PercentSlider("Debuff icon size", ref MonsterHudSettings.MonsterDebuffIconSize,
MonsterHudSettings.MinDebuffIconSize, MonsterHudSettings.MaxDebuffIconSize, w,
"How big the debuff icons on monster plates are (100% = the default): the icons, their countdown lines, " +
"the stack digits and \"+N\". On its own: the text size doesn't change it. On top of Look > Scale. " +
"Chat: /rv plates debuffs size 50-200.");
Section("Your plate", w);
changed |= Toggle("Show your plate", ref MonsterHudSettings.SelfPlate,
@ -114,7 +127,11 @@ internal static class MonsterHudSettingsUi
changed |= Toggle("Debuffs on you", ref MonsterHudSettings.SelfDebuffs,
"Icons under your mana bar for harmful spells on you (vulnerabilities, Imperil, Magic Yield, attribute and skill debuffs...), " +
"the monster plates' icons: one per kind, a line that runs out with the spell, blinking in its last 5 seconds, \"+N\" when more than fit. " +
"Only shows while you have one.", sub: true);
"Only shows while you have one. Chat: /rv plates self debuffs.", sub: true);
changed |= PercentSlider("Your debuff icon size", ref MonsterHudSettings.SelfDebuffIconSize,
MonsterHudSettings.MinDebuffIconSize, MonsterHudSettings.MaxDebuffIconSize, w,
"How big the icons under your bars are (100% = the default), apart from the monster plates' and from " +
"Your text size. On top of Look > Scale. Chat: /rv plates self debuffs size 50-200.");
changed |= SizeSlider("Your bar width", ref MonsterHudSettings.SelfBarWidth, MonsterHudSettings.MinBarWidth, MonsterHudSettings.MaxBarWidth, w,
"How wide your health, stamina and mana bars are (1.00x = the default).");
changed |= SizeSlider("Your bar height", ref MonsterHudSettings.SelfBarHeight, MonsterHudSettings.MinBarHeight, MonsterHudSettings.MaxBarHeight, w,
@ -188,13 +205,13 @@ internal static class MonsterHudSettingsUi
changed |= Toggle("Fade and shrink with distance", ref MonsterHudSettings.FadeWithDistance, null);
ImGuiNET.ImGui.Dummy(new Vector2(0, 8));
if (SmallButton("Reset bar and text sizes"))
if (SmallButton("Reset bar, text and icon sizes"))
{
MonsterHudSettings.ResetSizes(); // saves
changed = false;
}
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip("Every plate type's bar width, bar height and text size back to 1.00x.");
SafeImGui.SetTooltip("Every plate type's bar width, bar height and text size back to 1.00x, and both debuff icon sizes to 100%.");
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
if (SmallButton("Reset all to defaults"))
{
@ -292,6 +309,15 @@ internal static class MonsterHudSettingsUi
return EndSliderRow(changed);
}
/// <summary>A percent slider ("100%" = the default look) with a tooltip. Labels are the ids: keep them unique.</summary>
private static bool PercentSlider(string label, ref int value, int min, int max, float w, string tip)
{
BeginSliderRow(label, w);
bool changed = ImGuiNET.ImGui.SliderInt("##v", ref value, min, max, "%d%%", ImGuiSliderFlags.AlwaysClamp);
if (ImGuiNET.ImGui.IsItemHovered()) SafeImGui.SetTooltip(tip);
return EndSliderRow(changed);
}
private static bool SliderI(string label, ref int value, int min, int max, float w)
{
BeginSliderRow(label, w);

View file

@ -0,0 +1,33 @@
// ============================================================================
// RynthCore.Engine - ImGui/MonsterHud/PlateClass.cs
// What a world object is to the nameplates (MonsterHud.Classify), from the
// main-thread snapshot's ITEM_TYPE: a creature (its PublicWeenieDesc then
// says player, pet, vendor or other), a portal (a name label over it, since
// 2026-10-28), or nothing that gets a plate or a name.
//
// Pure code: MonsterHud feeds it the snapshot values; tools/PlateSizingTests
// compiles it in.
// ============================================================================
namespace RynthCore.Engine.ImGuiBackend.Hud;
internal static class PlateClass
{
// The values of MonsterHud's per-id cache (MonsterHud.Classes). Unknown: the snapshot has no type yet.
public const byte Unknown = 0, Other = 1, Creature = 2, Vendor = 3, Player = 4, Pet = 5;
/// <summary>A creature whose PWD isn't in the snapshot yet: never cached, asked again next scan.</summary>
public const byte CreatureNoPwd = 6;
/// <summary>A portal: a name label over it ("Portal names").</summary>
public const byte Portal = 7;
public const uint TypeCreature = 0x10; // ITEM_TYPE TYPE_CREATURE
public const uint TypePortal = 0x10000; // ITEM_TYPE TYPE_PORTAL (the radar and the Sense scan read it too)
/// <summary>
/// What the item type alone decides: <see cref="Creature"/> (its PWD then decides which kind),
/// <see cref="Portal"/>, or <see cref="Other"/>. A creature bit wins, so nothing that has a
/// monster plate ever turns into a portal name.
/// </summary>
public static byte FromItemType(uint type) =>
(type & TypeCreature) != 0 ? Creature : (type & TypePortal) != 0 ? Portal : Other;
}

View file

@ -0,0 +1,151 @@
// ============================================================================
// RynthCore.Engine - ImGui/MonsterHud/PlateMetrics.cs
// The plates' lengths that need no font, so the offline tests can check them:
// DebuffRowMetrics - the debuff icon row (DebuffIconRow) at a plate's scale
// and its "Debuff icon size" setting (2026-10-28: a player asked for
// bigger icons, apart from the text size). The monster plates and your
// own plate each have their own setting.
// SelfPlateMetrics - your plate's bars, the name's room above them and the
// debuff row under them (PlayerPlate.Measure), and the clamp that keeps
// all of it on screen.
// At 100 % every length is the expression the plates used before the setting
// existed (k x 1 is k exactly), so nothing moves by a pixel until it is set.
// Plain math, no engine dependencies (the offline tests compile it in).
// ============================================================================
using System;
namespace RynthCore.Engine.ImGuiBackend.Hud;
/// <summary>
/// The debuff icon row's lengths at a plate's scale <c>k</c> and an icon size setting (a percentage,
/// 100 = the size before the setting). Everything the row draws or reserves follows k x the setting:
/// the icon square, its glyph, the countdown line, the spacing; the stack digit and "+N" scale their
/// text size by <see cref="Scale"/> (<see cref="TextSize"/>). Text size settings never change it.
/// </summary>
internal readonly struct DebuffRowMetrics
{
/// <summary>The setting as a factor (1 = 100 %).</summary>
public readonly float Scale;
/// <summary>The plate's k times <see cref="Scale"/>: what the row's own lengths follow.</summary>
public readonly float K;
/// <summary>The icon square (13 px at k 1, 100 %).</summary>
public readonly float Icon;
/// <summary>The glyph inside the square (px).</summary>
public readonly float Glyph;
/// <summary>Between the bar(s) above and the icons.</summary>
public readonly float Above;
/// <summary>Under each icon: room for the countdown line.</summary>
public readonly float Below;
/// <summary>Between two icons (and before "+N" and the "debuffed by others" marker).</summary>
public readonly float Gap;
/// <summary>The countdown line: its distance under the icon and its thickness.</summary>
public readonly float LineGap, LineH;
/// <summary>The icon square's corner radius.</summary>
public readonly float Round;
/// <summary>The stack digit's offset from the icon's top-right corner (right, up).</summary>
public readonly float DigitDx, DigitDy;
/// <param name="k">The plate's scale (Look > Scale x UI scale, x the monster plate's distance shrink).</param>
/// <param name="sizePercent">The icon size setting (MonsterHudSettings: 50-200; 0 or less = 100).</param>
public DebuffRowMetrics(float k, int sizePercent)
{
float s = Scale = sizePercent > 0 ? sizePercent / 100f : 1f;
float ik = K = k * s;
Icon = MathF.Round(13f * ik);
Glyph = MathF.Round(Icon * 0.8f);
Above = MathF.Round(3f * ik);
Below = MathF.Round(3f * s);
Gap = MathF.Max(2f, MathF.Round(2f * ik));
LineGap = MathF.Max(1f, MathF.Round(s));
LineH = MathF.Max(1f, MathF.Round(1.5f * ik));
Round = 2f * ik;
DigitDx = MathF.Round(s);
DigitDy = MathF.Round(2f * s);
}
/// <summary>The room the row takes under the bar(s): the gap above, the icons, the countdown line.</summary>
public float Height => Above + Icon + Below;
/// <summary>The row's text size (stack digit, "+N") from the plate's small text size (whole px).</summary>
public float TextSize(float smallSize) => MathF.Round(smallSize * Scale);
/// <summary>
/// The row's width: <paramref name="slots"/> squares (icons and the "debuffed by others" marker) and,
/// when <paramref name="more"/>, the "+N" text <paramref name="moreTextW"/> px wide after them.
/// </summary>
public float Width(int slots, bool more, float moreTextW)
{
float moreW = more ? MoreWidth(moreTextW) : 0f;
return slots * Icon + Math.Max(0, slots - 1) * Gap + (more ? Gap + moreW : 0f);
}
/// <summary>The "+N" text's slot: its width plus a little room.</summary>
public float MoreWidth(float moreTextW) => moreTextW + 4f * K;
/// <summary>
/// A plate box <paramref name="width"/> wide, grown to hold an enlarged row (<paramref name="rowWidth"/>
/// plus <paramref name="pad"/>). At 100 % or smaller the box is left as it was before the setting.
/// </summary>
public float CoverWidth(float width, float rowWidth, float pad) =>
Scale > 1f ? MathF.Max(width, rowWidth + pad) : width;
/// <summary>
/// How far an enlarged row centred under bars <paramref name="barW"/> wide reaches past each of their
/// ends (whole px). 0 at 100 % or smaller, as before the setting.
/// </summary>
public float Overhang(float rowWidth, float barW) =>
Scale > 1f ? MathF.Max(0f, MathF.Ceiling((rowWidth - barW) * 0.5f)) : 0f;
}
/// <summary>
/// Your own plate's lengths (PlayerPlate.Measure): three bars, the name's room above them and the debuff
/// row under them. The plate is placed by the bars' top-left; it reaches <see cref="NameH"/> above that,
/// <see cref="BlockH"/> + <see cref="IconsH"/> below it and <see cref="IconsOver"/> past either end, and
/// <see cref="ClampLeft"/> / <see cref="ClampTop"/> keep all of it on screen (the fixed plate, and a
/// following one with Keep on screen); the drag area covers the same rect.
/// </summary>
internal struct SelfPlateMetrics
{
public float K, BarW, BarH, Gap, Round, BlockH, NameH;
/// <summary>The debuff row's room under the bars (0 without an icon) and its reach past the bars' ends.</summary>
public float IconsH, IconsOver;
public DebuffRowMetrics Row;
/// <summary>Your plate's measured height: the name, the bars and the debuff row.</summary>
public readonly float Height => NameH + BlockH + IconsH;
/// <summary>The debuff row's top, down from the bars' top.</summary>
public readonly float RowTop => BlockH + Row.Above;
/// <param name="k">Look > Scale x UI scale.</param>
/// <param name="numbers">"Numbers on your bars" (taller, wider bars).</param>
/// <param name="barWidth">"Your bar width" (1 = default).</param>
/// <param name="barHeight">"Your bar height" (1 = default).</param>
/// <param name="nameSize">The name's text size, 0 when the name is off.</param>
/// <param name="icons">There is a debuff icon to show.</param>
/// <param name="iconPercent">"Your debuff icon size" (100 = default).</param>
public static SelfPlateMetrics Measure(float k, bool numbers, float barWidth, float barHeight, float nameSize, bool icons, int iconPercent)
{
SelfPlateMetrics m = default;
m.K = k;
m.BarW = MathF.Round((numbers ? 124f : 96f) * k * barWidth);
m.BarH = MathF.Round((numbers ? 15f : 5f) * k * barHeight);
m.Gap = MathF.Max(2f, MathF.Round(2f * k));
m.Round = MathF.Max(1f, 1.5f * k);
m.BlockH = 3 * m.BarH + 2 * m.Gap;
m.NameH = nameSize > 0f ? nameSize + 3f * k : 0f;
m.Row = new DebuffRowMetrics(k, iconPercent);
m.IconsH = icons ? m.Row.Height : 0f;
m.IconsOver = 0f; // PlayerPlate sets it from the row's width (needs the "+N" text): Row.Overhang
return m;
}
/// <summary>The bars' left edge kept 4 px inside the screen, an enlarged debuff row's ends included.</summary>
public readonly float ClampLeft(float left, float displayW) =>
Math.Clamp(left, 4f + IconsOver, MathF.Max(4f + IconsOver, displayW - BarW - 4f - IconsOver));
/// <summary>The bars' top kept 4 px inside the screen, with the name above and the debuff row under.</summary>
public readonly float ClampTop(float y, float displayH) =>
Math.Clamp(y, 4f + NameH, MathF.Max(4f + NameH, displayH - BlockH - IconsH - 4f));
}

View file

@ -42,6 +42,11 @@
// (PortalSpellTable, queued by MonsterHud.Update while the row is on). The
// row hangs under the bars: placement keeps the bars where they are and
// only the clamp and the drag area grow to cover it.
// "Your debuff icon size" (2026-10-28, 50-200 %, 100 = as before): the row's
// own scale, apart from your text size. The lengths that need no font are in
// SelfPlateMetrics (PlateMetrics.cs, offline-tested): the clamp and the drag
// area cover the row at any size, and an enlarged row wider than the bars
// (IconsOver) too.
//
// Render thread only. Engine-owned statics.
// ============================================================================
@ -145,7 +150,7 @@ internal static class PlayerPlate
PlayerVitalsHooks.TryGetSnapshot(out _);
if (!Advance(ref f, show)) return;
Layout l = Measure(f.UiScale);
float k = l.K, barW = l.BarW, blockH = l.BlockH, nameH = l.NameH, iconsH = l.IconsH;
float k = l.M.K, barW = l.M.BarW, blockH = l.M.BlockH, nameH = l.M.NameH, iconsH = l.M.IconsH;
// Where the block goes: above the head (default), under the feet, or beside the character.
float left, y;
@ -181,8 +186,8 @@ internal static class PlayerPlate
}
if (MonsterHudSettings.KeepOnScreen)
{
left = Math.Clamp(left, 4f, MathF.Max(4f, f.Display.X - barW - 4f));
y = Math.Clamp(y, 4f + nameH, MathF.Max(4f + nameH, f.Display.Y - blockH - iconsH - 4f));
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);
// Gain text floats above the plate when it's over the head, else above the head itself.
@ -204,6 +209,7 @@ internal static class PlayerPlate
// The bars' centre from the saved fractions, then the block kept inside the screen.
Vector2 display = f.Display;
float cx = MonsterHudSettings.SelfFixedX * display.X, cy = MonsterHudSettings.SelfFixedY * display.Y;
ref SelfPlateMetrics m = ref l.M;
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
bool unlocked = !MonsterHudSettings.SelfLocked;
if (_dragging)
@ -221,23 +227,23 @@ internal static class PlayerPlate
}
}
// The saved spot is the bars' centre (a debuff row coming and going never moves them); the
// clamp keeps the row under them on screen too.
float left = Math.Clamp(cx - l.BarW * 0.5f, 4f, MathF.Max(4f, display.X - l.BarW - 4f));
float y = Math.Clamp(cy - l.BlockH * 0.5f, 4f + l.NameH, MathF.Max(4f + l.NameH, display.Y - l.BlockH - l.IconsH - 4f));
// clamp keeps the row under them (and past their ends, when it is wider) on screen too.
float left = m.ClampLeft(cx - m.BarW * 0.5f, display.X);
float y = m.ClampTop(cy - m.BlockH * 0.5f, display.Y);
left = MathF.Round(left);
y = MathF.Round(y);
if (_dragging && display.X > 1 && display.Y > 1)
{
// The spot as fractions (clamped, so letting go off screen keeps it reachable).
MonsterHudSettings.SelfFixedX = Math.Clamp((left + l.BarW * 0.5f) / display.X, 0f, 1f);
MonsterHudSettings.SelfFixedY = Math.Clamp((y + l.BlockH * 0.5f) / display.Y, 0f, 1f);
MonsterHudSettings.SelfFixedX = Math.Clamp((left + m.BarW * 0.5f) / display.X, 0f, 1f);
MonsterHudSettings.SelfFixedY = Math.Clamp((y + m.BlockH * 0.5f) / display.Y, 0f, 1f);
}
// The plate's rect (name and debuff row included), a little padded: the drag surface.
float pad = MathF.Round(4f * l.K);
var r0 = new Vector2(left - pad, y - l.NameH - pad);
var r1 = new Vector2(left + l.BarW + pad, y + l.BlockH + l.IconsH + pad);
Drag(unlocked, r0, r1, new Vector2(left + l.BarW * 0.5f, y + l.BlockH * 0.5f));
float pad = MathF.Round(4f * m.K);
var r0 = new Vector2(left - pad - m.IconsOver, y - m.NameH - pad);
var r1 = new Vector2(left + m.BarW + pad + m.IconsOver, y + m.BlockH + m.IconsH + pad);
Drag(unlocked, r0, r1, new Vector2(left + m.BarW * 0.5f, y + m.BlockH * 0.5f));
ImDrawListPtr dl = ImGuiNET.ImGui.GetBackgroundDrawList();
if (unlocked)
@ -333,45 +339,46 @@ internal static class PlayerPlate
/// <summary>The plate's sizes, fonts and look this frame.</summary>
private struct Layout
{
public float K, BarW, BarH, Gap, Round, BlockH, NameH, SmallSize, NameSize;
// The lengths that need no font: bars, the name's room, the debuff row (SelfPlateMetrics, offline-tested).
public SelfPlateMetrics M;
public float SmallSize, NameSize;
public bool Numbers;
public ImFontPtr Small, NameFont;
// Look options (MonsterHudSettings.SelfBarTrack ...), read once per frame.
public bool Track, Chip, Outline, Band;
// The debuff row under the bars: icon square, its text (stack digit, "+N"), and the room it takes (0 = none).
public float IconSize, IconTextSize, IconsH;
// The debuff row's text (stack digit, "+N") before the row's own size scales it.
public float IconTextSize;
public ImFontPtr IconText;
}
private static Layout Measure(float uiScale)
{
Layout l = default;
float k = l.K = MonsterHudSettings.Scale * uiScale;
float k = MonsterHudSettings.Scale * uiScale;
bool numbers = l.Numbers = MonsterHudSettings.SelfNumbers;
// With numbers on, the bars grow to fit bold, outlined text that reads over any fill.
// Width, height and text each have their own multiplier on top (1 = the default look).
l.BarW = MathF.Round((numbers ? 124f : 96f) * k * MonsterHudSettings.SelfBarWidth);
l.BarH = MathF.Round((numbers ? 15f : 5f) * k * MonsterHudSettings.SelfBarHeight);
l.Gap = MathF.Max(2f, MathF.Round(2f * k));
l.Round = MathF.Max(1f, 1.5f * k);
// Sized from the 11 px bold bake, drawn from the smallest bake at least that big (no blur when scaled up;
// nothing is re-baked when the text size changes).
float text = MonsterHudSettings.Scale * MonsterHudSettings.SelfTextSize;
l.SmallSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * text);
l.Small = ImGuiFonts.Sharp(l.SmallSize, bold: true);
l.BlockH = 3 * l.BarH + 2 * l.Gap;
l.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * text);
l.NameFont = ImGuiFonts.Sharp(l.NameSize, bold: true);
l.NameH = MonsterHudSettings.SelfName ? l.NameSize + 3f * k : 0f;
// With numbers on, the bars grow to fit bold, outlined text that reads over any fill. Width, height
// and text each have their own multiplier on top (1 = the default look). The debuff row takes room
// only while there is an icon, at "Your debuff icon size" (not the text size).
l.M = SelfPlateMetrics.Measure(k, numbers, MonsterHudSettings.SelfBarWidth, MonsterHudSettings.SelfBarHeight,
MonsterHudSettings.SelfName ? l.NameSize : 0f, _iconCount > 0, MonsterHudSettings.SelfDebuffIconSize);
l.Track = MonsterHudSettings.SelfBarTrack;
l.Chip = MonsterHudSettings.SelfBarChip;
l.Outline = MonsterHudSettings.SelfTextOutline;
l.Band = MonsterHudSettings.SelfNumberBand;
// The debuff row: the monster plates' icon size and small text, only while there is an icon.
l.IconSize = MathF.Round(13f * k);
// The debuff row's small text: the monster plates' 9 px bake at your text size (the row scales it).
l.IconTextSize = MathF.Round(ImGuiFonts.Get(UiFont.Ui9).FontSize * text);
l.IconText = ImGuiFonts.Sharp(l.IconTextSize, bold: false);
l.IconsH = _iconCount > 0 ? MathF.Round(3f * k) + l.IconSize + 3f : 0f;
// Icons made bigger than the default can be wider than the bars: the clamp and the drag area cover them.
if (_iconCount > 0 && l.M.Row.Scale > 1f)
l.M.IconsOver = l.M.Row.Overhang(DebuffIconRow.Width(_icons.Length, _iconCount, others: false, in l.M.Row,
l.IconText, l.IconTextSize, ref _overflowKey, ref _overflowText), l.M.BarW);
return l;
}
@ -382,12 +389,13 @@ internal static class PlayerPlate
private static float Paint(ImDrawListPtr dl, ref Layout l, float left, float y, long now)
{
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 + l.BarH + l.Gap, a, StaminaCol);
PaintOne(dl, ref _mn, ref l, left, y + 2 * (l.BarH + l.Gap), a, ManaCol);
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);
if (_iconCount > 0)
DebuffIconRow.Paint(dl, _icons, _iconCount, others: false, l.IconSize, l.IconText, l.IconTextSize,
ref _overflowKey, ref _overflowText, left + l.BarW * 0.5f, y + l.BlockH + MathF.Round(3f * l.K), l.K, a, now);
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);
float top = y - 1f;
if (MonsterHudSettings.SelfName)
{
@ -395,7 +403,7 @@ internal static class PlayerPlate
if (name.Length > 0)
{
float w = MonsterHud.TextWidth(l.NameFont, l.NameSize, name);
var pos = new Vector2(MathF.Round(left + (l.BarW - w) * 0.5f), MathF.Round(y - 3f * l.K - l.NameSize));
var pos = new Vector2(MathF.Round(left + (m.BarW - w) * 0.5f), MathF.Round(y - 3f * m.K - l.NameSize));
if (l.Outline) MonsterHud.OutlinedText(dl, l.NameFont, l.NameSize, pos, a, name);
dl.AddText(l.NameFont, l.NameSize, pos, MonsterHud.Mul(NameCol, a), name);
top = pos.Y;
@ -430,11 +438,11 @@ internal static class PlayerPlate
private static void PaintOne(ImDrawListPtr dl, ref BarState b, ref Layout l, float left, float top, float a, uint col)
{
float w = l.BarW, h = l.BarH, size = l.SmallSize;
float w = l.M.BarW, h = l.M.BarH, size = l.SmallSize;
ImFontPtr font = l.Small;
var b0 = new Vector2(left, top);
var b1 = new Vector2(left + w, top + h);
MonsterHud.PaintBar(dl, b0, b1, l.Round, a, b.Shown, b.Trail, col, ticks: false, track: l.Track, chip: l.Chip);
MonsterHud.PaintBar(dl, b0, b1, l.M.Round, a, b.Shown, b.Trail, col, ticks: false, track: l.Track, chip: l.Chip);
if (!l.Numbers || h < 8f || b.Max == 0) return;
long key = ((long)b.Max << 32) | b.Cur;
string? text = b.Text;

View file

@ -8,6 +8,13 @@
out-of-range values clamp, and an untouched opacity never changes a colour.
No file I/O: the settings file is written to and read from memory, and the background
writer is a stub that never runs its work (so %LocalAppData%\RynthCore is never touched).
Also the portal names (2026-10-28; src\RynthCore.Engine\ImGui\MonsterHud\PlateClass.cs compiled in): an
ITEM_TYPE portal classifies as a portal (a creature bit wins), "Portal names" defaults on and loads on
from an older file, it and its distance round-trip, the distance clamps, all on|off and reset include it.
Also the debuff icon sizes (2026-10-28; src\RynthCore.Engine\ImGui\MonsterHud\PlateMetrics.cs compiled in): the
monster plates' and your plate's "Debuff icon size" default 100 %, an older file loads 100 %, they clamp to
50-200, round-trip on their own (apart from the text sizes), reset with the sizes, the chat form parses; the
row's lengths at 100 % are the old expressions exactly at every scale, and its height and width grow with it.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
@ -22,6 +29,8 @@
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\MonsterHudSettings.cs" Link="Engine\MonsterHudSettings.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\Data\ArgbOpacity.cs" Link="Engine\ArgbOpacity.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\PlateClass.cs" Link="Engine\PlateClass.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\PlateMetrics.cs" Link="Engine\PlateMetrics.cs" />
</ItemGroup>
</Project>

View file

@ -18,7 +18,8 @@ namespace PlateSizingTests
/// <summary>
/// The nameplate sizing settings (per plate type: bar width, bar height, text size) and the
/// ArgbOpacity helper behind the Vision overlay opacity sliders.
/// ArgbOpacity helper behind the Vision overlay opacity sliders; the portal names' classification and settings;
/// the debuff icon sizes and the debuff row's lengths (DebuffRowMetrics).
/// </summary>
internal static class Program
{
@ -38,6 +39,23 @@ namespace PlateSizingTests
OpacityRoundTripsEveryAlpha();
OpacitySetKeepsRgb();
PortalsClassifyFromItemType();
PortalNamesDefaultOn();
PortalNamesOldFileLoadsOn();
PortalNamesRoundTrip();
PortalDistanceClamps();
PortalNamesFollowAllAndReset();
DebuffIconSizesDefault100();
DebuffIconSizesOldFileLoads100();
DebuffIconSizesClamp();
DebuffIconSizesRoundTripApart();
DebuffIconSizesReset();
DebuffIconSizeChatForm();
DebuffRowAt100IsTheOldRow();
DebuffRowScalesWithTheSetting();
DebuffRowWidthAndCover();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL PLATE SIZING TESTS PASSED." : $"{_failed} FAILED.");
@ -212,6 +230,357 @@ namespace PlateSizingTests
Check(ArgbOpacity.WithPercent(0x80FFD000, float.NaN) == 0x00FFD000, "NaN is 0");
}
// ── portal names (2026-10-28) ───────────────────────────────────────
private static void PortalsClassifyFromItemType()
{
Case("classification: ITEM_TYPE portal is a portal, a creature bit wins, everything else gets nothing");
Check(PlateClass.FromItemType(0x10000) == PlateClass.Portal, "TYPE_PORTAL (0x10000) -> portal");
Check(PlateClass.FromItemType(PlateClass.TypePortal) == PlateClass.Portal, "PlateClass.TypePortal -> portal");
Check(PlateClass.TypePortal == 0x10000u && PlateClass.TypeCreature == 0x10u, "the AC ITEM_TYPE values");
Check(PlateClass.FromItemType(0x10) == PlateClass.Creature, "TYPE_CREATURE (0x10) -> creature (its PWD decides the rest)");
Check(PlateClass.FromItemType(0x10010) == PlateClass.Creature, "creature + portal bits -> creature (never loses a monster plate)");
Check(PlateClass.FromItemType(0x10000 | 0x80) == PlateClass.Portal, "portal + another non-creature bit -> portal");
// Weapons, armour, clothing, jewelry, food, money, misc, containers, gems, keys, lifestones, doors (misc)...
uint[] others = { 0, 0x1, 0x2, 0x4, 0x8, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x2000, 0x8000, 0x20000, 0x80000, 0x100000, 0x80000000 };
foreach (uint t in others)
Check(PlateClass.FromItemType(t) == PlateClass.Other, $"type 0x{t:X} -> nothing");
byte[] all = { PlateClass.Unknown, PlateClass.Other, PlateClass.Creature, PlateClass.Vendor, PlateClass.Player,
PlateClass.Pet, PlateClass.CreatureNoPwd, PlateClass.Portal };
Check(all.Distinct().Count() == all.Length, "every class value is distinct (the per-id cache keeps them apart)");
Check(PlateClass.Unknown == 0, "Unknown is 0 (a fresh cache entry means 'not classified yet')");
}
private static void PortalNamesDefaultOn()
{
Case("defaults: Portal names on, 60 yd, inside the slider's range; written to the file");
S.ResetToDefaults();
Check(S.PortalNames, "PortalNames defaults on");
Check(S.PortalMaxDistance == 60f && S.DefaultPortalDistance == 60f, $"distance defaults to 60 (got {S.PortalMaxDistance})");
Check(S.MinPortalDistance <= 60f && 60f <= S.MaxPortalDistanceLimit, "the default is inside [min, max]");
Check(S.MaxPortalLabels > 0, "a positive cap of its own");
string[] lines = Written();
Check(lines.Contains("portalNames=1"), "portalNames=1 written");
Check(lines.Contains("portalDistance=60"), "portalDistance=60 written");
Check(S.Describe().Contains("portal names on (60yd)"), "the status line names it");
}
private static void PortalNamesOldFileLoadsOn()
{
Case("a file from before portal names (no portal keys) loads them on at 60 yd, with its own values");
S.ResetToDefaults();
S.NpcNames = false; S.PlayerNames = true; S.NpcMaxDistance = 45f; S.Scale = 1.2f;
// 2026.10.28.1's file = today's lines without the two new keys.
string[] old = Written().Where(l => !l.StartsWith("portalNames=", StringComparison.Ordinal) &&
!l.StartsWith("portalDistance=", StringComparison.Ordinal)).ToArray();
Check(old.Length == Written().Length - 2, "the old file lacks exactly the two keys");
S.PortalNames = false; S.PortalMaxDistance = 15f;
S.ResetToDefaults(); // the loader starts from the defaults
S.ApplyLines(old);
Check(S.PortalNames, "portal names on after loading the old file");
Check(S.PortalMaxDistance == 60f, "portal distance 60 after loading the old file");
Check(!S.NpcNames && S.PlayerNames && S.NpcMaxDistance == 45f && MathF.Abs(S.Scale - 1.2f) < 0.001f,
"the old file's own values still load");
S.ResetToDefaults();
S.ApplyLines(new[] { "# RynthCore monster nameplates", "enabled=1", "npcNames=0" });
Check(S.PortalNames && S.PortalMaxDistance == 60f, "on after a hand-written file without them (NPC names off there)");
S.ResetToDefaults();
}
private static void PortalNamesRoundTrip()
{
Case("save/load: off and a distance come back; back on too; write -> apply -> write is stable");
S.ResetToDefaults();
S.PortalNames = false; S.PortalMaxDistance = 85f;
string[] lines = Written();
Check(lines.Contains("portalNames=0") && lines.Contains("portalDistance=85"), "portalNames=0, portalDistance=85 written");
S.ResetToDefaults();
S.ApplyLines(lines);
Check(!S.PortalNames, "off after reload");
Check(S.PortalMaxDistance == 85f, $"85 yd after reload (got {S.PortalMaxDistance})");
Check(S.NpcNames && S.NpcMaxDistance == 30f && S.MaxNpcLabels == 15, "NPC names untouched by the portal keys");
Check(lines.SequenceEqual(Written()), "identical text after a reload");
S.PortalNames = true; S.PortalMaxDistance = 12.5f;
S.ApplyLines(Written());
Check(S.PortalNames && MathF.Abs(S.PortalMaxDistance - 12.5f) < 0.001f, "back on, 12.5 yd (one decimal kept)");
Check(S.Describe().Contains("portal names on (12yd)") || S.Describe().Contains("portal names on (13yd)"), "status line shows the distance");
S.ResetToDefaults();
}
private static void PortalDistanceClamps()
{
Case("load: the portal distance clamps to the slider's range, junk is ignored");
S.ResetToDefaults();
S.ApplyLines(new[] { "portalDistance=500" });
Check(S.PortalMaxDistance == S.MaxPortalDistanceLimit, $"500 capped at {S.MaxPortalDistanceLimit}");
S.ApplyLines(new[] { "portalDistance=1" });
Check(S.PortalMaxDistance == S.MinPortalDistance, $"1 floored at {S.MinPortalDistance}");
S.ApplyLines(new[] { "portalDistance=-40" });
Check(S.PortalMaxDistance == S.MinPortalDistance, "negative floored");
S.PortalMaxDistance = 70f;
S.ApplyLines(new[] { "portalDistance=abc", "portalDistance=", "portalNames=yes" });
Check(S.PortalMaxDistance == 70f, "junk and empty values leave the distance alone");
Check(!S.PortalNames, "a value other than 1 is off (as every switch in the file)");
Check(S.MinPortalDistance < S.MaxPortalDistanceLimit && S.MaxPortalDistanceLimit <= S.MaxDistanceLimit,
"a sane range, no further than the monster plates' limit");
S.ResetToDefaults();
}
private static void PortalNamesFollowAllAndReset()
{
Case("all off / all on (/rv plates all) and Reset all include portal names");
S.ResetToDefaults();
S.SetAll(false);
Check(!S.PortalNames && !S.NpcNames && !S.Enabled, "all off turns portal names off with NPC names");
S.SetAll(true);
Check(S.PortalNames && S.NpcNames && S.Enabled, "all on turns them back on");
S.PortalNames = false; S.PortalMaxDistance = 100f;
S.ResetToDefaults();
Check(S.PortalNames && S.PortalMaxDistance == 60f, "Reset all: on, 60 yd");
S.PortalMaxDistance = 100f;
S.ResetSizes();
Check(S.PortalMaxDistance == 100f, "Reset bar and text sizes leaves the portal distance alone");
S.ResetToDefaults();
}
// ── debuff icon sizes (2026-10-28) ──────────────────────────────────
private static (string Key, Func<int> Get, Action<int> Set)[] IconSizes => new (string, Func<int>, Action<int>)[]
{
("monsterDebuffIconSize", () => S.MonsterDebuffIconSize, v => S.MonsterDebuffIconSize = v),
("selfDebuffIconSize", () => S.SelfDebuffIconSize, v => S.SelfDebuffIconSize = v),
};
private static void DebuffIconSizesDefault100()
{
Case("defaults: both debuff icon sizes are 100 % (today's icons), inside 50-200; written to the file");
S.ResetToDefaults();
Check(S.DefaultDebuffIconSize == 100, "the default is 100");
Check(S.MinDebuffIconSize == 50 && S.MaxDebuffIconSize == 200, $"range 50-200 (got {S.MinDebuffIconSize}-{S.MaxDebuffIconSize})");
string[] lines = Written();
foreach (var s in IconSizes)
{
Check(s.Get() == 100, $"{s.Key} defaults to 100 (got {s.Get()})");
Check(lines.Contains(s.Key + "=100"), $"{s.Key}=100 written");
}
Check(S.Describe().Contains("text 1 debuff icons 100%") && S.Describe().EndsWith("debuff icons 100%."),
"the status line names both");
}
private static void DebuffIconSizesOldFileLoads100()
{
Case("a file from 2026.10.28.1 (no icon size keys) loads both at 100, with its own values");
S.ResetToDefaults();
S.MonsterTextSize = 1.5f; S.SelfTextSize = 0.75f; S.Scale = 1.3f; S.SelfDebuffs = false;
string[] old = Written().Where(l => !IconSizes.Any(s => l.StartsWith(s.Key + "=", StringComparison.Ordinal))).ToArray();
Check(old.Length == Written().Length - 2, "the old file lacks exactly the two keys");
foreach (var s in IconSizes) s.Set(170);
S.ResetToDefaults(); // the loader starts from the defaults
S.ApplyLines(old);
foreach (var s in IconSizes) Check(s.Get() == 100, $"{s.Key} is 100 after loading the old file (got {s.Get()})");
Check(S.MonsterTextSize == 1.5f && S.SelfTextSize == 0.75f && MathF.Abs(S.Scale - 1.3f) < 0.001f && !S.SelfDebuffs,
"the old file's own values (text sizes included) still load");
S.ResetToDefaults();
S.ApplyLines(new[] { "# RynthCore monster nameplates", "enabled=1", "monsterTextSize=2", "selfTextSize=2" });
foreach (var s in IconSizes) Check(s.Get() == 100, $"{s.Key} 100 after a hand-written file with big text (text never sets it)");
S.ResetToDefaults();
}
private static void DebuffIconSizesClamp()
{
Case("load: icon sizes clamp to 50-200, junk is ignored");
foreach (var s in IconSizes)
{
S.ResetToDefaults();
S.ApplyLines(new[] { s.Key + "=500" });
Check(s.Get() == 200, $"{s.Key}=500 capped at 200 (got {s.Get()})");
S.ApplyLines(new[] { s.Key + "=10" });
Check(s.Get() == 50, $"{s.Key}=10 floored at 50 (got {s.Get()})");
S.ApplyLines(new[] { s.Key + "=-40" });
Check(s.Get() == 50, $"{s.Key}=-40 floored at 50");
S.ApplyLines(new[] { s.Key + "=200" });
Check(s.Get() == 200, $"{s.Key}=200 kept (the top of the range)");
S.ApplyLines(new[] { s.Key + "=50" });
Check(s.Get() == 50, $"{s.Key}=50 kept (the bottom of the range)");
s.Set(130);
S.ApplyLines(new[] { s.Key + "=abc", s.Key + "=", s.Key + "=1.5", s.Key + "=99999999999" });
Check(s.Get() == 130, $"{s.Key}: junk, empty, a fraction and an overflow leave it alone (got {s.Get()})");
}
S.ResetToDefaults();
}
private static void DebuffIconSizesRoundTripApart()
{
Case("save/load: each icon size comes back on its own, apart from the other and from the text sizes");
foreach (var s in IconSizes)
{
S.ResetToDefaults();
s.Set(165);
string[] lines = Written();
Check(lines.Contains(s.Key + "=165"), $"{s.Key}=165 written");
S.ResetToDefaults();
S.ApplyLines(lines);
Check(s.Get() == 165, $"{s.Key} 165 after reload (got {s.Get()})");
foreach (var o in IconSizes)
if (o.Key != s.Key) Check(o.Get() == 100, $"{o.Key} still 100 when only {s.Key} changed");
Check(S.MonsterTextSize == 1f && S.SelfTextSize == 1f, $"text sizes untouched by {s.Key}");
}
S.ResetToDefaults();
S.MonsterDebuffIconSize = 60; S.SelfDebuffIconSize = 185; S.MonsterTextSize = 1.75f; S.SelfTextSize = 0.6f;
string[] first = Written();
S.ResetToDefaults();
S.ApplyLines(first);
Check(S.MonsterDebuffIconSize == 60 && S.SelfDebuffIconSize == 185, "both together");
Check(MathF.Abs(S.MonsterTextSize - 1.75f) < 0.001f && MathF.Abs(S.SelfTextSize - 0.6f) < 0.001f, "text sizes keep their own values");
Check(first.SequenceEqual(Written()), "write -> apply -> write is stable");
Check(S.Describe().Contains("debuff icons 60%") && S.Describe().Contains("debuff icons 185%"), "the status line shows them");
S.ResetToDefaults();
}
private static void DebuffIconSizesReset()
{
Case("Reset bar, text and icon sizes and Reset all put both back to 100");
S.ResetToDefaults();
foreach (var s in IconSizes) s.Set(150);
S.Scale = 1.4f;
int saves = RynthCore.Engine.UI.UiBackgroundWriter.Enqueued;
S.ResetSizes();
foreach (var s in IconSizes) Check(s.Get() == 100, $"{s.Key} back to 100 (sizes reset)");
Check(MathF.Abs(S.Scale - 1.4f) < 0.001f, "Scale kept");
Check(RynthCore.Engine.UI.UiBackgroundWriter.Enqueued == saves + 1, "one save queued");
foreach (var s in IconSizes) s.Set(70);
S.ResetToDefaults();
foreach (var s in IconSizes) Check(s.Get() == 100, $"{s.Key} back to 100 (reset all)");
S.SetAll(false);
S.SetAll(true);
foreach (var s in IconSizes) Check(s.Get() == 100, $"{s.Key} untouched by all off / on");
S.ResetToDefaults();
}
private static void DebuffIconSizeChatForm()
{
Case("chat: /rv plates [self] debuffs size takes a percent or a factor, clamped; junk refused");
(string Text, int Pct)[] good =
{
("150", 150), ("150%", 150), (" 150 % ", 150), ("1.5", 150), ("1.5x", 150), ("1.25X", 125), ("2", 200),
("100", 100), ("1", 100), ("75", 75), ("0.5", 50), ("500", 200), ("10", 50), ("0", 50), ("-3", 50), ("122.6", 123),
};
foreach (var g in good)
Check(S.TryParseDebuffIconSize(g.Text, out int p) && p == g.Pct,
$"\"{g.Text}\" -> {g.Pct} (got {(S.TryParseDebuffIconSize(g.Text, out int q) ? q.ToString(CultureInfo.InvariantCulture) : "refused")})");
foreach (string bad in new[] { null!, "", " ", "abc", "%", "x", "NaN", "Infinity", "1e999" })
Check(!S.TryParseDebuffIconSize(bad, out _), $"\"{bad}\" refused");
}
// The debuff row's lengths as the plates computed them before the setting (2026.10.28.1).
private static float OldIcon(float k) => MathF.Round(13f * k);
private static float OldRowHeight(float k) => OldIcon(k) + MathF.Round(3f * k) + 3f; // MonsterHud.Measure / PlayerPlate.Measure
private static float OldGap(float k) => MathF.Max(2f, MathF.Round(2f * k));
private static float OldRowWidth(float k, int slots, bool more, float moreTextW)
{
float sz = OldIcon(k), gap = OldGap(k);
float moreW = more ? moreTextW + 4f * k : 0f;
return slots * sz + Math.Max(0, slots - 1) * gap + (more ? gap + moreW : 0f);
}
/// <summary>Plate scales seen in game: Look > Scale x UI scale x the distance shrink and target pop, and a sweep.</summary>
private static IEnumerable<float> Ks()
{
for (int i = 30; i <= 400; i++) yield return i / 100f;
float[] scale = { 0.6f, 0.75f, 0.9f, 1f, 1.1f, 1.3f, 1.5f, 2f };
float[] ui = { 1f, 1.25f, 1.5f, 1.75f, 2f };
float[] dist = { 1f, 0.97f, 0.85f, 0.72f, 1.12f, 0.72f * 1.12f };
foreach (float s in scale)
foreach (float u in ui)
foreach (float d in dist)
{
yield return MathF.Max(0.3f, s * d) * u; // a monster plate
yield return s * u; // your plate
}
}
private static void DebuffRowAt100IsTheOldRow()
{
Case("100 %: every length of the row is the old expression exactly, at every plate scale");
int bad = 0, n = 0;
foreach (float k in Ks())
{
n++;
var r = new DebuffRowMetrics(k, 100);
bool ok = r.Scale == 1f && r.K == k && r.Icon == OldIcon(k) && r.Height == OldRowHeight(k)
&& r.Above == MathF.Round(3f * k) && r.Below == 3f && r.Gap == OldGap(k)
&& r.Glyph == MathF.Round(OldIcon(k) * 0.8f) && r.LineGap == 1f && r.LineH == MathF.Max(1f, MathF.Round(1.5f * k))
&& r.Round == 2f * k && r.DigitDx == 1f && r.DigitDy == 2f
&& r.Height == r.Above + r.Icon + r.Below;
for (int slots = 0; slots <= 6 && ok; slots++)
ok = r.Width(slots, false, 0f) == OldRowWidth(k, slots, false, 0f)
&& r.Width(slots, true, 11.37f) == OldRowWidth(k, slots, true, 11.37f);
foreach (float t in new[] { 7f, 9f, 11f, 14f, 18f })
ok &= r.TextSize(t) == t; // the digit and "+N" keep the plate's own text size
ok &= r.CoverWidth(57f, 300f, 8f * k) == 57f && r.Overhang(300f, 48f) == 0f; // the box is left as it was
if (!ok)
{
bad++;
if (bad <= 5) Console.WriteLine($" k={k:R}: icon {r.Icon} vs {OldIcon(k)}, height {r.Height} vs {OldRowHeight(k)}");
}
}
Check(bad == 0, $"{bad} of {n} scales differ from the old row");
var none = new DebuffRowMetrics(1.3f, 0);
Check(none.Scale == 1f && none.Height == OldRowHeight(1.3f), "a size of 0 (never set) reads as 100");
Check(default(DebuffRowMetrics).Height == 0f, "an empty row (name labels) takes no room");
}
private static void DebuffRowScalesWithTheSetting()
{
Case("the row's height grows with the setting, apart from the text size");
var r1 = new DebuffRowMetrics(1f, 100);
var r2 = new DebuffRowMetrics(1f, 200);
var rh = new DebuffRowMetrics(1f, 50);
Check(r1.Height == 19f, $"100 % at k 1: 3 + 13 + 3 = 19 (got {r1.Height})");
Check(r2.Icon == 26f && r2.Height == 38f, $"200 %: a 26 px icon, 38 px row (got {r2.Icon}, {r2.Height})");
Check(rh.Icon == 6f && rh.Height == 10f, $"50 %: a 6 px icon, 10 px row (got {rh.Icon}, {rh.Height})");
Check(r2.Glyph == 21f && r2.Gap == 4f && r2.LineH == 3f && r2.LineGap == 2f, "200 %: glyph, gap and countdown line scale");
Check(r2.TextSize(9f) == 18f && rh.TextSize(10f) == 5f && r2.TextSize(11f) == 22f, "200 % / 50 %: the digit and \"+N\" text scale");
Check(r2.DigitDx == 2f && r2.DigitDy == 4f, "200 %: the digit's corner offset scales");
Check(r2.LineGap + r2.LineH <= r2.Below + 1f, "200 %: the countdown line fits its room");
foreach (float k in new[] { 0.6f, 1f, 1.25f, 1.5f, 2f, 2.6f })
{
float prevH = 0f, prevIcon = 0f;
bool mono = true;
for (int pct = 50; pct <= 200; pct += 5)
{
var r = new DebuffRowMetrics(k, pct);
mono &= r.Height >= prevH && r.Icon >= prevIcon && r.Height == r.Above + r.Icon + r.Below;
mono &= MathF.Abs(r.Icon - 13f * k * pct / 100f) <= 0.5f; // the icon follows k x the setting
prevH = r.Height; prevIcon = r.Icon;
}
Check(mono, $"k {k}: height and icon never shrink as the setting grows; the icon is 13 x k x %");
Check(new DebuffRowMetrics(k, 200).Height > new DebuffRowMetrics(k, 100).Height &&
new DebuffRowMetrics(k, 100).Height > new DebuffRowMetrics(k, 50).Height, $"k {k}: 50 % < 100 % < 200 %");
}
}
private static void DebuffRowWidthAndCover()
{
Case("an enlarged row wider than the bar grows the plate box; a smaller or default one never does");
const float k = 1f;
var r = new DebuffRowMetrics(k, 200);
float six = r.Width(6, false, 0f); // five icons and the "debuffed by others" marker
Check(six == 6 * 26f + 5 * 4f, $"six 26 px squares, five 4 px gaps (got {six})");
Check(r.Width(5, true, 12f) == 5 * 26f + 4 * 4f + 4f + 12f + 4f * 2f, "with \"+N\": a gap, the text and its room");
float box = 120f; // a monster plate: bar 112 + 8
Check(r.CoverWidth(box, six, 8f * k) == six + 8f, $"the box holds the row (got {r.CoverWidth(box, six, 8f)})");
Check(r.CoverWidth(500f, six, 8f) == 500f, "a box already wider stays");
Check(r.Overhang(six, 96f) == MathF.Ceiling((six - 96f) / 2f), "past your 96 px bars: half the difference each side");
Check(r.Overhang(50f, 96f) == 0f, "a row narrower than the bars reaches past nothing");
var small = new DebuffRowMetrics(k, 75);
Check(small.CoverWidth(box, 999f, 8f) == box && small.Overhang(999f, 10f) == 0f, "75 %: the box is left as it was");
}
// ── harness ─────────────────────────────────────────────────────────
private static void Case(string name)

View file

@ -15,7 +15,7 @@ namespace SelfPlateTests
{
using S = MonsterHudSettings;
/// <summary>Your own plate's look switches, the lock from Follow mode, and the "Debuffs on you" selection.</summary>
/// <summary>Your own plate's look switches, the lock from Follow mode, the "Debuffs on you" selection, and its icon size.</summary>
internal static class Program
{
private static int _checks, _failed;
@ -43,6 +43,11 @@ namespace SelfPlateTests
CategoryZeroStandsAlone();
ShortArraysAndHugeExpiry();
SelfIconSizeSetting();
SelfPlateAt100IsTheOldPlate();
MeasuredHeightIncludesTheScaledRow();
ClampKeepsTheRowOnScreen();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL SELF PLATE TESTS PASSED." : $"{_failed} FAILED.");
@ -325,6 +330,163 @@ namespace SelfPlateTests
Check(c == 2, "an empty destination still counts");
}
// ── Your debuff icon size (2026-10-28) ──────────────────────────────
private static void SelfIconSizeSetting()
{
Case("Your debuff icon size: 100 by default and from an older file, round-trips apart from your text size");
S.ResetToDefaults();
Check(S.SelfDebuffIconSize == 100, $"defaults to 100 (got {S.SelfDebuffIconSize})");
Check(Written().Contains("selfDebuffIconSize=100"), "selfDebuffIconSize=100 written");
S.SelfTextSize = 1.8f; S.SelfNumbers = true;
string[] old = Written().Where(l => !l.StartsWith("selfDebuffIconSize=", StringComparison.Ordinal) &&
!l.StartsWith("monsterDebuffIconSize=", StringComparison.Ordinal)).ToArray();
S.SelfDebuffIconSize = 180;
S.ResetToDefaults();
S.ApplyLines(old);
Check(S.SelfDebuffIconSize == 100, "100 after loading a 2026.10.28.1 file (no key)");
Check(MathF.Abs(S.SelfTextSize - 1.8f) < 0.001f && S.SelfNumbers, "that file's text size still loads (and leaves the icons alone)");
S.SelfDebuffIconSize = 140;
string[] lines = Written();
S.ResetToDefaults();
S.ApplyLines(lines);
Check(S.SelfDebuffIconSize == 140 && S.MonsterDebuffIconSize == 100, "140 comes back; the monster plates' stays 100");
S.ApplyLines(new[] { "selfDebuffIconSize=1000" });
Check(S.SelfDebuffIconSize == S.MaxDebuffIconSize, "clamped to the top");
S.ApplyLines(new[] { "selfDebuffIconSize=1" });
Check(S.SelfDebuffIconSize == S.MinDebuffIconSize, "clamped to the bottom");
S.ResetToDefaults();
}
// Your plate's lengths as PlayerPlate.Measure computed them before the setting (2026.10.28.1).
private readonly record struct OldPlate(float BarW, float BarH, float Gap, float Round, float BlockH, float NameH, float IconsH)
{
public float Height => NameH + BlockH + IconsH;
}
private static OldPlate Old(float k, bool numbers, float bw, float bh, float nameSize, bool icons)
{
float barW = MathF.Round((numbers ? 124f : 96f) * k * bw);
float barH = MathF.Round((numbers ? 15f : 5f) * k * bh);
float gap = MathF.Max(2f, MathF.Round(2f * k));
float round = MathF.Max(1f, 1.5f * k);
float blockH = 3 * barH + 2 * gap;
float nameH = nameSize > 0f ? nameSize + 3f * k : 0f;
float iconSize = MathF.Round(13f * k);
float iconsH = icons ? MathF.Round(3f * k) + iconSize + 3f : 0f;
return new OldPlate(barW, barH, gap, round, blockH, nameH, iconsH);
}
private static IEnumerable<(float K, bool Numbers, float Bw, float Bh, float Name, bool Icons)> Plates()
{
float[] ks = { 0.6f, 0.75f, 1f, 1.1f, 1.25f, 1.3f * 1.25f, 1.5f, 1.75f, 2f, 2f * 1.5f, 0.6f * 1.75f };
float[] bws = { 0.5f, 0.85f, 1f, 1.37f, 2.5f };
float[] bhs = { 0.5f, 1f, 1.6f, 3f };
float[] names = { 0f, 6f, 11f, 13f, 22f };
foreach (float k in ks)
foreach (bool numbers in new[] { false, true })
foreach (float bw in bws)
foreach (float bh in bhs)
foreach (float name in names)
foreach (bool icons in new[] { false, true })
yield return (k, numbers, bw, bh, name, icons);
}
private static void SelfPlateAt100IsTheOldPlate()
{
Case("100 %: your plate's bars, name room, debuff row, measured height and clamp are the old ones exactly");
int bad = 0, n = 0;
float[] xs = { -500f, 0f, 3f, 4f, 37.5f, 900f, 1800f, 1890f, 5000f };
foreach (var c in Plates())
{
n++;
SelfPlateMetrics m = SelfPlateMetrics.Measure(c.K, c.Numbers, c.Bw, c.Bh, c.Name, c.Icons, 100);
OldPlate o = Old(c.K, c.Numbers, c.Bw, c.Bh, c.Name, c.Icons);
bool ok = m.K == c.K && m.BarW == o.BarW && m.BarH == o.BarH && m.Gap == o.Gap && m.Round == o.Round &&
m.BlockH == o.BlockH && m.NameH == o.NameH && m.IconsH == o.IconsH && m.Height == o.Height &&
m.IconsOver == 0f && m.RowTop == o.BlockH + MathF.Round(3f * c.K);
foreach (float x in xs)
{
// The fixed plate's and Keep on screen's clamp before the setting.
float oldLeft = Math.Clamp(x, 4f, MathF.Max(4f, 1920f - o.BarW - 4f));
float oldTop = Math.Clamp(x, 4f + o.NameH, MathF.Max(4f + o.NameH, 1080f - o.BlockH - o.IconsH - 4f));
ok &= m.ClampLeft(x, 1920f) == oldLeft && m.ClampTop(x, 1080f) == oldTop;
}
// Even a row wider than narrow bars reaches past nothing at 100 % (as before).
ok &= m.Row.Overhang(m.Row.Width(5, true, 14f), m.BarW) == 0f;
if (!ok)
{
bad++;
if (bad <= 5) Console.WriteLine($" k={c.K:R} numbers={c.Numbers} bw={c.Bw} bh={c.Bh} name={c.Name} icons={c.Icons}: " +
$"height {m.Height} vs {o.Height}, icons {m.IconsH} vs {o.IconsH}");
}
}
Check(bad == 0, $"{bad} of {n} plates differ from the old plate");
}
private static void MeasuredHeightIncludesTheScaledRow()
{
Case("the measured height is name + bars + the debuff row at its own size; no icon, no row");
foreach (float k in new[] { 0.75f, 1f, 1.5f, 2f })
foreach (bool numbers in new[] { false, true })
{
float prev = 0f;
bool ok = true;
for (int pct = 50; pct <= 200; pct += 10)
{
SelfPlateMetrics m = SelfPlateMetrics.Measure(k, numbers, 1f, 1f, 11f, icons: true, pct);
SelfPlateMetrics none = SelfPlateMetrics.Measure(k, numbers, 1f, 1f, 11f, icons: false, pct);
var row = new DebuffRowMetrics(k, pct);
ok &= m.IconsH == row.Height && m.Row.Height == row.Height;
ok &= m.Height == m.NameH + m.BlockH + row.Height;
ok &= none.IconsH == 0f && none.Height == none.NameH + none.BlockH;
ok &= m.BlockH == none.BlockH && m.NameH == none.NameH && m.BarW == none.BarW; // only the row changes
ok &= m.RowTop == m.BlockH + row.Above;
ok &= m.Height >= prev;
prev = m.Height;
}
Check(ok, $"k {k}, numbers {numbers}: 50-200 % - the row is in the height, grows with the setting, nothing else moves");
}
SelfPlateMetrics h100 = SelfPlateMetrics.Measure(1f, false, 1f, 1f, 0f, true, 100);
SelfPlateMetrics h200 = SelfPlateMetrics.Measure(1f, false, 1f, 1f, 0f, true, 200);
SelfPlateMetrics h50 = SelfPlateMetrics.Measure(1f, false, 1f, 1f, 0f, true, 50);
Check(h100.BlockH == 19f && h100.IconsH == 19f && h100.Height == 38f, $"k 1, 100 %: bars 19 + row 19 (got {h100.BlockH} + {h100.IconsH})");
Check(h200.IconsH == 38f && h200.Height == 57f, $"k 1, 200 %: the row doubles to 38 (got {h200.IconsH})");
Check(h50.IconsH == 10f && h50.Height == 29f, $"k 1, 50 %: a 10 px row (got {h50.IconsH})");
// Your text size never sizes the row: only the name's room follows it.
SelfPlateMetrics bigText = SelfPlateMetrics.Measure(1f, false, 1f, 1f, 22f, true, 100);
Check(bigText.IconsH == h100.IconsH && bigText.Row.Icon == h100.Row.Icon, "a bigger name (text size) leaves the row as it is");
}
private static void ClampKeepsTheRowOnScreen()
{
Case("fixed / keep on screen: the whole plate, an enlarged row included, stays inside the screen");
const float w = 1280f, h = 720f;
bool ok = true;
foreach (int pct in new[] { 50, 75, 100, 125, 150, 200 })
foreach (float k in new[] { 1f, 1.5f, 2f })
foreach (bool name in new[] { false, true })
{
SelfPlateMetrics m = SelfPlateMetrics.Measure(k, false, 0.5f, 1f, name ? 11f : 0f, true, pct);
// Five icons and "+N" under bars half the default width: wider than the bars once enlarged.
float rowW = m.Row.Width(5, true, 12f);
m.IconsOver = m.Row.Overhang(rowW, m.BarW);
if (pct > 100) ok &= m.IconsOver > 0f && m.IconsOver * 2f + m.BarW >= rowW;
else ok &= m.IconsOver == 0f;
foreach (float x in new[] { -9999f, 0f, 400f, 9999f })
{
float left = m.ClampLeft(x, w), top = m.ClampTop(x, h);
ok &= top - m.NameH >= 4f && top + m.BlockH + m.IconsH <= h - 4f; // name above, row under
ok &= left - m.IconsOver >= 4f && left + m.BarW + m.IconsOver <= w - 4f; // the row's ends
}
}
Check(ok, "every size: the name, the bars and the debuff row (and its ends) inside a 1280x720 screen");
SelfPlateMetrics big = SelfPlateMetrics.Measure(1f, false, 1f, 1f, 0f, true, 200);
SelfPlateMetrics def = SelfPlateMetrics.Measure(1f, false, 1f, 1f, 0f, true, 100);
Check(big.ClampTop(9999f, h) == h - 4f - big.BlockH - big.IconsH && big.ClampTop(9999f, h) < def.ClampTop(9999f, h),
"at the bottom edge a bigger row lifts the bars by exactly its extra height");
}
// ── harness ─────────────────────────────────────────────────────────
private static void Case(string name)

View file

@ -10,6 +10,10 @@
src\RynthCore.Engine\ImGui\MonsterHud\SelfDebuffs.cs (+ DebuffIcon.cs) - which spells on you get an icon:
harmful only, cooldowns / expired / never-ending entries dropped, one per category (the last to end),
one icon per kind (count + soonest end), kind order, "+N" overflow, server time to Stopwatch ticks.
src\RynthCore.Engine\ImGui\MonsterHud\PlateMetrics.cs - your plate's lengths (2026-10-28, "Your debuff
icon size"): at 100 % the bars, name room, debuff row, measured height and screen clamp are the old
expressions exactly; at any size the measured height includes the scaled row, the clamp keeps the row
(and an enlarged row's ends) on screen; the setting defaults 100, an older file loads 100, it round-trips.
All compiled in; no game, no engine. No file I/O: the background writer is a stub that never runs its work.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
@ -26,6 +30,7 @@
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\MonsterHudSettings.cs" Link="Engine\MonsterHudSettings.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\DebuffIcon.cs" Link="Engine\DebuffIcon.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\SelfDebuffs.cs" Link="Engine\SelfDebuffs.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\PlateMetrics.cs" Link="Engine\PlateMetrics.cs" />
</ItemGroup>
</Project>

View file

@ -162,7 +162,10 @@ internal static class Program
Check(server.LastContentType?.StartsWith("application/json") == true, "sent as application/json");
Check(server.LastUserAgent == "RynthCore-Launcher", "user agent is the launcher's, nothing more");
Check(!await s.MaybeSendAsync(() => enabled, "2026.10.3.1", plugins, 1, day1.AddHours(1)) && server.Count == 1, "a second check the same day sends nothing");
// Later the same UTC day: halfway to midnight (day1 + 1 h crossed into the next day when the
// tests ran after 23:00 UTC, 2026-10-28).
DateTime laterSameDay = day1 + (day1.Date.AddDays(1) - day1) / 2;
Check(!await s.MaybeSendAsync(() => enabled, "2026.10.3.1", plugins, 1, laterSameDay) && server.Count == 1, "a second check the same day sends nothing");
DateTime day2 = day1.Date.AddDays(1).AddHours(1);
Check(await s.MaybeSendAsync(() => enabled, "2026.10.3.1", plugins, 1, day2) && server.Count == 2, "next day: one more");