let menu update position when closed

This commit is contained in:
NotAKidoS 2023-03-03 16:41:48 -06:00
parent 3248dd6335
commit a8cd7122a8
4 changed files with 15 additions and 21 deletions

View file

@ -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
{

View file

@ -36,7 +36,7 @@ public class QuickMenuHelper : MonoBehaviour
UpdateMenuPosition();
if (NeedsPositionUpdate)
UpdateMenuPosition();
}
}
}
public void CreateWorldAnchors()

View file

@ -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);

View file

@ -7,7 +7,7 @@ public class MenuScalePatch : MelonMod
{
internal static MelonLogger.Instance Logger;
internal static MelonPreferences_Category m_categoryMenuScalePatch;
internal static MelonPreferences_Entry<bool>
internal static MelonPreferences_Entry<bool>
//m_entryWorldAnchorVRQM,
m_entryUseIndependentHeadTurn,
m_entryPlayerAnchorMenus;
@ -17,7 +17,7 @@ public class MenuScalePatch : MelonMod
//m_entryWorldAnchorVRQM = m_categoryMenuScalePatch.CreateEntry<bool>("World Anchor VR QM", false, description: "Should place QM in World Space while VR.");
m_entryUseIndependentHeadTurn = m_categoryMenuScalePatch.CreateEntry<bool>("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<bool>("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);