Class Core.Settings.Settings

Settings is the class that holds all the settings for the addon.

It maintains a list of setting groups, which in turn maintain a list of settings.

Local Functions

core.settings.settings.listSettings (groupMethod) Lists settings by invoking a method on each setting group.
core.settings.settings.maybeAddGeneralGroup () Maybe adds the general setting group to the list of setting groups if it doesn't already exist.
core.settings.settings.maybeCreateLibraryInstance () Maybe creates the library Settings instance if the library configuration is enabled.

Methods

core.settings.settings:addSetting (setting[, group='general']) Adds a setting to a group represented by its id.
core.settings.settings:addSettingGroup (settingGroup) Adds a setting group to the list of setting groups.
core.settings.settings:all () Gets all the setting instances that are stored in the setting groups.
core.settings.settings:allAccessibleByCommand () Gets all the command accessible setting instances that are stored in the setting groups.
core.settings.settings:hasSettings ([settingGroupMethod='hasSettings']) Determines whether the addon has at least one setting.
core.settings.settings:hasSettingsAccessibleByCommand () Determines whether the addon has at least one setting that is accessible by command.
core.settings.settings:mapFromAddonProperties () Gets all the settings that were configured in the addon properties to convert them into real setting and setting group instances.
core.settings.settings:setting (settingFullyQualifiedId) Gets a setting instance by its fully qualified id.

Metamethods

core.settings.settings:__construct () Settings constructor.


Local Functions

Methods
core.settings.settings.listSettings (groupMethod)
Lists settings by invoking a method on each setting group.

Parameters:

  • groupMethod string The method to be called for each setting group

Returns:

    table[Core.Settings.Setting] The setting instances
core.settings.settings.maybeAddGeneralGroup ()
Maybe adds the general setting group to the list of setting groups if it doesn't already exist.
core.settings.settings.maybeCreateLibraryInstance ()
Maybe creates the library Settings instance if the library configuration is enabled.

This method works as a static method that shouldn't be called directly by addons. It's just a way to isolate its logic from the library onLoad callback, which is the only place where it should be called.

If configuration is not enabled, this method will bail out early and won't create any Settings instance.

Methods

core.settings.settings:addSetting (setting[, group='general'])
Adds a setting to a group represented by its id.

Parameters:

  • setting Core.Settings.Setting The setting to be added
  • group string The id of the group to which the setting will be added (default 'general')

Returns:

    Core.Settings.Settings self
core.settings.settings:addSettingGroup (settingGroup)
Adds a setting group to the list of setting groups.

Parameters:

Returns:

    Core.Settings.Settings self
core.settings.settings:all ()
Gets all the setting instances that are stored in the setting groups.

Returns:

    table[Core.Settings.Setting] The setting instances
core.settings.settings:allAccessibleByCommand ()
Gets all the command accessible setting instances that are stored in the setting groups.

Returns:

    table[Core.Settings.Setting] The setting instances that are accessible by command
core.settings.settings:hasSettings ([settingGroupMethod='hasSettings'])
Determines whether the addon has at least one setting.

This method accepts an optional parameter that allows the caller to specify the method to be called for each setting group to determine whether it has at least one setting. With that, it's possible to add more filters in the future without replicating the same logic.

Parameters:

  • settingGroupMethod string The method to be called for each setting group (default 'hasSettings')

Returns:

    boolean Whether the addon has at least one setting
core.settings.settings:hasSettingsAccessibleByCommand ()
Determines whether the addon has at least one setting that is accessible by command.

Returns:

    boolean Whether the addon has at least one setting that is accessible by command
core.settings.settings:mapFromAddonProperties ()
Gets all the settings that were configured in the addon properties to convert them into real setting and setting group instances.

Although not a local method, addons shouldn't call this method directly as it is meant to be called by the library during the initialization process.

core.settings.settings:setting (settingFullyQualifiedId)
Gets a setting instance by its fully qualified id.

The fully qualified id is the id of the setting group followed by a dot and the id of the setting. If a single setting id is passed, it's assumed to be part of the general group.

Parameters:

  • settingFullyQualifiedId string The fully qualified id of the setting

Returns:

    Core.Settings.Setting or nil The setting instance

Metamethods

core.settings.settings:__construct ()
Settings constructor.
generated by LDoc 1.5.0 Last updated 2024-09-11 16:27:53