Move config options

This commit is contained in:
2022-04-11 09:04:51 +01:00
parent ab2408b480
commit d46d315203
8 changed files with 30 additions and 31 deletions
+10 -10
View File
@@ -9,15 +9,15 @@ data Configuration = Configuration
{ _volume_master :: Float
, _volume_sound :: Float
, _volume_music :: Float
, _wall_textured :: Bool
, _cloud_shadows :: Bool
, _resolution_factor :: ResFactor
, _graphics_wall_textured :: Bool
, _graphics_cloud_shadows :: Bool
, _graphics_resolution_factor :: ResFactor
, _windowX :: Float
, _windowY :: Float
, _windowPosX :: Int
, _windowPosY :: Int
, _rotate_to_wall :: Bool
, _show_sound :: Bool
, _gameplay_rotate_to_wall :: Bool
, _debug_show_sound :: Bool
, _debug_seconds_frame :: Bool
, _debug_noclip :: Bool
, _debug_cr_status :: Bool
@@ -55,15 +55,15 @@ defaultConfig = Configuration
{ _volume_master = 1
, _volume_sound = 1
, _volume_music = 1
, _wall_textured = True
, _cloud_shadows = True
, _resolution_factor = FullRes
, _graphics_wall_textured = True
, _graphics_cloud_shadows = True
, _graphics_resolution_factor = FullRes
, _windowX = 800
, _windowY = 600
, _windowPosX = 0
, _windowPosY = 0
, _rotate_to_wall = True
, _show_sound = False
, _gameplay_rotate_to_wall = True
, _debug_show_sound = False
, _debug_seconds_frame = True
, _debug_noclip = False
, _debug_cr_status = False
+4 -5
View File
@@ -12,8 +12,7 @@ import Sound
import Data.Preload
import Preload.Update
--import Data.Aeson (encodeFile)
import Data.Aeson.Encode.Pretty (encodePretty)
import qualified Data.Aeson.Encode.Pretty as AEP
import qualified Data.ByteString.Lazy as BS
--import Control.Monad (when)
{- |
@@ -22,8 +21,8 @@ Write the current world configuration to disk as a json file.
saveConfig :: Configuration -> (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" $ encodePretty cfig
-- encodeFile "data/dodge.config.json" cfig
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.
@@ -50,4 +49,4 @@ applyWorldConfig cfig pdata = do
where
x = round $ _windowX cfig
y = round $ _windowY cfig
divRes = resFactorNum $ _resolution_factor cfig
divRes = resFactorNum $ _graphics_resolution_factor cfig