From a8cd7122a87f7828b36edddeca1f8baf588a7d39 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Fri, 3 Mar 2023 16:41:48 -0600 Subject: [PATCH] let menu update position when closed --- MenuScalePatch/HarmonyPatches.cs | 18 ++++++------------ MenuScalePatch/Helpers/QuickMenuHelper.cs | 2 +- MenuScalePatch/MSP_Menus.cs | 12 ++++++------ MenuScalePatch/Main.cs | 4 ++-- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs index f8cac64..68aaa18 100644 --- a/MenuScalePatch/HarmonyPatches.cs +++ b/MenuScalePatch/HarmonyPatches.cs @@ -1,10 +1,9 @@ -using ABI_RC.Core.InteractionSystem; +using ABI_RC.Core; +using ABI_RC.Core.InteractionSystem; using ABI_RC.Core.Player; using ABI_RC.Core.Savior; using HarmonyLib; using NAK.Melons.MenuScalePatch.Helpers; -using System.Reflection; -using System.Reflection.Emit; using UnityEngine; namespace NAK.Melons.MenuScalePatch.HarmonyPatches; @@ -12,11 +11,6 @@ namespace NAK.Melons.MenuScalePatch.HarmonyPatches; /** ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug assuming its caused by cast from int to float getting the screen size, something floating point bleh - - ViewManager.UpdatePosition & CVR_MenuManager.UpdatePosition are called every second in a scheduled job. - (its why ViewManager.SetScale is called, because MM uses aspect ratio in scale calculation) - - I nuke those methods. Fuck them. I cannot disable the jobs though... **/ [HarmonyPatch] @@ -68,7 +62,7 @@ internal class HarmonyPatches [HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")] private static bool Prefix_CVR_MenuManager_UpdateMenuPosition() { - return false; + return !QuickMenuHelper.Instance.MenuIsOpen; } [HarmonyPrefix] @@ -79,7 +73,7 @@ internal class HarmonyPatches float ratio = (float)Screen.width / (float)Screen.height; float clamp = Mathf.Clamp(ratio, 0f, 1.8f); MSP_MenuInfo.AspectRatio = 1.7777779f / clamp; - return false; + return !MainMenuHelper.Instance.MenuIsOpen; } //Set QM stuff @@ -179,8 +173,8 @@ internal class HarmonyPatches //Support for changing VRMode during runtime. [HarmonyPostfix] - [HarmonyPatch(typeof(PlayerSetup), "CalibrateAvatar")] - private static void Postfix_PlayerSetup_CalibrateAvatar() + [HarmonyPatch(typeof(CVRTools), "ConfigureHudAffinity")] + private static void Postfix_CVRTools_ConfigureHudAffinity() { try { diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs index 5836f89..7a893e4 100644 --- a/MenuScalePatch/Helpers/QuickMenuHelper.cs +++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs @@ -36,7 +36,7 @@ public class QuickMenuHelper : MonoBehaviour UpdateMenuPosition(); if (NeedsPositionUpdate) UpdateMenuPosition(); - } + } } public void CreateWorldAnchors() diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs index b0e1617..5268e30 100644 --- a/MenuScalePatch/MSP_Menus.cs +++ b/MenuScalePatch/MSP_Menus.cs @@ -20,13 +20,13 @@ public class MSP_MenuInfo internal static bool UseIndependentHeadTurn = true; internal static bool PlayerAnchorMenus = true; - //if other mods need to disable? - internal static bool DisableQMHelper; - internal static bool DisableQMHelper_VR; - internal static bool DisableMMHelper; - internal static bool DisableMMHelper_VR; + //Debug/Integration + public static bool DisableQMHelper; + public static bool DisableQMHelper_VR; + public static bool DisableMMHelper; + public static bool DisableMMHelper_VR; - //reflection (traverse sucks ass) + //reflection internal static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance); internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance); internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance); diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs index e87f2fe..3f8387f 100644 --- a/MenuScalePatch/Main.cs +++ b/MenuScalePatch/Main.cs @@ -7,7 +7,7 @@ public class MenuScalePatch : MelonMod { internal static MelonLogger.Instance Logger; internal static MelonPreferences_Category m_categoryMenuScalePatch; - internal static MelonPreferences_Entry + internal static MelonPreferences_Entry //m_entryWorldAnchorVRQM, m_entryUseIndependentHeadTurn, m_entryPlayerAnchorMenus; @@ -17,7 +17,7 @@ public class MenuScalePatch : MelonMod //m_entryWorldAnchorVRQM = m_categoryMenuScalePatch.CreateEntry("World Anchor VR QM", false, description: "Should place QM in World Space while VR."); m_entryUseIndependentHeadTurn = m_categoryMenuScalePatch.CreateEntry("Use Independent Head Turn", true, description: "Should you be able to use independent head turn in a menu while in Desktop?"); m_entryPlayerAnchorMenus = m_categoryMenuScalePatch.CreateEntry("Player Anchor Menus", true, description: "Should the menus be anchored to & constantly follow the player?"); - + foreach (var setting in m_categoryMenuScalePatch.Entries) { setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);