summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests/P77LayoutTests.fs
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-29 15:44:35 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-29 15:44:35 +0800
commitdce50b835235a103af1d8e6ec836fe12d841f135 (patch)
tree820d2a5f8a092e66e31b5ca06527302dd81735ed /src/LivingVillage.Desktop.Tests/P77LayoutTests.fs
parent21b03c043466c3cbce1d71ff055c9d71631b6073 (diff)
downloadliving-village-dce50b835235a103af1d8e6ec836fe12d841f135.tar.gz
p77: 日历卡/浮动提示药丸化并修复面板遮挡快捷栏
- DrawCalendarCard 改半透明底+1px 描边+accent 发丝线,日历卡微缩(52→48) - FloatingPrompt 新增 layoutWrapped/wrapText,锚定长文本逐字折行(不丢字、居中锚点、避让 HUD 带) - 新增 HudLayout.panelRect,DrawPanel 用其几何;DialogOverlay.bottomMargin 24→72 1280x720 下对话 rect 底 648、任务面板底 652,均 < hotbar 顶 660,不再压 3-8 号槽 - 新增 P77LayoutTests(4 尺寸不破版/不遮挡 + 真实长提示折行) - 证据 LV_P43/P44/P67_SHOT + scripts/analyze-p77.py(verdict PASS) 落 docs/evidence/p77-* - Desktop 361/361, Kernel 120/120, digest 953775FA...F7F6C 不变
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/P77LayoutTests.fs')
-rw-r--r--src/LivingVillage.Desktop.Tests/P77LayoutTests.fs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/P77LayoutTests.fs b/src/LivingVillage.Desktop.Tests/P77LayoutTests.fs
new file mode 100644
index 0000000..df0e94f
--- /dev/null
+++ b/src/LivingVillage.Desktop.Tests/P77LayoutTests.fs
@@ -0,0 +1,54 @@
+namespace LivingVillage.Desktop.Tests
+
+open Microsoft.VisualStudio.TestTools.UnitTesting
+open Microsoft.Xna.Framework
+open LivingVillage.Desktop
+
+/// P77 回归:日历卡/浮动提示药丸化后的多尺寸不破版、面板与 hotbar 不遮挡、锚定长文本折行。
+[<TestClass>]
+type P77LayoutTests () =
+
+ let sizes = [ (1280, 720); (1024, 768); (800, 600); (640, 480) ]
+
+ [<TestMethod>]
+ member _.LayoutsStayInsideEveryViewportAndClearOfHotbar () =
+ for (w, h) in sizes do
+ let bar = HudLayout.hotbarBarRect w h
+ Assert.IsTrue(bar.X >= 0 && bar.Y >= 0 && bar.X + bar.Width <= w && bar.Y + bar.Height <= h,
+ sprintf "hotbar 越界 @%dx%d" w h)
+ let cal = HudLayout.calendarCardRect w (HudLayout.calendarReading 2592000L)
+ Assert.IsTrue(cal.X >= 0 && cal.X + cal.Width <= w && cal.Y >= 0, sprintf "日历卡越界 @%dx%d" w h)
+ let model = DialogOverlay.create "互动:村民 1" [ "1 闲聊"; "2 求助"; "3 交易"; "4 开玩笑"; "ESC 关闭" ] w true
+ let dialog = DialogOverlay.rect w h model
+ Assert.IsTrue(dialog.X >= 0 && dialog.Y >= 0 && dialog.X + dialog.Width <= w && dialog.Y + dialog.Height <= h,
+ sprintf "对话弹层越界 @%dx%d" w h)
+ let panel = HudLayout.panelRect w h 5
+ Assert.IsTrue(panel.X >= 0 && panel.Y >= 0 && panel.X + panel.Width <= w && panel.Y + panel.Height <= h,
+ sprintf "交互面板越界 @%dx%d" w h)
+
+ [<TestMethod>]
+ member _.DialogAndPanelNeverCoverTheHotbar () =
+ // 上单验收问题:互动面板压住 3-8 号格子。标准与常见尺寸下面板/弹层底边须在 hotbar 顶上方。
+ for (w, h) in [ (1280, 720); (1024, 768); (800, 600) ] do
+ let bar = HudLayout.hotbarBarRect w h
+ let panel = HudLayout.panelRect w h 5
+ Assert.IsTrue(panel.Y + panel.Height <= bar.Y, sprintf "交互面板压 hotbar @%dx%d: panelBottom=%d barTop=%d" w h (panel.Y + panel.Height) bar.Y)
+ let model = DialogOverlay.create "互动:村民 1" [ "1 闲聊"; "2 求助"; "3 交易"; "4 开玩笑"; "ESC 关闭" ] w true
+ let dialog = DialogOverlay.rect w h model
+ Assert.IsTrue(dialog.Y + dialog.Height <= bar.Y, sprintf "对话弹层压 hotbar @%dx%d: dialogBottom=%d barTop=%d" w h (dialog.Y + dialog.Height) bar.Y)
+
+ [<TestMethod>]
+ member _.AnchoredLongPromptWrapsWithoutLossAndStaysInBands () =
+ let text = "E 与河边的货郎交谈并查看今日货品是否齐全以及打听附近村里的传闻"
+ let layout = FloatingPrompt.layoutWrapped 1280 720 640.0f 360.0f 0.0f 0.0f 2 text
+ Assert.IsTrue(layout.Lines.Length >= 2, "长锚定文本须折成多行")
+ for line in layout.Lines do
+ Assert.IsTrue(FloatingPrompt.measureWidth line 2 <= FloatingPrompt.maxPromptWidth, sprintf "折行超宽: %s" line)
+ Assert.AreEqual<string>(text, System.String.Concat layout.Lines)
+ Assert.IsTrue(layout.X >= 0 && layout.X + layout.Width <= 1280, "提示不得越界")
+ Assert.IsTrue(layout.Y >= FloatingPrompt.hudTopBarHeight, "提示不得压顶部条")
+ Assert.IsTrue(layout.Y + layout.Height <= 720 - FloatingPrompt.hudBottomBandHeight, "提示不得压底部带")
+ // 短提示仍是单行,且宽度与既有单行版式一致。
+ let short = FloatingPrompt.layoutWrapped 1280 720 640.0f 360.0f 0.0f 0.0f 2 "E 交谈"
+ Assert.AreEqual<int>(1, short.Lines.Length)
+ Assert.AreEqual<int>(FloatingPrompt.measureWidth "E 交谈" 2, short.Width)