MapleWheels-BepInExExtensions icon

BepInExExtensions

Helper library for making writing ConfigFiles and profile support easy

Last updated 3 weeks ago
Total downloads 2366
Total rating 1 
Dependency string MapleWheels-BepInExExtensions-2.2.0
Dependants 2 other mods depend on this mod

This mod requires the following mods to function

bbepis-BepInExPack-5.3.1 icon
bbepis-BepInExPack

Unified BepInEx all-in-one modding pack - plugin framework, detour library

Preferred version: 5.3.1
README

Note: This project is not officially associated with BepInEx.

This BepInEx Extension library is a collection of various helper functionalities. As of now the current ready-to-use functions it includes are:

  • Configuration File Model

    > Simple, central place to make your configuration files and instantiate them. An up to date example can be found here: ExamplePlugin and ExampleModel

    > Designed to make BepInEx Configuration Files easy to write and instantiate.

    > Includes virtual methods and event hooks for easy customization of each variable in Pre and Post BepInEx.Configuration.ConfigFile.Bind() and for common ConfigFile events.

    > Migration/Profile Support: You can now change which ConfigFile a model is using live, including Migration hooks, with a simple, one-line command.

    > Allows you to create your own types/classes, just implement the interfaces and the rest will work.

Sample Usage:

public class ExampleModel : ConfigDataModel
{
    public ConfigData<float> ConfigOption1 { get; set; } //must be a property.
    public ConfigData<float> ConfigOption2 { get; set; } = new ConfigData<float>()  //constructor instantiation style.
    {
        Key = "Config_Variable_Name",   //This will be set to &#x27;configOption2&#x27; if not set by you. Defaults to the variable name.
        DefaultValue = 10f,
        DescriptionString = "I&#x27;m running out of flavor text",
        AcceptableValues = new AcceptableValueRange<float>(0f, 50f)
    };
    public ConfigData<float> ConfigOption3 { get; set; } //Intentionally left un-initiated. Late bind style.

    public override void SetDefaults()
    {
        this.SectionName = "Example Section";   //Define your section name here. 

        //you don&#x27;t need to define everything here;  DefaultValue and DescriptionString are recommended.
        this.ConfigOption1 = new ConfigData<float>()    //SetDefaults instantiation style.
        {
            DefaultValue = 15f,
            DescriptionString = "Here&#x27;s the description for the config file."
        };
    }
}

[BepInPlugin("dev.cdmtests", "CDM Tests", "0.0.0")]
public class ExamplePlugin : BaseUnityPlugin
{
    ExampleModel model;

    void Awake()
    {
        model = Config.BindModel<ExampleModel>(Logger); //Initialized and ready to use.
        Logger.LogInfo($"ExamplePlugin: model.ConfigOption1={model.ConfigOption1.Value}");

        model.ConfigOption1.Value = 20f;
        Logger.LogInfo($"ExamplePlugin: model.ConfigOption1={model.ConfigOption1.Value}");

        //If you didn&#x27;t initialize an entry in your config model type, or you want to do it externally, you can do so here. 
        //Late bind style.
        model.ConfigOption3 = new ConfigData<int>()
        {
            DefaultValue = 10,
            DescriptionString = "hello",
            SectionName = model.SectionName,
        }.Bind(Config, Logger); //Late Bind Call

        //Want to change config files for profile support? Easy.
        ConfigFile profile2 = new ConfigFile(
            System.IO.Path.Combine(Paths.BepInExConfigPath, "ExamplePlugin", "profile2"), true);    //Profile config file.
        model.SetConfigFile(profile2);  //New profile active.
    }
}

Available versions

Please note that the install buttons only work if you have compatible client software installed. Otherwise use the zip download links instead.

Upload date Version number Downloads Download link  
2020-10-2 2.2.0 2060 MapleWheels-BepInExExtensions-2.2.0.zip Install
2020-9-27 2.0.0 129 MapleWheels-BepInExExtensions-2.0.0.zip Install
2020-9-10 1.1.0 177 MapleWheels-BepInExExtensions-1.1.0.zip Install