From bb2360d3280ee96191a15908a5f4555258c9603d Mon Sep 17 00:00:00 2001 From: artum Date: Fri, 2 Jul 2021 15:53:19 +0000 Subject: [PATCH] More immersion settings (#422) * Added some immersion settings (HUD opacity, Feet/Hand laser visibility) * UnityExplorer compatibility * Bump version --- NomaiVR/Hands/LaserPointer.cs | 6 +++++- NomaiVR/ModConfig/ModSettings.cs | 6 ++++++ NomaiVR/ModConfig/default-config.json | 25 +++++++++++++++++++++++-- NomaiVR/Player/FeetMarker.cs | 19 ++++++++++++++++++- NomaiVR/UI/HelmetHUD.cs | 26 ++++++++++++++------------ NomaiVR/UI/Menus.cs | 2 +- NomaiVR/manifest.json | 2 +- 7 files changed, 68 insertions(+), 18 deletions(-) diff --git a/NomaiVR/Hands/LaserPointer.cs b/NomaiVR/Hands/LaserPointer.cs index 7f56509b..790b1a35 100644 --- a/NomaiVR/Hands/LaserPointer.cs +++ b/NomaiVR/Hands/LaserPointer.cs @@ -377,10 +377,14 @@ private void UpdateLineVisibility() { _lineRenderer.enabled = false; } - else if (!_lineRenderer.enabled && !isUsingTool) + else if(!_lineRenderer.enabled && InputHelper.IsUIInteractionMode(true)) { _lineRenderer.enabled = true; } + else if (!isUsingTool && !InputHelper.IsUIInteractionMode(true) && _lineRenderer.enabled != ModSettings.EnableHandLaser) + { + _lineRenderer.enabled = ModSettings.EnableHandLaser; + } } private bool IsPaused() diff --git a/NomaiVR/ModConfig/ModSettings.cs b/NomaiVR/ModConfig/ModSettings.cs index daaac199..0acd4a93 100644 --- a/NomaiVR/ModConfig/ModSettings.cs +++ b/NomaiVR/ModConfig/ModSettings.cs @@ -15,11 +15,14 @@ public static class ModSettings public static int OverrideRefreshRate { get; private set; } public static float VibrationStrength { get; private set; } public static bool EnableGesturePrompts { get; private set; } + public static bool EnableHandLaser { get; private set; } + public static bool EnableFeetMarker { get; private set; } public static bool ControllerOrientedMovement { get; private set; } public static bool AutoHideToolbelt { get; private set; } public static bool BypassFatalErrors { get; private set; } public static float ToolbeltHeight { get; private set; } public static float HudScale { get; private set; } + public static float HudOpacity { get; private set; } public static void SetConfig(IModConfig config) { @@ -29,10 +32,13 @@ public static void SetConfig(IModConfig config) ShowHelmet = config.GetSettingsValue("helmetVisibility"); ControllerOrientedMovement = config.GetSettingsValue("movementControllerOriented"); EnableGesturePrompts = config.GetSettingsValue("showGesturePrompts"); + EnableHandLaser = config.GetSettingsValue("showHandLaser"); + EnableFeetMarker = config.GetSettingsValue("showFeetMarker"); PreventCursorLock = config.GetSettingsValue("disableCursorLock"); DebugMode = config.GetSettingsValue("debug"); AutoHideToolbelt = config.GetSettingsValue("autoHideToolbelt"); HudScale = config.GetSettingsValue("hudScale"); + HudOpacity = config.GetSettingsValue("hudOpacity"); BypassFatalErrors = config.GetSettingsValue("bypassFatalErrors"); // OWML doesn't support negative slider values so I subtract it here. diff --git a/NomaiVR/ModConfig/default-config.json b/NomaiVR/ModConfig/default-config.json index 348bff3d..06f3e042 100644 --- a/NomaiVR/ModConfig/default-config.json +++ b/NomaiVR/ModConfig/default-config.json @@ -11,7 +11,7 @@ "refreshRateOverride": { "type": "selector", "value": 0, - "options": [0, 30, 60, 70, 72, 80, 90, 120, 144], + "options": [ 0, 30, 60, 70, 72, 80, 90, 120, 144 ], "title": "Physics refresh rate (zero = sync with HMD)" }, "vibrationIntensity": { @@ -49,6 +49,13 @@ "max": 1.8, "title": "Helmet HUD scale" }, + "hudOpacity": { + "type": "slider", + "value": 1, + "min": 0, + "max": 1, + "title": "Helmet HUD Opacity" + }, "movementControllerOriented": { "type": "toggle", "value": false, @@ -63,6 +70,20 @@ "yes": "Enabled", "no": "Disabled" }, + "showHandLaser": { + "type": "toggle", + "value": true, + "title": "Hand laser pointer", + "yes": "Show", + "no": "Hide" + }, + "showFeetMarker": { + "type": "toggle", + "value": true, + "title": "Feet markers", + "yes": "Show", + "no": "Hide" + }, "disableCursorLock": { "type": "toggle", "value": true, @@ -72,7 +93,7 @@ }, "debug": { "type": "toggle", - "value": true, + "value": false, "title": "Debug mode (more logs)", "yes": "Enabled", "no": "Disabled" diff --git a/NomaiVR/Player/FeetMarker.cs b/NomaiVR/Player/FeetMarker.cs index dcfc7551..f90faee8 100644 --- a/NomaiVR/Player/FeetMarker.cs +++ b/NomaiVR/Player/FeetMarker.cs @@ -9,6 +9,8 @@ internal class FeetMarker : NomaiVRModule().material = MaterialHelper.GetOverlayMaterial(); + _renderer = marker.GetComponentInChildren(); + _renderer.material = MaterialHelper.GetOverlayMaterial(); + + SetFeetMarkerVisibility(); + + ModSettings.OnConfigChange += SetFeetMarkerVisibility; + } + + internal void OnDestroy() + { + ModSettings.OnConfigChange -= SetFeetMarkerVisibility; + } + + void SetFeetMarkerVisibility() + { + _renderer.enabled = ModSettings.EnableFeetMarker; } } } diff --git a/NomaiVR/UI/HelmetHUD.cs b/NomaiVR/UI/HelmetHUD.cs index b8876004..e17f8f63 100644 --- a/NomaiVR/UI/HelmetHUD.cs +++ b/NomaiVR/UI/HelmetHUD.cs @@ -12,6 +12,7 @@ public class Behaviour : MonoBehaviour { private static Transform _thrusterHUD; private Transform _helmet; + private HUDHelmetAnimator _helmetAnimator; private static Behaviour _instance; internal void Awake() @@ -19,31 +20,32 @@ internal void Awake() _instance = this; FixCameraClipping(); - var helmetAnimator = SetUpHelmetAnimator(); - var helmet = SetUpHelmet(helmetAnimator); + _helmetAnimator = SetUpHelmetAnimator(); + var helmet = SetUpHelmet(_helmetAnimator); CreateForwardIndicator(helmet); ReplaceHelmetModel(helmet); - AdjustHudRenderer(helmetAnimator); + AdjustHudRenderer(_helmetAnimator); var playerHud = GetPlayerHud(helmet); FixLockOnUI(playerHud); HideHudDuringDialogue(playerHud); - SetHelmetScale(); - ModSettings.OnConfigChange += SetHelmetScale; + SetHelmetScaleAndHUDOpacity(); + ModSettings.OnConfigChange += SetHelmetScaleAndHUDOpacity; } internal void OnDestroy() { - ModSettings.OnConfigChange -= SetHelmetScale; + ModSettings.OnConfigChange -= SetHelmetScaleAndHUDOpacity; } - public static void SetHelmetScale() + public void SetHelmetScaleAndHUDOpacity() { - var helmet = _instance?._helmet; - if (!helmet) + if (_helmet) { - return; + _helmet.localScale = new Vector3(ModSettings.HudScale, ModSettings.HudScale, 1f) * 0.5f; + var uiColor = _helmetAnimator._hudRenderer.material.color; + uiColor.a = ModSettings.HudOpacity * ModSettings.HudOpacity; //Squared for more drastic changes + _helmetAnimator._hudRenderer.material.SetColor("_Color", uiColor); } - helmet.localScale = new Vector3(ModSettings.HudScale, ModSettings.HudScale, 1f) * 0.5f; } private void FixCameraClipping() @@ -103,7 +105,7 @@ private void AdjustHudRenderer(HUDHelmetAnimator helmetAnimator) // HUD shader looks funky in stereo, so it needs to be replaced. var surfaceRenderer = hudRenderer.GetComponent(); - surfaceRenderer.material.SetColor("_Color", new Color(1.5f, 1.5f, 1.5f, 1)); + surfaceRenderer.material.SetColor("_Color", new Color(1.5f, 1.5f, 1.5f, surfaceRenderer.material.color.a)); MaterialHelper.MakeMaterialDrawOnTop(surfaceRenderer.material); } diff --git a/NomaiVR/UI/Menus.cs b/NomaiVR/UI/Menus.cs index 15af61d4..77be9099 100644 --- a/NomaiVR/UI/Menus.cs +++ b/NomaiVR/UI/Menus.cs @@ -14,7 +14,7 @@ public class Behaviour : MonoBehaviour { private static bool _shouldRenderStarLogos; private static readonly List patchedCanvases = new List(); - private static readonly string[] _ignoredCanvases = { "LoadManagerFadeCanvas", "PauseBackdropCanvas", "Reticule" }; + private static readonly string[] _ignoredCanvases = { "LoadManagerFadeCanvas", "PauseBackdropCanvas", "Reticule", "ExplorerCanvas" }; private readonly List _canvasObjectsToHide = new List(); private Camera _flashbackCamera; private Transform _flashbackCameraParent; diff --git a/NomaiVR/manifest.json b/NomaiVR/manifest.json index eb8d634b..7c3af300 100644 --- a/NomaiVR/manifest.json +++ b/NomaiVR/manifest.json @@ -8,7 +8,7 @@ "title": "Follow these steps before starting the game in VR:", "body": "- Disable all other mods (can heavily affect performance);\n\n- Close SteamVR (let the game open SteamVR automatically);\n\n- Make sure your headset and both of your VR controllers are connected and working;\n\n- If you have the game on Steam:\n--- Right-click Outer Wilds on your Steam library\n--- Select 'Properties...'\n--- Disable 'Use Desktop Game Theatre.'" }, - "version": "1.2.1", + "version": "1.2.2", "owmlVersion": "1.0.1", "requireVR": true }