License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Swarm.Game.ResourceLoading
Description
Various utilities related to loading game data files.
Synopsis
- getDataDirSafe :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => AssetData -> FilePath -> m FilePath
- getDataFileNameSafe :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => AssetData -> FilePath -> m FilePath
- getSwarmConfigIniFile :: Bool -> IO (Bool, FilePath)
- getSwarmSavePath :: Bool -> IO FilePath
- getSwarmHistoryPath :: Bool -> IO FilePath
- getSwarmAchievementsPath :: Bool -> IO FilePath
- readAppData :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => m (Map Text Text)
- data NameGenerator = NameGenerator {}
- initNameGenerator :: Has (Throw SystemFailure) sig m => Map Text Text -> m NameGenerator
Generic data access
getDataDirSafe :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => AssetData -> FilePath -> m FilePath Source #
Get subdirectory from swarm data directory.
This will first look in Cabal generated path and then
try a data
directory in XdgData
path.
The idea is that when installing with Cabal/Stack the first is preferred, but when the players install a binary they need to extract the `data` archive to the XDG directory.
getDataFileNameSafe :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => AssetData -> FilePath -> m FilePath Source #
Get file from swarm data directory.
See the note in getDataDirSafe
.
Concrete data access
getSwarmSavePath :: Bool -> IO FilePath Source #
Get path to swarm saves, optionally creating necessary directories.
getSwarmHistoryPath :: Bool -> IO FilePath Source #
Get path to swarm history, optionally creating necessary directories.
getSwarmAchievementsPath :: Bool -> IO FilePath Source #
Get a path to the directory where achievement records are
stored. If the argument is set to True
, create the directory if
it does not exist.
Loading text files
readAppData :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => m (Map Text Text) Source #
Read all the .txt
files in the data/
directory.
data NameGenerator Source #
Read-only lists of adjectives and words for use in building random robot names
initNameGenerator :: Has (Throw SystemFailure) sig m => Map Text Text -> m NameGenerator Source #