module Codec.Tiled.Tileset.Transformations
  ( Transformations(..)
  , empty
  ) where

import GHC.Generics (Generic)

import Codec.Tiled.Aeson (FromJSON(..), ToJSON(..), genericParseJSON, genericToJSON)

data Transformations = Transformations
  { Transformations -> Maybe Bool
hFlip               :: Maybe Bool -- ^ Tiles can be flipped horizontally
  , Transformations -> Maybe Bool
vFlip               :: Maybe Bool -- ^ Tiles can be flipped vertically
  , Transformations -> Maybe Bool
rotate              :: Maybe Bool -- ^ Tiles can be rotated in 90-degree increments
  , Transformations -> Maybe Bool
preferUntransformed :: Maybe Bool -- ^ Whether untransformed tiles remain preferred, otherwise transformed tiles are used to produce more variations
  }
  deriving (Transformations -> Transformations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Transformations -> Transformations -> Bool
$c/= :: Transformations -> Transformations -> Bool
== :: Transformations -> Transformations -> Bool
$c== :: Transformations -> Transformations -> Bool
Eq, Int -> Transformations -> ShowS
[Transformations] -> ShowS
Transformations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Transformations] -> ShowS
$cshowList :: [Transformations] -> ShowS
show :: Transformations -> String
$cshow :: Transformations -> String
showsPrec :: Int -> Transformations -> ShowS
$cshowsPrec :: Int -> Transformations -> ShowS
Show, forall x. Rep Transformations x -> Transformations
forall x. Transformations -> Rep Transformations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Transformations x -> Transformations
$cfrom :: forall x. Transformations -> Rep Transformations x
Generic)

instance FromJSON Transformations where
  parseJSON :: Value -> Parser Transformations
parseJSON = forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
genericParseJSON

instance ToJSON Transformations where
  toJSON :: Transformations -> Value
toJSON = forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
genericToJSON

empty :: Transformations
empty :: Transformations
empty = Transformations
  { hFlip :: Maybe Bool
hFlip               = forall a. Maybe a
Nothing
  , vFlip :: Maybe Bool
vFlip               = forall a. Maybe a
Nothing
  , rotate :: Maybe Bool
rotate              = forall a. Maybe a
Nothing
  , preferUntransformed :: Maybe Bool
preferUntransformed = forall a. Maybe a
Nothing
  }