Skip to content

Commit 70678db

Browse files
Add PolyMod.json config
1 parent d75f706 commit 70678db

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Plugin.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Text.Json;
23
using BepInEx;
34
using BepInEx.Configuration;
45
using BepInEx.Logging;
@@ -10,17 +11,33 @@ namespace PolyMod
1011
[BepInPlugin("com.polymod", "PolyMod", VERSION)]
1112
public class Plugin : BepInEx.Unity.IL2CPP.BasePlugin
1213
{
14+
internal record PolyConfig(
15+
bool debug = false
16+
);
17+
1318
internal const string VERSION = "0.0.0";
1419
internal const int AUTOIDX_STARTS_FROM = 1000;
1520
internal static readonly string BASE_PATH = Path.Combine(BepInEx.Paths.BepInExRootPath, "..");
1621
internal static readonly string MODS_PATH = Path.Combine(BASE_PATH, "Mods");
22+
internal static readonly string CONFIG_PATH = Path.Combine(BASE_PATH, "PolyMod.json");
1723

1824
#pragma warning disable CS8618
25+
internal static PolyConfig config;
1926
internal static ManualLogSource logger;
2027
#pragma warning restore CS8618
2128

2229
public override void Load()
2330
{
31+
try
32+
{
33+
config = JsonSerializer.Deserialize<PolyConfig>(File.ReadAllText(CONFIG_PATH))!;
34+
}
35+
catch
36+
{
37+
config = new();
38+
File.WriteAllText(CONFIG_PATH, JsonSerializer.Serialize(config));
39+
}
40+
2441
logger = Log;
2542
ConfigFile.CoreConfig[new("Logging.Disk", "WriteUnityLog")].BoxedValue = true;
2643
AudioClipLoader.Init();

0 commit comments

Comments
 (0)