Gears

IModSetting

The members every setting shares, including categories.

InterfaceNamespace GearsAPI.SettingsAssembly GearsAPI.dllSource
public interface IModSetting

The members every setting shares, including categories: identity, display text, enabled state, the change flags, preview images, and the three operations the settings window performs.

Derived: IValueModSettingBase · IGlobalModSetting · IWorldModSetting

Properties

Name

string Name { get; }

Gets the setting's identity within its category. The name attribute in XML.

DisplayKey

string DisplayKey { get; }

Gets the localization key for the label. Falls back to Name when empty.

CaptionKey

string CaptionKey { get; set; }

Gets or sets the localization key for the short heading in the description pane.

DescriptionKey

string DescriptionKey { get; set; }

Gets or sets the localization key for the description text.

Enabled

bool Enabled { get; set; }

Gets or sets whether the setting can be changed in the menu. Starts true. On a value setting, global or world, while this is false assigning SelectedValue still changes the value but raises no OnSelectedChanged, and ApplyCurrentChange() does nothing at all.

IsChanged

bool IsChanged { get; }

Gets whether the selected value differs from the applied value.

IsDefault

bool IsDefault { get; }

Gets whether the applied value equals the default value.

Events

OnEnabled

event OnSettingEnabledEvent OnEnabled;

Occurs when Enabled changes to a different value. Type OnSettingEnabledEvent.

Methods

GetDisplayName()

string GetDisplayName();

Returns the localized label: Localization.Get(DisplayKey), or of Name when the key is empty.

HasCaption()

bool HasCaption();

Returns true if CaptionKey is set and not whitespace.

GetCaptionText()

string GetCaptionText();

Returns the localized caption, or the display name when there is no caption.

HasDescription()

bool HasDescription();

Returns true if DescriptionKey is set and not whitespace.

GetDescriptionText()

string GetDescriptionText();

Returns the localized description.

HasPreviews()

bool HasPreviews();

Returns true if the setting has any preview image.

GetCurrentPreview()

string GetCurrentPreview();

Returns the image path for the selected value, or the setting's own image when none is keyed to that value.

AddPreview(String)

void AddPreview(string path);

Sets the setting's own preview image path. The last call wins.

ResetToDefault()

void ResetToDefault();

Sets the selected value to the default value. The applied value is untouched, so call ApplyCurrentChange() after it to reset the value the mod acts on.

DiscardCurrentChange()

void DiscardCurrentChange();

Sets the selected value back to the applied value.

ApplyCurrentChange()

void ApplyCurrentChange();

Commits the selected value as the applied value, raising OnValueChanged and, on a global setting, OnSettingApplied. Does nothing on a value setting whose Enabled is false.

RefreshUI()

void RefreshUI();

Redraws this setting's row if the settings window is showing it, and registers the change with that window so Apply commits it and closing the window or switching mods discards it. Call this after changing SelectedValue, SettingValue or the allowed values from code; an assignment on its own changes nothing on screen and the window does not know the setting moved. Changing Enabled refreshes the row on its own and needs no call.

On this page