Change config serialisation folder, cleanup unused files
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
module Dodge.Config.Load (
|
||||
loadDodgeConfig,
|
||||
) where
|
||||
|
||||
import Data.Aeson
|
||||
import Dodge.Data.Config
|
||||
import System.Directory
|
||||
|
||||
loadDodgeConfig :: IO Config
|
||||
loadDodgeConfig = do
|
||||
fExists <- doesFileExist "data/dodge.config.json"
|
||||
if fExists
|
||||
then do
|
||||
mayConfig <- decodeFileStrict "data/dodge.config.json"
|
||||
case mayConfig of
|
||||
Just config -> return config
|
||||
Nothing -> do
|
||||
putStrLn "invalid data/dodge.config.json, loading defaults"
|
||||
return defaultConfig
|
||||
else do
|
||||
putStrLn "No data/data/dodge.config.json found, loading defaults"
|
||||
return defaultConfig
|
||||
@@ -1,44 +0,0 @@
|
||||
{- |
|
||||
IO actions that apply config side effects and save configuration settings to disk.
|
||||
-}
|
||||
module Dodge.Config.Update (
|
||||
saveConfig,
|
||||
applyWorldConfig,
|
||||
setVol,
|
||||
) where
|
||||
|
||||
import qualified Data.Aeson.Encode.Pretty as AEP
|
||||
import qualified Data.ByteString.Lazy as BS
|
||||
import Data.Preload
|
||||
import Dodge.Data.Config
|
||||
import Preload.Update
|
||||
import Sound
|
||||
|
||||
{- |
|
||||
Write the current world configuration to disk as a json file.
|
||||
-}
|
||||
saveConfig :: Config -> (a -> IO a) -> a -> IO a
|
||||
saveConfig cfig f x = do
|
||||
-- putStrLn "Saving config to data/dodge.config.json"
|
||||
BS.writeFile "data/dodge.config.json" $
|
||||
AEP.encodePretty' (AEP.Config (AEP.Spaces 2) compare AEP.Generic False) cfig
|
||||
f x
|
||||
|
||||
{- |
|
||||
Apply the volume settings from the world configuration to the running game.
|
||||
-}
|
||||
setVol :: Config -> IO ()
|
||||
setVol cfig = do
|
||||
setSoundVolume (_volume_master cfig * _volume_sound cfig)
|
||||
setMusicVolume (_volume_master cfig * _volume_music cfig)
|
||||
|
||||
{- |
|
||||
Apply /all/ of the values in the world configuration to the running game.
|
||||
-}
|
||||
applyWorldConfig ::
|
||||
Config ->
|
||||
PreloadData ->
|
||||
IO PreloadData
|
||||
applyWorldConfig cfig pdata = do
|
||||
setVol cfig
|
||||
renderData (renderDataResizeUpdate cfig) pdata
|
||||
+1
-1
@@ -10,7 +10,7 @@ import Data.ByteString.Lazy.Char8 (unpack)
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Coordinate
|
||||
import Dodge.Concurrent
|
||||
import Dodge.Config.Update
|
||||
import Dodge.Config
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Menu.Option
|
||||
import Dodge.Menu.OptionType
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
module Dodge.Room.Tutorial where
|
||||
|
||||
import Dodge.Item.Held.Utility
|
||||
import Control.Monad
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.IntSet as IS
|
||||
|
||||
Reference in New Issue
Block a user