Reify debug booleans

This commit is contained in:
2022-06-17 21:34:00 +01:00
parent 261bb0bb6b
commit 5053590792
10 changed files with 73 additions and 49 deletions
+32 -22
View File
@@ -3,6 +3,7 @@
{-# LANGUAGE StrictData #-}
module Dodge.Config.Data where
import Data.Aeson
import qualified Data.Set as S
import GHC.Generics
import Control.Lens
data Configuration = Configuration
@@ -18,20 +19,23 @@ data Configuration = Configuration
, _windowPosX :: Int
, _windowPosY :: Int
, _gameplay_rotate_to_wall :: Bool
, _debug_show_sound :: Bool
, _debug_seconds_frame :: Bool
, _debug_noclip :: Bool
, _debug_cr_status :: Bool
, _debug_cr_awareness :: Bool
, _debug_mouse_position :: Bool
, _debug_view_boundaries :: Bool
, _debug_walls :: Bool
, _debug_view_clip_bounds :: RoomClipping
, _debug_pathing :: Bool
, _debug_remove_LOS :: Bool
, _debug_cull_more_lights :: Bool
, _debug_booleans :: S.Set DebugBool -- consider using Data.BitSet
}
deriving (Generic, Show)
data DebugBool
= Show_sound
| Show_ms_frame
| Noclip
| Cr_status
| Cr_awareness
| Mouse_position
| View_boundaries
| Walls_info
| Pathing
| Remove_LOS
| Cull_more_lights
deriving (Generic, Eq,Ord,Bounded, Enum, Show)
data ResFactor = FullRes | HalfRes | QuarterRes
deriving (Generic, Show, Eq, Ord, Enum, Bounded)
instance ToJSON ResFactor where
@@ -49,10 +53,13 @@ resFactorNum rf = case rf of
QuarterRes -> 4
makeLenses ''Configuration
instance ToJSON DebugBool where
toEncoding = genericToEncoding defaultOptions
instance ToJSON Configuration where
toEncoding = genericToEncoding defaultOptions
instance FromJSON DebugBool
instance FromJSON Configuration
defaultConfig :: Configuration
@@ -69,16 +76,19 @@ defaultConfig = Configuration
, _windowPosX = 0
, _windowPosY = 0
, _gameplay_rotate_to_wall = True
, _debug_show_sound = False
, _debug_seconds_frame = True
, _debug_noclip = False
, _debug_mouse_position = False
, _debug_cr_status = False
, _debug_cr_awareness = False
, _debug_view_boundaries = False
, _debug_booleans = S.singleton Show_ms_frame
, _debug_view_clip_bounds = NoRoomClipBoundaries
, _debug_pathing = False
, _debug_walls = False
, _debug_remove_LOS = False
, _debug_cull_more_lights = False
-- , _debug_show_sound = False
-- , _debug_seconds_frame = True
-- , _debug_noclip = False
-- , _debug_mouse_position = False
-- , _debug_cr_status = False
-- , _debug_cr_awareness = False
-- , _debug_view_boundaries = False
-- , _debug_pathing = False
-- , _debug_walls = False
-- , _debug_remove_LOS = False
-- , _debug_cull_more_lights = False
}
debugOn :: DebugBool -> Configuration -> Bool
debugOn db = S.member db . _debug_booleans