Skip to content
Snippets Groups Projects
Commit 12025514 authored by stuebinm's avatar stuebinm
Browse files

fix group layer handling

we don't want to accidentally copy maps, whoopsie
parent 1734d1bd
No related branches found
No related tags found
No related merge requests found
...@@ -105,15 +105,17 @@ runLinter config tiledmap depth = MapResult ...@@ -105,15 +105,17 @@ runLinter config tiledmap depth = MapResult
checkThing getter checker = V.toList . V.map runCheck $ getter tiledmap checkThing getter checker = V.toList . V.map runCheck $ getter tiledmap
where runCheck thing = runLintWriter config thing depth checker where runCheck thing = runLintWriter config thing depth checker
-- | "inverts" a LintResult, i.e. groups it by lints instead of -- | "inverts" a LintResult, i.e. groups it by lints instead of
-- layers / maps -- layers / maps
invertThing thing = M.unionsWith (<>) $ fmap invertLintResult thing invertThing thing = M.unionsWith (<>) $ fmap invertLintResult thing
adjustedMap = (resultToAdjusted generalResult) adjustedMap = (resultToAdjusted generalResult)
{ tiledmapLayers = V.fromList $ fmap resultToAdjusted layer { tiledmapLayers = V.fromList
, tiledmapTilesets = V.fromList . fmap resultToAdjusted $ tileset . fmap resultToAdjusted
$ take (length (tiledmapLayers tiledmap)) layer
, tiledmapTilesets = V.fromList
. fmap resultToAdjusted
$ tileset
} }
-- | Recursively checks a layer. -- | Recursively checks a layer.
...@@ -121,15 +123,26 @@ runLinter config tiledmap depth = MapResult ...@@ -121,15 +123,26 @@ runLinter config tiledmap depth = MapResult
-- This is apparently necessary because someone thought it would be a good -- This is apparently necessary because someone thought it would be a good
-- idea to have group layers, even if their entire semantics appear to be -- idea to have group layers, even if their entire semantics appear to be
-- "they're group layers"; they don't seem to /do/ anything … -- "they're group layers"; they don't seem to /do/ anything …
--
-- Note that this will flatten the layer structure and give them all back
-- in a single list, but the ones that were passed in will always be at
-- the head of the list.
checkLayerRec :: LintConfig' -> Int -> [Layer] -> [LintResult Layer] checkLayerRec :: LintConfig' -> Int -> [Layer] -> [LintResult Layer]
checkLayerRec config depth = concatMap $ \parent -> checkLayerRec config depth layers =
-- reordering to get the correct ones back up front
(\rs -> fmap fst rs <> concatMap snd rs)
-- map over all input layers
$ flip fmap layers $ \parent ->
case layerLayers parent of case layerLayers parent of
-- not a group layer; just lint this one
Nothing -> Nothing ->
[runLintWriter config parent depth checkLayer] (runLintWriter config parent depth checkLayer,[])
-- this is a group layer. Fun!
Just sublayers -> Just sublayers ->
let let
-- before linting, append the group's top-level name to that of sublayers -- before linting, append the group's top-level name to that of sublayers
results = checkLayerRec config depth $ sublayers results = take (length sublayers)
$ checkLayerRec config depth $ sublayers
<&> \l -> l { layerName = layerName parent <> "/" <> layerName l } <&> \l -> l { layerName = layerName parent <> "/" <> layerName l }
-- get the original sublayer names -- get the original sublayer names
names = fmap layerName sublayers names = fmap layerName sublayers
...@@ -141,7 +154,7 @@ checkLayerRec config depth = concatMap $ \parent -> ...@@ -141,7 +154,7 @@ checkLayerRec config depth = concatMap $ \parent ->
names results names results
} }
) depth checkLayer ) depth checkLayer
in result:results in (result,results)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment