module Game.LambdaHack.Config
( Config(..), ConfigUI(..), FovMode(..)
) where
import Data.Text (Text)
import Data.Binary
import qualified Game.LambdaHack.Key as K
data FovMode =
Shadow
| Permissive
| Digital Int
| Blind
deriving (Show, Read)
data Config = Config
{ configSelfString :: !String
, configCaves :: ![(Text, Text)]
, configDepth :: !Int
, configFovMode :: !FovMode
, configSmellTimeout :: !Int
, configBaseHP :: !Int
, configExtraHeroes :: !Int
, configFirstDeathEnds :: !Bool
, configFaction :: !Text
} deriving Show
data ConfigUI = ConfigUI
{
configCommands :: ![(K.Key, String)]
, configAppDataDir :: !FilePath
, configDiaryFile :: !FilePath
, configSaveFile :: !FilePath
, configBkpFile :: !FilePath
, configScoresFile :: !FilePath
, configRulesCfgFile :: !FilePath
, configUICfgFile :: !FilePath
, configHeroNames :: ![(Int, Text)]
, configMacros :: ![(K.Key, K.Key)]
, configFont :: !String
, configHistoryMax :: !Int
} deriving Show
instance Binary FovMode where
put Shadow = putWord8 0
put Permissive = putWord8 1
put (Digital r) = putWord8 2 >> put r
put Blind = putWord8 3
get = do
tag <- getWord8
case tag of
0 -> return Shadow
1 -> return Permissive
2 -> fmap Digital get
3 -> return Blind
_ -> fail "no parse (FovMode)"
instance Binary Config where
put Config{..} = do
put configSelfString
put configCaves
put configDepth
put configFovMode
put configSmellTimeout
put configBaseHP
put configExtraHeroes
put configFirstDeathEnds
put configFaction
get = do
configSelfString <- get
configCaves <- get
configDepth <- get
configFovMode <- get
configSmellTimeout <- get
configBaseHP <- get
configExtraHeroes <- get
configFirstDeathEnds <- get
configFaction <- get
return Config{..}
instance Binary ConfigUI where
put ConfigUI{..} = do
put configCommands
put configAppDataDir
put configDiaryFile
put configSaveFile
put configBkpFile
put configRulesCfgFile
put configUICfgFile
put configScoresFile
put configHeroNames
put configMacros
put configFont
put configHistoryMax
get = do
configCommands <- get
configAppDataDir <- get
configDiaryFile <- get
configSaveFile <- get
configBkpFile <- get
configScoresFile <- get
configRulesCfgFile <- get
configUICfgFile <- get
configHeroNames <- get
configMacros <- get
configFont <- get
configHistoryMax <- get
return ConfigUI{..}