From e959b1df06f29fe6542cc6cbe2f9005f620d5dc9 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 29 Sep 2026 11:18:01 +0800 Subject: p75: HUD 顶部条去整宽深色带(改紧凑半透明药丸) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 一致。 --- .../P75HudStripTests.fs | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/LivingVillage.Desktop.Tests/P75HudStripTests.fs (limited to 'src/LivingVillage.Desktop.Tests/P75HudStripTests.fs') 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 顶部条改为紧凑半透明药丸(去整宽深色带),信息不遮挡、文字可读。 +[] +type P75HudStripTests () = + + let world = Sim.initialWorldN 42UL 4 + let control = SimulationControl.initial + let placed = HudLayout.layout (HudLayout.segments world control) + + [] + member _.TopBandIsRemovedForDayAndNight () = + for mode in [ Day; Night ] do + let palette = HudLayout.palette mode + Assert.AreEqual(0uy, palette.BarTop.A) + Assert.AreEqual(0uy, palette.BarBottom.A) + Assert.AreEqual(0uy, HudLayout.bandAlpha) + + [] + 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(max 1 (pill.Width - 2), hair.Width) + + [] + member _.StripLeavesWhitespaceAndDoesNotOverlapDateCard () = + Assert.IsTrue(placed.Length > 0) + let firstX = placed |> List.head |> fun (x, _, _) -> x + Assert.AreEqual(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, "日历卡不压顶部条") + + [] + 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(x + HudLayout.iconWidth + HudLayout.iconGap, HudLayout.textOrigin x) + Assert.IsFalse(System.String.IsNullOrEmpty segment.Value) -- cgit v1.2.3