TraGUS
Godot plugin for user settings
Loading...
Searching...
No Matches
UserSettingsServer Class Reference

The User Settings Manager. Handles configuration files and stores and manage settings states at runtime.
It should be an autoload, and be loaded before any UserSetting. More...

Inheritance diagram for UserSettingsServer:
[legend]
Collaboration diagram for UserSettingsServer:
[legend]

Public Member Functions

void Save ()
 Writes the current modifications into the user's .ini config file.
 
void Abort ()
 Aborts the current config modifications, and restores the active settings to the user's .ini config file.
 
void Load ()
 Effectively loads the current state of the configuration into the run-time UserSetting settings.
 
bool TryLoadSetting (string section, string settingKey, Variant value, out Variant effectiveValue)
 Tries to load the provided config.ini entry in the settings server.
 
void ResetSection (string section)
 Tries to reset all the settings from the specified section to the values specified in tragus_default_settings.ini.
This DOES NOT apply the changes to the user's config file. For that, you must still call Save afterwards.
 
void ResetAll ()
 Tries to reset all the settings to the value specified in tragus_default_settings.ini.
This DOES NOT apply the changes to the user's config file. For that, you must still call Save afterwards.
 
override void _EnterTree ()
 

Static Public Member Functions

static bool Default (UserSetting setting, out Variant value)
 Tries to retrieve the saved default value of this setting from tragus_default_settings.ini
 
static bool Init (UserSetting setting, out Variant value)
 Tries to retrieve the initial value of the setting, using the user's .ini config file if possible and the tragus_default_settings.ini otherwise.
 
static bool TryRegisterSetting (UserSetting setting)
 Tries to register the provided setting, using its UserSetting.Section and UserSetting.Key.
 
static bool TryUnregisterSetting (UserSetting setting)
 Tries to unregister the provided setting, using its UserSetting.Section and UserSetting.Key.
 
static bool GetSetting (string section, string key, out UserSetting setting)
 
static bool Reset (UserSetting setting)
 Tries to reset the setting to the value specified in tragus_default_settings.ini, if present.
This DOES NOT apply the changes to the user's config file. For that, you must still call Save afterwards.
 

Properties

static UserSettingsServer Instance [get, private set]
 The autoload Instance of this setting.
 
ConfigFile Config [get, private set]
 The config file edited on-the-go.
 
ConfigFile DefaultConfig [get, private set]
 The preloaded default config file.
 

Private Types

enum  LoadResult { Success , SectionNotFound , KeyNotFound , ValueRejected }
 

Static Private Member Functions

static LoadResult LoadSetting (string section, string key, Variant value, out Variant effectiveValue)
 Tries to load the provided config.ini entry in the settings server.
 

Private Attributes

Dictionary< string, Dictionary< string, UserSetting > > _settings = []
 The purpose of this hashmap is so that we can easily load from .ini config file.

The inner hashmap references user settings by their .ini key.
The outer hashmap references the inner hashmap, by their .ini section.

See LoadSetting for an example.
 

Static Private Attributes

const string SettingsFilePath = "user://settings.ini"
 
const string DefaultSettingsFilePath = "res://tragus_default_settings.ini"
 

Detailed Description

The User Settings Manager. Handles configuration files and stores and manage settings states at runtime.
It should be an autoload, and be loaded before any UserSetting.


The documentation for this class was generated from the following files: