mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
i hate all
holy shit this fucking bug took me two hours to fix why was the solution so simple... fuck
This commit is contained in:
parent
845baee849
commit
4a5527d7de
4 changed files with 38 additions and 126 deletions
|
@ -78,13 +78,16 @@ internal class HarmonyPatches
|
||||||
}
|
}
|
||||||
|
|
||||||
//hook quickmenu open/close
|
//hook quickmenu open/close
|
||||||
[HarmonyPostfix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
|
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
|
||||||
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
|
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show, ref bool ____quickMenuOpen)
|
||||||
{
|
{
|
||||||
if (QuickMenuHelper.Instance == null) return;
|
if (QuickMenuHelper.Instance == null) return;
|
||||||
QuickMenuHelper.Instance.UpdateWorldAnchors();
|
if (show != ____quickMenuOpen)
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(show);
|
{
|
||||||
|
QuickMenuHelper.Instance.UpdateWorldAnchors();
|
||||||
|
MSP_MenuInfo.ToggleDesktopInputMethod(show);
|
||||||
|
}
|
||||||
QuickMenuHelper.Instance.enabled = show;
|
QuickMenuHelper.Instance.enabled = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +100,16 @@ internal class HarmonyPatches
|
||||||
}
|
}
|
||||||
|
|
||||||
//hook menu open/close
|
//hook menu open/close
|
||||||
[HarmonyPostfix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
|
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
|
||||||
private static void Postfix_ViewManager_UiStateToggle(bool show)
|
private static void Postfix_ViewManager_UiStateToggle(bool show, ref bool ____gameMenuOpen)
|
||||||
{
|
{
|
||||||
if (MainMenuHelper.Instance == null) return;
|
if (MainMenuHelper.Instance == null) return;
|
||||||
MainMenuHelper.Instance.UpdateWorldAnchors();
|
if (show != ____gameMenuOpen)
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(show);
|
{
|
||||||
|
MainMenuHelper.Instance.UpdateWorldAnchors();
|
||||||
|
MSP_MenuInfo.ToggleDesktopInputMethod(show);
|
||||||
|
}
|
||||||
MainMenuHelper.Instance.enabled = show;
|
MainMenuHelper.Instance.enabled = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,13 +120,4 @@ internal class HarmonyPatches
|
||||||
{
|
{
|
||||||
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
|
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
//only fixes Desktop QM interaction while using independent head input...
|
|
||||||
//[HarmonyPrefix]
|
|
||||||
//[HarmonyPatch(typeof(ControllerRay), "LateUpdate")]
|
|
||||||
//private static void UpdateMenuPositionForInput()
|
|
||||||
//{
|
|
||||||
// MainMenuHelper.Instance.UpdateMenuPosition();
|
|
||||||
// QuickMenuHelper.Instance.UpdateMenuPosition();
|
|
||||||
//}
|
|
||||||
}
|
}
|
|
@ -28,11 +28,6 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
public static MainMenuHelper Instance;
|
public static MainMenuHelper Instance;
|
||||||
public Transform worldAnchor;
|
public Transform worldAnchor;
|
||||||
|
|
||||||
static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
private bool independentHeadTurn = false;
|
|
||||||
private bool returnIndependentHeadTurn = false;
|
|
||||||
private bool prevIndependentHeadTurn = false;
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
@ -41,23 +36,10 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
{
|
{
|
||||||
|
MSP_MenuInfo.HandleIndependentLookInput();
|
||||||
UpdateMenuPosition();
|
UpdateMenuPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable()
|
|
||||||
{
|
|
||||||
independentHeadTurn = false;
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
prevIndependentHeadTurn = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDisable()
|
|
||||||
{
|
|
||||||
independentHeadTurn = false;
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
prevIndependentHeadTurn = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateWorldAnchors()
|
public void CreateWorldAnchors()
|
||||||
{
|
{
|
||||||
//VR specific anchor
|
//VR specific anchor
|
||||||
|
@ -99,39 +81,6 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
HandleVRPosition();
|
HandleVRPosition();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
|
|
||||||
bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
|
|
||||||
if (independentHeadTurnChanged)
|
|
||||||
{
|
|
||||||
prevIndependentHeadTurn = CVRInputManager.Instance.independentHeadTurn;
|
|
||||||
//if pressing but not already enabled
|
|
||||||
if (prevIndependentHeadTurn)
|
|
||||||
{
|
|
||||||
if (!independentHeadTurn && angle == 0f)
|
|
||||||
{
|
|
||||||
UpdateWorldAnchors();
|
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
|
|
||||||
independentHeadTurn = true;
|
|
||||||
}
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
returnIndependentHeadTurn = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (returnIndependentHeadTurn)
|
|
||||||
{
|
|
||||||
if (angle == 0f)
|
|
||||||
{
|
|
||||||
independentHeadTurn = false;
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleDesktopPosition();
|
HandleDesktopPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +88,7 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
public void HandleDesktopPosition()
|
public void HandleDesktopPosition()
|
||||||
{
|
{
|
||||||
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
|
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
|
||||||
|
Transform activeAnchor = MSP_MenuInfo.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 * MSP_MenuInfo.AspectRatio;
|
transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio;
|
||||||
|
|
|
@ -27,11 +27,6 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
public Transform worldAnchor;
|
public Transform worldAnchor;
|
||||||
public Transform handAnchor;
|
public Transform handAnchor;
|
||||||
|
|
||||||
static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
private bool independentHeadTurn = false;
|
|
||||||
private bool returnIndependentHeadTurn = false;
|
|
||||||
private bool prevIndependentHeadTurn = false;
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
@ -40,23 +35,10 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
{
|
{
|
||||||
|
MSP_MenuInfo.HandleIndependentLookInput();
|
||||||
UpdateMenuPosition();
|
UpdateMenuPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable()
|
|
||||||
{
|
|
||||||
independentHeadTurn = false;
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
prevIndependentHeadTurn = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDisable()
|
|
||||||
{
|
|
||||||
independentHeadTurn = false;
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
prevIndependentHeadTurn = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateWorldAnchors()
|
public void CreateWorldAnchors()
|
||||||
{
|
{
|
||||||
//VR specific anchor
|
//VR specific anchor
|
||||||
|
@ -69,7 +51,6 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
public void UpdateWorldAnchors()
|
public void UpdateWorldAnchors()
|
||||||
{
|
{
|
||||||
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
|
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
|
||||||
|
|
||||||
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
|
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
|
||||||
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
|
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
|
||||||
}
|
}
|
||||||
|
@ -81,39 +62,6 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
HandleVRPosition();
|
HandleVRPosition();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
|
|
||||||
bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
|
|
||||||
if (independentHeadTurnChanged)
|
|
||||||
{
|
|
||||||
prevIndependentHeadTurn = CVRInputManager.Instance.independentHeadTurn;
|
|
||||||
//if pressing but not already enabled
|
|
||||||
if (prevIndependentHeadTurn)
|
|
||||||
{
|
|
||||||
if (!independentHeadTurn && angle == 0f)
|
|
||||||
{
|
|
||||||
UpdateWorldAnchors();
|
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
|
|
||||||
independentHeadTurn = true;
|
|
||||||
}
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
returnIndependentHeadTurn = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (returnIndependentHeadTurn)
|
|
||||||
{
|
|
||||||
if (angle == 0f)
|
|
||||||
{
|
|
||||||
independentHeadTurn = false;
|
|
||||||
returnIndependentHeadTurn = false;
|
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleDesktopPosition();
|
HandleDesktopPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +70,7 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return;
|
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return;
|
||||||
|
|
||||||
Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
|
Transform activeAnchor = MSP_MenuInfo.independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
|
||||||
transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
|
transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
|
||||||
transform.eulerAngles = activeAnchor.eulerAngles;
|
transform.eulerAngles = activeAnchor.eulerAngles;
|
||||||
transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
|
transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -32,11 +33,29 @@ public class MSP_MenuInfo
|
||||||
public static void ToggleDesktopInputMethod(bool flag)
|
public static void ToggleDesktopInputMethod(bool flag)
|
||||||
{
|
{
|
||||||
if (MetaPort.Instance.isUsingVr) return;
|
if (MetaPort.Instance.isUsingVr) return;
|
||||||
MelonLoader.MelonLogger.Msg("Toggled Desktop Input");
|
|
||||||
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
|
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
|
||||||
CVRInputManager.Instance.inputEnabled = !flag;
|
CVRInputManager.Instance.inputEnabled = !flag;
|
||||||
RootLogic.Instance.ToggleMouse(flag);
|
RootLogic.Instance.ToggleMouse(flag);
|
||||||
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
|
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
|
||||||
Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
|
Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
public static bool independentHeadTurn = false;
|
||||||
|
|
||||||
|
public static void HandleIndependentLookInput()
|
||||||
|
{
|
||||||
|
//angle of independent look axis
|
||||||
|
float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
|
||||||
|
bool isPressed = CVRInputManager.Instance.independentHeadTurn;
|
||||||
|
if (isPressed && !independentHeadTurn)
|
||||||
|
{
|
||||||
|
independentHeadTurn = true;
|
||||||
|
MSP_MenuInfo.ToggleDesktopInputMethod(false);
|
||||||
|
}else if (!isPressed && independentHeadTurn && angle == 0f)
|
||||||
|
{
|
||||||
|
independentHeadTurn = false;
|
||||||
|
MSP_MenuInfo.ToggleDesktopInputMethod(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue