Rune580.Mods.RiskOfRain2.RiskOfOptions 2.8.2

dotnet add package Rune580.Mods.RiskOfRain2.RiskOfOptions --version 2.8.2                
NuGet\Install-Package Rune580.Mods.RiskOfRain2.RiskOfOptions -Version 2.8.2                
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="Rune580.Mods.RiskOfRain2.RiskOfOptions" Version="2.8.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rune580.Mods.RiskOfRain2.RiskOfOptions --version 2.8.2                
#r "nuget: Rune580.Mods.RiskOfRain2.RiskOfOptions, 2.8.2"                
#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 Rune580.Mods.RiskOfRain2.RiskOfOptions as a Cake Addin
#addin nuget:?package=Rune580.Mods.RiskOfRain2.RiskOfOptions&version=2.8.2

// Install Rune580.Mods.RiskOfRain2.RiskOfOptions as a Cake Tool
#tool nuget:?package=Rune580.Mods.RiskOfRain2.RiskOfOptions&version=2.8.2                

RiskOfOptions

Animated icon made by UnsavedTrash#0001 on discord

NuGet Version Thunderstore Version Thunderstore Downloads GitHub Actions Workflow Status

An API to provide a user interface in game to interact with BepInEx ConfigEntry's.

Currently supported options

  • CheckBoxes bool
  • Sliders float
  • StepSliders float
  • IntSliders int
  • KeyBinds KeyboardShortcut
  • String Input Fields string
  • Choice DropDowns Enum
  • Color Picker UnityEngine.Color

Additional Components

  • GenericButtons

For feature requests or issues head over to my repository.

Developer Resources

Getting Started

First you need to grab the latest release from the Thunderstore. Extract the mod to your plugins folder, and then add a reference to the dll in your project in Visual Studio. [Project->Add Reference...->Browse]

Then add to where ever you will use this.

using RiskOfOptions;

Next you need to add Risk Of Options as a dependency for your mod.

[BepInDependency("com.rune580.riskofoptions")]

Finally make sure you know how to use BepInEx Config

Now you're ready to start adding options.

Adding an option

Given a ConfigEntry<bool>

ConfigEntry<bool> enableThing = Config.Bind(...);

ModSettingsManager.AddOption(new CheckBoxOption(enableThing);

Need a volume slider?

ConfigEntry<float> volume = Config.Bind(...);

ModSettingsManager.AddOption(new SliderOption(volume));

Every option constructor can take a Config for the example above it would be SliderConfig. Say you need a slider that only goes between 60 - 130. You would do:

ModSettingsManager.AddOption(new SliderOption(limitedRangeFloat, new SliderConfig() { min = 60, max = 130 }));

What about a slider that goes in increments of 0.15 and is limited between 1 - 5?

ModSettingsManager.AddOption(new StepSliderOption(incrementedFloat, new StepSliderConfig() { min = 1, max = 5, increment = 0.15f }));

Enough about floats, let's talk about the spaghetti and meatballs, KeyBinds.

ConfigEntry<KeyboardShortcut> keyBind = Config.Bind(...);

ModSettingsManager.AddOption(new KeyBindOption(keyBind)); // This also has a KeyBindConfig but can be omitted if defaults are desired.

And that's it, said KeyboardShortcut will show up on the ModOptions menu.

Checkbox and Slider configs can be set with a delegate that will be used to check if said option should be disabled in the menu.

ConfigEntry<bool> disableThing = Config.Bind(...);
ConfigEntry<bool> overridenThing = Config.Bind(...); 

ModSettingsManager.AddOption(new CheckBoxOption(disableThing));
ModSettingsManager.AddOption(new CheckBoxOption(overridenThing, new CheckBoxConfig() { checkIfDisabled = Check }));

...

private bool Check()
{
    return disabledThing.value;
}

When disableThing is enabled overridenThing will show up as non-interactable in the menu.

"Okay that's all fine but how do I, you know, do stuff when an value is changed?" Well thankfully ConfigEntry's have this innately:

ConfigEntry<bool> toggleThing = Config.Bind(...);

toggleThing.SettingChanged += (object, args) => { Debug.Log(toggleThing.Value) };

Of course when an option changes the value of a passed ConfigEntry, the value updates in real time, so in some cases where you are checking the value of the entry directly you don't need to do anything.

There may be cases where you just want a convenient button to open your own menu, as such you can do this:

ModSettingsManager.AddOption(new GenericButtonOption("Custom Menu", "Misc", "Configure stuff in here", "Open Custom Menu", OpenMenu));

private void OpenMenu()
{
    /// Do stuff
}

The GenericButtonOption may be used to provide an entry point for opening your custom GUI's.

Setting the description of the mod

ModSettingsManager.SetModDescription("Describe your mod in incredible detail over the course of the next 2 hours");

Setting the icon of the mod

Sprite icon = ...;

ModSettingsManager.SetModIcon(icon);

Quick Showcase

Showcase

Contact

Discord: @rune

Github: Rune580

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.

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
2.8.2 97 9/7/2024
2.8.1 76 8/28/2024
2.8.0 109 5/20/2024
2.7.2 312 5/19/2024