Skip to content

Settings.md

cfloutier edited this page Apr 27, 2024 · 4 revisions

Settings is used for 2 purposes :

  • Save user preferences
  • Bind the internal mod values with UI controls

All internal values of the mod could used one setting class to keep data saved and shared with UI.

Setting

this is a generic class that can be used for main primitives including :

  • string
  • boolean
  • integer
  • float
  • double
  • Color
  • Vector3

other types could be added later if needed

constructor

public Setting(string key, T default_value)
  • the key is used to define where the value will be saved in the settings file. If key is null or empty it just won't be saved, the default value will be the same on startup
  • the default_value, defines the initial value, it will be overloaded on settings first load.

ex : Define your setting value like that

public Setting<bool> bool_item = new Setting<bool>("my_settings.bool_item", true);

value

the value is a property

ex:

    bool_item.value = true;

   if (bool_item.value) ...

Reset

the default value can be recovered using the Reset function

Reset

Clone this wiki locally