mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
fixed shit
This commit is contained in:
parent
83268619da
commit
e54a20ee42
3 changed files with 63 additions and 18 deletions
|
@ -13,26 +13,42 @@ public class MenuScalePatch : MelonMod
|
|||
[HarmonyPatch]
|
||||
private class HarmonyPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
|
||||
private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor)
|
||||
internal static bool adjustedMenuPosition = false;
|
||||
internal static void SetMenuPosition(Transform menuTransform, float scale)
|
||||
{
|
||||
Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
//correct quickmenu - pretty much needsQuickmenuPositionUpdate()
|
||||
Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
|
||||
___quickMenu.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
|
||||
___quickMenu.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ____scaleFactor;
|
||||
menuTransform.eulerAngles = rotationPivot.eulerAngles;
|
||||
}
|
||||
menuTransform.position = rotationPivot.position + rotationPivot.forward * 1f * scale;
|
||||
adjustedMenuPosition = true;
|
||||
}
|
||||
|
||||
//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
|
||||
//attempting to ignore that call if there wasnt actually a change
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
|
||||
private static void SetQMScale(ref CohtmlView ___quickMenu, ref bool ___needsQuickmenuPositionUpdate, ref float ____scaleFactor, ref GameObject ____leftVrAnchor)
|
||||
{
|
||||
if (MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
___quickMenu.transform.position = ____leftVrAnchor.transform.position;
|
||||
___quickMenu.transform.rotation = ____leftVrAnchor.transform.rotation;
|
||||
___needsQuickmenuPositionUpdate = false;
|
||||
return;
|
||||
}
|
||||
SetMenuPosition(___quickMenu.transform, ____scaleFactor);
|
||||
___needsQuickmenuPositionUpdate = false;
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
attempting to ignore that call if there wasnt actually a change
|
||||
**/
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ViewManager), "SetScale")]
|
||||
private static void CheckLegit(float avatarHeight, ref float ___cachedAvatarHeight, out bool __state)
|
||||
private static void CheckMMScale(float avatarHeight, ref float ___cachedAvatarHeight, out bool __state)
|
||||
{
|
||||
if (___cachedAvatarHeight == avatarHeight)
|
||||
{
|
||||
|
@ -48,10 +64,39 @@ public class MenuScalePatch : MelonMod
|
|||
{
|
||||
if (!__state) return;
|
||||
|
||||
//correct main menu - pretty much UpdateMenuPosition()
|
||||
Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
|
||||
__instance.gameObject.transform.position = rotationPivot.position + __instance.gameObject.transform.forward * 1f * ___scaleFactor;
|
||||
SetMenuPosition(__instance.transform, ___scaleFactor);
|
||||
___needsMenuPositionUpdate = false;
|
||||
}
|
||||
|
||||
/**
|
||||
Following code resets the menu position on LateUpdate so you can use the menu while moving/falling.
|
||||
It is Desktop only. QM inputs still don't work because they do their input checks in LateUpdate???
|
||||
**/
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "LateUpdate")]
|
||||
private static void DesktopQMFix(ref CohtmlView ___quickMenu, ref bool ___needsQuickmenuPositionUpdate, ref float ____scaleFactor, ref bool ____quickMenuOpen)
|
||||
{
|
||||
if (MetaPort.Instance.isUsingVr) return;
|
||||
if (____quickMenuOpen && !adjustedMenuPosition)
|
||||
{
|
||||
SetMenuPosition(___quickMenu.transform, ____scaleFactor);
|
||||
___needsQuickmenuPositionUpdate = false;
|
||||
}
|
||||
adjustedMenuPosition = false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ViewManager), "LateUpdate")]
|
||||
private static void DesktopMMFix(ref ViewManager __instance, ref bool ___needsMenuPositionUpdate, ref float ___scaleFactor, bool __state, ref bool ____gameMenuOpen)
|
||||
{
|
||||
if (MetaPort.Instance.isUsingVr) return;
|
||||
if (____gameMenuOpen && !adjustedMenuPosition)
|
||||
{
|
||||
SetMenuPosition(__instance.transform, ___scaleFactor);
|
||||
___needsMenuPositionUpdate = false;
|
||||
}
|
||||
adjustedMenuPosition = false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue