Move config options
This commit is contained in:
+10
-10
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ handleResizeEvent sev u = return . Just $ u
|
||||
x = fromIntegral x'
|
||||
y = fromIntegral y'
|
||||
V2 x' y' = windowSizeChangedEventSize sev
|
||||
divRes = resFactorNum $ u ^. config . resolution_factor
|
||||
divRes = resFactorNum $ u ^. config . graphics_resolution_factor
|
||||
|
||||
handlePressedMouseButton :: MouseButton -> Universe -> Maybe Universe
|
||||
handlePressedMouseButton but w = case (_hudElement (_hud $ _uvWorld w), but) of
|
||||
|
||||
+6
-6
@@ -77,11 +77,12 @@ debugMenuOptions :: [MenuOption]
|
||||
debugMenuOptions =
|
||||
[ doption ScancodeF debug_seconds_frame "SHOW SECONDS/FRAME" _debug_seconds_frame
|
||||
, doption ScancodeC debug_noclip "NOCLIP" _debug_noclip
|
||||
, doption ScancodeS debug_cr_status "SHOW CREATURE STATUS" _debug_cr_status
|
||||
, doption ScancodeT debug_cr_status "SHOW CREATURE STATUS" _debug_cr_status
|
||||
, doption ScancodeA debug_cr_awareness "SHOW CREATURE AWARENESS" _debug_cr_awareness
|
||||
, doption ScancodeV debug_view_boundaries "SHOW VIEW BOUNDARIES" _debug_view_boundaries
|
||||
, makeEnumOption ScancodeB debug_view_clip_bounds "SHOW ROOM CLIP" return
|
||||
, doption ScancodeP debug_pathing "SHOW PATHING" _debug_pathing
|
||||
, doption ScancodeS debug_show_sound "SHOW VISUAL SOUNDS" _debug_show_sound
|
||||
]
|
||||
where
|
||||
doption scode l t rec
|
||||
@@ -93,8 +94,7 @@ gameplayMenu = slTitleOptions
|
||||
|
||||
gameplayMenuOptions :: [MenuOption]
|
||||
gameplayMenuOptions =
|
||||
[ makeBoolOption ScancodeR rotate_to_wall "ROTATE TO WALL"
|
||||
, makeBoolOption ScancodeS show_sound "SHOW VISUAL SOUNDS"
|
||||
[ makeBoolOption ScancodeR gameplay_rotate_to_wall "ROTATE TO WALL"
|
||||
]
|
||||
|
||||
soundMenu :: ScreenLayer
|
||||
@@ -128,9 +128,9 @@ graphicsMenu = slTitleOptions "OPTIONS:GRAPHICS" graphicsMenuOptions
|
||||
|
||||
graphicsMenuOptions :: [MenuOption]
|
||||
graphicsMenuOptions =
|
||||
[ makeEnumOption ScancodeS resolution_factor "RESOLUTION" updateFramebufferSize
|
||||
, makeBoolOption ScancodeW wall_textured "WALL TEXTURES"
|
||||
, makeBoolOption ScancodeD cloud_shadows "CLOUD SHADOWS"
|
||||
[ makeEnumOption ScancodeS graphics_resolution_factor "RESOLUTION" updateFramebufferSize
|
||||
, makeBoolOption ScancodeW graphics_wall_textured "WALL TEXTURES"
|
||||
, makeBoolOption ScancodeD graphics_cloud_shadows "CLOUD SHADOWS"
|
||||
]
|
||||
|
||||
gameOverMenu :: ScreenLayer
|
||||
|
||||
@@ -26,4 +26,4 @@ updateFramebufferSize u = updatePreload divRes x y u
|
||||
where
|
||||
(x,y) = (round $ _windowX cfig, round $ _windowY cfig)
|
||||
cfig = _config u
|
||||
divRes = resFactorNum $ u ^. config . resolution_factor
|
||||
divRes = resFactorNum $ u ^. config . graphics_resolution_factor
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ doDrawing pdata u = do
|
||||
camzoom = _cameraZoom w
|
||||
trans = _cameraCenter w
|
||||
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
|
||||
resFact = resFactorNum $ cfig ^. resolution_factor
|
||||
resFact = resFactorNum $ cfig ^. graphics_resolution_factor
|
||||
(wallPointsCol,windowPoints) = wallsAndWindows cfig w
|
||||
lightPoints = lightsForGloom w
|
||||
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
||||
@@ -112,7 +112,7 @@ doDrawing pdata u = do
|
||||
0
|
||||
(fromIntegral nWalls)
|
||||
--draw walls onto base buffer
|
||||
if cfig ^. wall_textured
|
||||
if cfig ^. graphics_wall_textured
|
||||
then renderTextureWalls pdata nWalls
|
||||
else renderBlankWalls pdata nWalls
|
||||
--draw object pictures onto base buffer
|
||||
@@ -174,7 +174,7 @@ doDrawing pdata u = do
|
||||
renderLayer MidLayer shadV layerCounts
|
||||
--renderWindows pdata windowPoints
|
||||
drawShader (_windowShader pdata) nWins
|
||||
when (_cloud_shadows cfig) $ do
|
||||
when (_graphics_cloud_shadows cfig) $ do
|
||||
----render transparency depths
|
||||
depthMask $= Enabled
|
||||
blend $= Disabled
|
||||
|
||||
@@ -79,7 +79,7 @@ mcSPic bt = uncurryV translateSPf (_mcPos bt)
|
||||
|
||||
soundPics :: Configuration -> World -> Picture
|
||||
soundPics cfig w
|
||||
| _show_sound cfig = pictures $ M.map (soundPic cfig w) $ _playingSounds w
|
||||
| _debug_show_sound cfig = pictures $ M.map (soundPic cfig w) $ _playingSounds w
|
||||
| otherwise = []
|
||||
|
||||
soundPic :: Configuration -> World -> Sound -> Picture
|
||||
@@ -122,9 +122,9 @@ crDisplayInfo cfig w cr
|
||||
|
||||
drawCrInfo :: Configuration -> World -> Picture
|
||||
drawCrInfo cfig w
|
||||
-- | _debug_cr_awareness cfig = setLayer FixedCoordLayer
|
||||
-- $ renderInfoListsAt (2*hw - 200) 0 cfig w
|
||||
-- $ mapMaybe (crDisplayInfo cfig w) $ IM.elems $ _creatures w
|
||||
| _debug_cr_status cfig = setLayer FixedCoordLayer
|
||||
$ renderInfoListsAt (2*hw - 200) 0 cfig w
|
||||
$ mapMaybe (crDisplayInfo cfig w) $ IM.elems $ _creatures w
|
||||
| otherwise = mempty
|
||||
where
|
||||
hw = halfWidth cfig
|
||||
|
||||
@@ -97,7 +97,7 @@ zoomOutLongGun w
|
||||
|
||||
ifConfigWallRotate :: Configuration -> World -> World
|
||||
ifConfigWallRotate cfig w
|
||||
| _rotate_to_wall cfig && not (SDL.ButtonRight `S.member` _mouseButtons w)
|
||||
| _gameplay_rotate_to_wall cfig && not (SDL.ButtonRight `S.member` _mouseButtons w)
|
||||
= rotateToOverlappingWall w
|
||||
| otherwise = w
|
||||
|
||||
|
||||
Reference in New Issue
Block a user