summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop/MenuState.fs
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 23:03:16 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 23:03:16 +0800
commit6ce29c5e87d32e49dfe92b398fe45ef0b9de6cdf (patch)
tree859a902d27e069e0e087579b6ea38dec76dc4bf3 /src/LivingVillage.Desktop/MenuState.fs
parent11a2a1d8786a660d0f370a46f5ee0c69c108f823 (diff)
parent50875bb65cc4cdba92f6745d2430a92d85474872 (diff)
downloadliving-village-6ce29c5e87d32e49dfe92b398fe45ef0b9de6cdf.tar.gz
merge: P15 职业玩法收口——开局职业选择/货郎书生模板/CJK补字/全链路回归(独立复验全绿)
Diffstat (limited to 'src/LivingVillage.Desktop/MenuState.fs')
-rw-r--r--src/LivingVillage.Desktop/MenuState.fs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/MenuState.fs b/src/LivingVillage.Desktop/MenuState.fs
index 2848e22..619ac58 100644
--- a/src/LivingVillage.Desktop/MenuState.fs
+++ b/src/LivingVillage.Desktop/MenuState.fs
@@ -4,6 +4,7 @@ open LivingVillage.Kernel
type MenuPage =
| MainMenu
+ | OccupationSelect
| Settings
| Controls
| Playing
@@ -33,6 +34,7 @@ type MenuCommand =
| NoCommand
| ContinueGame
| StartNewGame
+ | StartNewGameWith of Occupation.Kind option
| LoadGame
| ApplySettings of SimulationControl
| ExitGame
@@ -100,9 +102,26 @@ module MenuState =
| ControlsItem -> "操作说明"
| ExitItem -> "退出"
+ /// 开局四选一 + 「暂不选择」(None = 旧行为,无职业)。
+ let occupationOptions : Occupation.Kind option list =
+ [ Some Occupation.Farmer
+ Some Occupation.Fisher
+ Some Occupation.Peddler
+ Some Occupation.Scholar
+ None ]
+
+ let occupationLabel (occupation: Occupation.Kind option) : string =
+ match occupation with
+ | Some kind -> Occupation.nameOf kind
+ | None -> "暂不选择"
+
+ let selectedOccupation (state: MenuState) : Occupation.Kind option =
+ occupationOptions |> List.item state.Selected
+
let private optionsFor (state: MenuState) : int =
match state.Page with
| MainMenu -> items state |> List.length
+ | OccupationSelect -> occupationOptions.Length
| Settings -> settings.Length
| _ -> 0
@@ -150,6 +169,14 @@ module MenuState =
let openSettings (state: MenuState) : MenuState =
{ state with Page = Settings; Selected = 0; ReturnPage = state.Page; Error = None }
+ /// 新档确认后进入职业选择页;默认选中「暂不选择」= 不写职业的旧行为。
+ let openOccupationSelect (state: MenuState) : MenuState =
+ { state with
+ Page = OccupationSelect
+ Selected = occupationOptions.Length - 1
+ ReturnPage = state.Page
+ Error = None }
+
let openControls (state: MenuState) : MenuState =
{ state with Page = Controls; Selected = 0; ReturnPage = state.Page; Error = None }
@@ -187,6 +214,7 @@ module MenuState =
| Back ->
match state.Page with
| MainMenu -> state, ExitGame
+ | OccupationSelect -> openMain state, NoCommand
| Settings
| Controls -> returnFromSubpage state, NoCommand
| LoadError -> openMain state, NoCommand
@@ -194,6 +222,7 @@ module MenuState =
| Confirm ->
match state.Page with
| MainMenu -> confirmMain state
+ | OccupationSelect -> state, StartNewGameWith (selectedOccupation state)
| Settings ->
let nextSettings = selectedControl state
{ state with Settings = nextSettings }, ApplySettings nextSettings