Feature Settings

FeatureSetting object, is a setting object, which is bound to a Feature. These objects can be casted to other higher-level setting.

Creating a Setting

To create a FeatureSetting, simply call addSetting on the Feature object. Let's start with CheckboxSetting (checkbox):

feature.addSetting(
    /* setting type  */ 'checkbox'                 
    /* setting name  */ 'Enable something',  
    /* setting value */ false);

This method will return a higher-level FeatureSetting object, which has the properties of the corresponding type, meaning you don't have to call .as('CheckboxSetting'), for example.

Creating a ComboSetting (combo) isn't difficult either:

feature.addSetting(
    'combo',
    'Bypass mode',
    { 
        /* (1) Acceptable values   */ values : [ 'Simple', 'Advanced' ],
        /* (2) Default value index */ default: 1 
    });

Here, instead of false, we supply an object instead, because a setting value is unique to each setting type. Let's break down the parameters:

  1. String Array of Combobox elements

  2. Index of the default element in the abovementioned array. Array indexes start with 0

To create a SliderSetting (slider), you need to do the following:

feature.addSetting(
    'slider', 
    'Skid delay', 
    [
        3.0 /* (1) Default value */, 
        1.0 /* (2) Min value */, 
        5.0 /* (3) Max value */
    ]);
  1. Default value for the Slider setting

  2. Minimum allowed value

  3. Maximum allowed value

1, 2, 3 can either be decimal or integer; you can't mix number types!

To create a MultiComboSetting (multi_combo), use the following snippet:

feature.addSetting(
    'multi_combo', 
    'Addons', 
    {
        /* (1) */ 'First Element': true,
        'Second Element': /* (2) */ true,
    });

As you can see, we use an object here instead of a simple argument. The keys (1) in this object are the Elements' names, and values (2) - are the Elements' default states.

Creating a ColorSetting (color) is trivial:

feature.addSetting('color', 'Some color', /* (1) */ 0xff00FFFF);
  1. Hex color code (can be obtained by using rgb(0, 255, 0) or rgba(0, 255, 0, 255) , for example.

Once you create a Setting, you can assign the function call to a variable and use it afterwards in your Script. Take a look at your Setting's Properties in order to find out what you can do with it.

Overrides

You're able to override shouldShow/interactCallback, by passing a 4th argument - object, to the addSetting method, which may contain these function definitions:

feature.addSetting('multi_combo', 'Addons', {
        'Skid Akrien': true,
        'Skid AAL': true,
    }, {
        interactCallback: () => print(addonsSetting.getName()),
        shouldShow: () => someOtherCheckboxSetting.isEnabled()
    }
);

Properties

TypeNameDescriptionSignature

field

featureSettingType

Type of the FeatureSetting (checkbox, color, combo, multi_combo, slider)

string

function

getReference

Returns the Feature, that this setting is assigned to.

function

shouldShow

Whether the setting should be currently displayed.

boolean()

function

interactCallback

Runs the setting's interact callback.

void()

Inherits (higher-level objects)

CheckboxSetting

TypeNameDescriptionSignature

function

toggle

Toggles the setting's state

void()

function

isEnabled

Whether the setting is enabled

boolean()

function

setEnabled

Sets the setting's state

void(boolean)

function

isDefaultState

Returns the setting's state on the default config

boolean()

ComboSetting

TypeNameDescriptionSignature

function

getElements

Returns the combobox's elements

string[]()

function

getCurrentElement

Returns the current active element's index

int()

function

getCurrentElementAsString

Returns the current active element's name

string()

function

getDefaultState

Returns the default active element index

int()

function

setCurrentElement

Sets the current element by index

void(int)

function

setCurrentElementByName

Sets the current element by name

void(string)

function

isExtended

Whether the combobox is extended in the UI

boolean()

function

setExtended

Sets the extended UI state

void(boolean)

SliderSetting

TypeNameDescriptionSignature

function

getMinValue

Returns the slider's minimum value

decimal()

function

getMaxValue

Returns the slider's maximum value

decimal()

function

getCurrentValue

Returns the slider's current value

decimal()

function

getDefaultState

Returns the slider's default value

decimal()

function

setCurrentValue

Sets the slider's value

void(decimal)

function

setCurrentValueIgnoreNormalize

Sets the slider's value without rounding

void(decimal)

field

type

Slider's type (int, decimal)

string

MultiComboSetting

TypeNameDescriptionSignature

function

add

Adds an Element to the setting

void(string, boolean)

function

isSelected

Whether the Element by this index is selected

boolean(int)

function

byName

Returns an Element by its name

Element(string)

function

getElements

Returns the setting's Elements

List<Element>()

Object Element is a MultiComboSetting's entry, its state can be set to true/false.

TypeNameDescriptionSignature

function

isSelected

Whether the Element is selected

boolean()

function

setSelected

Sets the Element's state

void(boolean)

function

getName

Returns the Element's name

string()

function

isDefaultState

Returns the Element's default state

boolean()

function

toggleSelection

Toggle the Element's state

void()

ColorSetting

TypeNameDescriptionSignature

function

getColor

Returns the current HEX color

int()

function

setColor

Sets the current HEX color

void(int)

Last updated