diff options
author | stuebinm | 2022-02-28 00:39:54 +0100 |
---|---|---|
committer | stuebinm | 2022-02-28 00:39:54 +0100 |
commit | 8a201e8658c9365d301a7cda9077ddf005b014c9 (patch) | |
tree | c2f400c9c7d52c179682e57061709391b0ca05bd /lib/TiledAbstract.hs | |
parent | 55c2994e856ceaf82edd06587e2faffb7c58950c (diff) |
separate tiled modules out into own package
Diffstat (limited to 'lib/TiledAbstract.hs')
-rw-r--r-- | lib/TiledAbstract.hs | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/lib/TiledAbstract.hs b/lib/TiledAbstract.hs deleted file mode 100644 index 9fd2df0..0000000 --- a/lib/TiledAbstract.hs +++ /dev/null @@ -1,66 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module TiledAbstract where - -import Universum - -import qualified Data.Vector as V -import Tiled (Layer (..), Object (..), Property (..), - PropertyValue (..), Tile (..), Tiledmap (..), - Tileset (..)) - -class HasProperties a where - getProperties :: a -> [Property] - adjustProperties :: ([Property] -> Maybe [Property]) -> a -> a - -instance HasProperties Layer where - getProperties = maybeToMonoid . layerProperties - adjustProperties f layer = layer - { layerProperties = f (getProperties layer) } - -instance HasProperties Tileset where - getProperties = maybeToMonoid . tilesetProperties - adjustProperties f tileset = tileset - { tilesetProperties = f (getProperties tileset) } - -instance HasProperties Tile where - getProperties = V.toList . maybeToMonoid . tileProperties - adjustProperties f tile = tile - { tileProperties = (fmap V.fromList . f) (getProperties tile) } - -instance HasProperties Object where - getProperties = V.toList . maybeToMonoid . objectProperties - adjustProperties f obj = obj - { objectProperties = (fmap V.fromList . f) (getProperties obj) } - -instance HasProperties Tiledmap where - getProperties = maybeToMonoid . tiledmapProperties - adjustProperties f tiledmap = tiledmap - { tiledmapProperties = f (getProperties tiledmap) } - -class HasTypeName a where - typeName :: Proxy a -> Text -instance HasTypeName Layer where - typeName _ = "layer" -instance HasTypeName Tileset where - typeName _ = "tileset" -instance HasTypeName Property where - typeName _ = "property" - -class HasName a where - getName :: a -> Text -instance HasName Layer where - getName = layerName -instance HasName Tileset where - getName = tilesetName -instance HasName Property where - getName (Property n _) = n - -class IsProperty a where - asProperty :: a -> PropertyValue -instance IsProperty PropertyValue where - asProperty = id - {-# INLINE asProperty #-} -instance IsProperty Text where - asProperty = StrProp - {-# INLINE asProperty #-} |