{-# LANGUAGE CPP #-}

module Commons where

import Affection

import qualified SDL

import Control.Monad.IO.Class (MonadIO)
import Control.Monad.State

import System.Clock

import Debug.Trace (traceIO)

--internals

import Types.StateData

debug :: MonadIO m => String -> m ()
debug =
#ifdef DEBUG
  liftIO . traceIO
#else
  const (return())
#endif

-- toggleScreen :: Affection StateData ()
-- toggleScreen = do
--   ad <- get
--   sd <- getAffection
--   case screen sd of
--     SDL.Windowed -> do
--       debug "going fullscreen"
--       SDL.setWindowMode (drawWindow ad) SDL.Fullscreen
--       now <- liftIO $ getTime Monotonic
--       put ad
--         { sysTime = now
--         }
--       putAffection sd
--         { screen = SDL.Fullscreen
--         }
--     SDL.Fullscreen -> do
--       debug "going windowed"
--       SDL.setWindowMode (drawWindow ad) SDL.Windowed
--       now <- liftIO $ getTime Monotonic
--       put ad
--         { sysTime = now
--         }
--       putAffection sd
--         { screen = SDL.Windowed
--         }

pre :: Affection StateData () -> Affection StateData ()
pre loader = do
  loader
