Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/ConfigFileManager


Ignore:
Timestamp:
Oct 7, 2008, 11:33:38 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/ConfigFileManager

    v1 v1  
     1= !ConfigFileManager =
     2[[TracNav(TracNav/TOC_Development)]]
     3
     4== Description ==
     5The !ConfigFileManager loads and saves config-files. Config-files are a list of [wiki:howto/ConfigValue config-values] divided into sections. Usually one section corresponds to une class and one config-value corresponds to one variable of this class. Read [wiki:howto/ConfigFile this guide] to learn more about how to edit the config-file.
     6
     7General structure of a config-file:
     8{{{
     9[Section1]
     10variable1=value
     11variable2=value
     12
     13[Section2]
     14other_variable1=value
     15other_variable2=value
     16other_variable3=value
     17
     18...
     19}}}
     20
     21== Types ==
     22There are several types of config-files, denoted by an enum:
     23 * '''CFT_Settings''': Normal config file, usually {{{orxonox.ini}}}
     24 * '''CFT_Keybindings''': Keybinding file, usually {{{keybindings.ini}}}
     25 * '''CFT_JoyStickCalibration''': Special file for joystick callibration
     26
     27== Usage ==
     28=== Load ===
     29 * '''setFile('''''type, filename''''')''': Sets the path to the config-file of the given type (CFT_Settings, CFT_Keybindings, CFT_JoyStickCalibration) and loads the file.
     30
     31 * '''load('''''type''''')''': Reloads the config-file of the given type if the path was already set by setFile, else loads the default file.
     32
     33When loading a config-file, the file is parsed into sections and values. Each value belongs to a section, each section usually belongs to a class. For every value a [wiki:ConfigValueContainer] is created to store the value. The container is then stored in the [wiki:Identifier] of the corresponding class (usually denoted by the section). This allows new instances of a class to get the loaded config-values without parsing the file every time.
     34
     35=== Save ===
     36 * '''load('''''type''''')''': Saves the config-file of the given type if the path was already set by setFile, else saves the default file.
     37
     38When saving a config-file, every existing [wiki:ConfigValueContainer] writes it's value into the file, grouped into sections (where a section usually corresponds to a class). New config-values and sections are automatically added to the file.
     39
     40A config-file is usually saved after a config-value has changed (for example by using the '''config''' or '''keybind''' commands) except for temporary changes (for example by using '''tconfig''' or '''tkeybind''').