Settings

Context menu

When a player right-clicks your module in the HUD editor, a context menu opens. Extend it by overriding getContextMenuSettings().

By default it holds Reset Position, Reset Settings and Open Settings. Keep it short: it is the quick reach, not the full panel, and everything you put in it also shows on your module's settings page.

The six setting types

All six live in com.eymistaken.simplecps.api. Their constructors are on the HudModuleSetting reference.

BooleanSettingAn [ON] or [OFF] toggle.
ColorSettingA color swatch that opens the color picker.
TextSettingShows the current value and opens an inline text field.
CycleSettingSteps through a fixed list of options on each click.
ActionSettingA plain button with no value. Since 1.2.5 it can tint its label, to mark a row that opens something rather than changing a value.
SliderSettingA draggable integer slider with a live value and a Reset button. Takes a minimum, a maximum and a default.

All six in one menu

MyCustomModule.java
import com.eymistaken.simplecps.api.*;
import java.util.Arrays;
import java.util.List;

// Inside your MyCustomModule class:

@Override
public List<HudModuleSetting> getContextMenuSettings() {
    List<HudModuleSetting> settings = new java.util.ArrayList<>(super.getContextMenuSettings());

    // Toggle, shown as [ON] or [OFF]
    settings.add(new BooleanSetting("Enable My Module",
        () -> MyAddonConfig.enabled,
        val -> { MyAddonConfig.enabled = val; MyAddonConfig.save(); }
    ));

    // Color, opens the color picker on click
    settings.add(new ColorSetting("Text Color",
        () -> MyAddonConfig.textColor,
        color -> { MyAddonConfig.textColor = color; MyAddonConfig.save(); }
    ));

    // Text, opens an inline field on click
    settings.add(new TextSetting("Suffix Text",
        () -> MyAddonConfig.suffix,
        val -> { MyAddonConfig.suffix = val; MyAddonConfig.save(); }
    ));

    // Cycle, clicks through the options
    settings.add(new CycleSetting("Display Mode",
        Arrays.asList("Compact", "Full", "Minimal"),
        () -> MyAddonConfig.displayModeIndex,
        idx -> { MyAddonConfig.displayModeIndex = idx; MyAddonConfig.save(); }
    ));

    // Action, a plain button with no value
    settings.add(new ActionSetting("Reset My Settings", () -> {
        MyAddonConfig.resetVisuals();
        MyAddonConfig.save();
    }));

    // Slider, an integer range with a Reset button
    settings.add(new SliderSetting("Scale %",
        50, 300, 100,
        () -> MyAddonConfig.scale,
        val -> { MyAddonConfig.scale = val; MyAddonConfig.save(); }
    ));

    return settings;
}

Keep the super call. Calling super.getContextMenuSettings() and copying it into a new ArrayList keeps the default Reset Settings row at the top of the menu. Leave it out only to replace that row on purpose. Reset Position is there either way: the editor adds it, not getContextMenuSettings().

What Reset Settings does

Override resetVisualDefaults() to define it for your module. Reset visual and behavioral fields, and leave the enabled state and the offsets to the player. If your module treats scale as a visual preference it is safe to reset it here, as the built-in modules do.

MyCustomModule.java
@Override
public void resetVisualDefaults() {
    MyAddonConfig.textColor        = 0xFFFFFF;
    MyAddonConfig.suffix           = "";
    MyAddonConfig.displayModeIndex = 0;
    MyAddonConfig.scale            = 100;
    MyAddonConfig.save();
}

**Never reset enabled, the anchor or the offsets here.** Position belongs to Reset Position, and whether the module is on is always the player's choice.