IModGlobalSettings
The root of a mod's global settings: the tabs, and operations across the whole tree.
public interface IModGlobalSettingsThe root of a mod's global settings: the tabs, and operations across the whole tree. Handed to IGearsModApi.OnGlobalSettingsLoaded; also IGearsMod.GlobalSettings.
Methods
GetTab(String)
IGlobalModSettingsTab GetTab(string name);Returns the IGlobalModSettingsTab named name, or null.
CreateTab(String)
IGlobalModSettingsTab CreateTab(string name);Creates a tab whose display key is its name. Throws ArgumentException if a tab with that name exists.
CreateTab(String, String)
IGlobalModSettingsTab CreateTab(string name, string displayNameKey);Creates a tab with the given name and display key. Throws ArgumentException on a duplicate name.
GetOrCreateTab(String)
IGlobalModSettingsTab GetOrCreateTab(string name);Returns the existing tab named name, or creates it with its name as display key.
GetOrCreateTab(String, String)
IGlobalModSettingsTab GetOrCreateTab(string name, string displayNameKey);Returns the existing tab named name, or creates it with the given display key.
GetTabs()
List<IGlobalModSettingsTab> GetTabs();Returns every tab as a List<IGlobalModSettingsTab>.
GetAllGlobalSettings()
List<IGlobalModSetting> GetAllGlobalSettings();Returns every setting in every category of every tab, categories included, as a List<IGlobalModSetting>.
BindSettingsClass(Type)
void BindSettingsClass(Type settingsType);Binds a settings class. A type is bound once; later calls for it do nothing.
Scans settingsType for tagged static members carrying a "Tab.Category.Setting" path. Fields and properties tagged SettingAttribute are assigned the named setting first, then methods tagged SettingOnValueChangedAttribute, SettingOnSelectedChangedAttribute, SettingOnAppliedAttribute or SettingOnEnabledAttribute are subscribed.
Call this from IGearsModApi.InitMod. ModSettings.xml is read before that callback, so every setting exists by then, and one InitMod can bind the world class too. Binding is a one-time wiring job; use SyncSettingsToClass in OnGlobalSettingsLoaded for the values.
This binds and nothing else. No listener is called, whether or not it asked for IncludeInSync. Calling this again with a type already bound does nothing at all, so binding from OnGlobalSettingsLoaded instead is safe - just harder to follow.
Throws ArgumentNullException for null; every other problem is logged and that one member skipped. See the Bind Settings with Attributes guide.
SyncSettingsToClass(Type)
void SyncSettingsToClass(Type settingsType);Calls the opted-in value listeners on an already-bound class with the values their settings hold now.
Calls every method on settingsType tagged SettingOnValueChangedAttribute or SettingOnSelectedChangedAttribute with includeInSync: true, handing each the value its setting holds at that moment, exactly as if the event had fired. Nothing is bound or subscribed, so this is safe to call as often as you like.
Call it from OnGlobalSettingsLoaded, where the player's saved values are final, with the BindSettingsClass done earlier in InitMod. That starts a mod off in step with what is saved, rather than waiting for the first change.
A listener without IncludeInSync is skipped — it runs only when its event fires. Throws ArgumentNullException for null, and logs a type that has never been bound rather than doing anything.
When OnGlobalSettingsLoaded returns, Gears warns about every bound class that has an includeInSync listener and was not passed to this method during that callback. A class with no includeInSync listener is never reported.
SaveSettings()
void SaveSettings();Writes the player-level saved settings file now.