From d7879a92af1f0382328ca9f9dcac71fec2a3d38e Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 18 Nov 2019 22:11:17 -0500 Subject: [PATCH] broke YTD and lifetime menus off from player edit menu --- src/Mtlstats/Control/EditPlayer.hs | 4 +-- src/Mtlstats/Menu/EditPlayer.hs | 48 +++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/Mtlstats/Control/EditPlayer.hs b/src/Mtlstats/Control/EditPlayer.hs index 598f738..1aeb464 100644 --- a/src/Mtlstats/Control/EditPlayer.hs +++ b/src/Mtlstats/Control/EditPlayer.hs @@ -67,10 +67,10 @@ positionC :: Controller positionC = promptController editPlayerPosPrompt ytdC :: Controller -ytdC = undefined +ytdC = menuControllerWith header editPlayerYtdMenu lifetimeC :: Controller -lifetimeC = undefined +lifetimeC = menuControllerWith header editPlayerLtMenu ytdGoalsC :: Controller ytdGoalsC = promptController editPlayerYtdGoalsPrompt diff --git a/src/Mtlstats/Menu/EditPlayer.hs b/src/Mtlstats/Menu/EditPlayer.hs index f08478e..8167f88 100644 --- a/src/Mtlstats/Menu/EditPlayer.hs +++ b/src/Mtlstats/Menu/EditPlayer.hs @@ -21,6 +21,8 @@ along with this program. If not, see . module Mtlstats.Menu.EditPlayer ( editPlayerMenu + , editPlayerYtdMenu + , editPlayerLtMenu ) where import Control.Monad.Trans.State (modify) @@ -29,20 +31,44 @@ import Lens.Micro ((.~)) import Mtlstats.Types import Mtlstats.Types.Menu --- | The player edit menu +-- | The 'Player' edit menu editPlayerMenu :: Menu () editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map (\(ch, label, mode) -> MenuItem ch label $ case mode of Nothing -> modify $ progMode .~ MainMenu Just m -> modify $ progMode.editPlayerStateL.epsMode .~ m) - [ ( '1', "Change number", Just EPNumber ) - , ( '2', "Change name", Just EPName ) - , ( '3', "Change position", Just EPPosition ) - , ( '4', "YTD goals", Just EPYtdGoals ) - , ( '5', "YTD assists", Just EPYtdAssists ) - , ( '6', "YTD penalty mins", Just EPYtdPMin ) - , ( '7', "Lifetime goals", Just EPLtGoals ) - , ( '8', "Lifetime assists", Just EPLtAssists ) - , ( '9', "Lifetime penalty mins", Just EPLtPMin ) - , ( '0', "Finished editing", Nothing ) + -- key, label, value + [ ( '1', "Edit number", Just EPNumber ) + , ( '2', "Edit name", Just EPName ) + , ( '3', "Edit position", Just EPPosition ) + , ( '4', "Edit YTD stats", Just EPYtd ) + , ( '5', "Edit lifetime stats", Just EPLifetime ) + , ( 'R', "Finished editing", Nothing ) ] + +-- | The 'Player' YTD stats edit menu +editPlayerYtdMenu :: Menu () +editPlayerYtdMenu = editMenu + "*** EDIT PLAYER YEAR-TO-DATE ***" + -- key, label, value + [ ( '1', "Edit YTD goals", EPYtdGoals ) + , ( '2', "Edit YTD assists", EPYtdAssists ) + , ( '3', "Edit YTD penalty mins", EPYtdPMin ) + , ( 'R', "Return to player edit menu", EPMenu ) + ] + +-- | The 'Player' lifetime stats edit menu +editPlayerLtMenu :: Menu () +editPlayerLtMenu = editMenu + "*** EDIT PLAYER LIFETIME ***" + -- key, label, value + [ ( '1', "Edit lifetime goals", EPLtGoals ) + , ( '2', "Edit lifetime assits", EPLtAssists ) + , ( '3', "Edit lifetime penalty mins", EPLtPMin ) + , ( 'R', "Return to edit player menu", EPMenu ) + ] + +editMenu :: String -> [(Char, String, EditPlayerMode)] -> Menu () +editMenu title = Menu title () . map + (\(key, label, val) -> MenuItem key label $ + modify $ progMode.editPlayerStateL.epsMode .~ val)