diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-21 12:05:26 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-21 12:05:26 +0800 |
| commit | 2851a030db0f0bc5892305fb189a41c97c13578d (patch) | |
| tree | dbb834c31ad43777fd43f39c00f58449cb753388 /src/LivingVillage.Desktop/TitleScreen.fs | |
| parent | 3812e78ba39764b3844d52ee7382b1350960ecb9 (diff) | |
| download | living-village-2851a030db0f0bc5892305fb189a41c97c13578d.tar.gz | |
fix(desktop): 标题菜单光标与文字分列不再叠印
根因:页面标题行(panelY+24)与首行内容(MenuTopY)同为 y=320 造成两串文字叠印。修复:TitleScreen 布局新增 HeadingY/FirstItemY 分层与独立光标列(CursorX/CursorWidth/TextX),selectionRects 纯函数返回光标与文字矩形,回归测试断言逐行矩形不相交且标题行净空≥32px;渲染改为光标、文字分别绘制。
Diffstat (limited to 'src/LivingVillage.Desktop/TitleScreen.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/TitleScreen.fs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/LivingVillage.Desktop/TitleScreen.fs b/src/LivingVillage.Desktop/TitleScreen.fs index 8b1c5d5..00cf5b8 100644 --- a/src/LivingVillage.Desktop/TitleScreen.fs +++ b/src/LivingVillage.Desktop/TitleScreen.fs @@ -24,7 +24,31 @@ module TitleScreen = PanelX: int PanelY: int PanelWidth: int - PanelHeight: int } + PanelHeight: int + HeadingY: int + FirstItemY: int + CursorX: int + CursorWidth: int + TextX: int } + + type TextRect = + { X: int + Y: int + Width: int + Height: int } + + let rectsDisjoint (a: TextRect) (b: TextRect) : bool = + a.X + a.Width <= b.X + || b.X + b.Width <= a.X + || a.Y + a.Height <= b.Y + || b.Y + b.Height <= a.Y + + /// Cursor and label rectangles for one menu row. The cursor is drawn in its own + /// column; the label always starts to the right of it, so they can never overprint. + let selectionRects (layout: TitleLayout) (rowIndex: int) : TextRect * TextRect = + let y = layout.FirstItemY + rowIndex * layout.MenuLineHeight + { X = layout.CursorX; Y = y; Width = layout.CursorWidth; Height = 16 }, + { X = layout.TextX; Y = y; Width = layout.PanelX + layout.PanelWidth - layout.TextX - 24; Height = 16 } // Palette mirrors the VillageArt atlas: roof (45,49,57)/(30,33,38), water (54,116,145), // lantern paper (212,92,74). Purely decorative reuse of existing art colors. @@ -82,4 +106,9 @@ module TitleScreen = PanelX = (width - panelWidth) / 2 PanelY = height / 2 - 64 PanelWidth = panelWidth - PanelHeight = min 360 (height - height / 2 - 40) } + PanelHeight = min 360 (height - height / 2 - 40) + HeadingY = height / 2 - 64 + 20 + FirstItemY = height / 2 - 64 + 60 + CursorX = (width - panelWidth) / 2 + 24 + CursorWidth = 20 + TextX = (width - panelWidth) / 2 + 24 + 20 + 12 } |
