mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
tweaks to head turn
This commit is contained in:
parent
a8cd7122a8
commit
ff70ae9652
6 changed files with 39 additions and 32 deletions
|
@ -62,6 +62,7 @@ internal class HarmonyPatches
|
||||||
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
|
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
|
||||||
private static bool Prefix_CVR_MenuManager_UpdateMenuPosition()
|
private static bool Prefix_CVR_MenuManager_UpdateMenuPosition()
|
||||||
{
|
{
|
||||||
|
if (QuickMenuHelper.Instance == null) return true;
|
||||||
return !QuickMenuHelper.Instance.MenuIsOpen;
|
return !QuickMenuHelper.Instance.MenuIsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ internal class HarmonyPatches
|
||||||
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
|
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
|
||||||
private static bool Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio)
|
private static bool Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio)
|
||||||
{
|
{
|
||||||
|
if (MainMenuHelper.Instance == null) return true;
|
||||||
//this is called once a second, so ill fix their dumb aspect ratio shit
|
//this is called once a second, so ill fix their dumb aspect ratio shit
|
||||||
float ratio = (float)Screen.width / (float)Screen.height;
|
float ratio = (float)Screen.width / (float)Screen.height;
|
||||||
float clamp = Mathf.Clamp(ratio, 0f, 1.8f);
|
float clamp = Mathf.Clamp(ratio, 0f, 1.8f);
|
||||||
|
|
|
@ -30,14 +30,16 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
{
|
{
|
||||||
if (MenuIsOpen)
|
if (!MenuIsOpen) return;
|
||||||
|
|
||||||
|
if (MSP_MenuInfo.PlayerAnchorMenus || NeedsPositionUpdate)
|
||||||
{
|
{
|
||||||
if (MSP_MenuInfo.UseIndependentHeadTurn)
|
UpdateMenuPosition();
|
||||||
MSP_MenuInfo.HandleIndependentLookInput();
|
}
|
||||||
if (MSP_MenuInfo.PlayerAnchorMenus)
|
|
||||||
UpdateMenuPosition();
|
if (MSP_MenuInfo.UseIndependentHeadTurn)
|
||||||
if (NeedsPositionUpdate)
|
{
|
||||||
UpdateMenuPosition();
|
MSP_MenuInfo.HandleIndependentLookInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,13 +66,13 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
|
worldAnchor.rotation = MSP_MenuInfo.CameraTransform.rotation;
|
||||||
}
|
}
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
|
worldAnchor.rotation = MSP_MenuInfo.CameraTransform.rotation;
|
||||||
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
|
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
|
||||||
}
|
}
|
||||||
if (updateMenuPos) UpdateMenuPosition();
|
if (updateMenuPos) UpdateMenuPosition();
|
||||||
|
@ -93,8 +95,8 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
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 = MSP_MenuInfo.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.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;
|
||||||
|
transform.rotation = activeAnchor.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
//VR Main Menu
|
//VR Main Menu
|
||||||
|
@ -103,6 +105,6 @@ public class MainMenuHelper : MonoBehaviour
|
||||||
if (worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return;
|
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.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f);
|
||||||
transform.position = worldAnchor.position;
|
transform.position = worldAnchor.position;
|
||||||
transform.eulerAngles = worldAnchor.eulerAngles;
|
transform.rotation = worldAnchor.rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,16 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
{
|
{
|
||||||
if (MenuIsOpen)
|
if (!MenuIsOpen) return;
|
||||||
|
|
||||||
|
if (MSP_MenuInfo.PlayerAnchorMenus || NeedsPositionUpdate || MetaPort.Instance.isUsingVr)
|
||||||
{
|
{
|
||||||
if (MSP_MenuInfo.UseIndependentHeadTurn)
|
UpdateMenuPosition();
|
||||||
MSP_MenuInfo.HandleIndependentLookInput();
|
}
|
||||||
if (MSP_MenuInfo.PlayerAnchorMenus || MetaPort.Instance.isUsingVr)
|
|
||||||
UpdateMenuPosition();
|
if (MSP_MenuInfo.UseIndependentHeadTurn)
|
||||||
if (NeedsPositionUpdate)
|
{
|
||||||
UpdateMenuPosition();
|
MSP_MenuInfo.HandleIndependentLookInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +53,8 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
public void UpdateWorldAnchors(bool updateMenuPos = false)
|
public void UpdateWorldAnchors(bool updateMenuPos = false)
|
||||||
{
|
{
|
||||||
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
|
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
|
||||||
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
|
|
||||||
|
worldAnchor.rotation = MSP_MenuInfo.CameraTransform.rotation;
|
||||||
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
|
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
|
||||||
if (updateMenuPos) UpdateMenuPosition();
|
if (updateMenuPos) UpdateMenuPosition();
|
||||||
}
|
}
|
||||||
|
@ -74,7 +77,7 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
|
|
||||||
Transform activeAnchor = MSP_MenuInfo.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.rotation = activeAnchor.rotation;
|
||||||
transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
|
transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +89,8 @@ public class QuickMenuHelper : MonoBehaviour
|
||||||
if (MSP_MenuInfo.WorldAnchorQM)
|
if (MSP_MenuInfo.WorldAnchorQM)
|
||||||
{
|
{
|
||||||
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 = worldAnchor.eulerAngles;
|
|
||||||
transform.position = worldAnchor.position + worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
|
transform.position = worldAnchor.position + worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
|
||||||
|
transform.rotation = worldAnchor.rotation;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using ABI_RC.Core;
|
using ABI_RC.Core;
|
||||||
using ABI_RC.Core.InteractionSystem;
|
using ABI_RC.Core.InteractionSystem;
|
||||||
using ABI_RC.Core.Player;
|
|
||||||
using ABI_RC.Core.Savior;
|
using ABI_RC.Core.Savior;
|
||||||
using ABI_RC.Systems.MovementSystem;
|
using ABI_RC.Systems.MovementSystem;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -31,7 +30,7 @@ public class MSP_MenuInfo
|
||||||
internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
|
internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
|
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
internal static bool independentHeadTurn = false;
|
internal static bool isIndependentHeadTurn = false;
|
||||||
|
|
||||||
internal static void ToggleDesktopInputMethod(bool flag)
|
internal static void ToggleDesktopInputMethod(bool flag)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +41,6 @@ public class MSP_MenuInfo
|
||||||
|
|
||||||
RootLogic.Instance.ToggleMouse(flag);
|
RootLogic.Instance.ToggleMouse(flag);
|
||||||
CVRInputManager.Instance.inputEnabled = !flag;
|
CVRInputManager.Instance.inputEnabled = !flag;
|
||||||
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
|
|
||||||
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
|
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,20 +48,22 @@ public class MSP_MenuInfo
|
||||||
{
|
{
|
||||||
//angle of independent look axis
|
//angle of independent look axis
|
||||||
bool isPressed = CVRInputManager.Instance.independentHeadTurn || CVRInputManager.Instance.independentHeadToggle;
|
bool isPressed = CVRInputManager.Instance.independentHeadTurn || CVRInputManager.Instance.independentHeadToggle;
|
||||||
if (isPressed && !independentHeadTurn)
|
if (isPressed && !isIndependentHeadTurn)
|
||||||
{
|
{
|
||||||
independentHeadTurn = true;
|
isIndependentHeadTurn = true;
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(false);
|
MSP_MenuInfo.ToggleDesktopInputMethod(false);
|
||||||
QuickMenuHelper.Instance.UpdateWorldAnchors();
|
QuickMenuHelper.Instance.UpdateWorldAnchors();
|
||||||
MainMenuHelper.Instance.UpdateWorldAnchors();
|
MainMenuHelper.Instance.UpdateWorldAnchors();
|
||||||
}
|
}
|
||||||
else if (!isPressed && independentHeadTurn)
|
else if (!isPressed && isIndependentHeadTurn)
|
||||||
{
|
{
|
||||||
float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
|
float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
|
||||||
if (angle == 0f)
|
if (angle == 0f)
|
||||||
{
|
{
|
||||||
independentHeadTurn = false;
|
isIndependentHeadTurn = false;
|
||||||
MSP_MenuInfo.ToggleDesktopInputMethod(true);
|
MSP_MenuInfo.ToggleDesktopInputMethod(true);
|
||||||
|
QuickMenuHelper.Instance.NeedsPositionUpdate = true;
|
||||||
|
MainMenuHelper.Instance.NeedsPositionUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,6 @@ using System.Reflection;
|
||||||
namespace NAK.Melons.MenuScalePatch.Properties;
|
namespace NAK.Melons.MenuScalePatch.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "4.2.3";
|
public const string Version = "4.2.5";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_id": 95,
|
"_id": 95,
|
||||||
"name": "MenuScalePatch",
|
"name": "MenuScalePatch",
|
||||||
"modversion": "4.2.2",
|
"modversion": "4.2.5",
|
||||||
"gameversion": "2022r170",
|
"gameversion": "2022r170",
|
||||||
"loaderversion": "0.5.7",
|
"loaderversion": "0.5.7",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.2/MenuScalePatch.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.4/MenuScalePatch.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
|
||||||
"changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed. Don't disable CohtmlView, only enable it.",
|
"changelog": "- Tweaked independent head turn implementation. Menu will now recenter after head has returned to target angle.",
|
||||||
"embedcolor": "804221"
|
"embedcolor": "804221"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue