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

@ -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");