Skip to content

About

Universal BepInEx Menu mod

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

CT Mods Dynamic Mod menu

This BepInEx-Mod allows to create Dynamic Mod menus easily.

How To Use

  1. use the DLL of this mod as an Assembly Reference in your BepInEx-Mod.
  2. add a dependency for this BepInExMod
  3. use the included CustomCommand and CommandInput classes to create each Mod to execute -> f.e.: MyCustomCommand:CustomCommand
  4. use RegisterCommand(CustomCommand) to register any command you want to be executed
    -> top of file: Using CTDynamicModMenu.CTDynamicModMenu;
    -> CTDynamicModMenu.Instance.RegisterCommand(MyCustomCommand)
  5. compile your mod
  6. Install both this and your mod as a plugin and enjoy

Template

Here is Template which you can use to get a basic structure for your Mod: https://github.com/Toemmsen96/CTDynMMTemplate

Using this Template you can skip steps 1-4 to have a first working Version.

Sliders

Commands can expose numeric values as sliders in the menu. Register them from your command's constructor:

public class MyCommand : CustomCommand
{
    public override string Name => "My Command";
    public override string Description => "Does a thing";
    public override string Format => "/mycommand";
    public override string Category => "Mods";

    // Required for slider values to be persisted to the config file
    public override bool HasConfig => true;
    public override bool PersistConfig => true;

    public MyCommand()
    {
        // float slider: name, min, max, default, step
        AddSlider("Speed", 1f, 20f, 5f, 0.5f, "Movement speed multiplier");

        // whole-number slider: name, min, max, default
        AddIntSlider("Count", 1, 64, 8);

        // react to changes as they happen
        AddSlider(new CommandSlider("Range", 0f, 100f, 25f,
            onValueChanged: value => ApplyRange(value)));
    }

    public override void Execute(CommandInput? message)
    {
        float speed = GetSliderValue("Speed");
        int count = GetSliderIntValue("Count");
    }
}

Read values any time with GetSliderValue(name) / GetSliderIntValue(name), and set them from code with SetSliderValue(name, value). Values persist across sessions when the command sets HasConfig and PersistConfig to true.

Sliders appear in the menu under their command: click the ▸ arrow on the command row to expand it.

Menu Usability

  • Drag the menu and log window by their title bars only, so buttons and sliders stay clickable.
  • Search box filters commands across all categories.
  • Command rows expand to show the description and sliders.
  • Toggles show their state inline as [ON] / [OFF].
  • Windows are clamped on screen and the command list scrolls when it overflows.
  • Log window has Clear and auto-scroll, with newest entries at the bottom.
  • Settings panel holds UI scale and background opacity.

About

Universal BepInEx Menu mod

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages