-
Notifications
You must be signed in to change notification settings - Fork 1
Stepper
Adding a ConfigStepper
object to your menu displays a Plus/Minus Control which has two buttons which can be clicked to increase or decrease a number by a specified step size.
ConfigStepper myPlusMinus = new ConfigStepper("mySetting", "Option Label", 0.0m, 100.0m, 5.0m, 50.0m);
ConfigStepper
initialization requires an identifier
, label
, a decimal min
, decimal max
, decimal stepsize
, and a decimal defaultValue
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.
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 or using the StepUp()
and StepDown()
methods. If Value
is set directly it will be verified to be a multiple of stepsize
or it will be dropped to the closest multiple.
ConfigStepper(string identifier, string labelText, decimal min, decimal max, decimal stepSize, decimal defaultValue, RangeDisplayType type = RangeDisplayType.DEFAULT, bool enabled = true);
decimal Value { get; set; }
decimal StepSize { get; }
decimal Max { get; }
decimal Min { get; }
RangeDisplayType DisplayType { get; }
bool CanStepUp { get; }
bool CanStepDown { get; }
void StepUp();
void StepDown();
event StepperHandler ValueDidChange;