Config#
Defined in Config.hpp. Persistent key-value storage for plugin settings. Each plugin has its own config scope — keys don't collide between plugins.
Getters#
GetBool#
Returns the stored boolean value, or defaultValue if the key doesn't exist.
GetInt#
Returns the stored integer value, or defaultValue if the key doesn't exist.
GetFloat#
Returns the stored float value, or defaultValue if the key doesn't exist.
Setters#
SetBool#
Stores a boolean value. Not written to disk until Save() is called.
SetInt#
Stores an integer value.
SetFloat#
Stores a float value.
Save#
Writes all pending config changes to disk. Call this in on_unload() to persist settings.
Color Helpers#
GetColor#
Loads a Color from 4 integer keys: key_r, key_g, key_b, key_a. Returns defaultColor if keys don't exist.
SetColor#
Saves a Color as 4 integer keys: key_r, key_g, key_b, key_a.
Tip
GetColor/SetColor replace the tedious pattern of 4 separate GetInt/SetInt calls per color. The key suffixes (_r, _g, _b, _a) are added automatically.
Typical Pattern#
Load settings in on_load, save them in on_unload:
static bool g_enabled = true;
static float g_range = 50.f;
static int32_t g_mode = 0;
extern "C" void on_load()
{
g_enabled = Config::GetBool("enabled", true);
g_range = Config::GetFloat("range", 50.f);
g_mode = Config::GetInt("mode", 0);
}
extern "C" void on_unload()
{
Config::SetBool("enabled", g_enabled);
Config::SetFloat("range", g_range);
Config::SetInt("mode", g_mode);
Config::Save();
}
Note
Config is scoped per plugin — two plugins can both use the key "enabled" without conflicts.