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
(Transformations -> Transformations -> Bool)
-> (Transformations -> Transformations -> Bool)
-> Eq Transformations
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
(Int -> Transformations -> ShowS)
-> (Transformations -> String)
-> ([Transformations] -> ShowS)
-> Show Transformations
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. Transformations -> Rep Transformations x)
-> (forall x. Rep Transformations x -> Transformations)
-> Generic Transformations
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 = Value -> Parser Transformations
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
genericParseJSON

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

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