Move from store to flat

This commit is contained in:
2022-08-20 17:54:35 +01:00
parent 8571ab9254
commit ff9dbdf068
95 changed files with 793 additions and 748 deletions
+5 -5
View File
@@ -10,7 +10,7 @@ module Dodge.Save (
fromJSONSaveSlot,
) where
import qualified Data.Store as Store
import Flat
import Dodge.Concurrent
import Control.Lens
import Dodge.Data.SaveSlot
@@ -27,7 +27,7 @@ writeSaveSlot ss u = do
putStrLn $ "Saving " ++ saveSlotPath ss
createDirectoryIfMissing True "saveSlot"
BSS.writeFile (saveSlotPath ss) $
Store.encode
flat
(u ^. uvWorld . cWorld)
return Just
@@ -37,10 +37,10 @@ readSaveSlot ss = do
if fExists
then do
bsstr <- BSS.readFile $ saveSlotPath ss
cwstr <- Store.decodeIO $ bsstr
let cwstr = unflat bsstr
case cwstr of
Nothing -> putStrLn "loadSaveSlot failed to read saved file" >> return removescreenlayers
Just cw -> return $ \uv -> Just $ uv & uvWorld . cWorld .~ cw
Left _ -> putStrLn "loadSaveSlot failed to read saved file" >> return removescreenlayers
Right cw -> return $ \uv -> Just $ uv & uvWorld . cWorld .~ cw
& uvScreenLayers .~ []
else putStrLn "loadSaveSlot failed to find saved file" >> return removescreenlayers
where