• Stars
    star
    227
  • Rank 175,900 (Top 4 %)
  • Language
    C#
  • License
    GNU Lesser Genera...
  • Created about 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Plugin configuration manager for BepInEx

Plugin / mod configuration manager for BepInEx 5

An easy way to let user configure how a plugin behaves without the need to make your own GUI. The user can change any of the settings you expose, even keyboard shortcuts.

The configuration manager can be accessed in-game by pressing the hotkey (by default F1). Hover over the setting names to see their descriptions, if any.

Configuration manager

How to use

  • Install BepInEx v5.4.20 or newer (older v5 versions won't work, v6 won't work either without a compatibility layer).
  • Download latest release from the Releases tab above.
  • Place the .dll inside your BepInEx\Plugins folder.
  • Start the game and press F1.

Note: The .xml file is useful for plugin developers when referencing ConfigurationManager.dll in your plugin, it will provide descriptions for types and methods to your IDE. Users can ignore it.

How to make my mod compatible?

ConfigurationManager will automatically display all settings from your plugin's Config. All metadata (e.g. description, value range) will be used by ConfigurationManager to display the settings to the user.

In most cases you don't have to reference ConfigurationManager.dll or do anything special with your settings. Simply make sure to add as much metadata as possible (doing so will help all users, even if they use the config files directly). Always add descriptive section and key names, descriptions, and acceptable value lists or ranges (wherever applicable).

How to make my setting into a slider?

Specify AcceptableValueRange when creating your setting. If the range is 0f - 1f or 0 - 100 the slider will be shown as % (this can be overridden below).

CaptureWidth = Config.Bind("Section", "Key", 1, new ConfigDescription("Description", new AcceptableValueRange<int>(0, 100)));

How to make my setting into a drop-down list?

Specify AcceptableValueList when creating your setting. If you use an enum you don't need to specify AcceptableValueList, all of the enum values will be shown. If you want to hide some values, you will have to use the attribute.

Note: You can add System.ComponentModel.DescriptionAttribute to your enum's items to override their displayed names. For example:

public enum MyEnum
{
    // Entry1 will be shown in the combo box as Entry1
    Entry1,
    [Description("Entry2 will be shown in the combo box as this string")]
    Entry2
}

How to allow user to change my keyboard shorcuts / How to easily check for key presses?

Add a setting of type KeyboardShortcut. Use the value of this setting to check for inputs (recommend using IsDown) inside of your Update method.

The KeyboardShortcut class supports modifier keys - Shift, Control and Alt. They are properly handled, preventing common problems like K+Shift+Control triggering K+Shift when it shouldn't have.

private ConfigEntry<KeyboardShortcut> ShowCounter { get; set; }

public Constructor()
{
    ShowCounter = Config.Bind("Hotkeys", "Show FPS counter", new KeyboardShortcut(KeyCode.U, KeyCode.LeftShift));
}

private void Update()
{
    if (ShowCounter.Value.IsDown())
    {
        // Handle the key press
    }
}

Overriding default Configuration Manager behavior

You can change how a setting is shown inside the configuration manager window by passing an instance of a special class as a tag of the setting. The special class code can be downloaded here. Simply download the .cs file and drag it into your project.

  • You do not have to reference ConfigurationManager.dll for this to work.
  • The class will work as long as name of the class and declarations of its fields remain unchanged.
  • Avoid making the class public to prevent conflicts with other plugins. If you want to share it between your plugins either give each a copy, or move it to your custom namespace.
  • If the ConfigurationManager plugin is not installed in the game, this class will be safely ignored and your plugin will work as normal.

Here's an example of overriding order of settings and marking one of the settings as advanced:

// Override IsAdvanced and Order
Config.Bind("X", "1", 1, new ConfigDescription("", null, new ConfigurationManagerAttributes { IsAdvanced = true, Order = 3 }));
// Override only Order, IsAdvanced stays as the default value assigned by ConfigManager
Config.Bind("X", "2", 2, new ConfigDescription("", null, new ConfigurationManagerAttributes { Order = 1 }));
Config.Bind("X", "3", 3, new ConfigDescription("", null, new ConfigurationManagerAttributes { Order = 2 }));

How to make a custom editor for my setting?

If you are using a setting type that is not supported by ConfigurationManager, you can add a drawer Action for it. The Action will be executed inside OnGUI, use GUILayout to draw your setting as shown in the example below.

To use a custom seting drawer for an individual setting, use the CustomDrawer field in the attribute class. See above for more info on the attribute class.

void Start()
{
    // Add the drawer as a tag to this setting.
    Config.Bind("Section", "Key", "Some value" 
        new ConfigDescription("Desc", null, new ConfigurationManagerAttributes{ CustomDrawer = MyDrawer });
}

static void MyDrawer(BepInEx.Configuration.ConfigEntryBase entry)
{
    // Make sure to use GUILayout.ExpandWidth(true) to use all available space
    GUILayout.Label(entry.BoxedValue, GUILayout.ExpandWidth(true));
}

Add a custom editor globally

You can specify a drawer for all settings of a setting type. Do this by using ConfigurationManager.RegisterCustomSettingDrawer(Type, Action<SettingEntryBase>).

Warning: This requires you to reference ConfigurationManager.dll in your project and is not recommended unless you are sure all users will have it installed. It's usually better to use the above method to add the custom drawer to each setting individually instead.

void Start()
{
    ConfigurationManager.RegisterCustomSettingDrawer(typeof(MyType), CustomDrawer);
}

static void CustomDrawer(SettingEntryBase entry)
{
    GUILayout.Label((MyType)entry.Get(), GUILayout.ExpandWidth(true));
}

More Repositories

1

BepInEx

Unity / XNA game patcher and plugin framework
C#
4,717
star
2

HarmonyX

Harmony built on top of MonoMod.RuntimeDetours with additional features
C#
303
star
3

Il2CppInterop

A tool interoperate between CoreCLR and Il2Cpp at runtime
C#
203
star
4

BepInEx.Debug

Tools for debugging and developing BepInEx plugins (mono)
C#
99
star
5

BepInEx.Utility

Generic utility plugins for the BepInEx plugin loader (mono)
C#
69
star
6

BepInEx.AssemblyPublicizer

C#
49
star
7

BepInEx.MelonLoader.Loader

BepInEx loader for MelonLoader mods and plugins
C#
35
star
8

IPALoaderX

IPA plugin loader for BepInEx
C#
33
star
9

BepInEx.GraphicsSettings

Unity graphics settings plugin for BepInEx
C#
26
star
10

BepInEx.UnityInjectorLoader

UnityInjector loader for BepInEx
C#
24
star
11

NRedirect

Gain early code execution in a .NET application without patching any files
C#
17
star
12

BepInEx.Utility.IL2CPP

Generic utility plugins for the BepInEx plugin loader (IL2CPP)
C#
16
star
13

BepInEx.SybarisLoader.Patcher

Loads Sybaris plugins via the BepInEx framework
C#
15
star
14

BepInEx.Templates

A collection of dotnet templates for BepInEx
C#
13
star
15

Dobby

Fork of jmpews/Dobby with stability edits for Windows
C
11
star
16

BepInEx.MonoMod.Loader

Runtime MonoMod loader for BepInEx
C#
10
star
17

BepInEx.uMod.Loader

uMod mod loader for BepInEx
C#
8
star
18

BepInEx.BSIPA.Loader

BepInEx loader for BSIPA plugins
C#
8
star
19

BepInEx.SlimVML.Loader

A simple DLL loader with SlimVML support. Small, simple and works on Windows, Linux and macOS.
C#
7
star
20

BepInEx.PluginTemplate

A starter template for BepInEx 5.4 plugin development
C#
7
star
21

BepInEx.BepInEx4Upgrader

A preloader patcher that allows running BepInEx 4 plugins in BepInEx 5
C#
7
star
22

BepInEx.SRML.Loader

SRML mod loader plugin for BepInEx
C#
6
star
23

DeveloperConsole

Plugin for displaying an on screen BepInEx console window
C#
6
star
24

BepInEx.Analyzers

Roslyn analyzers for BepInEx plugin developers
C#
5
star
25

UnityDataMiner

Tool to mine data off Unity installers
C#
5
star
26

BepInEx.MultiFolderLoader

Loader to load plugins and patcher from multiple folders
C#
5
star
27

BepInEx.NuGetUpload.Service

Web service for uploading game assemblies to BepInEx NuGet
C#
3
star
28

BepInEx.Harmony

Harmony wrapper for BepInEx
C#
3
star
29

BepInEx.IL2CPP.MSBuild

MSBuild integration for BepInEx.IL2CPP plugin developers
C#
2
star
30

TestGame

C#
2
star
31

BepInEx.MDML.Loader

MuseDash ModLoader loader plugin for BepInEx
C#
2
star
32

BepInEx.UMMLoader

BepInEx loader for UnityModManager
C#
2
star
33

BepInEx.AutoPlugin

Source generator for quickly creating a BepInEx plugin scaffolding.
C#
2
star
34

bepinex-docs

Documentation and API pages for BepInEx
1
star
35

Il2Cpp.TlsAdapter

C#
1
star
36

HarmonyInteropDlls

Various Harmony DLLs to enable automatic upgrading of old Harmony versions
C#
1
star
37

bepinex-docs-template

Template for BepInEx Docs website
TypeScript
1
star