2020-10-25 18:33:18 +00:00
|
|
|
{-# LANGUAGE ExistentialQuantification #-}
|
2020-09-21 02:26:45 +00:00
|
|
|
module Types.Application where
|
|
|
|
|
|
|
|
import Affection
|
|
|
|
|
|
|
|
import qualified SDL
|
|
|
|
|
2020-09-23 23:26:47 +00:00
|
|
|
import Control.Concurrent.STM
|
2020-09-21 02:26:45 +00:00
|
|
|
|
|
|
|
import qualified Data.Map.Strict as M
|
|
|
|
|
2020-10-17 08:35:25 +00:00
|
|
|
import qualified Data.Text as T
|
|
|
|
|
2020-09-21 02:26:45 +00:00
|
|
|
-- internal imports
|
|
|
|
|
|
|
|
import Types.Subsystems
|
2020-10-09 23:00:33 +00:00
|
|
|
import Types.GameMap
|
2020-09-21 02:26:45 +00:00
|
|
|
|
|
|
|
data GameData = GameData
|
2020-10-25 18:33:18 +00:00
|
|
|
{ gameScene :: TMVar Stage
|
|
|
|
, gameState :: TVar State
|
2020-10-17 08:35:25 +00:00
|
|
|
, gameStateLoadProgress :: TMVar Progress
|
2020-09-21 02:26:45 +00:00
|
|
|
, gameSubsystems :: Subsystems
|
|
|
|
, gameActionTranslation :: TVar ActionTranslation
|
2020-09-23 23:26:47 +00:00
|
|
|
, gameRunning :: TVar Bool
|
2020-09-21 02:26:45 +00:00
|
|
|
}
|
|
|
|
|
2020-10-25 18:33:18 +00:00
|
|
|
-- Existential type wrapper to make all Scenes implementing Scene
|
|
|
|
-- homogenous.
|
|
|
|
-- See more at https://wiki.haskell.org/Existential_type#Dynamic_dispatch_mechanism_of_OOP
|
|
|
|
data Stage = forall a. Scene a => Stage a
|
|
|
|
|
2020-09-21 02:26:45 +00:00
|
|
|
data State
|
2020-09-22 12:07:13 +00:00
|
|
|
= Loading
|
2020-10-25 18:33:18 +00:00
|
|
|
| Running
|
|
|
|
| Pausing
|
2020-09-21 02:26:45 +00:00
|
|
|
|
2020-10-17 08:35:25 +00:00
|
|
|
type Progress = (Float, T.Text)
|
|
|
|
|
2020-09-21 02:26:45 +00:00
|
|
|
type ActionTranslation = M.Map SDL.Keycode Action
|