From 506afd9e38cad2ab0752734b79ef02da0864db67 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 12:07:13 +0800 Subject: fix(desktop): 键位页键名列统一宽度不叠印 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Controls 页按键名列独立成列(ControlsKeyX/KeyWidth=120/ActionX),controlRowRects 纯函数返回键名与动作矩形,回归测试断言逐行矩形不相交、全部行键名列 x/宽度一致、列宽容纳最长键名 F1/F2/F3;面板上移至 ControlsPanelY 保证 14 行键位加页脚完整落入视口。 --- src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/LivingVillage.Desktop.Tests') diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index c85287f..77d2530 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -218,6 +218,29 @@ type PrototypeTests () = Assert.IsFalse(restoredControl.Paused) Assert.AreEqual(original, restoredControl) + [] + member _.ControlsPageKeyColumnIsUniformAndNeverOverprintsActions () = + let layout = TitleScreen.layout 1280 720 + let rows = MenuState.controlRows + + // Every row: key-name rectangle and action rectangle must be disjoint. + for rowIndex in 0 .. rows.Length - 1 do + let keyRect, actionRect = TitleScreen.controlRowRects layout rowIndex + Assert.IsTrue(TitleScreen.rectsDisjoint keyRect actionRect, sprintf "row %d key overlaps action" rowIndex) + + // The key column is uniform: every row shares the same x and width. + let keyRects = [ 0 .. rows.Length - 1 ] |> List.map (fun index -> TitleScreen.controlRowRects layout index |> fst) + Assert.AreEqual(1, keyRects |> List.map (fun rect -> rect.X) |> List.distinct |> List.length) + Assert.AreEqual(1, keyRects |> List.map (fun rect -> rect.Width) |> List.distinct |> List.length) + + // The key column fits the longest key name (latin glyph: 6px * scale 2 per char). + let longestKey = rows |> List.maxBy (fun row -> row.Keys.Length) + Assert.IsTrue(layout.ControlsKeyWidth >= longestKey.Keys.Length * 12, sprintf "key width %d too small for %s" layout.ControlsKeyWidth longestKey.Keys) + + // The controls panel holds every row plus the footer inside the viewport. + let panelBottom = layout.ControlsPanelY + 60 + rows.Length * layout.ControlsRowHeight + 48 + Assert.IsTrue(panelBottom <= 720, sprintf "controls panel bottom %d overflows" panelBottom) + [] member _.CornerStatusShowsDayMoneyAndEnergyFromRealData () = let world = Sim.initialWorldN 42UL 0 -- cgit v1.2.3