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 の設定ファイルとクラスをシリアライズ/デシリアライズします。
このツールを使うには、指定された属性を持つ設定用のクラスを作成する必要があります。
あとは、ツールによって追加された拡張メソッドを呼び出すと、クラスに設定された属性に応じて設定の保存・読み込みが行われます。
A simple sample is provided here.
ここには簡単なサンプルを記載します。
There is a plugin for testing in BepInExCoinfgTest, so please refer to it.
BepInExCoinfgTest にテスト用のプラグインがあるので参考にしてください。
Create config class. 設定用クラスを作る。
[BepInExConfig] // 設定用クラスには必須
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. 設定をロード
public static TestConfig PluginConfig { get; set; }
public static void PluginConfigLoad()
{
this.PluginConfig = Config.LoadConfig<TestConfig>();
Logger.LogInfo($"TestField : {hoge.TestField}");
Logger.LogInfo($"TestKey : {hoge.TestKey}");
Logger.LogInfo($"TestProp : {hoge.TestProp}");
Logger.LogInfo("Loaded config.");
}
Save config. 設定を保存
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<ConfigDefinition, string>;
orphanedEntries?.Clear();
Config.SaveConfig(PluginConfig);
Logger.LogInfo("Saved config.");
}
Saved Config Sample 保存されたコンフィグのサンプル
## 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
BepInExConfig
BepInExConfigMember(string section, string key, string defaultValue, string description = "", int order = 0)
T LoadConfig<T>(this ConfigFile config)
void SaveConfig<T>(this ConfigFile config, T saveTarget)
BepInExConfig
BepInExConfigMember(string section, string key, string defaultValue, string description = "", int order = 0)
T LoadConfig<T>(this ConfigFile config)
void SaveConfig<T>(this ConfigFile config, T saveTarget)
We mistakenly released manifest.json under the name BepInConfig, but please delete that and use BepInExConfig.
manifest.json を間違えて BepInConfig という名前でリリースしましたが、そちらは削除して BepInExConfig の方を使用してください。