mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
rename mod & add settings
This commit is contained in:
parent
ef3efc001d
commit
28347e45a4
8 changed files with 39 additions and 20 deletions
57
FuckMetrics/Main.cs
Normal file
57
FuckMetrics/Main.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using MelonLoader;
|
||||
|
||||
namespace NAK.Melons.FuckMetrics;
|
||||
|
||||
public class FuckMetricsMod : MelonMod
|
||||
{
|
||||
public static MelonLogger.Instance Logger;
|
||||
|
||||
public const string SettingsCategory = "FuckMetrics";
|
||||
public static readonly MelonPreferences_Category CategoryFuckMetrics = MelonPreferences.CreateCategory(SettingsCategory);
|
||||
|
||||
public static readonly MelonPreferences_Entry<SettingState> EntryDisableMetrics =
|
||||
CategoryFuckMetrics.CreateEntry("Menu Metrics", SettingState.MenuOnly, description: "Disables menu metrics (FPS & Ping). Updates once on menu open if disabled.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<SettingState> EntryDisableCoreUpdates =
|
||||
CategoryFuckMetrics.CreateEntry("Menu Core Updates", SettingState.MenuOnly, description: "Disables menu core updates (Gamerule Icons & Debug Status). Updates once on menu open if disabled.");
|
||||
|
||||
public enum SettingState
|
||||
{
|
||||
Enabled,
|
||||
MenuOnly,
|
||||
Disabled
|
||||
}
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
Logger = LoggerInstance;
|
||||
EntryDisableMetrics.OnEntryValueChangedUntyped.Subscribe(OnDisableMetrics);
|
||||
EntryDisableCoreUpdates.OnEntryValueChangedUntyped.Subscribe(OnDisableCoreUpdates);
|
||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
ApplyPatches(typeof(HarmonyPatches.CVR_MenuManagerPatches));
|
||||
ApplyPatches(typeof(HarmonyPatches.ViewManagerPatches));
|
||||
}
|
||||
|
||||
private void OnDisableMetrics(object arg1, object arg2)
|
||||
{
|
||||
FuckMetrics.ToggleMetrics(EntryDisableMetrics.Value == SettingState.Enabled);
|
||||
}
|
||||
|
||||
private void OnDisableCoreUpdates(object arg1, object arg2)
|
||||
{
|
||||
FuckMetrics.ToggleCoreUpdates(EntryDisableMetrics.Value == SettingState.Enabled);
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Msg($"Failed while patching {type.Name}!");
|
||||
Logger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue