added new game menu
This commit is contained in:
30
src/Mtlstats/Actions.hs
Normal file
30
src/Mtlstats/Actions.hs
Normal 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
|
||||||
@@ -26,6 +26,7 @@ import Lens.Micro ((.~))
|
|||||||
import Lens.Micro.Extras (view)
|
import Lens.Micro.Extras (view)
|
||||||
import qualified UI.NCurses as C
|
import qualified UI.NCurses as C
|
||||||
|
|
||||||
|
import Mtlstats.Actions
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
|
|
||||||
-- | Event handler
|
-- | Event handler
|
||||||
@@ -37,17 +38,19 @@ handleEvent e = do
|
|||||||
m <- gets $ view progMode
|
m <- gets $ view progMode
|
||||||
case m of
|
case m of
|
||||||
MainMenu -> mainMenu e
|
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.Event -> StateT ProgState C.Curses Bool
|
||||||
mainMenu (C.EventCharacter c) = case c of
|
mainMenu (C.EventCharacter c) = case c of
|
||||||
'1' -> startNewSeason >> return True
|
'1' -> modify startNewSeason >> return True
|
||||||
'2' -> return False
|
'2' -> modify startNewGame >> return True
|
||||||
|
'3' -> return False
|
||||||
_ -> return True
|
_ -> return True
|
||||||
mainMenu _ = return True
|
mainMenu _ = return True
|
||||||
|
|
||||||
newSeason :: C.Event -> StateT ProgState C.Curses ()
|
newSeason :: C.Event -> StateT ProgState C.Curses ()
|
||||||
newSeason = undefined
|
newSeason = undefined
|
||||||
|
|
||||||
startNewSeason :: StateT ProgState C.Curses ()
|
newGame :: C.Event -> StateT ProgState C.Curses ()
|
||||||
startNewSeason = modify $ progMode .~ NewSeason
|
newGame = undefined
|
||||||
|
|||||||
@@ -94,7 +94,11 @@ data ProgState = ProgState
|
|||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
-- | The program mode
|
-- | The program mode
|
||||||
data ProgMode = MainMenu | NewSeason deriving (Eq, Show)
|
data ProgMode
|
||||||
|
= MainMenu
|
||||||
|
| NewSeason
|
||||||
|
| NewGame
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
-- | Represents the database
|
-- | Represents the database
|
||||||
data Database = Database
|
data Database = Database
|
||||||
|
|||||||
@@ -35,13 +35,15 @@ draw s = do
|
|||||||
case s ^. progMode of
|
case s ^. progMode of
|
||||||
MainMenu -> mainMenu
|
MainMenu -> mainMenu
|
||||||
NewSeason -> newSeason
|
NewSeason -> newSeason
|
||||||
|
NewGame -> newGame
|
||||||
C.render
|
C.render
|
||||||
|
|
||||||
mainMenu :: C.Update ()
|
mainMenu :: C.Update ()
|
||||||
mainMenu = C.drawString $ unlines
|
mainMenu = C.drawString $ unlines
|
||||||
[ "*** MAIN MENU ***"
|
[ "*** MAIN MENU ***"
|
||||||
, "1) New Season"
|
, "1) New Season"
|
||||||
, "2) Exit"
|
, "2) New Game"
|
||||||
|
, "3) Exit"
|
||||||
]
|
]
|
||||||
|
|
||||||
newSeason :: C.Update ()
|
newSeason :: C.Update ()
|
||||||
@@ -50,3 +52,6 @@ newSeason = C.drawString $ unlines
|
|||||||
, "1) Regular Season"
|
, "1) Regular Season"
|
||||||
, "2) Playoffs"
|
, "2) Playoffs"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
newGame :: C.Update ()
|
||||||
|
newGame = return ()
|
||||||
|
|||||||
Reference in New Issue
Block a user