From 7e56eff88474ceb0d4906610fb5a7724f60fab7c Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 15 Jun 2026 14:10:17 +0200 Subject: [PATCH] =?UTF-8?q?refactor(D.2b):=20VitalsController=20review=20f?= =?UTF-8?q?ixes=20=E2=80=94=20cite=20format=20doc=20+=20use=20consts=20in?= =?UTF-8?q?=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix 1: Added a 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 --- src/AcDream.App/UI/Layout/VitalsController.cs | 4 ++++ .../UI/Layout/VitalsBindingTests.cs | 15 +++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/AcDream.App/UI/Layout/VitalsController.cs b/src/AcDream.App/UI/Layout/VitalsController.cs index a455761a..c570fb34 100644 --- a/src/AcDream.App/UI/Layout/VitalsController.cs +++ b/src/AcDream.App/UI/Layout/VitalsController.cs @@ -12,6 +12,10 @@ namespace AcDream.App.UI.Layout; /// The slice sprites + dat font on each are already /// set by during tree construction; this controller /// only binds the dynamic vitals data. Do not touch meter rendering fields here. +/// +/// Element ids confirmed from +/// docs/research/2026-06-15-layoutdesc-format.md §11 +/// (vitals window 0x2100006C dump). /// public static class VitalsController { diff --git a/tests/AcDream.App.Tests/UI/Layout/VitalsBindingTests.cs b/tests/AcDream.App.Tests/UI/Layout/VitalsBindingTests.cs index 8b430265..133d51ca 100644 --- a/tests/AcDream.App.Tests/UI/Layout/VitalsBindingTests.cs +++ b/tests/AcDream.App.Tests/UI/Layout/VitalsBindingTests.cs @@ -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(); 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; }