-
Notifications
You must be signed in to change notification settings - Fork 1
Range
Adding a ConfigRange object to your menu displays a Slider Control which has a handle constrained to a linear range.
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.
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.
ConfigRange(string identifier, string label, decimal min, decimal max, decimal stepSize, decimal defaultValue, bool showValue, RangeDisplayType type = RangeDisplayType.DEFAULT, bool enabled = true);decimal Value { get; set; }
decimal StepSize { get; }
decimal Max { get; }
decimal Min { get; }
RangeDisplayType DisplayType { get; }event RangeHandler ValueDidChange;