mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
overcomplicated shit
This commit is contained in:
parent
84cf4c0875
commit
72c9f12376
6 changed files with 458 additions and 90 deletions
108
MenuScalePatch/HarmonyPatches.cs
Normal file
108
MenuScalePatch/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,108 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core;
|
||||
using cohtml;
|
||||
using HarmonyLib;
|
||||
using NAK.Melons.MenuScalePatch.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal class HarmonyPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
|
||||
private static void SetQMScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
|
||||
{
|
||||
____scaleFactor = avatarHeight / 1.8f;
|
||||
if (MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
____scaleFactor *= 0.5f;
|
||||
}
|
||||
MSP_MenuInfo.ScaleFactor = ____scaleFactor;
|
||||
__runOriginal = false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ViewManager), "SetScale")]
|
||||
private static void CheckMMScale(out bool __runOriginal)
|
||||
{
|
||||
/**
|
||||
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;
|
||||
}
|
||||
|
||||
//nuke UpdateMenuPosition methods
|
||||
//there are 2 Jobs calling this each second, which is fucking my shit
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
|
||||
private static void Prefix_CVR_MenuManager_UpdateMenuPosition(out bool __runOriginal)
|
||||
{
|
||||
__runOriginal = false;
|
||||
}
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
|
||||
private static void Prefix_ViewManager_UpdateMenuPosition(out bool __runOriginal)
|
||||
{
|
||||
__runOriginal = false;
|
||||
}
|
||||
|
||||
//Set QM stuff
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
|
||||
private static void SetupQMHelper(ref CVR_MenuManager __instance, ref GameObject ____leftVrAnchor)
|
||||
{
|
||||
QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent<QuickMenuHelper>();
|
||||
helper.handAnchor = ____leftVrAnchor.transform;
|
||||
}
|
||||
|
||||
//Set MM stuff
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ViewManager), "Start")]
|
||||
private static void SetupMMHelper(ref ViewManager __instance)
|
||||
{
|
||||
__instance.gameObject.AddComponent<MainMenuHelper>();
|
||||
}
|
||||
|
||||
//hook quickmenu open/close
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
|
||||
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
|
||||
{
|
||||
if (QuickMenuHelper.Instance == null) return;
|
||||
QuickMenuHelper.Instance.UpdateWorldAnchors();
|
||||
QuickMenuHelper.Instance.ToggleDesktopInputMethod(show);
|
||||
QuickMenuHelper.Instance.enabled = show;
|
||||
}
|
||||
|
||||
//add independent head movement to important input
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(InputModuleMouseKeyboard), "UpdateImportantInput")]
|
||||
private static void Postfix_InputModuleMouseKeyboard_UpdateImportantInput(ref CVRInputManager ____inputManager)
|
||||
{
|
||||
____inputManager.independentHeadTurn |= Input.GetKey(KeyCode.LeftAlt);
|
||||
}
|
||||
|
||||
//hook menu open/close
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
|
||||
private static void Postfix_ViewManager_UiStateToggle(bool show)
|
||||
{
|
||||
if (MainMenuHelper.Instance == null) return;
|
||||
MainMenuHelper.Instance.UpdateWorldAnchors();
|
||||
MainMenuHelper.Instance.enabled = show;
|
||||
}
|
||||
|
||||
//Support for changing VRMode during runtime.
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "CalibrateAvatar")]
|
||||
private static void CheckVRModeOnSwitch()
|
||||
{
|
||||
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue