Skip to content

Adding New Config Options

shartte edited this page Apr 8, 2015 · 1 revision

The config system (TemplePlus.ini) currently supports the following data types:

  • string
  • double
  • int
  • bool

To get a new config option, simply add your config field to config.h (don't forget to set a default value) with the right data type. Let's say it's int myField. Then you can access it from anywhere by including config.h and accessing config.myField, since config is a global variable.

To make the config system actually read and write your new config variable from and to TemplePlus.ini, go into config.cpp to the array of configuration options:

static ConfigSetting configSettings[] = {
	CONF_BOOL(skipIntro),
	CONF_BOOL(skipLegal),
        ...
};

Add your configuration option to the end of that list using one of the provided macros:

  • CONF_BOOL for fields of type bool
  • CONF_INT for fields of type int
  • CONF_STRING for fields of type string
  • CONF_DOUBLE for fields of type double

So using our example from above: CONF_INT(myField)

Clone this wiki locally