Add true quicksave and guickload

This commit is contained in:
2023-03-26 12:13:21 +01:00
parent a652b13fa0
commit cfb0a49059
6 changed files with 32 additions and 29 deletions
+10 -10
View File
@@ -2,6 +2,7 @@ module Dodge.Save (
saveWorldInSlot,
loadSaveSlot,
doQuicksave,
doQuickload,
-- saveLevelStartSlot,
writeSaveSlot,
readSaveSlot,
@@ -9,6 +10,7 @@ module Dodge.Save (
) where
import Data.Maybe
import Dodge.WorldLoad
import Dodge.Path.Translate
import Data.Graph.Inductive (labEdges, labNodes)
@@ -70,16 +72,14 @@ reloadLevelStart :: Universe -> Universe
reloadLevelStart = loadSaveSlot (LevelStartSlot 0)
loadSaveSlot :: SaveSlot -> Universe -> Universe
loadSaveSlot slot = blockingLoad "LOADING SAVE" $ readSaveSlot slot
loadSaveSlot slot = blockingLoad ("DESERIALISING "++ show slot) $ readSaveSlot slot
doQuicksave :: Universe -> Universe
doQuicksave = saveWorldInSlot QuicksaveSlot
doQuicksave u = u
& uvRAMSave ?~ _uvWorld u
& saveWorldInSlot QuicksaveSlot
--clearKeys :: World -> World
--clearKeys = (keys .~ mempty) . (mouseButtons .~ mempty)
--saveLevelStartSlot :: Universe -> Universe
----saveLevelStartSlot = id
--saveLevelStartSlot = saveWorldInSlot LevelStartSlot
--saveLevelStartSlot = sideEffects %~ (fmap (undefined) . )
doQuickload :: Universe -> Universe
doQuickload u = fromMaybe (loadSaveSlot QuicksaveSlot u) $ do
w <- u ^. uvRAMSave
return $ u & uvWorld .~ w