Skip to content

Commit

Permalink
Merge pull request DaXcess#149 from DaXcess/main-menu-whack
Browse files Browse the repository at this point in the history
Fix invisible pause menu
  • Loading branch information
DaXcess authored Jan 18, 2024
2 parents ab4e6b3 + 0d924f5 commit 803ffdb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Docs/controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This VR mod divides the controls into two categories: **Lethal Company Controls** and **VR Controls**. The reason behind this is how they are implemented. **LC Controls** are replacing the built in controls of the game, by overriding the player input controller with them. The **VR Controls** however are exclusively used within the mod, and are not injected into the game's built in controls.

## Default Lethal Company Inputs
## Default LC Controls

| Action | PC | VR | Notes |
| :--------------: | ---------------- | ----------------- | ------------------------------------------------------------------- |
Expand Down
8 changes: 5 additions & 3 deletions LCVR/OpenXR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static bool GetDiagnosticReport(out OpenXRReport report)

var sectionRegex = new Regex("^==== ([A-z0-9-_ ]+) ====$", RegexOptions.Multiline);
var errorRegex = new Regex("^\\[FAILURE\\] [A-z]+: ([A-Z_]+) \\(\\d+x\\)$");

string raw = GenerateReport();

var rawSections = sectionRegex.Split(raw).Skip(1).Select(v => v.Trim()).ToArray();
Expand Down Expand Up @@ -76,7 +76,7 @@ public static bool GetDiagnosticReport(out OpenXRReport report)
var match = errorRegex.Match(section.Split('\n')[0].Trim());
if (match == null)
return false;

var error = match.Groups[1].Value;

report = new OpenXRReport(runtimeName, runtimeVersion, error);
Expand Down Expand Up @@ -119,7 +119,7 @@ public static string[] DetectOpenXRRuntimes()
var cbValueName = maxValueNameLength + 1;

int result = Native.RegEnumValue(hKey, i, valueName, ref cbValueName, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

if (result != 0)
return null;

Expand Down Expand Up @@ -171,6 +171,7 @@ public class OpenXRReport(string runtimeName, string runtimeVersion, string erro
public string Error { get; } = error;
}

#pragma warning disable 0649
[Serializable]
private struct OpenXRRuntime
{
Expand All @@ -182,5 +183,6 @@ private struct RuntimeInfo
{
public string name;
}
#pragma warning restore 0649
}
}
1 change: 1 addition & 0 deletions Patches/UIPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static void InitMenuScene()

var canvasFollow = canvas.gameObject.AddComponent<CanvasTransformFollow>();
canvasFollow.sourceTransform = uiCamera.transform;
canvasFollow.heightOffset = 1;

// Allow canvas interactions using XR raycaster

Expand Down
7 changes: 5 additions & 2 deletions Player/VRPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.MixedReality.Toolkit.Experimental.UI;
using LCVR.Patches;
using HarmonyLib;
using LCVR.UI;

namespace LCVR.Player
{
Expand Down Expand Up @@ -239,8 +240,8 @@ private IEnumerator RebuildRig()

// Set up rigging
var model = Find("ScavengerModel/metarig/ScavengerModelArmsOnly", true).gameObject;
var modelMetarig = Find("ScavengerModel/metarig/ScavengerModelArmsOnly/metarig", true);
var modelMetarig = Find("ScavengerModel/metarig/ScavengerModelArmsOnly/metarig", true);

Find("ScavengerModel/metarig/ScavengerModelArmsOnly/metarig/spine.003/RigArms", true);

var rigFollow = model.GetComponent<IKRigFollowVRRig>() ?? model.AddComponent<IKRigFollowVRRig>();
Expand Down Expand Up @@ -637,6 +638,8 @@ private void SwitchToUICamera()
uiCamera.nearClipPlane = 0.01f;
uiCamera.farClipPlane = 15f;
uiCamera.enabled = true;

FindObjectsOfType<CanvasTransformFollow>().Do(follow => follow.ResetPosition(true));
}

private void SwitchToGameCamera()
Expand Down
3 changes: 2 additions & 1 deletion UI/CanvasTransformFollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class CanvasTransformFollow : MonoBehaviour
private InputAction resetPositionAction;

public Transform sourceTransform;
public float heightOffset;

private Quaternion targetRotation;
private Vector3 targetPosition;
Expand Down Expand Up @@ -42,7 +43,7 @@ public void ResetPosition(bool force = false)
var forward = rotation * Vector3.forward;
var position = forward * CANVAS_DISTANCE;

targetPosition = new Vector3(position.x + sourceTransform.position.x, transform.position.y, position.z + sourceTransform.position.z);
targetPosition = new Vector3(position.x + sourceTransform.position.x, heightOffset, position.z + sourceTransform.position.z);
targetRotation = Quaternion.Euler(0, sourceTransform.eulerAngles.y, 0);

if (force)
Expand Down
1 change: 1 addition & 0 deletions UI/VRHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public void Initialize(VRPlayer player)

var follow = spectateCanvas.gameObject.AddComponent<CanvasTransformFollow>();
follow.sourceTransform = player.uiCamera.transform;
follow.heightOffset = -999;

transform.localScale = Vector3.one * 0.0007f;

Expand Down

0 comments on commit 803ffdb

Please sign in to comment.