BepInExConfig

v0.1.2·Updated 2021-05-30

Serialize and deserialize the BepInEx configration file into class.

About this mod Machine translation

BepInExConfig

What's this?

This isn't Mod. BepInEx Tools.

This tool is BepInEx ConfigFile Class Serializer/Deserializer.

You need to do is to create a class for the configuration with the specified attributes.

Then, when you call the extension methods added by the tool, the settings will be saved and loaded according to the attributes set in the class.

これは Mod ではなく、BepInEx のツールです。

このツールは BepInEx のSET ファイルとクラスをシリアライズ/デシリアライズします.

The このツールをmakes the うには, specifies the された attribute をhold つ and sets the のクラスを to make the するnecessary があります.

あとは、ツールによってAdditional された拡张メソッドを火び出すと、クラスにSETされたAttributeに応じてSETのsaving・読み込みが行われます.

INSTALL インストール

If r2modman

  • Install BepInEx
  • Install BepInExConfig
  • Add BeinExConfig.dll to the project reference. (for Visual Stuio)

r2modman's occasion

  • BepInEx をインストールします。
  • BepInExConfig をインストールします。
  • BepInExConfig.dll (Visual Stuio)

If Manual

  • Install BepInEx
  • Then copy BeinExConfig.dll into ~~~/steamapps/common/Dyson Sphere Program/BepInEx/plugins
  • Add BeinExConfig.dll to the project reference. (for Visual Stuio)

Manual occasions

  • BepInEx をインストールします。
  • ダウンロードした BepInExConfig.dll を ~~~/steamapps/common/Dyson Sphere Program/BepInEx/plugins にコピーします
  • BepInExConfig.dll (Visual Stuio)

Usage 使い方

A simple sample is provided here.

ここには简単なサンプルをrecord します.

There is a plugin for testing in BepInExCoinfgTest, so please refer to it.

BepInExCoinfgTest にテスト用のプラグインがあるのでReferenceにしてください.

Sample Code サンプルコード

Create config class.

The settings are made by クラスをる.

TestConfig.cs

[BepInExConfig] // Required for setting using クラスには

public class TestConfig

{

// Work - Public Property

[BepInExConfigMember("Base", "TestProp", 10, order: 99)]

public int TestProp { get; set; }

// Work - Public Field

[BepInExConfigMember("Base", "TestField", "hogehoge", "Descripton", order: 0)]

public string TestField;

// Work - Enum

[BepInExConfigMember("Base", "TestKey", KeyCode.Tab, "Sample Key Code Config", order: 1)]

public KeyCode TestKey;

// Not Work - Only public properties or field will work.

[BepInExConfigMember("Base", "TestProp", 10)]

private int PrivateProp { get; set; }

// Not Work - If you don't add the attribute, it won't work.

public int NoAttributeProp { get; set; }

}

Load config.

settingsをロード.cs

public static TestConfig PluginConfig { get; set; }

public static void PluginConfigLoad()

{

this.PluginConfig = Config.LoadConfig();

Logger.LogInfo($"TestField: {hoge.TestField}");

Logger.LogInfo($"TestKey: {hoge.TestKey}");

Logger.LogInfo($"TestProp: {hoge.TestProp}");

Logger.LogInfo("Loaded config.");

}

Save config.

settingsをsave.cs

public static TestConfig PluginConfig { get; set; }

public static void PluginConfigSave()

{

this.PluginConfig = new TestConfig()

{

TestField = "hugahuga",

TestKey = KeyCode.KeypadEnter,

TestProp = 999,

}

var orphanedEntries = typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Config, null) as Dictionary;

orphanedEntries?.Clear();

Config.SaveConfig(PluginConfig);

Logger.LogInfo("Saved config.");

}

Saved Config Sample

Save されたコンフィグのサンプル.cfg

Settings file was created by plugin BepInExCoinfgTest v0.0.1

Plugin GUID: Fuhduki.DSP.BepInExCoinfgTest

[Base]

Descripton

Setting type: String

Default value: hogehoge

TestField = hugahuga

Sample Key Code Config

Setting type: KeyCode

Default value: Tab

Acceptable values: None,...

TestKey = KeypadEnter

Setting type: Int32

Default value: 10

TestProp = 999

Simply API Document

Attributes

  • BepInExConfig
  • Can only be given to classes.
  • The configuration class must have a no-argument constructor. (It's OK if you don't write a constructor)
  • BepInExConfigMember(string section, string key, string defaultValue, string description = "", int order = 0)
  • Can only be given to field or property.
  • Only Work to public field or property.
  • DefaultValue Typse are string, bool, byte, short, ushort, int, uint, long, ulong, float, double, decimal or object(for …

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

xiaoye97-BepInEx

File & checksum

Filename
BepInExConfig-0.1.2.zip
File size
18.3 KiB