Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 6 (modified by landauf, 16 years ago) (diff)

ConfigValueContainer

TracNav(TracNav/TOC_Development)?

Description

The ConfigValueContainer is a class that manages config-values. A config-value is a member-variable of a class that can be changed through the config-file. The config-file is usually orxonox.ini.

Every config-value has it's own ConfigValueContainer. The container is stored in a map inside the Identifier of the corresponding class. This way it's possible to iterate through all ConfigValueContainers of a class.

A ConfigValueContainer for a specific config-value is either created as soon as a class declares the config-value or when a new config-file with a new value gets loaded.

Creating a new config-value

A new config-value can be defined by using the SetConfigValue(varname, defvalue) macro where varname is a member variable of a class and defvalue the default value that will be used if no other value is configured. The macro-call must take place within the setConfigValues() function of this class.

Calling setConfigValues() of an object causes all ConfigValueContainers of it's class to assign the stored values to the variables of the object. The values are initially read from the config-file but can be changed during the game by using a ConsoleCommand in the Shell? ("config classname varname value"). It's possible to change variables only temporary without saving the new value in the config-file ("tconfig classname varname value").

See ConfigValueIncludes for more information about how to create and modify different types of config-values.