diff options
author | stuebinm | 2021-11-14 21:26:46 +0100 |
---|---|---|
committer | stuebinm | 2021-11-14 21:26:46 +0100 |
commit | 8fc10996e17ba164dc8e29d77efd03113a1f63f0 (patch) | |
tree | 7dc755cc80981388f82b96e11b0555177a26bde0 /lib/Properties.hs | |
parent | bb5277dc5b492e0e27777f7eb42c54b45c66835a (diff) |
config options: implement script-related options
Diffstat (limited to 'lib/Properties.hs')
-rw-r--r-- | lib/Properties.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Properties.hs b/lib/Properties.hs index e6a3384..50fec53 100644 --- a/lib/Properties.hs +++ b/lib/Properties.hs @@ -15,7 +15,7 @@ import Tiled2 (HasProperties (adjustProperties, getProperties), import Util (layerIsEmpty, prettyprint) import Data.Maybe (fromMaybe) -import LintConfig (LintConfig (configAssemblyTag)) +import LintConfig (LintConfig (..)) import LintWriter (LintWriter, adjust, askContext, askFileDepth, complain, dependsOn, forbid, lintConfig, offersEntrypoint, suggest, warn) @@ -62,7 +62,18 @@ checkMap = do -- longer function same as checkLayerProperty. checkMapProperty :: Property -> LintWriter Tiledmap checkMapProperty (Property name _value) = case name of - "script" -> isForbidden + "script" -> do + -- this is kind of stupid, since if we also inject script this + -- will be overriden anyways, but it also doesn't really hurt I guess + -- TODO: perhaps include an explanation in the lint, or allow + -- exactly that one value? + lintConfig configAllowScripts >>= \case + False -> isForbidden + True -> pure () + lintConfig configScriptInject >>= \case + Nothing -> pure () + Just url -> setProperty "script" url + _ -> complain $ "unknown map property " <> prettyprint name where -- | this property is forbidden and should not be used |