diff options
Diffstat (limited to 'src/LivingVillage.Desktop/Game.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/Game.fs | 94 |
1 files changed, 57 insertions, 37 deletions
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs index 8402a72..3bb43f8 100644 --- a/src/LivingVillage.Desktop/Game.fs +++ b/src/LivingVillage.Desktop/Game.fs @@ -864,52 +864,72 @@ type LivingVillageGame() as this = this.DrawM5Overlay() member private this.DrawM5Overlay() = + this.DrawHudBar() + if m5View.Panel = WorldPanel then + this.DrawTransientStatus() + else + this.DrawPanel() + + /// 顶部窄信息条:时段/时间/倍速/体力/钱币,半透明渐变 + 强调线,绝非大黑块。 + member private this.DrawHudBar() = let viewport = this.GraphicsDevice.Viewport - let textScale = 2 - let lineHeight = 18 let profile = M6Presentation.profileAtTick world.Tick - let timeLine = sprintf "时间 %s %s" (M6Presentation.dayNightLabel profile.Mode) (M6Presentation.clockLabel simulationControl) - let persistentLines = - timeLine :: (m5View.Prompt |> Option.toList) - let dialogueLines = - match m5View.Panel, m5View.Menu with - | DialoguePanel, Some menu -> - menu.Options - |> List.mapi (fun index intent -> sprintf "%d %s" (index + 1) (M5Interaction.intentLine intent)) - |> fun options -> [ sprintf "互动:村民 %d" (M5Interaction.menuNpcNumber menu) ] @ options - | _ -> [] + let palette = HudLayout.palette profile.Mode + let placed = HudLayout.layout (HudLayout.segments world simulationControl) + let barHeight = HudLayout.barHeight + let textY = (barHeight - 8 * HudLayout.textScale) / 2 + spriteBatch.Begin() + // 竖向渐变:上半略亮、下半压暗,避免整条纯色。 + spriteBatch.Draw(pixel, Rectangle(0, 0, viewport.Width, barHeight / 2), palette.BarTop) + spriteBatch.Draw(pixel, Rectangle(0, barHeight / 2, viewport.Width, barHeight - barHeight / 2), palette.BarBottom) + spriteBatch.Draw(pixel, Rectangle(0, barHeight, viewport.Width, HudLayout.accentHeight), palette.Accent) + for (x, _, segment) in placed do + PixelText.draw spriteBatch pixel cjkAtlas x textY HudLayout.textScale palette.Label segment.Label + let labelAdvanced = FloatingPrompt.measureWidth (segment.Label + " ") HudLayout.textScale + PixelText.draw spriteBatch pixel cjkAtlas (x + labelAdvanced) textY HudLayout.textScale palette.Value segment.Value + spriteBatch.End() + + /// 常驻情境状态:顶部条下方的小药丸,仅 WorldPanel 且瞬态未过期时出现。 + member private this.DrawTransientStatus() = + let viewport = this.GraphicsDevice.Viewport let statusView = { m5View with StatusTick = Some hudStatusAt } - let statusLine = M5Interaction.transientStatusLine hudClock statusView |> Option.toList - let allLines = persistentLines @ dialogueLines @ statusLine - let cornerLines = M5Interaction.cornerStatusLines world - let panelWidth = min 360 (max 1 (viewport.Width - 32)) - let maxLines = max 1 ((viewport.Height - 48) / lineHeight) - let lines = allLines |> List.truncate maxLines - let panelHeight = lines.Length * lineHeight + 24 + match M5Interaction.transientStatusLine hudClock statusView with + | None -> () + | Some line -> + let scale = 2 + let width = FloatingPrompt.measureWidth line scale + let x = 16 + let y = HudLayout.barHeight + HudLayout.accentHeight + 8 + spriteBatch.Begin() + spriteBatch.Draw(pixel, Rectangle(x - 8, y - 6, width + 16, 8 * scale + 12), Color(16, 26, 32, 200)) + spriteBatch.Draw(pixel, Rectangle(x - 8, y - 6, 2, 8 * scale + 12), Color(92, 180, 190)) + PixelText.draw spriteBatch pixel cjkAtlas x y scale (Color(232, 242, 232)) line + spriteBatch.End() + + /// 打开的面板(对话/需求/观察/年鉴/任务):底部左侧轻量渐变板,沿用既有 panelLines。 + member private this.DrawPanel() = + let viewport = this.GraphicsDevice.Viewport + let textScale = 2 + let lineHeight = 18 + let lines = M5Interaction.panelLines world m5View + let panelWidth = min 380 (max 1 (viewport.Width - 32)) + let maxLines = max 1 ((viewport.Height - HudLayout.barHeight - 48) / lineHeight) + let visibleLines = lines |> List.truncate maxLines + let panelHeight = visibleLines.Length * lineHeight + 26 let panelX = 16 - let panelY = max 16 (viewport.Height - panelHeight - 16) - let panel = Rectangle(panelX, panelY, panelWidth, panelHeight) + let panelY = max (HudLayout.barHeight + 12) (viewport.Height - panelHeight - 16) let innerX = panelX + 12 let innerWidth = max 1 (panelWidth - 24) let maxChars = max 1 (innerWidth / (6 * textScale)) spriteBatch.Begin() - spriteBatch.Draw(pixel, panel, Color(15, 19, 25, 160)) + // 竖向渐变板(半透明,非纯黑),顶部与左侧各一条强调线。 + spriteBatch.Draw(pixel, Rectangle(panelX, panelY, panelWidth, panelHeight / 2), Color(30, 44, 52, 190)) + spriteBatch.Draw(pixel, Rectangle(panelX, panelY + panelHeight / 2, panelWidth, panelHeight - panelHeight / 2), Color(16, 24, 30, 190)) spriteBatch.Draw(pixel, Rectangle(panelX, panelY, panelWidth, 3), Color(92, 180, 190)) - lines - |> List.iteri (fun index line -> - let visible = if line.Length > maxChars then line.Substring(0, maxChars) else line - let color = if index = 0 then Color(220, 235, 220) else Color(190, 205, 210) - PixelText.draw spriteBatch pixel cjkAtlas innerX (panelY + 12 + index * lineHeight) textScale color visible) - - // Minimal top-right status strip: day counter + real money/energy values. - let cornerWidth = 232 - let cornerHeight = List.length cornerLines * lineHeight + 20 - let cornerX = viewport.Width - cornerWidth - 16 - let cornerY = 16 - spriteBatch.Draw(pixel, Rectangle(cornerX, cornerY, cornerWidth, cornerHeight), Color(15, 19, 25, 150)) - spriteBatch.Draw(pixel, Rectangle(cornerX, cornerY, cornerWidth, 3), Color(92, 180, 190)) - cornerLines + spriteBatch.Draw(pixel, Rectangle(panelX, panelY, 2, panelHeight), Color(92, 180, 190, 160)) + visibleLines |> List.iteri (fun index line -> let visible = if line.Length > maxChars then line.Substring(0, maxChars) else line - PixelText.draw spriteBatch pixel cjkAtlas (cornerX + 10) (cornerY + 10 + index * lineHeight) textScale (Color(220, 235, 220)) visible) + let color = if index = 0 then Color(226, 238, 226) else Color(192, 208, 212) + PixelText.draw spriteBatch pixel cjkAtlas innerX (panelY + 13 + index * lineHeight) textScale color visible) spriteBatch.End() |
