refactor(D.2b): VitalsController review fixes — cite format doc + use consts in test
Fix 1: Added a <para> to the VitalsController class summary citing docs/research/2026-06-15-layoutdesc-format.md §11 as the source of the three dat element ids, giving a paper trail back to the evidence per the project's cite-in-comments rule. Fix 2: Changed FakeLayout in VitalsBindingTests to accept (uint id, UiElement e) tuples instead of (string idHex, UiElement e), and updated all three call sites to pass VitalsController.Health/.Stamina/.Mana. Tests now follow the constants automatically if they ever change rather than silently passing with stale hex literals. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9d2527d9c8
commit
7e56eff884
2 changed files with 11 additions and 8 deletions
|
|
@ -12,6 +12,10 @@ namespace AcDream.App.UI.Layout;
|
|||
/// <para>The slice sprites + dat font on each <see cref="UiMeter"/> are already
|
||||
/// set by <see cref="DatWidgetFactory"/> during tree construction; this controller
|
||||
/// only binds the dynamic vitals data. Do not touch meter rendering fields here.</para>
|
||||
///
|
||||
/// <para>Element ids confirmed from
|
||||
/// <c>docs/research/2026-06-15-layoutdesc-format.md §11</c>
|
||||
/// (vitals window 0x2100006C dump).</para>
|
||||
/// </summary>
|
||||
public static class VitalsController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class VitalsBindingTests
|
|||
public void Bind_SetsHealthMeterFillFromProvider()
|
||||
{
|
||||
var health = new UiMeter();
|
||||
var layout = FakeLayout(("0x100000E6", health));
|
||||
var layout = FakeLayout((VitalsController.Health, health));
|
||||
float hp = 0.42f;
|
||||
|
||||
VitalsController.Bind(layout,
|
||||
|
|
@ -40,9 +40,9 @@ public class VitalsBindingTests
|
|||
var stamina = new UiMeter();
|
||||
var mana = new UiMeter();
|
||||
var layout = FakeLayout(
|
||||
("0x100000E6", health),
|
||||
("0x100000EC", stamina),
|
||||
("0x100000EE", mana));
|
||||
(VitalsController.Health, health),
|
||||
(VitalsController.Stamina, stamina),
|
||||
(VitalsController.Mana, mana));
|
||||
|
||||
VitalsController.Bind(layout,
|
||||
healthPct: () => 0.25f,
|
||||
|
|
@ -70,7 +70,7 @@ public class VitalsBindingTests
|
|||
{
|
||||
// Only Health is present; Stamina and Mana are absent from the layout.
|
||||
var health = new UiMeter();
|
||||
var layout = FakeLayout(("0x100000E6", health));
|
||||
var layout = FakeLayout((VitalsController.Health, health));
|
||||
|
||||
// Should not throw even though Stamina/Mana are missing.
|
||||
VitalsController.Bind(layout,
|
||||
|
|
@ -87,13 +87,12 @@ public class VitalsBindingTests
|
|||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static ImportedLayout FakeLayout(params (string idHex, UiElement e)[] items)
|
||||
private static ImportedLayout FakeLayout(params (uint id, UiElement e)[] items)
|
||||
{
|
||||
var dict = new Dictionary<uint, UiElement>();
|
||||
var root = new UiPanel();
|
||||
foreach (var (idHex, e) in items)
|
||||
foreach (var (id, e) in items)
|
||||
{
|
||||
uint id = Convert.ToUInt32(idHex, 16);
|
||||
root.AddChild(e);
|
||||
dict[id] = e;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue