diff --git a/src/Mtlstats.hs b/src/Mtlstats.hs
index 6d0a303..440d87c 100644
--- a/src/Mtlstats.hs
+++ b/src/Mtlstats.hs
@@ -21,6 +21,7 @@ along with this program. If not, see .
module Mtlstats (initState, mainLoop) where
+import Control.Monad (void)
import Control.Monad.Extra (whenM)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.State (StateT, get)
@@ -33,7 +34,10 @@ import Mtlstats.UI
-- | Initializes the progran
initState :: C.Curses ProgState
-initState = return newProgState
+initState = do
+ C.setEcho False
+ void $ C.setCursorMode C.CursorInvisible
+ return newProgState
-- | Main program loop
mainLoop :: StateT ProgState C.Curses ()
diff --git a/src/Mtlstats/Events.hs b/src/Mtlstats/Events.hs
index 285363c..01f1e38 100644
--- a/src/Mtlstats/Events.hs
+++ b/src/Mtlstats/Events.hs
@@ -21,7 +21,9 @@ along with this program. If not, see .
module Mtlstats.Events (handleEvent) where
-import Control.Monad.Trans.State (StateT)
+import Control.Monad.Trans.State (StateT, gets, modify)
+import Lens.Micro ((.~))
+import Lens.Micro.Extras (view)
import qualified UI.NCurses as C
import Mtlstats.Types
@@ -31,4 +33,21 @@ handleEvent
:: C.Event
-- ^ The even being handled
-> StateT ProgState C.Curses Bool
-handleEvent _ = return False
+handleEvent e = do
+ m <- gets $ view progMode
+ case m of
+ MainMenu -> mainMenu e
+ NewSeason -> newSeason e >> return False
+
+mainMenu :: C.Event -> StateT ProgState C.Curses Bool
+mainMenu (C.EventCharacter c) = case c of
+ '1' -> startNewSeason >> return True
+ '2' -> 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
diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs
index 23307f4..e9fe7ca 100644
--- a/src/Mtlstats/Types.hs
+++ b/src/Mtlstats/Types.hs
@@ -24,6 +24,7 @@ along with this program. If not, see .
module Mtlstats.Types (
-- * Types
ProgState (..),
+ ProgMode (..),
Database (..),
Player (..),
PlayerStats (..),
@@ -32,6 +33,7 @@ module Mtlstats.Types (
-- * Lenses
-- ** ProgState Lenses
database,
+ progMode,
-- ** Database Lenses
dbPlayers,
dbGoalies,
@@ -86,10 +88,14 @@ import Lens.Micro ((^.))
import Lens.Micro.TH (makeLenses)
-- | Represents the program state
-newtype ProgState = ProgState
+data ProgState = ProgState
{ _database :: Database
+ , _progMode :: ProgMode
} deriving (Eq, Show)
+-- | The program mode
+data ProgMode = MainMenu | NewSeason deriving (Eq, Show)
+
-- | Represents the database
data Database = Database
{ _dbPlayers :: [Player]
@@ -271,6 +277,7 @@ makeLenses ''GoalieStats
newProgState :: ProgState
newProgState = ProgState
{ _database = newDatabase
+ , _progMode = MainMenu
}
-- | Constructor for a 'Database'
diff --git a/src/Mtlstats/UI.hs b/src/Mtlstats/UI.hs
index 5741813..9e095fe 100644
--- a/src/Mtlstats/UI.hs
+++ b/src/Mtlstats/UI.hs
@@ -21,10 +21,28 @@ along with this program. If not, see .
module Mtlstats.UI (draw) where
+import Lens.Micro ((^.))
import qualified UI.NCurses as C
import Mtlstats.Types
-- | Drawing function
draw :: ProgState -> C.Curses ()
-draw _ = return ()
+draw s = do
+ w <- C.defaultWindow
+ C.updateWindow w $ do
+ C.clear
+ case s ^. progMode of
+ MainMenu -> mainMenu
+ NewSeason -> newSeason
+ C.render
+
+mainMenu :: C.Update ()
+mainMenu = C.drawString $ unlines
+ [ "*** MAIN MENU ***"
+ , "1) New Season"
+ , "2) Exit"
+ ]
+
+newSeason :: C.Update ()
+newSeason = return ()