summaryrefslogtreecommitdiff
path: root/lib/Util.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-19 23:21:47 +0200
committerstuebinm2021-09-19 23:21:47 +0200
commit33d2b0c5da01c48c8106876665e646e1d2f560e9 (patch)
tree2415125337bf4dca8624607a1cf5ba6ea680d394 /lib/Util.hs
parent70d37dcb8b381ba1b0b0d1f97d2fe99522f387a6 (diff)
some properties require non-empty layers
Diffstat (limited to 'lib/Util.hs')
-rw-r--r--lib/Util.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Util.hs b/lib/Util.hs
index 82d326f..5cf27e3 100644
--- a/lib/Util.hs
+++ b/lib/Util.hs
@@ -9,7 +9,7 @@ module Util where
import Data.Aeson as Aeson
import Data.Text (Text)
import qualified Data.Text as T
-import Tiled2 (PropertyValue(..))
+import Tiled2 (Layer (layerData), PropertyValue (..), mkTiledId)
-- | haskell's many string types are FUN …
showText :: Show a => a -> Text
@@ -32,7 +32,7 @@ instance PrettyPrint Aeson.Value where
instance PrettyPrint PropertyValue where
prettyprint = \case
- StrProp str -> str
+ StrProp str -> str
BoolProp bool -> if bool then "true" else "false"
-- | here since Unit is sometimes used as dummy type
@@ -41,3 +41,9 @@ instance PrettyPrint () where
printPretty :: PrettyPrint a => a -> IO ()
printPretty = putStr . T.unpack . prettyprint
+
+
+layerIsEmpty :: Layer -> Bool
+layerIsEmpty layer = case layerData layer of
+ Nothing -> True
+ Just d -> all ((==) $ mkTiledId 0) d