summaryrefslogtreecommitdiff
path: root/lib/CheckMap.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CheckMap.hs')
-rw-r--r--lib/CheckMap.hs17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs
index 9dc3a4c..9e3027c 100644
--- a/lib/CheckMap.hs
+++ b/lib/CheckMap.hs
@@ -25,6 +25,9 @@ import qualified Data.Vector as V
import Badges (Badge)
+import Data.Tiled (Layer (layerLayers, layerName),
+ Tiledmap (tiledmapLayers, tiledmapTilesets),
+ loadTiledmap)
import LintConfig (LintConfig (configAssemblyTag), LintConfig')
import LintWriter (LintResult, invertLintResult,
resultToAdjusted, resultToBadges,
@@ -32,10 +35,6 @@ import LintWriter (LintResult, invertLintResult,
runLintWriter)
import Properties (checkLayer, checkMap, checkTileset)
import System.FilePath (takeFileName)
-import Data.Tiled (Layer (layerLayers, layerName),
- LoadResult (..),
- Tiledmap (tiledmapLayers, tiledmapTilesets),
- loadTiledmap)
import Types (Dep (MapLink),
Hint (Hint, hintLevel, hintMsg), Level (..),
lintsToHints)
@@ -102,14 +101,13 @@ shrinkMapResult !res = res { mapresultAdjusted = () }
-- Lints the map at `path`, and limits local links to at most `depth`
-- layers upwards in the file hierarchy
loadAndLintMap :: LintConfig' -> FilePath -> Int -> IO (Maybe (MapResult Full))
-loadAndLintMap config path depth = loadTiledmap path <&> (\case
- DecodeErr err -> Just (MapResult mempty mempty mempty mempty Nothing mempty
+loadAndLintMap config path depth = loadTiledmap path <&> \case
+ Left err -> Just (MapResult mempty mempty mempty mempty Nothing mempty
[ Hint Fatal . toText $
path <> ": Fatal: " <> err
])
- IOErr _ -> Nothing
- Loaded waMap ->
- Just (runLinter (takeFileName path == "main.json") config waMap depth))
+ Right waMap ->
+ Just (runLinter (takeFileName path == "main.json") config waMap depth)
-- | lint a loaded map
runLinter :: Bool -> LintConfig' -> Tiledmap -> Int -> MapResult Full
@@ -212,7 +210,6 @@ instance PrettyPrint (Level, MapResult a) where
prettyLints getter = fmap
(\(h, cs) -> prettyprint h
<> "\n (in "
- -- foldl :: ((length of current line, acc) -> next ctxt -> list) -> ...
<> snd (foldl (\(l,a) c -> case l of
0 -> (T.length c, c)
_ | l < 70 -> (l+2+T.length c, a <> ", " <> c)