This repository has been archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cs
82 lines (72 loc) · 2.49 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
using System.IO;
using MelonLoader;
using MuseDashMirror.CommonPatches;
using Tomlet;
using UnityEngine;
using static MuseDashMirror.BattleComponent;
using static MuseDashMirror.PlayerData;
using static ChartReview.Save;
namespace ChartReview;
internal class Main : MelonMod
{
private static int LastOffset { get; set; }
private static int LastCharacter { get; set; } = -1;
private static int LastElfin { get; set; } = -1;
public override void OnInitializeMelon()
{
Load();
LastCharacter = Save.Data.LastCharacter;
LastElfin = Save.Data.LastElfin;
LastOffset = Save.Data.LastOffset;
PatchEvents.PnlMenuEvent += Patch.PnlMenuPostfix;
PatchEvents.SwitchLanguagesEvent += Patch.SwitchLanguagesPostfix;
PatchEvents.MenuSelectEvent += DisableToggle;
GameStartEvent += DisableUI;
MelonLogger.Msg("Chart Review is loaded!");
}
public override void OnDeinitializeMelon()
{
Save.Data.LastCharacter = SelectedCharacterIndex == 2 ? LastCharacter : SelectedCharacterIndex;
Save.Data.LastElfin = SelectedElfinIndex == -1 ? SelectedElfinIndex : LastElfin;
Save.Data.LastOffset = Offset == 0 ? LastOffset : Offset;
File.WriteAllText(Path.Combine("UserData", "ChartReview.cfg"), TomletMain.TomlStringFrom(Save.Data));
}
internal static void ChangeSettings()
{
if (Save.Data.ChartReviewEnabled)
{
LastCharacter = SelectedCharacterIndex;
LastElfin = SelectedElfinIndex;
LastOffset = Offset;
SetCharacter(2);
SetElfin(-1);
SetOffset(0);
SetAutoFever(false);
}
else
{
SetCharacter(LastCharacter);
SetElfin(LastElfin);
SetOffset(LastOffset);
SetAutoFever(true);
}
}
private static void DisableUI()
{
// if is in game scene and objects are not disabled
if (Save.Data.ChartReviewEnabled)
{
GameObject.Find("Below").SetActive(false);
GameObject.Find("Score").SetActive(false);
GameObject.Find("HitPointRoad").SetActive(false);
GameObject.Find("HitPointAir").SetActive(false);
}
}
private static void DisableToggle(int listIndex, int index, bool isOn)
{
if (listIndex == 0 && index == 0 && isOn)
Patch.ChartReviewToggle.SetActive(true);
else
Patch.ChartReviewToggle.SetActive(false);
}
}