Skip to content
Justin Oroz edited this page Jul 8, 2018 · 6 revisions

Overview

Adding a ConfigRange object to your menu displays a Slider Control which has a handle constrained to a linear range.

Usage

Initializing

ConfigRange myRange = new ConfigRange("mySetting", "Option Label", 0.0m, 100.0m, 5.0m, 50.0m, true);

ConfigRange initialization requires an identifier, label, a decimal min, decimal max, decimal stepsize, decimal defaultValue, and a boolean showValue, but can be initialized with additional arguments type and the standard enabled. You can then add it to an OptionsTab.

stepsize determines the amount the value changes when clicking the Plus and Minus buttons.

min is the minimum value of the Stepper and the basis for all values. For example, if an attempt is made to set the value of the stepper, the stepper will check if the new value is min * stepsize * n, where n is some multiple, and set the value to the closest matching value.

max is the maximum value of the stepper. If max does not fall on min * stepsize * n the stepper will be set to the maximum when it is pushed passed the final valid multiple of stepsize. i.e with min = 0, max = 1, stepsize = 0.3: When the Plus button is pushed at 0.9 the value will be set to 1.0, even though it is not a multiple of stepsize. Afterward, if Minus is clicked it will return to 0.9.

The type argument decides which icon to display and requires a RangeDisplayType enum value which currently includes:

public enum RangeDisplayType
{
    DEFAULT, PERCENT
}

If PERCENT is chosen a % will be displayed after the value, otherwise, only the value is shown.

showValue determines whether the value of the slider should be shown next to the slider.

Reading/Modifying Values

To read the checkbox value check the decimal Value property. The event ValueDidChange is triggered every time the Value property is changed, except on initialization.

The mod can manually change the state of the checkbox by writing to the Value property. If Value is set directly it will be verified to be a multiple of stepsize or it will be dropped to the closest multiple.

Properties and Methods

Initializers

ConfigRange(string identifier, string label, decimal min, decimal max, decimal stepSize, decimal defaultValue, bool showValue, RangeDisplayType type = RangeDisplayType.DEFAULT, bool enabled = true);

Properties

decimal Value { get; set; }
decimal StepSize { get; }
decimal Max { get; }
decimal Min { get; }
RangeDisplayType DisplayType { get; }

Events

event RangeHandler ValueDidChange;
Clone this wiki locally