move to forgejo
Some checks are pending
build / Build (push) Waiting to run

This commit is contained in:
sherlock 2025-03-13 12:21:05 +05:30
parent f074add7a3
commit 725b7bdf94
2 changed files with 17 additions and 7 deletions

View file

@ -61,7 +61,10 @@ app = App
, appAttrMap = const theMap
}
playGame :: Int -> Maybe String -> Bool -> IO Game
playGame :: Int -- ^ Starting level
-> Maybe String -- ^ Preview cell (Nothing == no preview)
-> Bool -- ^ Enable level progression
-> IO Game
playGame lvl mp prog = do
chan <- newBChan 10
tv <- newTVarIO lvl
@ -218,10 +221,10 @@ drawStats g =
drawProgression :: Bool -> Widget Name
drawProgression True =
padLeftRight 1 $ str "Level Mode: " <+>
withAttr progressionAttr (str "ON")
withAttr progressionAttr (padLeft Max $ str "ON")
drawProgression False =
padLeftRight 1 $ str "Level Mode: " <+>
withAttr fixedAttr (str "OFF")
withAttr fixedAttr (padLeft Max $ str "Fixed")
drawStat :: String -> Int -> Widget Name
drawStat s n = padLeftRight 1 $ str s <+> padLeft Max (str $ show n)

View file

@ -59,11 +59,14 @@ ui ps =
else vBox
[ str "Level Progression?"
, str ""
, drawOption "YES" YesOption (selectedOption ps)
, drawOption "NO" NoOption (selectedOption ps)
, C.hCenter $ drawOption "YES" YesOption (selectedOption ps)
, C.hCenter $ drawOption "NO" NoOption (selectedOption ps)
, str ""
, str "Use ↑↓ to select"
, str "Press Enter to continue"
, C.hCenter $ str "Use ↑↓ or j/k"
, C.hCenter $ str "to Select."
, str ""
, C.hCenter $ str "Press Enter"
, C.hCenter $ str "to Continue."
]
]
@ -91,6 +94,10 @@ handleEvent (VtyEvent (V.EvKey V.KUp [])) =
whenNotPickingLevel $ modify $ \s -> s { selectedOption = YesOption }
handleEvent (VtyEvent (V.EvKey V.KDown [])) =
whenNotPickingLevel $ modify $ \s -> s { selectedOption = NoOption }
handleEvent (VtyEvent (V.EvKey (V.KChar 'j') [])) =
whenNotPickingLevel $ modify $ \s -> s { selectedOption = YesOption }
handleEvent (VtyEvent (V.EvKey (V.KChar 'k') [])) =
whenNotPickingLevel $ modify $ \s -> s { selectedOption = NoOption }
handleEvent _ = pure ()
whenPickingLevel :: EventM () PickState () -> EventM () PickState ()