module Data.Tiled.Types where
import Data.Map (Map)
import Data.Word (Word8, Word32)
data MapOrientation = Orthogonal | Isometric deriving (Show, Eq)
type Properties = [(String, String)]
data TiledMap = TiledMap
{ mapPath ∷ FilePath
, mapOrientation ∷ MapOrientation
, mapWidth, mapHeight ∷ Int
, mapTileWidth ∷ Int
, mapTileHeight ∷ Int
, mapProperties ∷ Properties
, mapTilesets ∷ [Tileset]
, mapLayers ∷ [Layer]
} deriving (Show, Eq)
data Tileset = Tileset
{ tsName ∷ String
, tsInitialGid ∷ Word32
, tsTileWidth, tsTileHeight ∷ Int
, tsSpacing, tsMargin ∷ Int
, tsImages ∷ [Image]
, tsTileProperties ∷ [(Word32, Properties)]
} deriving (Show, Eq)
data Image = Image
{ iSource ∷ FilePath
, iTrans ∷ Maybe (Word8, Word8, Word8)
, iWidth, iHeight ∷ Int
} deriving (Show, Eq)
data Object = Object
{ objectName ∷ Maybe String
, objectType ∷ Maybe String
, objectProperties ∷ Properties
, objectX, objectY ∷ Int
, objectWidth, objectHeight ∷ Maybe Int
, objectGid ∷ Maybe Word32
, objectPolygon ∷ Maybe Polygon
, objectPolyline ∷ Maybe Polyline
} deriving (Show, Eq)
data Polygon = Polygon [(Int, Int)] deriving (Show, Eq)
data Polyline = Polyline [(Int, Int)] deriving (Show, Eq)
data Layer = Layer
{ layerName ∷ String
, layerOpacity ∷ Float
, layerIsVisible ∷ Bool
, layerProperties ∷ Properties
, layerData ∷ Map (Int, Int) Tile
}
| ObjectLayer
{ layerName ∷ String
, layerOpacity ∷ Float
, layerIsVisible ∷ Bool
, layerProperties ∷ Properties
, layerObjects ∷ [Object]
}
| ImageLayer
{ layerName ∷ String
, layerOpacity ∷ Float
, layerIsVisible ∷ Bool
, layerProperties ∷ Properties
, layerImage ∷ Image
} deriving Eq
data Tile = Tile { tileGid ∷ Word32
, tileIsVFlipped, tileIsHFlipped, tileIsDiagFlipped ∷ Bool
} deriving (Show, Eq, Ord)
instance Show Layer where
show Layer {..} = "Layer { layerName = " ++ show layerName ++
", layerOpacity = " ++ show layerOpacity ++
", layerIsVisible = " ++ show layerIsVisible ++
", layerProperties = " ++ show layerProperties ++
", layerData = \"...\" }"
show ObjectLayer {..} = "ObjectLayer { layerName = " ++ show layerName ++
", layerOpacity = " ++ show layerOpacity ++
", layerIsVisible = " ++ show layerIsVisible ++
", layerProperties = " ++ show layerProperties ++
", layerObjects = " ++ show layerObjects ++ " }"
show ImageLayer {..} = "ObjectLayer { layerName = " ++ show layerName ++
", layerOpacity = " ++ show layerOpacity ++
", layerIsVisible = " ++ show layerIsVisible ++
", layerProperties = " ++ show layerProperties ++
", layerImage = " ++ show layerImage ++ " }"