DynamicHUD Dev Guide
DownloadNeed Support?
  • Dynamic HUD
  • Import using Gradle
  • Integrating DynamicHUD
    • Integrating DynamicHUD
    • Adding Widgets
    • Adding your own WidgetRenderer
    • Passing AbstractMoveableScreen instance
    • Changing default key bind
    • Changing save and load file
    • Registering Custom Widgets
  • Widget
    • Widget class
    • How to create a custom widget
    • Widget Renderer
    • WidgetData
    • DynamicValueRegistry
    • Scaling
  • Screens
    • AbstractMoveableScreen
  • ContextMenu
    • ContextMenu class
    • Using context menu
    • Option<T> class
      • Color Option
      • Boolean Option
      • Double Option
      • Runnable Option
      • Enum Option
      • List Option
      • SubMenu Option
Powered by GitBook
On this page
  • DoubleOption Class
  • General Summary
  • Constructor Parameters
  • Interactivity
  • Rendering
  • Example Usage

Was this helpful?

  1. ContextMenu
  2. Option<T> class

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.

The width of the slider is limited to only 30 pixels unit, so incase of vast difference between the min and max values along with small step value, the slider may break and not function properly.

Step cannot be less than or equal to 0. Passing 0 will result in a crash.

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
);
PreviousBoolean OptionNextRunnable Option

Last updated 9 months ago

Was this helpful?