added new game menu

This commit is contained in:
Jonathan Lamothe 2019-08-20 11:17:24 -04:00
parent 113127d33d
commit 43c2a4ff4e
4 changed files with 49 additions and 7 deletions

30
src/Mtlstats/Actions.hs Normal file
View File

@ -0,0 +1,30 @@
{- |
mtlstats
Copyright (C) 2019 Rhéal Lamothe
<rheal.lamothe@gmail.com>
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 <https://www.gnu.org/licenses/>.
-}
module Mtlstats.Actions (startNewSeason, startNewGame) where
import Mtlstats.Types
startNewSeason :: ProgState -> ProgState
startNewSeason = undefined
startNewGame :: ProgState -> ProgState
startNewGame = undefined

View File

@ -26,6 +26,7 @@ import Lens.Micro ((.~))
import Lens.Micro.Extras (view)
import qualified UI.NCurses as C
import Mtlstats.Actions
import Mtlstats.Types
-- | Event handler
@ -37,17 +38,19 @@ handleEvent e = do
m <- gets $ view progMode
case m of
MainMenu -> mainMenu e
NewSeason -> newSeason e >> return False
NewSeason -> newSeason e >> return True
NewGame -> newGame e >> return True
mainMenu :: C.Event -> StateT ProgState C.Curses Bool
mainMenu (C.EventCharacter c) = case c of
'1' -> startNewSeason >> return True
'2' -> return False
'1' -> modify startNewSeason >> return True
'2' -> modify startNewGame >> return True
'3' -> return False
_ -> return True
mainMenu _ = return True
newSeason :: C.Event -> StateT ProgState C.Curses ()
newSeason = undefined
startNewSeason :: StateT ProgState C.Curses ()
startNewSeason = modify $ progMode .~ NewSeason
newGame :: C.Event -> StateT ProgState C.Curses ()
newGame = undefined

View File

@ -94,7 +94,11 @@ data ProgState = ProgState
} deriving (Eq, Show)
-- | The program mode
data ProgMode = MainMenu | NewSeason deriving (Eq, Show)
data ProgMode
= MainMenu
| NewSeason
| NewGame
deriving (Eq, Show)
-- | Represents the database
data Database = Database

View File

@ -35,13 +35,15 @@ draw s = do
case s ^. progMode of
MainMenu -> mainMenu
NewSeason -> newSeason
NewGame -> newGame
C.render
mainMenu :: C.Update ()
mainMenu = C.drawString $ unlines
[ "*** MAIN MENU ***"
, "1) New Season"
, "2) Exit"
, "2) New Game"
, "3) Exit"
]
newSeason :: C.Update ()
@ -50,3 +52,6 @@ newSeason = C.drawString $ unlines
, "1) Regular Season"
, "2) Playoffs"
]
newGame :: C.Update ()
newGame = return ()