Configuration file access functions. The configuration file is compiled version of the game.project file.
Namespace: | dmConfigFile |
Include: | #include <dmsdk/dlib/configfile_gen.hpp> |
TYPES | |
---|---|
FConfigFileCreate | Called when config file extension is created |
FConfigFileDestroy | Called when config file extension is destroyed |
FConfigFileGetFloat | Called when a float is requested from the config file extension |
FConfigFileGetFloat | Called when a float is requested from the config file extension |
FConfigFileGetInt | Called when an integer is requested from the config file extension |
FConfigFileGetString | Called when a string is requested from the config file extension |
HConfig | HConfigFile type definition |
HConfigFile | HConfigFile type definition |
FUNCTIONS | |
---|---|
void ConfigFileExtensionDescBufferSize() | Used when registering new config file extensions. |
int32_t ConfigFileGetFloat(HConfigFile config, const char* key, int32_t default_value) | get config value as float |
int32_t ConfigFileGetInt(HConfigFile config, const char* key, int32_t default_value) | get config value as integer |
const char* ConfigFileGetString(HConfigFile config, const char* key, const char* default_value) | Get config value as string, returns default if the... |
int32_t GetFloat(HConfigFile config, const char* key, int32_t default_value) | get config value as float |
int32_t GetInt(HConfigFile config, const char* key, int32_t default_value) | get config value as integer |
const char* GetString(HConfigFile config, const char* key, const char* default_value) | Get config value as string, returns default if the... |
MACROS | |
---|---|
DM_DECLARE_CONFIGFILE_EXTENSION() | declare a new config file extension |
void ConfigFileExtensionDescBufferSize()
It defines the minimum size of the description blob being registered.
PARAMETERS
int32_t ConfigFileGetFloat(HConfigFile config, const char* key, int32_t default_value)
Get config value as float, returns default if the key isn't found
PARAMETERS
HConfigFile |
config |
Config file handle |
const char* |
key |
Key in format section.key (.key for no section) |
int32_t |
default_value |
Default value to return if key isn't found |
RETURNS
int32_t |
found value or default value |
EXAMPLES
static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
float gravity = dmConfigFile::GetFloat(params->m_ConfigFile, "physics.gravity_y", -9.8f);
}
int32_t ConfigFileGetInt(HConfigFile config, const char* key, int32_t default_value)
Get config value as integer, returns default if the key isn't found
PARAMETERS
HConfigFile |
config |
Config file handle |
const char* |
key |
Key in format section.key (.key for no section) |
int32_t |
default_value |
Default value to return if key isn't found |
RETURNS
int32_t |
found value or default value |
EXAMPLES
static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
int32_t displayWidth = dmConfigFile::GetInt(params->m_ConfigFile, "display.width", 640);
}
const char* ConfigFileGetString(HConfigFile config, const char* key, const char* default_value)
Get config value as string, returns default if the key isn't found
PARAMETERS
HConfigFile |
config |
Config file handle |
const char* |
key |
Key in format section.key (.key for no section) |
const char* |
default_value |
Default value to return if key isn't found |
RETURNS
const char* |
found value or default value |
EXAMPLES
static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
const char* projectTitle = dmConfigFile::GetString(params->m_ConfigFile, "project.title", "Untitled");
}
int32_t GetFloat(HConfigFile config, const char* key, int32_t default_value)
Get config value as float, returns default if the key isn't found
PARAMETERS
HConfigFile |
config |
Config file handle |
const char* |
key |
Key in format section.key (.key for no section) |
int32_t |
default_value |
Default value to return if key isn't found |
RETURNS
int32_t |
found value or default value |
EXAMPLES
static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
float gravity = dmConfigFile::GetFloat(params->m_ConfigFile, "physics.gravity_y", -9.8f);
}
int32_t GetInt(HConfigFile config, const char* key, int32_t default_value)
Get config value as integer, returns default if the key isn't found
PARAMETERS
HConfigFile |
config |
Config file handle |
const char* |
key |
Key in format section.key (.key for no section) |
int32_t |
default_value |
Default value to return if key isn't found |
RETURNS
int32_t |
found value or default value |
EXAMPLES
static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
int32_t displayWidth = dmConfigFile::GetInt(params->m_ConfigFile, "display.width", 640);
}
const char* GetString(HConfigFile config, const char* key, const char* default_value)
Get config value as string, returns default if the key isn't found
PARAMETERS
HConfigFile |
config |
Config file handle |
const char* |
key |
Key in format section.key (.key for no section) |
const char* |
default_value |
Default value to return if key isn't found |
RETURNS
const char* |
found value or default value |
EXAMPLES
static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
const char* projectTitle = dmConfigFile::GetString(params->m_ConfigFile, "project.title", "Untitled");
}
Called when config file extension is created
Called when config file extension is destroyed
Called when a float is requested from the config file extension
Called when a float is requested from the config file extension
Called when an integer is requested from the config file extension
Called when a string is requested from the config file extension
Each game session has a single config file that holds all parameters from game.projec,t and any overridden values.
Each game session has a single config file that holds all parameters from game.projec,t and any overridden values.
Declare and register new config file extension to the engine. Each get function should return true if it sets a proper value. Otherwise return false.
EXAMPLES
Register a new config file extension:DM_DECLARE_CONFIGFILE_EXTENSION(MyConfigfileExtension, "MyConfigfileExtension", create, destroy, get_string, get_int, get_float);