feat(D.2b): vitals numbers as UiText (widget-generalization Task 8)

The vitals cur/max numbers now render through the generic UiText widget — retail
gmVitalsUI uses UIElement_Text for them, not a meter-internal label. VitalsController
attaches a centered, non-interactive UiText child to each meter and stops the meter
drawing its own label (UiMeter.Label -> null). New UiText.Centered draws the first line
centered H+V with the SAME formula UiMeter's overlay used, so the numbers are
pixel-identical — user-confirmed in the live client.

This completes the D.2b widget-generalization pass: every chat + vitals widget is now
built generically and registered to its retail Type (Button/Field*/Menu/Meter/Scrollbar/
Text), with thin find-by-id controllers. (*Field is controller-placed; Type 3 stays
UiDatElement for chrome.)

Divergence register: AP-37 vitals-numbers-via-UiMeter.Label clause retired. Full suite:
404 passed, 2 skipped, 0 failed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-16 18:52:42 +02:00
parent d7002552bc
commit 89626cd400
4 changed files with 83 additions and 10 deletions

View file

@ -28,7 +28,9 @@ public class VitalsBindingTests
manaText: () => "");
Assert.Equal(0.42f, health.Fill()!.Value);
Assert.Equal("42/100", health.Label());
// The meter no longer draws its own label; the cur/max is a centered UiText child.
Assert.Null(health.Label());
Assert.Equal("42/100", NumberText(health));
}
// ── Test 2: All three meters wired to distinct providers ──────────────────
@ -54,13 +56,13 @@ public class VitalsBindingTests
// Each meter should reflect its own provider, not another's.
Assert.Equal(0.25f, health.Fill()!.Value);
Assert.Equal("25/100", health.Label());
Assert.Equal("25/100", NumberText(health));
Assert.Equal(0.50f, stamina.Fill()!.Value);
Assert.Equal("50/100", stamina.Label());
Assert.Equal("50/100", NumberText(stamina));
Assert.Equal(0.75f, mana.Fill()!.Value);
Assert.Equal("75/100", mana.Label());
Assert.Equal("75/100", NumberText(mana));
}
// ── Test 3: Missing meter ids are silently skipped (no throw) ─────────────
@ -87,6 +89,16 @@ public class VitalsBindingTests
// ── Helpers ───────────────────────────────────────────────────────────────
/// <summary>The cur/max text from the centered <see cref="UiText"/> number that
/// <see cref="VitalsController"/> attaches as the meter's child.</summary>
private static string NumberText(UiMeter m)
{
var num = Assert.IsType<UiText>(m.Children[0]);
Assert.True(num.Centered);
var lines = num.LinesProvider();
return lines.Count > 0 ? lines[0].Text : "";
}
private static ImportedLayout FakeLayout(params (uint id, UiElement e)[] items)
{
var dict = new Dictionary<uint, UiElement>();