Zamos-Mod_Menu icon

Mod Menu

A Mods tab in Options with every mod's settings, full controller support, and a HUD layout editor to move and resize mods' HUD elements. Also an API for mod makers.

By Zamos
Last updated an hour ago
Total downloads 3
Total rating 1 
Categories Mods Libraries
Dependency string Zamos-Mod_Menu-1.0.1
Dependants 6 other packages depend on this package

This mod requires the following mods to function

BepInEx-BepInExPack_IL2CPP-6.0.788 icon
BepInEx-BepInExPack_IL2CPP

BepInEx pack for IL2CPP x64 Unity games. Preconfigured and ready to use.

Preferred version: 6.0.788

README

Mod Menu

A Mods tab in the game's Options with every installed mod's settings, and a HUD layout editor where you move and resize mods' HUD elements on top of the game's own HUD. Mod makers get a small API for both.

For players

The Mods tab

Open Options → Mods. The list on the left has every mod with settings, and the settings of the one you pick appear on the right.

  • Every mod is covered. Mods that add their own page get it. Any other BepInEx mod gets a page built from its config file, so its settings show up with no extra work.
  • Reset: a circular-arrow button next to a value puts that setting back to its default. It only appears when the setting isn't at its default.
  • Controller: works throughout.
    • The Mods tab is part of the tab row.
    • Left / right changes a value, or moves between buttons in a row.
    • Back goes from a mod's settings → the mod list → Options.

The HUD layout editor

Mods with something on the HUD (a timer, quest cards, badges...) have an Edit Position & Size button. It opens the editor, where you place them all on the game's HUD:

  • Outside a mission, the editor shows a copy of the game's HUD. Mod Menu records it by itself about 10 seconds into your first mission, so play one mission after installing (and after game updates).
  • During a mission (from the pause menu), it shows your real game. Menus and blur are moved out of the way, and HUD parts the game has hidden (being dead, an objective running...) are shown, all put back when you close it.
Mouse Controller
Pick an element Click it Y (next element)
Move Drag it Left stick / d-pad
Resize Drag an edge or corner, or mouse wheel LB / RB
Done Right-click, Escape or Done A or B

Reset in the controls box puts the picked element back to its default place and size. The controls box can be dragged out of the way.

For mod makers

Mod Menu is an optional dependency: your mod should still run without it. Reference BrigadeModMenu.dll (from this package), and only touch its types from a method that isn't inlined, called after checking it's loaded:

[BepInDependency("BrigadeModMenu", BepInDependency.DependencyFlags.SoftDependency)]
public class MyPlugin : BasePlugin
{
    public override void Load()
    {
        // ... your setup ...
        if (Array.Exists(AppDomain.CurrentDomain.GetAssemblies(), a => a.GetName().Name == "BrigadeModMenu"))
            MenuPage.Register();   // all Mod Menu calls live in this class
    }
}

internal static class MenuPage
{
    [MethodImpl(MethodImplOptions.NoInlining)]
    internal static void Register() { /* Menu.AddPage(...), HudEditor.Register(...) */ }
}

Add Zamos-Mod_Menu to your Thunderstore dependencies if your mod needs it. Everything is in the BrigadeModMenu namespace.

Settings pages

You don't have to do anything: your BepInEx config gets an automatic page, which uses these tags (the same ones as BepInEx's Configuration Manager) when you give them:

  • DispName: the label.
  • Browsable = false: leave the setting out.
  • Order: higher numbers come first.

Values come from your config: bools are toggles, enums and AcceptableValueList are choices, and numbers use their AcceptableValueRange.

To lay out a page yourself:

Menu.AddPage("MyMod", "My Mod")                      // id (your config section), title
    .Header("Display")
    .Entry(MyPlugin.ShowThing, () => "Show Thing")   // a ConfigEntry: toggle, choice or number
    .Toggle("Loud", () => loud, v => loud = v)
    .Choice("Mode", new[] { "Calm", "Wild" }, () => mode, v => mode = v)
    .Number("Speed", 0.5f, 2f, 0.1f, () => speed, v => speed = v, format: v => v.ToString("0.0"))
    .Note("Some explanation in smaller, dimmer text.")
    .Buttons(new MenuButton("Do Thing", DoThing),
             new MenuButton("Delete All", DeleteAll, danger: true))   // white, then red
    .List(() => SavedThings(), () => "Nothing saved yet.");
Call What it adds
Header(text) A gold section heading.
Note(text) A line of dimmed explanation.
Entry(configEntry, label) A setting from your config, with a reset button.
Toggle / Choice / Number(...) A value you read and write yourself. Pass defaultValue to get a reset button.
Button(text, onClick, danger) One button (red when danger is true).
Buttons(params MenuButton[]) Several buttons side by side in one row. Left / right moves between them.
List(entries, whenEmpty) A list of ListEntry(text, note, buttons...), e.g. saved items with a Delete button. It's read again a few times a second, so it follows your data.
Custom(height, build) Your own UI in a row of that height. Return the Selectable a controller should stop on, or null.
  • Labels can change: every label and text has a Func<string> overload, for text that changes.
  • Section to hide: Menu.HideCategory(id) leaves a config section out of the automatic pages.
  • Redraw: Menu.Refresh() rebuilds the page on screen after you change what it shows.
  • Look and feel: rows, highlights, reset buttons and controller navigation are handled for you, so every mod's page looks and works the same.

HUD layout editor

Register each HUD element once when your mod starts, and add a button that opens the editor on it:

HudEditor.RecordSprites("ui_stat_icon_time");          // pictures your preview needs (see rule 3)
HudEditor.Register(MyElement);
Menu.AddPage("MyMod", "My Mod")
    .Buttons(new MenuButton("Edit Position & Size", () => HudEditor.Open(MyElement)));

static readonly HudElement MyElement = new()
{
    Name = "My Thing",
    Build = parent => BuildPreview(parent),            // outside missions: a preview inside `parent`
    Place = root => PlaceThing(root),                  // place the preview from your settings (every frame)
    Live = () => RealThingForEditor(),                 // in a mission: your real element (see rule 6)
    GetOffset = () => new Vector2(X.Value, Y.Value),   // your position, in HUD units
    SetOffset = v => { X.Value = v.x; Y.Value = v.y; },
    GetSize = () => Size.Value,                        // optional: a uniform scale
    SetSize = s => Size.Value = s,
    GetDimensions = () => new Vector2(W.Value, H.Value), // optional: separate width and height
    SetDimensions = d => { W.Value = d.x; H.Value = d.y; },
    Reset = () => { /* your defaults */ },
};
  • Optional fields:
    • MinSize / MaxSize / SizeStep limit size changes.
    • MinDimensions / MaxDimensions limit width and height changes.
    • HideFromPreview lists name prefixes of your objects, so they're left out of the recorded HUD.
  • Resizing: with GetDimensions set, dragging an edge changes width or height. With only GetSize, every drag changes the scale.
  • Every element shows at once, so players place each mod's HUD with all the others in view.

Rules: it must look exactly like the mission

The editor is only useful if your element sits and looks exactly as it does in a mission. Never place it with numbers that only look about right. These rules, and the tools that come with them, make that possible:

  1. Use your mission code. Build and Place should call the same functions your mod uses in a mission (same sizes, fonts, pictures and maths). Split your mission code into small functions both can call. Don't write a second version for the editor.

  2. Line up with the game's HUD through the recording. HudEditor.Recorded("RunProgress_Panel/Progress_Slider") gives you that part of the recorded HUD, laid out exactly as in the mission. Parent or measure your preview against it rather than hard-coding where you think it is. Every recorded path is listed in BrigadeModMenu_hud.txt, in the BepInEx config folder.

  3. Pictures: many HUD pictures aren't loaded outside missions. Call HudEditor.RecordSprites("sprite_name") when your mod starts, so they're saved with the recording. Get them back with HudEditor.Sprite("sprite_name").

  4. Anything only a running mission knows (where the camera draws a point in the world, a size taken from one of the game's texts...): measure it during the mission with HudEditor.Measure("YourMod.Name", values...). Read it in the editor with HudEditor.Measured("YourMod.Name"). Measurements are kept between game sessions in BrigadeModMenu_measured.txt, and only written when they change.

  5. If you don't have it, don't show it. When the recording or a measurement isn't there yet (no mission played since installing), return null from Build, or hide that part, instead of showing it in the wrong place.

  6. Give the editor your real element during missions (Live). In a mission, the editor uses your real HUD object instead of the preview. It calls Live every frame while it's open, and straight after changing your settings, to measure the result. On each call:

    • show your element, even if it would normally be hidden (with sample content if it has nothing to show);
    • place it from your settings right then;
    • once the calls stop, go back to normal (e.g. hide it again 0.3 s after the last call).

    Without Live, your preview is drawn over the game, and your real element shows under it too.

  7. Offsets are in HUD units. These are the units of the game's HUD canvas: 3840 × 2160 reference, matched on height, so wider screens are wider than 3840. parent in Build covers the whole HUD in those units. If your real element sits under a scaled part of the game's HUD, convert the same way in both places.

Checking it: play a mission, take a screenshot, then open the editor and compare. If anything differs, find which rule it breaks rather than nudging numbers until it looks close.

Other calls

Call What it does
HudEditor.Open(element) / Close() / IsOpen Opens the editor with that element picked, closes it, or tells you if it's open.
HudEditor.Recorded(path) A part of the recorded HUD while the editor is open (null otherwise, or during a mission).
HudEditor.Sprite(name) A picture by name: loaded in the game now, or saved with the recording.
HudEditor.Measure(key, values) / Measured(key) Save a mission-only value / read it back (null until measured).