diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index e255301..68258e5 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -54,7 +54,9 @@ import Mtlstats.Util -- | Starts a new season startNewSeason :: ProgState -> ProgState -startNewSeason = (progMode .~ NewSeason) . (database . dbGames .~ 0) +startNewSeason + = (progMode .~ NewSeason False) + . (database.dbGames .~ 0) -- | Resets all players year-to-date stats resetYtd :: ProgState -> ProgState diff --git a/src/Mtlstats/Control.hs b/src/Mtlstats/Control.hs index ae5bb71..fa013cb 100644 --- a/src/Mtlstats/Control.hs +++ b/src/Mtlstats/Control.hs @@ -41,10 +41,10 @@ import Mtlstats.Types -- run dispatch :: ProgState -> Controller dispatch s = case s^.progMode of - MainMenu -> mainMenuC - NewSeason -> newSeasonC - NewGame gs -> newGameC gs - EditMenu -> editMenuC + MainMenu -> mainMenuC + NewSeason flag -> newSeasonC flag + NewGame gs -> newGameC gs + EditMenu -> editMenuC CreatePlayer cps | null $ cps^.cpsNumber -> getPlayerNumC | null $ cps^.cpsName -> getPlayerNameC @@ -63,13 +63,9 @@ mainMenuC = Controller , handleController = menuHandler mainMenu } -newSeasonC :: Controller -newSeasonC = Controller - { drawController = const $ drawMenu newSeasonMenu - , handleController = \e -> do - menuHandler newSeasonMenu e - return True - } +newSeasonC :: Bool -> Controller +newSeasonC False = promptController newSeasonPrompt +newSeasonC True = menuController newSeasonMenu editMenuC :: Controller editMenuC = menuController editMenu diff --git a/src/Mtlstats/Prompt.hs b/src/Mtlstats/Prompt.hs index daf2f01..298cac7 100644 --- a/src/Mtlstats/Prompt.hs +++ b/src/Mtlstats/Prompt.hs @@ -34,6 +34,7 @@ module Mtlstats.Prompt ( numPromptWithFallback, selectPrompt, -- * Individual prompts + newSeasonPrompt, playerNumPrompt, playerNamePrompt, playerPosPrompt, @@ -167,6 +168,11 @@ numPromptWithFallback pStr fallback act = Prompt , promptSpecialKey = const $ return () } +-- | Prompts the user for a filename to save a backup of the database +-- to +newSeasonPrompt :: Prompt +newSeasonPrompt = undefined + -- | Builds a selection prompt selectPrompt :: SelectParams a -> Prompt selectPrompt params = Prompt diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index e020b09..9f0fd41 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -232,7 +232,7 @@ data ProgState = ProgState -- | The program mode data ProgMode = MainMenu - | NewSeason + | NewSeason Bool | NewGame GameState | EditMenu | CreatePlayer CreatePlayerState @@ -242,7 +242,7 @@ data ProgMode instance Show ProgMode where show MainMenu = "MainMenu" - show NewSeason = "NewSeason" + show (NewSeason _) = "NewSeason" show (NewGame _) = "NewGame" show EditMenu = "EditMenu" show (CreatePlayer _) = "CreatePlayer"