From 9b9feefa4f186ee6ad374f4fb95cd60f715cfadd Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 18 Nov 2019 21:52:54 -0500 Subject: [PATCH] broke Mtlstats.Menu.EditPlayer off from Mtlstats.Menu --- src/Mtlstats/Control/EditPlayer.hs | 1 + src/Mtlstats/Menu.hs | 21 +------------ src/Mtlstats/Menu/EditPlayer.hs | 48 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 src/Mtlstats/Menu/EditPlayer.hs diff --git a/src/Mtlstats/Control/EditPlayer.hs b/src/Mtlstats/Control/EditPlayer.hs index 105915d..598f738 100644 --- a/src/Mtlstats/Control/EditPlayer.hs +++ b/src/Mtlstats/Control/EditPlayer.hs @@ -27,6 +27,7 @@ import qualified UI.NCurses as C import Mtlstats.Helpers.Player import Mtlstats.Menu +import Mtlstats.Menu.EditPlayer import Mtlstats.Prompt import Mtlstats.Prompt.EditPlayer import Mtlstats.Types diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index cfad6b8..db404ae 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -30,7 +30,6 @@ module Mtlstats.Menu ( newSeasonMenu, gameMonthMenu, gameTypeMenu, - editPlayerMenu, gameGoalieMenu ) where @@ -40,7 +39,7 @@ import Data.Aeson (encodeFile) import Data.Char (toUpper) import qualified Data.Map as M import Data.Maybe (mapMaybe) -import Lens.Micro ((^.), (.~), (?~)) +import Lens.Micro ((^.), (?~)) import Lens.Micro.Extras (view) import System.EasyFile ( createDirectoryIfMissing @@ -157,24 +156,6 @@ gameTypeMenu = Menu "Game type:" () modify $ progMode.gameStateL.gameType ?~ AwayGame ] --- | 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 ) - ] - -- | Game goalie selection menu gameGoalieMenu :: ProgState -> Menu () gameGoalieMenu s = let diff --git a/src/Mtlstats/Menu/EditPlayer.hs b/src/Mtlstats/Menu/EditPlayer.hs new file mode 100644 index 0000000..f08478e --- /dev/null +++ b/src/Mtlstats/Menu/EditPlayer.hs @@ -0,0 +1,48 @@ +{- | + +mtlstats +Copyright (C) 2019 Rhéal Lamothe + + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +-} + +module Mtlstats.Menu.EditPlayer + ( editPlayerMenu + ) where + +import Control.Monad.Trans.State (modify) +import Lens.Micro ((.~)) + +import Mtlstats.Types +import Mtlstats.Types.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 ) + ]