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
  • Introduction
  • Details
  • Interactivity
  • Example Usage

Was this helpful?

  1. ContextMenu
  2. Option<T> class

Enum Option

Introduction

EnumOption is an option that allows cycling through an enumeration of values. It extends Option<E> for enum types, providing a user interface for selecting from a predefined set of options.

Details

  • Supplier Requirement: Retrieves the current enum value.

  • Consumer Provision: Updates the enum value upon user interaction.

  • Name Parameter: Labels the option in the HUD.

  • Values Array: Holds the enumeration of possible values.

Interactivity

  • Click Response: Left-click cycles forward, right-click cycles backward through the enum values.

  • Render Behavior: Displays the option's name followed by the current enum value, with visual feedback for the active selection.

Example Usage

// Enum representing difficulty levels
enum Difficulty {
    EASY, MEDIUM, HARD
}

// Create an EnumOption for selecting difficulty
EnumOption<Difficulty> difficultyOption = new EnumOption<>(
    "Difficulty",
    () -> this.getDifficulty(), // Getter
    value -> this.setDifficulty(value), // Setter
    Difficulty.values() // Enum values
);

Ensure that the getter is synchronized with the setter; otherwise, the option will enter a soft lock, and the value will not update. (Meaning the getter and setter are updating the same variables or referencing the same variable)

PreviousRunnable OptionNextList Option

Last updated 1 year ago

Was this helpful?