module Codec.Tiled.Layer.Chunk where

import GHC.Generics (Generic)

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

data Chunk = Chunk
  { Chunk -> LayerData
data_  :: LayerData -- ^ Array of unsigned int (GIDs) or base64-encoded data
  , Chunk -> Int
height :: Int       -- ^ Height in tiles
  , Chunk -> Int
width  :: Int       -- ^ Width in tiles
  , Chunk -> Int
x      :: Int       -- ^ X coordinate in tiles
  , Chunk -> Int
y      :: Int       -- ^ Y coordinate in tiles
  }
  deriving (Chunk -> Chunk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Chunk -> Chunk -> Bool
$c/= :: Chunk -> Chunk -> Bool
== :: Chunk -> Chunk -> Bool
$c== :: Chunk -> Chunk -> Bool
Eq, Int -> Chunk -> ShowS
[Chunk] -> ShowS
Chunk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Chunk] -> ShowS
$cshowList :: [Chunk] -> ShowS
show :: Chunk -> String
$cshow :: Chunk -> String
showsPrec :: Int -> Chunk -> ShowS
$cshowsPrec :: Int -> Chunk -> ShowS
Show, forall x. Rep Chunk x -> Chunk
forall x. Chunk -> Rep Chunk x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Chunk x -> Chunk
$cfrom :: forall x. Chunk -> Rep Chunk x
Generic)

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

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