From 77c1e0fea97c63f65d8dfd9416bded5875faedc4 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Tue, 3 Jan 2023 11:59:13 -0600 Subject: [PATCH] dont change mouse input while in VR bruh --- MenuScalePatch/HarmonyPatches.cs | 1 + .../{ => Helpers}/MainMenuHelper.cs | 37 ++++++++++--------- .../{ => Helpers}/QuickMenuHelper.cs | 34 +++++++++-------- MenuScalePatch/Properties/AssemblyInfo.cs | 2 +- 4 files changed, 39 insertions(+), 35 deletions(-) rename MenuScalePatch/{ => Helpers}/MainMenuHelper.cs (73%) rename MenuScalePatch/{ => Helpers}/QuickMenuHelper.cs (72%) diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs index 3d24450..d0c1abc 100644 --- a/MenuScalePatch/HarmonyPatches.cs +++ b/MenuScalePatch/HarmonyPatches.cs @@ -6,6 +6,7 @@ using cohtml; using HarmonyLib; using NAK.Melons.MenuScalePatch.Helpers; using UnityEngine; +using MenuScalePatch.Helpers; namespace NAK.Melons.MenuScalePatch.HarmonyPatches; diff --git a/MenuScalePatch/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs similarity index 73% rename from MenuScalePatch/MainMenuHelper.cs rename to MenuScalePatch/Helpers/MainMenuHelper.cs index ba3f83d..fd93a19 100644 --- a/MenuScalePatch/MainMenuHelper.cs +++ b/MenuScalePatch/Helpers/MainMenuHelper.cs @@ -8,8 +8,9 @@ using HarmonyLib; using MelonLoader; using UnityEngine; using System.Reflection; +using NAK.Melons.MenuScalePatch.Helpers; -namespace NAK.Melons.MenuScalePatch.Helpers; +namespace MenuScalePatch.Helpers; //TODO: Implement desktop ratio scaling back to MM @@ -52,6 +53,7 @@ public class MainMenuHelper : MonoBehaviour public void ToggleDesktopInputMethod(bool flag) { + if (MetaPort.Instance.isUsingVr) return; PlayerSetup.Instance._movementSystem.disableCameraControl = flag; CVRInputManager.Instance.inputEnabled = !flag; RootLogic.Instance.ToggleMouse(flag); @@ -65,12 +67,12 @@ public class MainMenuHelper : MonoBehaviour GameObject vrAnchor = new GameObject("MSP_MMVR_Anchor"); vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform; vrAnchor.transform.localPosition = Vector3.zero; - this.worldAnchor = vrAnchor.transform; + worldAnchor = vrAnchor.transform; } public void UpdateWorldAnchors() { - if (this.worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return; + if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return; if (MetaPort.Instance.isUsingVr) { @@ -78,18 +80,18 @@ public class MainMenuHelper : MonoBehaviour float minTilt = MetaPort.Instance.settings.GetSettingsFloat("GeneralMinimumMenuTilt", 0f); if (zRotation <= minTilt || zRotation >= 360f - minTilt) { - this.worldAnchor.rotation = Quaternion.LookRotation(MSP_MenuInfo.CameraTransform.forward, Vector3.up); + worldAnchor.rotation = Quaternion.LookRotation(MSP_MenuInfo.CameraTransform.forward, Vector3.up); } else { - this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles; + worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles; } - this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position + MSP_MenuInfo.CameraTransform.forward * 2f * MSP_MenuInfo.ScaleFactor; + worldAnchor.position = MSP_MenuInfo.CameraTransform.position + MSP_MenuInfo.CameraTransform.forward * 2f * MSP_MenuInfo.ScaleFactor; } else { - this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles; - this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position; + worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles; + worldAnchor.position = MSP_MenuInfo.CameraTransform.position; } } @@ -141,19 +143,18 @@ public class MainMenuHelper : MonoBehaviour { if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return; - Transform activeAnchor = independentHeadTurn ? this.worldAnchor : MSP_MenuInfo.CameraTransform; - this.transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f); - this.transform.eulerAngles = activeAnchor.eulerAngles; - this.transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor; + Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform; + transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f); + transform.eulerAngles = activeAnchor.eulerAngles; + transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor; } //VR Main Menu public void HandleVRPosition() { - if (this.worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return; - this.transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f); - this.transform.position = this.worldAnchor.position; - this.transform.eulerAngles = this.worldAnchor.eulerAngles; + if (worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return; + transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f); + transform.position = worldAnchor.position; + transform.eulerAngles = worldAnchor.eulerAngles; } -} - +} \ No newline at end of file diff --git a/MenuScalePatch/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs similarity index 72% rename from MenuScalePatch/QuickMenuHelper.cs rename to MenuScalePatch/Helpers/QuickMenuHelper.cs index 82e5791..b99c5a5 100644 --- a/MenuScalePatch/QuickMenuHelper.cs +++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs @@ -8,8 +8,9 @@ using HarmonyLib; using MelonLoader; using UnityEngine; using System.Reflection; +using NAK.Melons.MenuScalePatch.Helpers; -namespace NAK.Melons.MenuScalePatch.Helpers; +namespace MenuScalePatch.Helpers; /** @@ -51,6 +52,7 @@ public class QuickMenuHelper : MonoBehaviour public void ToggleDesktopInputMethod(bool flag) { + if (MetaPort.Instance.isUsingVr) return; PlayerSetup.Instance._movementSystem.disableCameraControl = flag; CVRInputManager.Instance.inputEnabled = !flag; RootLogic.Instance.ToggleMouse(flag); @@ -64,15 +66,15 @@ public class QuickMenuHelper : MonoBehaviour GameObject vrAnchor = new GameObject("MSP_QMVR_Anchor"); vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform; vrAnchor.transform.localPosition = Vector3.zero; - this.worldAnchor = vrAnchor.transform; + worldAnchor = vrAnchor.transform; } public void UpdateWorldAnchors() { - if (this.worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return; + if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return; - this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles; - this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position; + worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles; + worldAnchor.position = MSP_MenuInfo.CameraTransform.position; } public void UpdateMenuPosition() @@ -123,26 +125,26 @@ public class QuickMenuHelper : MonoBehaviour { if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return; - Transform activeAnchor = independentHeadTurn ? this.worldAnchor : MSP_MenuInfo.CameraTransform; - this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f); - this.transform.eulerAngles = activeAnchor.eulerAngles; - this.transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor; + Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform; + transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f); + transform.eulerAngles = activeAnchor.eulerAngles; + transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor; } //VR Quick Menu public void HandleVRPosition() { - if (this.handAnchor == null || MSP_MenuInfo.DisableQMHelper_VR) return; + if (handAnchor == null || MSP_MenuInfo.DisableQMHelper_VR) return; if (MSP_MenuInfo.WorldAnchorQM) { - this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f); - this.transform.eulerAngles = this.worldAnchor.eulerAngles; - this.transform.position = this.worldAnchor.position + this.worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor; + transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f); + transform.eulerAngles = worldAnchor.eulerAngles; + transform.position = worldAnchor.position + worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor; return; } - this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f); - this.transform.position = this.handAnchor.position; - this.transform.rotation = this.handAnchor.rotation; + transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f); + transform.position = handAnchor.position; + transform.rotation = handAnchor.rotation; } } \ No newline at end of file diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs index 34cef9b..ab7045d 100644 --- a/MenuScalePatch/Properties/AssemblyInfo.cs +++ b/MenuScalePatch/Properties/AssemblyInfo.cs @@ -25,6 +25,6 @@ using System.Reflection; namespace MenuScalePatch.Properties; internal static class AssemblyInfoParams { - public const string Version = "4.0.0"; + public const string Version = "4.0.1"; public const string Author = "NotAKidoS"; } \ No newline at end of file