Hamunii.ModMenuAPI 0.1.1-dev

This is a prerelease version of Hamunii.ModMenuAPI.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Hamunii.ModMenuAPI --version 0.1.1-dev                
NuGet\Install-Package Hamunii.ModMenuAPI -Version 0.1.1-dev                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hamunii.ModMenuAPI" Version="0.1.1-dev" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hamunii.ModMenuAPI --version 0.1.1-dev                
#r "nuget: Hamunii.ModMenuAPI, 0.1.1-dev"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hamunii.ModMenuAPI as a Cake Addin
#addin nuget:?package=Hamunii.ModMenuAPI&version=0.1.1-dev&prerelease

// Install Hamunii.ModMenuAPI as a Cake Tool
#tool nuget:?package=Hamunii.ModMenuAPI&version=0.1.1-dev&prerelease                

ModMenuAPI

[!NOTE]
This API is not quite yet released.

An API to add your stuff as buttons on a menu that is accessible during gameplay.

Support

Engine Supported?
Unity Mono
Unity IL2CPP
Other
Modloader Supported?
BepInEx 5
Other
Games with mods using this API
Game Mods
Lethal Company ModMenuAPI.CoreMod.LC
Content Warning ModMenuAPI.CoreMod.CW

Usage

using ModMenuAPI.ModMenuItems;

class CWPatches
{
    internal static void Init()
    {
        // menuTitle: The name of the menu this item will be listed under.
        ModMenu.RegisterItem(new InfiniteJumpPatch(), menuTitle: "Player");
        ModMenu.RegisterItem(new SetMoneyPatch(), menuTitle: "Stats");
    }
}

// This is an example of a toggle button
class InfiniteJumpPatch : ModMenuButtonToggle
{
    readonly ModMenuItemMetadata meta = new("Infinite Jump", "Removes check for touching ground when jumping.");
    public override ModMenuItemMetadata Metadata => meta;

    protected override void OnEnable() => IL.PlayerController.TryJump += PlayerController_TryJump;
    protected override void OnDisable() => IL.PlayerController.TryJump -= PlayerController_TryJump;

    private static void PlayerController_TryJump(ILContext il)
    {
        ILCursor c = new(il);
        // we remove `if` branches and pop the values that would have been popped
        while (c.TryGotoNext(x => x.MatchBgeUn(out _) || x.MatchBleUn(out _)))
        {
            c.Remove();
            c.Emit(OpCodes.Pop);
            c.Emit(OpCodes.Pop);
        }
    }
}

// This is an example of an action button - it isn't a toggle
class SetMoneyPatch : ModMenuButtonAction
{
    readonly ModMenuItemMetadata meta = new("Set Money");
    public override ModMenuItemMetadata Metadata => meta;

    public override void OnClick()
    {
        SurfaceNetworkHandler.RoomStats.Money = 100000000;
        SurfaceNetworkHandler.RoomStats.OnStatsUpdated();
    }
}

ModMenuAPI Architecture

ModMenuAPI is designed to be modular and lightweight. This is because the goal of this project is to be a generic mod menu API for any game.

Namespace Purpose
ModMenuAPI The entry point of the software; handles loading and unloading itself so it plays well with hot loading. This is the only modloader-specific part, and adding support for another modloader should be incredibly easy.
ModMenuAPI.ModMenuItems & ModMenuAPI.ModMenuItems.BaseItems Contains the mod menu button components that are used, including the API methods used for registering buttons on the menu.
ModMenuAPI.MenuGUI Contains the graphical menu implementation, which currently is Unity's OnGUI. A new implementation should be easy, as the most significant thing this does (other than the graphics) is invoke button presses using ModMenuBaseItemBase's CommonInvoke().
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0-dev 72 5/31/2024
0.2.0-dev 66 5/16/2024
0.1.2-dev 69 5/15/2024
0.1.1-dev 55 5/14/2024