-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
98 lines (86 loc) · 3.37 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.IO;
using MelonLoader;
using Mu3Assist.Cheat;
using Mu3Assist.Common;
using Mu3Assist.Fix;
namespace Mu3Assist
{
public static class BuildInfo
{
public const string Name = "Mu3-Assist";
public const string Description = "Melonloader Mod For O.N.G.E.K.I";
public const string Author = "WYH2004(Slim)";
public const string Company = null;
public const string Version = "1.0.0";
public const string DownloadLink = null;
}
public class Mu3Assist : MelonMod
{
public readonly ConfigManager Config = new ConfigManager();
public override void OnInitializeMelon()
{
PrintLogo();
MelonLogger.Msg("Load Mod Config.");
var configPath = $"{BuildInfo.Name}/config.ini";
if (!File.Exists(configPath))
{
MelonLogger.Error($"Path: \"{configPath}\" Not Found.");
return;
}
try
{
Config.Initialize();
}
catch (Exception e)
{
MelonLogger.Error($"Error initializing mod config: \n{e}");
}
//Patch
// [Common]
if (Config.InfinityTimer) Patch(typeof(InfinityTimer));
if (Config.SkipWarningScreen) Patch(typeof(SkipWarningScreen));
// [Cheat]
if (Config.FastSkip) Patch(typeof(FastSkip));
if (Config.FastRestart) Patch(typeof(FastRestart));
if (Config.UnlockMaster) Patch(typeof(UnlockMaster));
if (Config.UnlockEvent) Patch(typeof(UnlockEvent));
if (Config.UnlockMusic) Patch(typeof(UnlockMusic));
// [Fix]
if (Config.DisableEncryption) Patch(typeof(DisableEncryption));
MelonLogger.Msg("Loading completed");
}
public override void OnGUI()
{
if(Config.ShowFPS) ShowFPS.OnGUI();
}
private static bool Patch(Type type)
{
try
{
MelonLogger.Msg($"- Patch: {type}");
HarmonyLib.Harmony.CreateAndPatchAll(type);
return true;
}
catch (Exception e)
{
MelonLogger.Error($"Patch {type} failed.");
MelonLogger.Error(e);
return false;
}
}
private static void PrintLogo()
{
MelonLogger.Msg("\n" +
"\r\n __ __ ____ _ _ " +
"\r\n | \\/ | |___ \\ /\\ (_) | | " +
"\r\n | \\ / |_ _ __) |_____ / \\ ___ ___ _ ___| |_ " +
"\r\n | |\\/| | | | ||__ <______/ /\\ \\ / __/ __| / __| __|" +
"\r\n | | | | |_| |___) | / ____ \\\\__ \\__ \\ \\__ \\ |_ " +
"\r\n |_| |_|\\__,_|____/ /_/ \\_\\___/___/_|___/\\__|" +
"\r\n " +
"\r\n=====================================================" +
$"\r\n Version: {BuildInfo.Version} Author: {BuildInfo.Author}");
}
}
}