HoverRace
2.0
|
Global configuration manager, shared by all aspects of the system. More...
#include <Config.h>
Classes | |
struct | app_t |
struct | audio_t |
struct | cameraHash_t |
struct | controlsHash_t |
See Client/Control/Controller.h for the hash function. More... | |
struct | i18n_t |
struct | misc_t |
struct | net_t |
struct | player_t |
struct | runtime_t |
struct | ui_t |
struct | video_t |
Public Member Functions | |
~Config () | |
OS::path_t | GenerateScreenshotPath (const std::string &ext) const |
Generates a new unique file for the screenshot. More... | |
OS::path_t | GetBaseConfigPath () const |
Determine the OS-specific private configuration directory. More... | |
OS::path_t | GetBaseDataPath () const |
Determine the OS-specific private data directory. More... | |
const int & | GetBuild () const |
Retrieve the build number of the version. More... | |
OS::path_t | GetConfigFilename () const |
const std::string & | GetDefaultFontName () const |
Retrieve the default UI font name. More... | |
OS::path_t | GetDefaultMediaPath () |
Retrieve the OS-specific default media path. More... | |
const std::string & | GetDefaultMonospaceFontName () const |
Retrieve the default font name for monospace text (e.g. More... | |
const std::string & | GetDefaultSymbolFontName () const |
Retrieve the default font name for symbols. More... | |
const std::string & | GetFullVersion () const |
Retrieve the long form (x.x.x.x) of the version number. More... | |
Locale & | GetLocale () |
const OS::path_t & | GetMediaPath () const |
Retrieve the directory for media files. More... | |
OS::path_t | GetMediaPath (const std::string &file) const |
Retrieve the path to a media file. More... | |
const OS::path_t & | GetProfilePath () const |
Retrieve the path to where local user profiles are stored. More... | |
OS::path_t | GetProfilePath (const std::string &uid) const |
Retrieve the path to a specific user profile. More... | |
Parcel::ResBundle & | GetResBundle () const |
OS::path_t | GetScriptHelpPath (const std::string &className) const |
Retrieve the path to the help file for a class in the scripting API. More... | |
Parcel::TrackBundle & | GetTrackBundle () const |
const std::string & | GetUserAgentId () const |
Retrieve the user agent identifier used for HTTP requests. More... | |
const OS::path_t & | GetUserTrackPath () const |
Retrieve the path to where downloaded and user-installed tracks are stored. More... | |
OS::path_t | GetUserTrackPath (const std::string &name) const |
Retrieve the path to a downloaded track. More... | |
const std::string & | GetVersion () const |
Retrieve the short form (x.x or x.x.x) of the version number. More... | |
bool | IsPrerelease () const |
Check if this build is a prerelease (development) version. More... | |
bool | IsUnlinked () const |
Check if saving the config to disk is disabled. More... | |
void | Load () |
Load the configuration. More... | |
void | ResetToDefaults () |
Resets the configuration to the default "factory" settings. More... | |
void | Save () const |
Save the configuration. More... | |
void | SetUnlinked (bool unlinked) |
Enable or disable saving the configuration to disk. More... | |
std::shared_ptr< Parcel::ResBundle > | ShareResBundle () const |
std::shared_ptr< Parcel::TrackBundle > | ShareTrackBundle () const |
Retrieve the track bundle. More... | |
Static Public Member Functions | |
static OS::path_t | GetDefaultChatLogPath () |
Retrieve the default path for the chat log. More... | |
static std::string | GetDefaultRoomListUrl () |
Retrieve the default URL for the IMR room list. More... | |
static OS::path_t | GetDefaultScreenshotPath () |
Retrieve the default path for screenshots. More... | |
static std::string | GetDefaultUpdateServerUrl () |
Retrieve the default URL for the update server list. More... | |
static Config * | GetInstance () |
static Config & | Init (const std::string &packageName, int verMajor, int verMinor, int verPatch, int verBuild, bool prerelease, const OS::path_t &mediaPath, const OS::path_t &sysCfgPath, const OS::path_t &path={}) |
Initialize the singleton instance. More... | |
Public Attributes | |
struct HoverRace::Util::Config::app_t | app |
struct HoverRace::Util::Config::audio_t | audio |
struct HoverRace::Util::Config::cameraHash_t | cameraHash |
struct HoverRace::Util::Config::controlsHash_t | controlsHash [MAX_PLAYERS] |
struct HoverRace::Util::Config::i18n_t | i18n |
struct HoverRace::Util::Config::misc_t | misc |
struct HoverRace::Util::Config::net_t | net |
struct HoverRace::Util::Config::player_t | player |
struct HoverRace::Util::Config::runtime_t | runtime |
struct HoverRace::Util::Config::ui_t | ui |
struct HoverRace::Util::Config::video_t | video |
Static Public Attributes | |
static const int | MAX_PLAYERS = 4 |
static const std::string | TRACK_EXT |
Private Member Functions | |
Config (const std::string &packageName, int verMajor, int verMinor, int verPatch, int verBuild, bool prerelease, const OS::path_t &mediaPath, const OS::path_t &sysCfgPath, const OS::path_t &path={}) | |
Create a new instance using the specified directory. More... | |
void | AppendPackageSubdir (OS::path_t &path) const |
Append our package namespace to the base configuration directory. More... | |
void | LoadSystem () |
void | LoadSystem (const OS::path_t &path) |
void | SaveVersion (yaml::Emitter &) const |
Static Private Member Functions | |
static OS::path_t | GetDefaultBasePath () |
Determine the OS-specific default configuration directory. More... | |
Private Attributes | |
OS::path_t | cfgPath |
Base path for config files. More... | |
OS::path_t | dataPath |
Base path for data files. More... | |
std::string | defaultFontName |
std::string | defaultMonospaceFontName |
std::string | defaultSymbolFontName |
std::string | fullVersion |
std::unique_ptr< Locale > | locale |
OS::path_t | mediaPath |
std::string | packageName |
bool | prerelease |
OS::path_t | profilePath |
std::shared_ptr< Parcel::ResBundle > | resBundle |
std::string | shortVersion |
OS::path_t | sysCfgPath |
std::shared_ptr< Parcel::TrackBundle > | trackBundle |
bool | unlinked |
if true , will prevent saving config. More... | |
std::string | userAgentId |
OS::path_t | userTrackPath |
int | verBuild |
xdgHandle * | xdg |
Static Private Attributes | |
static std::unique_ptr< Config > | instance {} |
Global configuration manager, shared by all aspects of the system.
|
private |
Create a new instance using the specified directory.
packageName | The name of the application for shared data files. |
verMajor | The major (first) component of the version number. |
verMinor | The minor (second) component of the version number. |
verPatch | The patch (third) component of the version number. |
verBuild | The build (fourth) component of the version number. |
prerelease | Whether this build is a development version. |
mediaPath | (Optional) The directory for finding media files. The default is to use GetDefaultMediaPath(). |
sysCfgPath | (Optional) The directory to use for the system config file. The default is to search a platform-specific list of directories. |
path | (Optional) The directory for storing configuration data. The default is to use GetBaseDataPath() and GetBaseConfigPath(). |
HoverRace::Util::Config::~Config | ( | ) |
|
private |
Append our package namespace to the base configuration directory.
path | The path to append the namespace onto. |
OS::path_t HoverRace::Util::Config::GenerateScreenshotPath | ( | const std::string & | ext | ) | const |
Generates a new unique file for the screenshot.
ext | The extension to use on the generated filename. |
Exception | The path could not be generated. |
OS::path_t HoverRace::Util::Config::GetBaseConfigPath | ( | ) | const |
Determine the OS-specific private configuration directory.
OS::path_t HoverRace::Util::Config::GetBaseDataPath | ( | ) | const |
Determine the OS-specific private data directory.
const int & HoverRace::Util::Config::GetBuild | ( | ) | const |
Retrieve the build number of the version.
OS::path_t HoverRace::Util::Config::GetConfigFilename | ( | ) | const |
|
staticprivate |
Determine the OS-specific default configuration directory.
Note: This is the top-level directory for per-user data, without our package namespace.
ConfigExn | if unable to retrieve the default directory. |
|
static |
Retrieve the default path for the chat log.
const std::string & HoverRace::Util::Config::GetDefaultFontName | ( | ) | const |
Retrieve the default UI font name.
OS::path_t HoverRace::Util::Config::GetDefaultMediaPath | ( | ) |
Retrieve the OS-specific default media path.
First, we look for a config file in the current directory, then in the system-global directory (if applicable), then finally the relative directory.
const std::string & HoverRace::Util::Config::GetDefaultMonospaceFontName | ( | ) | const |
Retrieve the default font name for monospace text (e.g.
the console).
|
static |
Retrieve the default URL for the IMR room list.
|
static |
Retrieve the default path for screenshots.
const std::string & HoverRace::Util::Config::GetDefaultSymbolFontName | ( | ) | const |
Retrieve the default font name for symbols.
|
static |
Retrieve the default URL for the update server list.
const std::string & HoverRace::Util::Config::GetFullVersion | ( | ) | const |
Retrieve the long form (x.x.x.x) of the version number.
|
inlinestatic |
|
inline |
const OS::path_t & HoverRace::Util::Config::GetMediaPath | ( | ) | const |
Retrieve the directory for media files.
OS::path_t HoverRace::Util::Config::GetMediaPath | ( | const std::string & | file | ) | const |
Retrieve the path to a media file.
file | The media filename (may not be blank). |
const OS::path_t & HoverRace::Util::Config::GetProfilePath | ( | ) | const |
Retrieve the path to where local user profiles are stored.
OS::path_t HoverRace::Util::Config::GetProfilePath | ( | const std::string & | uid | ) | const |
Retrieve the path to a specific user profile.
uid | The UID of the profile, as a string. |
Player::ProfileExn | The UID was in an invalid format. |
|
inline |
OS::path_t HoverRace::Util::Config::GetScriptHelpPath | ( | const std::string & | className | ) | const |
Retrieve the path to the help file for a class in the scripting API.
className | The name of the class. |
|
inline |
const std::string & HoverRace::Util::Config::GetUserAgentId | ( | ) | const |
Retrieve the user agent identifier used for HTTP requests.
const OS::path_t & HoverRace::Util::Config::GetUserTrackPath | ( | ) | const |
Retrieve the path to where downloaded and user-installed tracks are stored.
OS::path_t HoverRace::Util::Config::GetUserTrackPath | ( | const std::string & | name | ) | const |
Retrieve the path to a downloaded track.
name | The track filename (may not be blank). If the filename does not end in ".trk", it will be appended automatically. |
const std::string & HoverRace::Util::Config::GetVersion | ( | ) | const |
Retrieve the short form (x.x or x.x.x) of the version number.
|
static |
Initialize the singleton instance.
packageName | The name of the application for shared data files. |
verMajor | The major (first) component of the version number. |
verMinor | The minor (second) component of the version number. |
verPatch | The patch (third) component of the version number. |
verBuild | The build (fourth) component of the version number. |
prerelease | Whether this build is a development version. |
mediaPath | (Optional) The directory for finding media files. The default is to use GetDefaultMediaPath(). |
sysCfgPath | (Optional) The directory to use for the system config file. The default is to search a platform-specific list of directories. |
path | (Optional) The directory for storing configuration data. The default is to use GetBaseDataPath() and GetBaseConfigPath(). |
bool HoverRace::Util::Config::IsPrerelease | ( | ) | const |
Check if this build is a prerelease (development) version.
true
if prerelease. bool HoverRace::Util::Config::IsUnlinked | ( | ) | const |
Check if saving the config to disk is disabled.
true
if saving is disabled. void HoverRace::Util::Config::Load | ( | ) |
Load the configuration.
Does nothing if the configuration file doesn't exist.
ConfigExn | If an error occurs while reading. |
|
private |
|
private |
void HoverRace::Util::Config::ResetToDefaults | ( | ) |
Resets the configuration to the default "factory" settings.
void HoverRace::Util::Config::Save | ( | ) | const |
Save the configuration.
std::exception | If an error occurs while saving. |
|
private |
void HoverRace::Util::Config::SetUnlinked | ( | bool | unlinked | ) |
Enable or disable saving the configuration to disk.
This is useful for testing, since it allows temporary changes without overwriting the config previously saved to disk.
unlinked | true to prevent saving config to disk. |
|
inline |
|
inline |
Retrieve the track bundle.
nullptr
). struct HoverRace::Util::Config::app_t HoverRace::Util::Config::app |
struct HoverRace::Util::Config::audio_t HoverRace::Util::Config::audio |
struct HoverRace::Util::Config::cameraHash_t HoverRace::Util::Config::cameraHash |
|
private |
Base path for config files.
struct HoverRace::Util::Config::controlsHash_t HoverRace::Util::Config::controlsHash[MAX_PLAYERS] |
|
private |
Base path for data files.
|
private |
|
private |
|
private |
|
private |
struct HoverRace::Util::Config::i18n_t HoverRace::Util::Config::i18n |
|
staticprivate |
|
private |
|
static |
|
private |
struct HoverRace::Util::Config::misc_t HoverRace::Util::Config::misc |
struct HoverRace::Util::Config::net_t HoverRace::Util::Config::net |
|
private |
struct HoverRace::Util::Config::player_t HoverRace::Util::Config::player |
|
private |
|
private |
|
private |
struct HoverRace::Util::Config::runtime_t HoverRace::Util::Config::runtime |
|
private |
|
private |
|
static |
|
private |
struct HoverRace::Util::Config::ui_t HoverRace::Util::Config::ui |
|
private |
if true
, will prevent saving config.
|
private |
|
private |
|
private |
struct HoverRace::Util::Config::video_t HoverRace::Util::Config::video |
|
private |