prompt for player name

This commit is contained in:
Jonathan Lamothe 2019-09-09 22:50:44 -04:00
parent 754b3dd25c
commit 57ac90038a
2 changed files with 16 additions and 1 deletions

View File

@ -55,6 +55,7 @@ dispatch s = case s^.progMode of
| otherwise -> reportC | otherwise -> reportC
CreatePlayer cps CreatePlayer cps
| null $ cps^.cpsNumber -> getPlayerNumC | null $ cps^.cpsNumber -> getPlayerNumC
| null $ cps^.cpsName -> getPlayerNameC
| otherwise -> undefined | otherwise -> undefined
mainMenuC :: Controller mainMenuC :: Controller
@ -205,3 +206,11 @@ getPlayerNumC = Controller
promptHandler playerNumPrompt e promptHandler playerNumPrompt e
return True return True
} }
getPlayerNameC :: Controller
getPlayerNameC = Controller
{ drawController = drawPrompt playerNamePrompt
, handleController = \e -> do
promptHandler playerNamePrompt e
return True
}

View File

@ -31,7 +31,8 @@ module Mtlstats.Prompt (
otherTeamPrompt, otherTeamPrompt,
homeScorePrompt, homeScorePrompt,
awayScorePrompt, awayScorePrompt,
playerNumPrompt playerNumPrompt,
playerNamePrompt,
) where ) where
import Control.Monad (when) import Control.Monad (when)
@ -126,5 +127,10 @@ playerNumPrompt :: Prompt
playerNumPrompt = numPrompt "Player number: " $ playerNumPrompt = numPrompt "Player number: " $
modify . (progMode.createPlayerStateL.cpsNumber ?~) modify . (progMode.createPlayerStateL.cpsNumber ?~)
-- | Prompts for a new player's name
playerNamePrompt :: Prompt
playerNamePrompt = strPrompt "Player name: " $
modify . (progMode.createPlayerStateL.cpsName .~)
drawSimplePrompt :: String -> ProgState -> C.Update () drawSimplePrompt :: String -> ProgState -> C.Update ()
drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer