Double Option

DoubleOption Class

General Summary

DoubleOption provides a slider for selecting a double value within a specified range in the DynamicHUD library.

Constructor Parameters

  • name: The display name for the slider.

  • minValue: The minimum value the slider can represent.

  • maxValue: The maximum value the slider can represent.

  • step: The increment between each value on the slider is defined by the "step." For a slider ranging from 0 to 1, with a step of 0.1f, the slider will be divided into ten equal parts. Each movement will increase the value by one step, or 0.1f.

  • getter: Supplier that retrieves the current value.

  • setter: Consumer that sets the new value after interaction.

Interactivity

  • Click: Initiates the value change and starts dragging.

  • Drag: Adjusts the slider's value as the user drags the handle.

  • Release: Stops the dragging action and finalizes the value selection.

Rendering

  • Label: Shows the name and current value.

  • Slider: A visual representation of the value range, with a handle that moves to represent the current value.

Example Usage

DoubleOption volumeOption = new DoubleOption(
    "Volume",
    0.0, // Minimum volume
    100.0, // Maximum volume
    10f, // Step, with 10f each "slide", the value will be incremented by 10
    () -> audioSettings.getVolume(), // Getter
    value -> audioSettings.setVolume(value) // Setter
);

Last updated

Was this helpful?