From ba7d694b14a605115a978c54e79b0ac1b52853cd Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 4 Sep 2019 13:47:17 -0400 Subject: [PATCH] defined Controller --- src/Mtlstats/Types.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 973b00c..eff5abf 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -23,6 +23,7 @@ along with this program. If not, see . module Mtlstats.Types ( -- * Types + Controller (..), Action, ProgState (..), GameState (..), @@ -125,12 +126,20 @@ import Data.Aeson ) import Lens.Micro (Lens', lens, (&), (^.), (.~)) import Lens.Micro.TH (makeLenses) -import UI.NCurses (Curses, Update) +import qualified UI.NCurses as C import Mtlstats.Config +-- | Controls the program flow +data Controller = Controller + { drawController :: ProgState -> C.Update C.CursorMode + -- ^ The drawing phase + , handleController :: C.Event -> Action Bool + -- ^ The event handler + } + -- | Action which maintains program state -type Action a = StateT ProgState Curses a +type Action a = StateT ProgState C.Curses a -- | Represents the program state data ProgState = ProgState @@ -384,7 +393,7 @@ instance ToJSON GameStats where -- | Defines a user prompt data Prompt = Prompt - { promptDrawer :: ProgState -> Update () + { promptDrawer :: ProgState -> C.Update () -- ^ Draws the prompt to thr screen , promptCharCheck :: Char -> Bool -- ^ Determines whether or not the character is valid