defined Controller

This commit is contained in:
Jonathan Lamothe 2019-09-04 13:47:17 -04:00
parent 1e2f65234b
commit ba7d694b14

View File

@ -23,6 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats.Types ( module Mtlstats.Types (
-- * Types -- * Types
Controller (..),
Action, Action,
ProgState (..), ProgState (..),
GameState (..), GameState (..),
@ -125,12 +126,20 @@ import Data.Aeson
) )
import Lens.Micro (Lens', lens, (&), (^.), (.~)) import Lens.Micro (Lens', lens, (&), (^.), (.~))
import Lens.Micro.TH (makeLenses) import Lens.Micro.TH (makeLenses)
import UI.NCurses (Curses, Update) import qualified UI.NCurses as C
import Mtlstats.Config 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 -- | Action which maintains program state
type Action a = StateT ProgState Curses a type Action a = StateT ProgState C.Curses a
-- | Represents the program state -- | Represents the program state
data ProgState = ProgState data ProgState = ProgState
@ -384,7 +393,7 @@ instance ToJSON GameStats where
-- | Defines a user prompt -- | Defines a user prompt
data Prompt = Prompt data Prompt = Prompt
{ promptDrawer :: ProgState -> Update () { promptDrawer :: ProgState -> C.Update ()
-- ^ Draws the prompt to thr screen -- ^ Draws the prompt to thr screen
, promptCharCheck :: Char -> Bool , promptCharCheck :: Char -> Bool
-- ^ Determines whether or not the character is valid -- ^ Determines whether or not the character is valid