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.Player;
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using HarmonyLib; using HarmonyLib;
using NAK.Melons.MenuScalePatch.Helpers; using NAK.Melons.MenuScalePatch.Helpers;
using System.Reflection;
using System.Reflection.Emit;
using UnityEngine; using UnityEngine;
namespace NAK.Melons.MenuScalePatch.HarmonyPatches; 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 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 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] [HarmonyPatch]
@ -68,7 +62,7 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")] [HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
private static bool Prefix_CVR_MenuManager_UpdateMenuPosition() private static bool Prefix_CVR_MenuManager_UpdateMenuPosition()
{ {
return false; return !QuickMenuHelper.Instance.MenuIsOpen;
} }
[HarmonyPrefix] [HarmonyPrefix]
@ -79,7 +73,7 @@ internal class HarmonyPatches
float ratio = (float)Screen.width / (float)Screen.height; float ratio = (float)Screen.width / (float)Screen.height;
float clamp = Mathf.Clamp(ratio, 0f, 1.8f); float clamp = Mathf.Clamp(ratio, 0f, 1.8f);
MSP_MenuInfo.AspectRatio = 1.7777779f / clamp; MSP_MenuInfo.AspectRatio = 1.7777779f / clamp;
return false; return !MainMenuHelper.Instance.MenuIsOpen;
} }
//Set QM stuff //Set QM stuff
@ -179,8 +173,8 @@ internal class HarmonyPatches
//Support for changing VRMode during runtime. //Support for changing VRMode during runtime.
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "CalibrateAvatar")] [HarmonyPatch(typeof(CVRTools), "ConfigureHudAffinity")]
private static void Postfix_PlayerSetup_CalibrateAvatar() private static void Postfix_CVRTools_ConfigureHudAffinity()
{ {
try try
{ {

View file

@ -20,13 +20,13 @@ public class MSP_MenuInfo
internal static bool UseIndependentHeadTurn = true; internal static bool UseIndependentHeadTurn = true;
internal static bool PlayerAnchorMenus = true; internal static bool PlayerAnchorMenus = true;
//if other mods need to disable? //Debug/Integration
internal static bool DisableQMHelper; public static bool DisableQMHelper;
internal static bool DisableQMHelper_VR; public static bool DisableQMHelper_VR;
internal static bool DisableMMHelper; public static bool DisableMMHelper;
internal static bool DisableMMHelper_VR; 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 _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 _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance); internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);