CustomMenuBarButtons

v0.1.1·Updated 2024-06-25

API for Plugin Devs to add buttons to the top menu bar

About this mod Author’s original text

Allows adding custom buttons to the top menubar.

Note: the current implementation is not final and changes could be made

For Plugin Developers

Example:

using UnityEngine;

using CustomMenuBarButtons;

using CellMenu;

using CustomMenuBarButtons;

namespace CrashButtonExample;

public sealed class CrashMenuBarButton(MenuBarHandler handler, CM_MenuBarItem item): MenuBarCustomButton(handler, item, "Crash")

{

// controls whether or not the menu bar button should be visible.

// GTFO checks this every ~0.2 seconds

public sealed override bool ShouldBeVisible

=> RundownManager.ExpeditionIsStarted;

// called when the button is clicked.

protected sealed override void OnButtonClick(int id)

{

Application.ForceCrash(0);

}

}

Registering:

using BepInEx;

using BepInEx.Unity.IL2CPP;

using CustomMenuBarButtons;

namespace CrashButtonExample;

internal sealed class EntryPoint: BasePlugin

{

public override void Load()

{

// Add listener to MenuBarHandler.

// This should be done before startup as that's when all of the

// menu bars GTFO uses are created.

MenuBarHandler.CreateButtons += CreateCustomButtons;

}

// keep in mind the callback is invoked for every

// menu bar that is created.

//

// This allows you to conditionally add your button to

// (for example) the lobby page only.

private static void CreateMenuBarButtons(MenuBarHandler menubar)

{

// MenuBarHandler has two methods to add buttons:

// 1. AddLeftButton

// 2. AddRightButton

menubar.AddLeftButton(

// argument 1: factory function that creates the button

(handler, item) => new StorylineMenuBarButton(handler, item),

// optional argument 2: the index to insert the button

insertIndex: int.MaxValue,

// optional argument 3: The page the button is for. Used for adding custom pages.

page: eCM_MenuPage.EMPTY);

}

}

Install & use Install: follow the bundled instructions

  1. Unzip the archive from playbuff and read the bundled readme / instructions first.
  2. Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
  3. For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
  4. Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.

Install locations vary a lot between mods — the bundled readme is the most reliable guide.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPack_GTFO

File & checksum

Filename
CustomMenuBarButtons-0.1.1.zip
File size
20.0 KiB