mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
add aspect ratio calculation
This commit is contained in:
parent
de1a54c7a0
commit
8ef891434a
3 changed files with 19 additions and 11 deletions
|
@ -10,6 +10,16 @@ using MenuScalePatch.Helpers;
|
||||||
|
|
||||||
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
|
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]
|
[HarmonyPatch]
|
||||||
internal class HarmonyPatches
|
internal class HarmonyPatches
|
||||||
{
|
{
|
||||||
|
@ -18,10 +28,7 @@ internal class HarmonyPatches
|
||||||
private static void SetQMScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
|
private static void SetQMScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
|
||||||
{
|
{
|
||||||
____scaleFactor = avatarHeight / 1.8f;
|
____scaleFactor = avatarHeight / 1.8f;
|
||||||
if (MetaPort.Instance.isUsingVr)
|
if (MetaPort.Instance.isUsingVr) ____scaleFactor *= 0.5f;
|
||||||
{
|
|
||||||
____scaleFactor *= 0.5f;
|
|
||||||
}
|
|
||||||
MSP_MenuInfo.ScaleFactor = ____scaleFactor;
|
MSP_MenuInfo.ScaleFactor = ____scaleFactor;
|
||||||
__runOriginal = false;
|
__runOriginal = false;
|
||||||
}
|
}
|
||||||
|
@ -30,11 +37,7 @@ internal class HarmonyPatches
|
||||||
[HarmonyPatch(typeof(ViewManager), "SetScale")]
|
[HarmonyPatch(typeof(ViewManager), "SetScale")]
|
||||||
private static void CheckMMScale(out bool __runOriginal)
|
private static void CheckMMScale(out bool __runOriginal)
|
||||||
{
|
{
|
||||||
/**
|
//bitch
|
||||||
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
|
|
||||||
i dont need it so i will nuke it >:)
|
|
||||||
**/
|
|
||||||
__runOriginal = false;
|
__runOriginal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +51,11 @@ internal class HarmonyPatches
|
||||||
}
|
}
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
|
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
|
||||||
private static void Prefix_ViewManager_UpdateMenuPosition(out bool __runOriginal)
|
private static void Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio, out bool __runOriginal)
|
||||||
{
|
{
|
||||||
|
//this is called once a second, so ill fix their dumb aspect ratio shit
|
||||||
|
float ratio = (float)Screen.width / (float)Screen.height;
|
||||||
|
MSP_MenuInfo.AspectRatio = 1.7777779f / ratio;
|
||||||
__runOriginal = false;
|
__runOriginal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +102,7 @@ internal class HarmonyPatches
|
||||||
{
|
{
|
||||||
if (MainMenuHelper.Instance == null) return;
|
if (MainMenuHelper.Instance == null) return;
|
||||||
MainMenuHelper.Instance.UpdateWorldAnchors();
|
MainMenuHelper.Instance.UpdateWorldAnchors();
|
||||||
|
MainMenuHelper.Instance.ToggleDesktopInputMethod(show);
|
||||||
MainMenuHelper.Instance.enabled = show;
|
MainMenuHelper.Instance.enabled = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
|
Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
|
||||||
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
|
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
|
||||||
transform.eulerAngles = activeAnchor.eulerAngles;
|
transform.eulerAngles = activeAnchor.eulerAngles;
|
||||||
transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor;
|
transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
//VR Main Menu
|
//VR Main Menu
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class MSP_MenuInfo
|
||||||
{
|
{
|
||||||
//Shared Info
|
//Shared Info
|
||||||
public static float ScaleFactor = 1f;
|
public static float ScaleFactor = 1f;
|
||||||
|
public static float AspectRatio = 1f;
|
||||||
public static Transform CameraTransform;
|
public static Transform CameraTransform;
|
||||||
|
|
||||||
//Settings...?
|
//Settings...?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue