-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
59 lines (49 loc) · 1.45 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
using MelonLoader;
using MuseDashMirror;
using SelectiveEffects.Managers;
using SelectiveEffects.Properties;
namespace SelectiveEffects;
public sealed partial class Main : MelonMod
{
private static event Action ReloadEvent;
public override void OnInitializeMelon()
{
LoggerInstance.Msg($"{MelonBuildInfo.ModName} has loaded correctly!");
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
// Reload if needed outside of GameMain
if (SceneInfo.IsGameScene) return;
ReloadEvent?.Invoke();
ReloadEvent = null;
}
// Reload if needed before quitting to save the current settings
public override void OnApplicationQuit()
{
SettingsManager.DisableWatcherEvents();
ReloadEvent?.Invoke();
base.OnApplicationQuit();
}
// Late initialization of the file watcher
public override void OnLateInitializeMelon()
{
SettingsManager.EnableWatcherEvents();
}
internal static void QueueReload(object sender, FileSystemEventArgs e)
{
if (!SceneInfo.IsGameScene)
{
Reload();
return;
}
ReloadEvent = null;
ReloadEvent += Reload;
}
private static void Reload()
{
SettingsManager.Load();
EffectsDisablerManager.ReloadToggle();
EffectsDisablerManager.Load();
Melon<Main>.Logger.Msg("Reloaded successfully!");
}
}