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
CreatePlayer cps
| null $ cps^.cpsNumber -> getPlayerNumC
| null $ cps^.cpsName -> getPlayerNameC
| otherwise -> undefined
mainMenuC :: Controller
@ -205,3 +206,11 @@ getPlayerNumC = Controller
promptHandler playerNumPrompt e
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,
homeScorePrompt,
awayScorePrompt,
playerNumPrompt
playerNumPrompt,
playerNamePrompt,
) where
import Control.Monad (when)
@ -126,5 +127,10 @@ playerNumPrompt :: Prompt
playerNumPrompt = numPrompt "Player number: " $
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 pStr s = C.drawString $ pStr ++ s^.inputBuffer