{-# LANGUAGE ExistentialQuantification #-}
module Types.Application where

import Affection

import qualified SDL

import Control.Concurrent (ThreadId)
import Control.Concurrent.STM

import qualified Data.Map.Strict as M

import qualified Data.Text as T

-- internal imports

import Types.Subsystems
import Types.Map
import Types.Util

import Classes.Scene

data GameData = GameData
  { gameScene             :: TMVar Stage
  , gameState             :: TVar State
  , gameStateLoadProgress :: TMVar Progress
  , gameSubsystems        :: Subsystems
  , gameActionTranslation :: TVar ActionTranslation
  , gameRunning           :: TVar Bool
  , gameLoadThread        :: TVar (Maybe ThreadId)
  , gameLoadContext       :: TVar (Maybe SDL.GLContext)
  }

-- 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

data State
  = Loading
  | Running
  | Pausing
  deriving (Show)
