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
|
module Mtlstats.Events (handleEvent) where
|
||||||
|
|
||||||
import Control.Monad.Trans.State (gets, modify)
|
import Control.Monad.Trans.State (gets, modify)
|
||||||
|
@ -35,11 +37,10 @@ handleEvent
|
||||||
:: C.Event
|
:: C.Event
|
||||||
-- ^ The event being handled
|
-- ^ The event being handled
|
||||||
-> Action Bool
|
-> Action Bool
|
||||||
handleEvent e = do
|
handleEvent e = gets (view progMode) >>= \case
|
||||||
m <- gets $ view progMode
|
MainMenu -> menuHandler mainMenu e
|
||||||
case m of
|
NewSeason -> menuHandler newSeasonMenu e >> return True
|
||||||
MainMenu -> menuHandler mainMenu e
|
NewGame gs
|
||||||
NewSeason -> menuHandler newSeasonMenu e >> return True
|
| null $ gs ^. gameType ->
|
||||||
NewGame gs -> if null $ gs ^. gameType
|
menuHandler gameTypeMenu e >> return True
|
||||||
then menuHandler gameTypeMenu e >> return True
|
| otherwise -> undefined
|
||||||
else undefined
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ draw s = do
|
||||||
case s ^. progMode of
|
case s ^. progMode of
|
||||||
MainMenu -> drawMenu mainMenu
|
MainMenu -> drawMenu mainMenu
|
||||||
NewSeason -> drawMenu newSeasonMenu
|
NewSeason -> drawMenu newSeasonMenu
|
||||||
NewGame gs -> if null $ gs ^. gameType
|
NewGame gs
|
||||||
then drawMenu gameTypeMenu
|
| null $ gs ^. gameType -> drawMenu gameTypeMenu
|
||||||
else undefined
|
| otherwise ->undefined
|
||||||
C.render
|
C.render
|
||||||
|
|
Loading…
Reference in New Issue
Block a user