From 33d2b0c5da01c48c8106876665e646e1d2f560e9 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 19 Sep 2021 23:21:47 +0200 Subject: some properties require non-empty layers --- lib/Util.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/Util.hs') 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 -- cgit v1.2.3