rename mod & add settings

This commit is contained in:
NotAKidoS 2023-03-16 02:05:05 -05:00
parent ef3efc001d
commit 28347e45a4
8 changed files with 39 additions and 20 deletions

View file

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.2.32630.192 VisualStudioVersion = 17.2.32630.192
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FuckCohtml", "FuckCohtml.csproj", "{D3BA0B4E-9DE9-4AD4-91E2-0A18D0283754}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FuckMetrics", "FuckMetrics.csproj", "{D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3BA0B4E-9DE9-4AD4-91E2-0A18D0283754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3BA0B4E-9DE9-4AD4-91E2-0A18D0283754}.Debug|Any CPU.Build.0 = Debug|Any CPU {D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3BA0B4E-9DE9-4AD4-91E2-0A18D0283754}.Release|Any CPU.ActiveCfg = Release|Any CPU {D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3BA0B4E-9DE9-4AD4-91E2-0A18D0283754}.Release|Any CPU.Build.0 = Release|Any CPU {D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A63345C7-1CD9-4EA0-B891-8CE1CEB97C8B} SolutionGuid = {CE55D93A-682A-47F4-A971-65132B854210}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -10,8 +10,8 @@ class PlayerSetupPatches
[HarmonyPatch(typeof(PlayerSetup), "Start")] [HarmonyPatch(typeof(PlayerSetup), "Start")]
private static void Postfix_PlayerSetup_Start() private static void Postfix_PlayerSetup_Start()
{ {
FuckMetrics.ToggleMetrics(FuckMetricsMod.EntryDisableMetrics.Value); FuckMetrics.ToggleMetrics(FuckMetricsMod.EntryDisableMetrics.Value == FuckMetricsMod.SettingState.Enabled);
FuckMetrics.ToggleCoreUpdates(FuckMetricsMod.EntryDisableCoreUpdates.Value); FuckMetrics.ToggleCoreUpdates(FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.Enabled);
} }
} }
@ -21,11 +21,17 @@ class CVR_MenuManagerPatches
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })] [HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show) private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
{ {
if (!FuckMetricsMod.EntryDisableCoreUpdates.Value) return; if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.Disabled) return;
if (show)
if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.MenuOnly)
{
FuckMetrics.ToggleMetrics(show);
FuckMetrics.ToggleCoreUpdates(show);
}
else if (show)
{ {
CVR_MenuManager.Instance.SendCoreUpdate();
ViewManager.Instance.UpdateMetrics(); ViewManager.Instance.UpdateMetrics();
CVR_MenuManager.Instance.SendCoreUpdate();
} }
} }
} }
@ -36,11 +42,17 @@ class ViewManagerPatches
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })] [HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
private static void Postfix_ViewManager_UiStateToggle(bool show) private static void Postfix_ViewManager_UiStateToggle(bool show)
{ {
if (!FuckMetricsMod.EntryDisableMetrics.Value) return; if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.Disabled) return;
if (show)
if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.MenuOnly)
{
FuckMetrics.ToggleMetrics(show);
FuckMetrics.ToggleCoreUpdates(show);
}
else if (show)
{ {
CVR_MenuManager.Instance.SendCoreUpdate();
ViewManager.Instance.UpdateMetrics(); ViewManager.Instance.UpdateMetrics();
CVR_MenuManager.Instance.SendCoreUpdate();
} }
} }
} }

View file

@ -9,11 +9,18 @@ public class FuckMetricsMod : MelonMod
public const string SettingsCategory = "FuckMetrics"; public const string SettingsCategory = "FuckMetrics";
public static readonly MelonPreferences_Category CategoryFuckMetrics = MelonPreferences.CreateCategory(SettingsCategory); public static readonly MelonPreferences_Category CategoryFuckMetrics = MelonPreferences.CreateCategory(SettingsCategory);
public static readonly MelonPreferences_Entry<bool> EntryDisableMetrics = public static readonly MelonPreferences_Entry<SettingState> EntryDisableMetrics =
CategoryFuckMetrics.CreateEntry("Disable Metrics", true, description: "Disables menu metrics (FPS & Ping). Updates once on menu open if disabled."); CategoryFuckMetrics.CreateEntry("Menu Metrics", SettingState.MenuOnly, description: "Disables menu metrics (FPS & Ping). Updates once on menu open if disabled.");
public static readonly MelonPreferences_Entry<bool> EntryDisableCoreUpdates = public static readonly MelonPreferences_Entry<SettingState> EntryDisableCoreUpdates =
CategoryFuckMetrics.CreateEntry("Disable Core Updates", true, description: "Disables menu core updates (Gamerule Icons & Debug Status). Updates once on menu open if disabled."); 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() public override void OnInitializeMelon()
{ {
@ -27,12 +34,12 @@ public class FuckMetricsMod : MelonMod
private void OnDisableMetrics(object arg1, object arg2) private void OnDisableMetrics(object arg1, object arg2)
{ {
FuckMetrics.ToggleMetrics(EntryDisableMetrics.Value); FuckMetrics.ToggleMetrics(EntryDisableMetrics.Value == SettingState.Enabled);
} }
private void OnDisableCoreUpdates(object arg1, object arg2) private void OnDisableCoreUpdates(object arg1, object arg2)
{ {
FuckMetrics.ToggleCoreUpdates(EntryDisableCoreUpdates.Value); FuckMetrics.ToggleCoreUpdates(EntryDisableMetrics.Value == SettingState.Enabled);
} }
private void ApplyPatches(Type type) private void ApplyPatches(Type type)