fixed shit

This commit is contained in:
NotAKidoS 2022-12-26 22:21:43 -06:00
parent 83268619da
commit e54a20ee42
3 changed files with 63 additions and 18 deletions

View file

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

View file

@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "2.0.0";
public const string Version = "3.0.0";
public const string Author = "NotAKidoS";
}

View file

@ -1,8 +1,8 @@
{
"_id": 95,
"name": "MenuScalePatch",
"modversion": "2.0.0",
"gameversion": "2022r169",
"modversion": "3.0.0",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
"author": "NotAKidoS",
@ -18,6 +18,6 @@
],
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r4/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
"changelog": "Removed collision scaling feature as it is now native.",
"changelog": "Removed collision scaling feature as it is now native.\nImplemented adjusted QM scaling for VR.\nAdded menu correction for Desktop so you can use menus while moving.",
"embedcolor": "804221"
}