forked from xoxfaby/BetterUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterUI.cs
82 lines (69 loc) · 2.98 KB
/
BetterUI.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;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using BepInEx;
using MonoMod.RuntimeDetour;
using System.Reflection;
namespace BetterUI
{
[BepInDependency("dev.ontrigger.itemstats", BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency("com.xoxfaby.BetterAPI", BepInDependency.DependencyFlags.SoftDependency)]
[BepInPlugin(GUID, Name, Version)]
public partial class BetterUIPlugin : BetterUnityPlugin.BetterUnityPlugin<BetterUIPlugin>
{
public const string GUID = "com.xoxfaby.BetterUI";
public const string Name = "BetterUI";
public const string Version = "2.7.2";
internal static BetterUIPlugin instance;
internal delegate void HUDAwakeEvent(RoR2.UI.HUD self);
internal static event HUDAwakeEvent onHUDAwake;
internal static bool BetterAPIModIntegration = false;
internal static RoR2.UI.HUD hud;
internal static RoR2.UI.ObjectivePanelController objectivePanelController;
public static StringBuilder sharedStringBuilder = new StringBuilder();
public override BaseUnityPlugin typeReference => throw new NotImplementedException();
protected override void Awake()
{
base.Awake();
instance = this;
this.gameObject.hideFlags |= UnityEngine.HideFlags.HideAndDontSave;
this.gameObject.AddComponent<BetterUI.Language.UpdateChecker>();
BetterUI.Language.LoadLanguages();
if (ConfigManager.ComponentsItemSorting.Value)
ItemSorting.Hook();
if (ConfigManager.ComponentsStatsDisplay.Value)
StatsDisplay.Hook();
if (ConfigManager.ComponentsCommandImprovements.Value)
CommandImprovements.Hook();
if (ConfigManager.ComponentsDPSMeter.Value)
DPSMeter.Initialize();
if (ConfigManager.ComponentsBuffTimers.Value)
Buffs.Hook();
if (ConfigManager.ComponentsAdvancedIcons.Value)
AdvancedIcons.Hook();
if (ConfigManager.ComponentsItemCounters.Value)
ItemCounters.Hook();
if (ConfigManager.ComponentsMisc.Value)
Misc.Hook();
BetterUIWindow.Init();
RoR2.ItemCatalog.availability.CallWhenAvailable(ItemStats.Initialize);
}
protected override void OnEnable()
{
base.OnEnable();
BetterAPIModIntegration = BepInEx.Bootstrap.Chainloader.PluginInfos.ContainsKey("com.xoxfaby.BetterAPI");
BetterUIPlugin.Hooks.Add<RoR2.UI.HUD>("Awake", HUD_Awake);
}
internal static void HUD_Awake(Action<RoR2.UI.HUD> orig, RoR2.UI.HUD self)
{
orig(self);
hud = self;
objectivePanelController = self.GetComponentInChildren<RoR2.UI.ObjectivePanelController>(true);
if (onHUDAwake != null)
{
onHUDAwake.Invoke(hud);
}
}
}
}