summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop/HudLayout.fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Desktop/HudLayout.fs')
-rw-r--r--src/LivingVillage.Desktop/HudLayout.fs56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/HudLayout.fs b/src/LivingVillage.Desktop/HudLayout.fs
index cd06224..4310586 100644
--- a/src/LivingVillage.Desktop/HudLayout.fs
+++ b/src/LivingVillage.Desktop/HudLayout.fs
@@ -260,6 +260,39 @@ module HudLayout =
let size = iconGrid * hotbarIconScale
Rectangle(slot.X + (slot.Width - size) / 2, slot.Y + (slot.Height - size) / 2, size, size)
+ // ---- P76:底部条/槽位药丸化(键位符号 + 图形并排,去大色块)----
+
+ /// 键位符号小片(数字 1..0)尺寸:放在槽位左侧,与图标并排。
+ let hotbarKeyChipWidth = 12
+ let hotbarKeyChipHeight = 12
+
+ /// 槽位内的键位小片矩形(左对齐、垂直居中)。
+ let hotbarKeyChipRect (slot: Rectangle) : Rectangle =
+ Rectangle(slot.X + 3, slot.Y + (slot.Height - hotbarKeyChipHeight) / 2, hotbarKeyChipWidth, hotbarKeyChipHeight)
+
+ /// 槽位内图形矩形(键位小片右侧,与图标并排)。
+ let hotbarIconRectBesideKey (slot: Rectangle) : Rectangle =
+ let size = iconGrid * hotbarIconScale
+ let x = (hotbarKeyChipRect slot).Right + 4
+ Rectangle(x, slot.Y + (slot.Height - size) / 2, size, size)
+
+ /// 底部条顶部 1px 强调发丝线(与 P75 顶部条同语言)。
+ let hotbarBarHairline (bar: Rectangle) : Rectangle = Rectangle(bar.X + 1, bar.Y + 1, max 1 (bar.Width - 2), 1)
+
+ // ---- P76:真实按键 + 动作名图例(纯展示,取自 MenuState.controlRows,不改任何绑定)----
+
+ /// 底部图例:真实存在的按键/动作对(subset of MenuState.controlRows 的顺序)。
+ /// 仅做信息层次展示,不新增/改动任何快捷键;hotbar 的 1-0 选中语义保持不变。
+ let actionLegendKeys : string list = [ "E"; "Q"; "TAB"; "C"; "L"; "F6"; "F7" ]
+
+ let actionLegend (rows: ControlRow list) : ControlRow list =
+ actionLegendKeys
+ |> List.choose (fun key -> rows |> List.tryFind (fun row -> row.Keys = key))
+
+ /// 图例单条文本宽度(键位 + 空格 + 动作名)。
+ let legendEntryWidth (row: ControlRow) : int =
+ FloatingPrompt.measureWidth (sprintf "%s %s" row.Keys row.Action) textScale
+
/// 10 个原创 7x7 点阵占位图标(0..9),仅用现有像素贴图绘制,无外部素材。
let hotbarIconPatterns : string list list =
[ [ "0011100"; "0100010"; "1000001"; "1000001"; "1000001"; "0100010"; "0011100" ]
@@ -290,3 +323,26 @@ module HudLayout =
/// hotbar 输入仅在「游戏内(非菜单)」且世界输入允许(无面板/对话)时生效。
let hotbarInputAllowed (menuPlaying: bool) (worldInputAllowed: bool) : bool =
menuPlaying && worldInputAllowed
+
+ // ---- P76:面板文本按实测像素宽度折行(换行而非整行截断,中文逐字、拉丁逐字)----
+
+ let wrapText (maxWidth: int) (scale: int) (text: string) : string list =
+ if text = "" then
+ [ "" ]
+ else
+ let builder = System.Text.StringBuilder()
+ let mutable lines = []
+ for ch in text.ToCharArray() do
+ let candidate = builder.ToString() + string ch
+ if builder.Length > 0 && FloatingPrompt.measureWidth candidate scale > maxWidth then
+ lines <- builder.ToString() :: lines
+ builder.Clear() |> ignore
+ builder.Append(ch) |> ignore
+ else
+ builder.Append(ch) |> ignore
+ lines <- builder.ToString() :: lines
+ List.rev lines
+
+ /// 把多行按宽度折行后铺平(不丢字符、不截断)。
+ let wrapLines (maxWidth: int) (scale: int) (lines: string list) : string list =
+ lines |> List.collect (wrapText maxWidth scale)