Skip to content

Commit 28b9d79

Browse files
committed
[+] Read config & Compat layer
1 parent 99c779d commit 28b9d79

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

mod/Compat.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
using MelonLoader;
4+
using WorldLink;
5+
6+
static class AquaMai
7+
{
8+
public static string ReadString(string key)
9+
{
10+
return key == "Mods.WorldLink.LobbyUrl" ? Core.Config.LobbyUrl : null;
11+
}
12+
}
13+
14+
[AttributeUsage(AttributeTargets.Class)]
15+
class EnableIf: Attribute
16+
{
17+
public EnableIf(Type tpye, string condition) { }
18+
}
19+
20+
[AttributeUsage(AttributeTargets.All)]
21+
class ConfigEntry: Attribute
22+
{
23+
public ConfigEntry(bool hideWhenDefault) { }
24+
25+
public ConfigEntry(string name, string desc) { }
26+
}
27+
28+
[AttributeUsage(AttributeTargets.All)]
29+
public class ConfigSection: Attribute
30+
{
31+
public ConfigSection(string zh, string en, bool defaultOn = false) { }
32+
}

mod/Core.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using MelonLoader;
2+
using Tomlet;
3+
4+
[assembly: MelonInfo(typeof(WorldLink.Core), "WorldLink", "1.0.0", "Azalea")]
5+
[assembly: MelonGame("sega-interactive", "Sinmai")]
6+
7+
namespace WorldLink;
8+
9+
public class Config
10+
{
11+
public string LobbyUrl { get; set; }
12+
public bool Debug { get; set; }
13+
}
14+
15+
public class Core : MelonMod
16+
{
17+
public static Config Config;
18+
19+
public override void OnInitializeMelon()
20+
{
21+
// Load config
22+
LoggerInstance.Msg("Loading config...");
23+
Config = TomletMain.To<Config>(File.ReadAllText("WorldLink.toml"));
24+
25+
LoggerInstance.Msg("Patching...");
26+
HarmonyLib.Harmony.CreateAndPatchAll(typeof(Futari));
27+
28+
if (Config.Debug)
29+
{
30+
LoggerInstance.Msg("Patching debug...");
31+
HarmonyLib.Harmony.CreateAndPatchAll(typeof(Futari.FutariDebug));
32+
}
33+
34+
LoggerInstance.Msg("Initialized.");
35+
}
36+
}

0 commit comments

Comments
 (0)