Add generic derivations and To/FromJSON instances

This commit is contained in:
2022-07-25 22:49:18 +01:00
parent f5604ef429
commit b8e8413daa
99 changed files with 1406 additions and 517 deletions
+15 -7
View File
@@ -1,14 +1,18 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.HUD where
import GHC.Generics
import Data.Aeson
import Geometry.Data
import Control.Lens
data HUDElement
= DisplayInventory {_subInventory :: SubInventory}
| DisplayCarte
deriving (Eq,Ord,Show,Read)
-- deriving (Eq,Ord,Show)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON HUDElement where
toEncoding = genericToEncoding defaultOptions
instance FromJSON HUDElement
data SubInventory
= NoSubInventory
| TweakInventory
@@ -16,16 +20,20 @@ data SubInventory
| InspectInventory
| LockedInventory
| DisplayTerminal {_termID :: Int }
deriving (Eq,Ord,Show,Read)
-- deriving (Eq,Ord,Show)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON SubInventory where
toEncoding = genericToEncoding defaultOptions
instance FromJSON SubInventory
data HUD = HUD
{ _hudElement :: HUDElement
, _carteCenter :: Point2
, _carteZoom :: Float
, _carteRot :: Float
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON HUD where
toEncoding = genericToEncoding defaultOptions
instance FromJSON HUD
makeLenses ''HUD
makeLenses ''HUDElement
makeLenses ''SubInventory