Improve configuration handling

This commit is contained in:
jgk
2021-04-08 02:48:25 +02:00
parent ddb1171e2e
commit f1214c0584
14 changed files with 118 additions and 54 deletions
+22
View File
@@ -0,0 +1,22 @@
{-|
IO actions that apply config side effects and save it to disk.
-}
module Dodge.Config.Update
where
import Dodge.Data
import Dodge.LoadConfig
import Sound
import Data.Aeson (encodeFile)
import Control.Monad (when)
updateDodgeConfig :: World -> IO ()
updateDodgeConfig w = case _menuLayers w of
(ConfigSaveScreen _: _) -> do
putStrLn "Saving config"
encodeFile "data/dodge.config.json" cfig
_ -> when (_configNeedsUpdate w) $ do
setSoundVolume ( _volume_master cfig * _volume_sound cfig)
setMusicVolume ( _volume_master cfig * _volume_music cfig)
where
cfig = _config w