refactored handleEvent and draw
This commit is contained in:
parent
a3ccb47128
commit
2c77053bbe
|
@ -19,6 +19,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
-}
|
||||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Mtlstats.Events (handleEvent) where
|
||||
|
||||
import Control.Monad.Trans.State (gets, modify)
|
||||
|
@ -35,11 +37,10 @@ handleEvent
|
|||
:: C.Event
|
||||
-- ^ The event being handled
|
||||
-> Action Bool
|
||||
handleEvent e = do
|
||||
m <- gets $ view progMode
|
||||
case m of
|
||||
MainMenu -> menuHandler mainMenu e
|
||||
NewSeason -> menuHandler newSeasonMenu e >> return True
|
||||
NewGame gs -> if null $ gs ^. gameType
|
||||
then menuHandler gameTypeMenu e >> return True
|
||||
else undefined
|
||||
handleEvent e = gets (view progMode) >>= \case
|
||||
MainMenu -> menuHandler mainMenu e
|
||||
NewSeason -> menuHandler newSeasonMenu e >> return True
|
||||
NewGame gs
|
||||
| null $ gs ^. gameType ->
|
||||
menuHandler gameTypeMenu e >> return True
|
||||
| otherwise -> undefined
|
||||
|
|
|
@ -36,7 +36,7 @@ draw s = do
|
|||
case s ^. progMode of
|
||||
MainMenu -> drawMenu mainMenu
|
||||
NewSeason -> drawMenu newSeasonMenu
|
||||
NewGame gs -> if null $ gs ^. gameType
|
||||
then drawMenu gameTypeMenu
|
||||
else undefined
|
||||
NewGame gs
|
||||
| null $ gs ^. gameType -> drawMenu gameTypeMenu
|
||||
| otherwise ->undefined
|
||||
C.render
|
||||
|
|
Loading…
Reference in New Issue
Block a user