CustomMenuBarButtons
API for Plugin Devs to add buttons to the top menu bar
模組介紹 作者原文
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);
}
}
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: