From c89872d393566ab414301cc84f30b8e8d08900b2 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 15 Dec 2021 23:06:42 +0100 Subject: suggest setting map meta properties if not given --- lib/Paths.hs | 2 +- lib/Properties.hs | 9 +++++++++ lib/Util.hs | 12 ++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Paths.hs b/lib/Paths.hs index 83c065f..99774c5 100644 --- a/lib/Paths.hs +++ b/lib/Paths.hs @@ -67,7 +67,7 @@ isOldStyle :: RelPath -> Bool isOldStyle (Path _ text frag) = path =~ ("{<.+>*}" :: Text) where path = case frag of Just f -> text <> f - _ -> text + _ -> text getExtension :: RelPath -> Text getExtension (Path _ text frag) = case length splitted of diff --git a/lib/Properties.hs b/lib/Properties.hs index c1ade06..ce79ff8 100644 --- a/lib/Properties.hs +++ b/lib/Properties.hs @@ -27,6 +27,7 @@ import Badges (Badge (Badge), parseToken) import Data.Data (Proxy (Proxy)) import Data.Functor ((<&>)) +import Data.List ((\\)) import Data.Maybe (fromMaybe, isJust) import Data.Set (Set) import qualified Data.Set as S @@ -83,6 +84,14 @@ checkMap = do whenLayerCollisions layers (\(Property name _) -> name == "exitUrl" || name == "startLayer") $ \cols -> warn $ "collisions between entry and / or exit layers: " <> prettyprint cols + let missingMetaInfo = + ["mapName","mapDescription","mapLink","mapImage"] + \\ fmap getName (getProperties tiledmap) + + unless (null missingMetaInfo) + $ suggest $ "consider adding meta information to your map using the " + <> prettyprint missingMetaInfo <> " properties." + where -- recursively find all layers (to deal with nested group layers) collectLayers :: Tiledmap -> V.Vector Layer diff --git a/lib/Util.hs b/lib/Util.hs index 1e5826c..a6c8354 100644 --- a/lib/Util.hs +++ b/lib/Util.hs @@ -39,13 +39,14 @@ instance PrettyPrint Aeson.Value where v -> (T.pack . show) v instance PrettyPrint t => PrettyPrint (Set t) where - prettyprint = T.intercalate ", " . fmap prettyprint . S.toList + prettyprint = prettyprint . S.toList instance PrettyPrint PropertyValue where prettyprint = \case - StrProp str -> str - BoolProp bool -> if bool then "true" else "false" - IntProp int -> showText int + StrProp str -> str + BoolProp bool -> if bool then "true" else "false" + IntProp int -> showText int + FloatProp float -> showText float -- | here since Unit is sometimes used as dummy type instance PrettyPrint () where @@ -57,6 +58,9 @@ instance PrettyPrint Layer where instance PrettyPrint Tileset where prettyprint = (<>) "tileset " . tilesetName +instance PrettyPrint a => PrettyPrint [a] where + prettyprint = T.intercalate ", " . fmap prettyprint + printPretty :: PrettyPrint a => a -> IO () printPretty = putStr . T.unpack . prettyprint -- cgit v1.2.3