The “configs” system is a key part of Dangerous Rays modding. A config is a XML file that contain a list of properties that can be read by the engine. The engine can then configure various things according to config properties values.
With the config system modders can modify a hudge amount of things like UI elements colors or define new terrain vegetation layers…
The engine will perform a sanity check of every config file at the game startup and will log any errors or warnings found in the dev console.

Here is what a config file syntax looks like:

<?xml version="1.0"?>
<config type="font">
    <property name="Font" type="resourcepath" value="Fonts/RobotoCondensed/RobotoCondensed-Bold.ttf" />
    <property name="Size" type="float" value="24.0" />
</config>



Each config have a:

  • Name used as an identifier. The config name is simply defined by it's XML file name.
  • Type that define what config type it is and what it will configure.

In the above example, it's a “Font” config type (so it's used to define a font used by the UI) and this config is named “Button”.


Each config property have a:

  • Name used as a property identifier.
  • Type that define if the property is a integer or decimal number, a file path, a resource path…
  • Value.

In the above example, we have two properties:

  • One “Font” property of “resourcepath” type that is used to define the resource path of the font.
  • One “Size” property of “float” (decimal number) type that is used to define the size of the font.

As mentioned above each config property must have an assigned type. Here is the list of variable type that you can assign to your properties.

Type Description Example
Int Integer number 46
Bool true or false true
float Decimal number 11.07
vector2 2 dimensional vector 2.0, 4.0
vector3 3 dimensional vector 2.0, 4.0, 6.0
vector4 4 dimensional vector 2.0, 4.0, 6.0, 8.0
color R G B A normalized (from 0.0 to 1.0) color values 1.0, 0.0, 0.0, 1.0
string A text string hello world !
intvector2 2 dimensional vector of integer numbers 2, 4
intvector3 3 dimensional vector of integer numbers 2, 4, 8
configname Config name myconfigname
filepath Complete file path C:/Folder/File.txt
resourcepath Resource path Core/Models/SM_Cube.mdl
soundeventname Sound Event Name /AmbientMusic/AmbientMusic01

Each registered config type must have one (and only one) default config. Here what a default config (for the “Font” config type) looks like:

<config type="font" default="true">
	<property name="Font" type="resourcepath" value="Fonts/Roboto/Roboto-Medium.ttf" />
	<property name="Size" type="float" value="18.0" />
	<property name="MergeIcons" type="bool" value="false" />
</config>

As you can see it is almost identical to a regular config. except that boolean attribute that is set to true:

default="true"

With that attribute we are specifying that this is the default config for the “Font” config type. In the default config you can see all properties that can be modified in any config of the same config type.
The main purpose of default configs is that they can be used as a fallback in case if some properties are missing from a config. Take this for example this default config:

<config type="font" default="true">
	<property name="Font" type="resourcepath" value="Fonts/Roboto/Roboto-Medium.ttf" />
	<property name="Size" type="float" value="18.0" />
	<property name="MergeIcons" type="bool" value="false" />
</config>

In the above default config there is 3 different properties that are declared. If we have another font config that look like this:

<config type="font">
	<property name="Size" type="float" value="32.0" />
</config>

You can see that only 1 property is declared but the default config for the “Font” config type have 3 declared properties. Is it a problem ? No !

In this case when the “MyFont01” config will be loaded the config system is going to read the missing properties value from the default config. So the properties are going to have those assigned values when the “MyFont01” config will be loaded:

  • Font: Fonts/Roboto/Roboto-Medium.ttf (value from default config)
  • Size: 32 (value from “MyFont01” config)
  • MergeIcons: False (value from default config)

This concept might be difficult to understand at first (especially if you are not familiar with Object Oriented Programming for example) but you will understand it by trying to make new configs and explore the existing configs of the game.

  • modding/config_system_documentation.txt
  • Last modified: 30/01/2019 15:16
  • by admin