You are viewing a potentially older version of this package. View all versions.
Zamos-Mod_Menu-1.1.0 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
Date uploaded 21 hours ago
Version 1.1.0
Download link Zamos-Mod_Menu-1.1.0.zip
Downloads 34
Dependency string Zamos-Mod_Menu-1.1.0

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.
OrderList(entries, move, setOn) Lines the player drags into order (or, on a controller, presses to pick up, moves, and presses again), each with a checkbox. entries returns OrderEntry(text, on); move(from, to) and setOn(index, on) change your data.
TextField(label, get, set, maxLength) A text box for a short name. set gets the text on Enter or when it loses focus. The menu's controls pause while typing.
Keybinds(modId) Your mod's hotkeys (see below), each with its keys. Added for you on automatic pages.
  • 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.
  • Start over: page.Clear() empties a page so you can fill it again, e.g. when the player adds or removes something it has a section for.
  • Look and feel: rows, highlights, reset buttons and controller navigation are handled for you, so every mod's page looks and works the same.

Hotkeys

Register your hotkeys with Mod Menu instead of reading keys yourself. Players then see them on your mod's page, and the Rebind Controls mod lets them change them in Options → Controls, in a section for your mod:

// Once at start. Keys are Input System paths; leave the gamepad one out (or "") for none.
var open = Keybinds.Register("MyMod", "My Mod", "OpenThing", "Open Thing", "<Keyboard>/f6", "<Gamepad>/buttonNorth");

// Each frame:
if (open.WasPressed) OpenThing();      // also IsPressed (held) and WasReleased
  • The player's keys are saved by Mod Menu, so Register returns the saved ones on the next start.
  • open.Describe() gives the keys as text, e.g. "F6 / Y / Triangle".
  • While the player is typing in a text box or setting a key, Keybinds.Suspended is true and IsPressed / WasPressed return false.
  • Found automatically: KeyCode settings (a BepInEx ConfigEntry<KeyCode> or MelonLoader entry) already show up as hotkeys, so older mods get a section too. Registering is better: it supports controllers and mouse buttons.
  • Keybinds.Remove(modId, id) takes one away (e.g. when the player deletes what it opened).

Changing controls yourself: setting Keybinds.OpenEditor makes the hotkey buttons on mods' pages call your code (with the mod's id), and Menu.OpenTab("Controls") shows the Options screen's Controls tab. Rebind Controls does all of this, so most mods only need Keybinds.Register.

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).

CHANGELOG

Changelog

1.1.0

  • HUD editor: the recorded HUD's texts show in the game's language and with a font that can draw them (re-recorded in your next mission). Texts given another font for a language get their own back when you switch back.
  • Mods' names are translated too.
  • The mouse wheel always scrolls a page and never changes a value. A selected text box or list no longer holds the page in place.
  • Follows the game's language setting, also for indented settings.
  • HUD editor: the mouse wheel's picture for resizing, and the controller pictures switch when you change controller.
  • Hotkeys: mods can register their hotkeys (Keybinds.Register). Each mod's page lists its hotkeys, and the Rebind Controls mod changes them in Options → Controls. Mods' KeyCode settings are found automatically.
  • Menu.OpenTab(name) opens another tab of the Options screen (e.g. "Controls"); with Rebind Controls, a mod's hotkey buttons open its section there.
  • New page items for mod makers: OrderList (drag into order, with checkboxes), TextField, and Clear to fill a page again.
  • The HUD editor records the HUD again when a mod wants a picture that wasn't recorded yet.

1.0.2

  • The HUD layout editor's copy of the HUD now shows three collected scrolls in the bottom-right corner, laid out by the game's own scroll panel (it records the HUD again in your next mission).

1.0.1

  • Text boxes on mod pages keep the keyboard while you type. The game used to move the selection after every letter.

1.0.0

  • First release on Thunderstore.