-
Notifications
You must be signed in to change notification settings - Fork 1
Stepper
Adding a ModOptionStepper
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.
ModOptionStepper myPlusMinus = new ModOptionStepper("mySetting", "Option Label", 0.0m, 100.0m, 5.0m, 50.0m);
(string identifier, string labelText, decimal min, decimal max, decimal stepsize, decimal defaultValue, DisplayType type = DisplayType.NONE, bool enabled = true)
ModOptionStepper
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 ModOptions
.
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
.
The type
argument decides which icon to display and requires a DisplayType
enum value which currently includes:
public enum DisplayType
{
NONE, 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 ValueChanged
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.
public ModOptionStepper(string identifier, string labelText, decimal min, decimal max, decimal stepsize, decimal defaultSelection, DisplayType type = DisplayType.NONE, bool enabled = true)
public void StepUp()
public void StepDown()
public decimal Value { get; set; }
public delegate void ModOptionStepperHandler(string identifier, decimal currentValue)
public event ModOptionStepperHandler ValueChanged