diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-29 11:18:01 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-29 11:18:01 +0800 |
| commit | e959b1df06f29fe6542cc6cbe2f9005f620d5dc9 (patch) | |
| tree | 92e5842f16d86861494508ee642dbf5bedd85d9c /src/LivingVillage.Desktop.Tests/P75HudStripTests.fs | |
| parent | 016471d580d1c41babc3e04e3b49b31c007e5562 (diff) | |
| download | living-village-e959b1df06f29fe6542cc6cbe2f9005f620d5dc9.tar.gz | |
p75: HUD 顶部条去整宽深色带(改紧凑半透明药丸)
HudLayout:BarTop/BarBottom alpha=0,新增 pillHairline 1px 发丝线与 pillHeight;DrawHudBar 不再铺整条底色与整宽 accent,改画每段半透明药丸+发丝线,图标+数值并排、右侧留白充足。布局/语义/快捷键不变,HUD 结构仅视觉层次。新增 P75HudStripTests(4 例);LV_P43_SHOT 同机位昼/夜证据 + analyze-p75(顶部条近黑 2.6% vs 整宽带 100%、无实心黑块、亮字仍在,verdict=PASS)。Desktop 354/354、Kernel 120/120、digest 与 p70 一致。
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/P75HudStripTests.fs')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/P75HudStripTests.fs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/P75HudStripTests.fs b/src/LivingVillage.Desktop.Tests/P75HudStripTests.fs new file mode 100644 index 0000000..e80d91f --- /dev/null +++ b/src/LivingVillage.Desktop.Tests/P75HudStripTests.fs @@ -0,0 +1,59 @@ +namespace LivingVillage.Desktop.Tests + +open Microsoft.VisualStudio.TestTools.UnitTesting +open LivingVillage.Desktop +open LivingVillage.Kernel +open LivingVillage.Kernel.Sim + +/// P75 回归:HUD 顶部条改为紧凑半透明药丸(去整宽深色带),信息不遮挡、文字可读。 +[<TestClass>] +type P75HudStripTests () = + + let world = Sim.initialWorldN 42UL 4 + let control = SimulationControl.initial + let placed = HudLayout.layout (HudLayout.segments world control) + + [<TestMethod>] + member _.TopBandIsRemovedForDayAndNight () = + for mode in [ Day; Night ] do + let palette = HudLayout.palette mode + Assert.AreEqual<byte>(0uy, palette.BarTop.A) + Assert.AreEqual<byte>(0uy, palette.BarBottom.A) + Assert.AreEqual<byte>(0uy, HudLayout.bandAlpha) + + [<TestMethod>] + member _.PillsAreCompactInsideTheStrip () = + Assert.IsTrue(HudLayout.pillHeight < HudLayout.barHeight, "药丸须比窄条矮,留出上下留白") + for (x, width, _) in placed do + let pill = HudLayout.segmentBackdrop x width + Assert.IsTrue(pill.Y >= 0 && pill.Y + pill.Height <= HudLayout.barHeight, "药丸须在窄条内") + let hair = HudLayout.pillHairline x width + Assert.IsTrue(hair.Height = 1, "发丝线为 1px") + Assert.IsTrue(hair.X >= pill.X && hair.X + hair.Width <= pill.X + pill.Width, "发丝线须在药丸内") + Assert.AreEqual<int>(max 1 (pill.Width - 2), hair.Width) + + [<TestMethod>] + member _.StripLeavesWhitespaceAndDoesNotOverlapDateCard () = + Assert.IsTrue(placed.Length > 0) + let firstX = placed |> List.head |> fun (x, _, _) -> x + Assert.AreEqual<int>(HudLayout.paddingX, firstX) + let lastEnd = placed |> List.last |> fun (x, width, _) -> x + width + // 药丸总跨度远小于通栏宽度,右侧留白充足(不再铺满整宽)。 + Assert.IsTrue(lastEnd < 1280 / 2, sprintf "HUD 只占左半,右侧留白;lastEnd=%d" lastEnd) + let reading = HudLayout.calendarReading world.Tick + let cal = HudLayout.calendarCardRect 1280 reading + Assert.IsTrue(cal.Y >= HudLayout.barHeight + HudLayout.accentHeight, "日历卡不压顶部条") + + [<TestMethod>] + member _.TextStaysReadableOnTranslucentPills () = + for mode in [ Day; Night ] do + let palette = HudLayout.palette mode + Assert.IsTrue(palette.SegmentBackdrop.A > 0uy && palette.SegmentBackdrop.A < 255uy, "药丸半透明") + let valueLuma = int palette.Value.R + int palette.Value.G + int palette.Value.B + let outlineLuma = int palette.Outline.R + int palette.Outline.G + int palette.Outline.B + Assert.IsTrue(valueLuma > 600, "数值色须够亮") + Assert.IsTrue(valueLuma > outlineLuma + 400, "亮字 vs 深描边对比须足够") + // 图标与数值并排:文本起始在图标右侧。 + for (x, _, segment) in placed do + Assert.AreEqual<int>(x + HudLayout.iconWidth + HudLayout.iconGap, HudLayout.textOrigin x) + Assert.IsFalse(System.String.IsNullOrEmpty segment.Value) |
