Skip to content

Commit

Permalink
Misc 1.3.9 bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Jan 8, 2025
1 parent cb370d3 commit 7912871
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

**Bug fixes**:
- Fixed issue where "VR Settings" button would render on top of the rebinding panel
- Fixed issue where pressing the menu button wouldn't work while in the rebinding menu
- Fixed issue where some unused UI elements were sometimes visible in the pause menu

**Removals**:
- Removed the cave dweller from the main menu
Expand Down
5 changes: 3 additions & 2 deletions Docs/Thunderstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ Here is a list of LCVR versions and which version(s) of Lethal Company it suppor

| LCVR | Lethal Company |
|-------------------|-------------------|
| v1.3.8 *(LATEST)* | V64 - V69* |
| v1.3.9 *(LATEST)* | V64 - V69.1 |
| v1.3.8 | V64 - V69 |
| v1.3.7 | V64 - V67 |
| v1.3.6 | V64 - V67 |
| v1.3.6* | V64 - V67 |
| v1.3.5 | V64 - V66 |
| v1.3.4 | V64 and V64.1 |
| v1.3.3 | V64 and V64.1 |
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ Here is a list of LCVR versions and which version(s) of Lethal Company it suppor

| LCVR | Lethal Company |
|-------------------|-------------------|
| v1.3.8 *(LATEST)* | V64 - V69* |
| v1.3.9 *(LATEST)* | V64 - V69.1 |
| v1.3.8 | V64 - V69 |
| v1.3.7 | V64 - V67 |
| v1.3.6 | V64 - V67 |
| v1.3.6* | V64 - V67 |
| v1.3.5 | V64 - V66 |
| v1.3.4 | V64 and V64.1 |
| v1.3.3 | V64 and V64.1 |
Expand Down
4 changes: 2 additions & 2 deletions Source/Compatibility/MoreCompany/MoreCompanyCompatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace LCVR.Compatibility.MoreCompany;

internal static class MoreCompanyCompatibility
{
private static GameObject canvasUi;
private static Transform previousParent;
private static Vector3 previousPosition;
private static Vector3 previousRotation;
Expand All @@ -18,7 +19,7 @@ public static void SetupMoreCompanyUIMainMenu()
if (overlay == null)
return;

var canvasUi = overlay.Find("Canvas/GlobalScale");
canvasUi = overlay.Find("Canvas/GlobalScale");

previousParent = canvasUi.transform.parent;
previousPosition = canvasUi.transform.localPosition;
Expand Down Expand Up @@ -46,7 +47,6 @@ public static void RevertMoreCompanyUIMainMenu()
if (overlay == null)
return;

var canvasUi = overlay.Find("Canvas/GlobalScale");
canvasUi.transform.parent = previousParent;
canvasUi.transform.localPosition = previousPosition;
canvasUi.transform.localEulerAngles = previousRotation;
Expand Down
6 changes: 4 additions & 2 deletions Source/Input/KeyRemapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ public class KeyRemapManager : MonoBehaviour

public static KeyRemapManager Instance { get; private set; }

public bool IsRebinding => currentOperation != null || Time.realtimeSinceStartup - lastRebindTime < 0.5f;

private KepRemapPanel panel;
private TextMeshProUGUI sectionText;

private PlayerInput playerInput;
private InputActionRebindingExtensions.RebindingOperation currentOperation;
private SettingsOption currentOption;
private List<(RemappableControl, SettingsOption)> controlsList = [];
private readonly List<GameObject> panelObjects = [];

private float lastRebindTime;

Expand Down Expand Up @@ -87,7 +88,6 @@ private void Awake()
var obj = Instantiate(panel.keyRemapSlotPrefab, panel.keyRemapContainer);
var discard = Instantiate(AssetManager.KeybindDiscard, obj.transform);

panelObjects.Add(obj);
panel.keySlots.Add(obj);

obj.GetComponentInChildren<TextMeshProUGUI>().text = remappableKey.controlName;
Expand Down Expand Up @@ -249,6 +249,8 @@ private void CompleteRebind(SettingsOption option, int rebindIndex)
var action = currentOperation.action;

currentOperation.Dispose();
currentOperation = null;

playerInput.ActivateInput();

var image = option.transform.Find("ControlImage").GetComponent<Image>();
Expand Down
25 changes: 18 additions & 7 deletions Source/OpenXR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,26 @@ private static bool EnumRuntimeFiles(IntPtr hKey, List<string> files)
/// </summary>
private static IEnumerable<Runtime> LocateCommonRuntimes()
{
Runtime rt;

// 1. SteamVR
if (SteamClient.IsValid && SteamApps.IsAppInstalled(250820) && SteamApps.AppInstallDir(250820) is { } path)
var runtime = Utils.ExecuteWithSteamAPI<Runtime?>(() =>
{
if (SteamApps.IsAppInstalled(250820) && SteamApps.AppInstallDir(250820) is { } path &&
Runtime.ReadFromJson(Path.Combine(path, "steamxr_win64.json"), out var runtime))
return runtime;

return null;
});

if (runtime != null)
{
if (Runtime.ReadFromJson(Path.Combine(path, "steamxr_win64.json"), out rt))
yield return rt;
yield return runtime.Value;
}

// 2. Virtual Desktop
path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
@"Virtual Desktop Streamer\OpenXR\virtualdesktop-openxr.json");

if (File.Exists(path) && Runtime.ReadFromJson(path, out rt))
if (File.Exists(path) && Runtime.ReadFromJson(path, out var rt))
yield return rt;

// 3. Oculus
Expand Down Expand Up @@ -324,6 +330,11 @@ public static bool InitializeXR()
return InitializeXR(null);
}

foreach (var wtf in LocateCommonRuntimes())
{
Logger.LogDebug($"{wtf.Name}: {wtf.Path} (Default: {wtf.Default})");
}

if (GetRuntimes() is var runtimes && runtimes.Count == 0)
{
Logger.LogWarning("Failed to query runtimes, or no runtimes were found. Falling back to old behavior.");
Expand Down
17 changes: 16 additions & 1 deletion Source/Patches/QuickMenuManagerPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HarmonyLib;
using LCVR.Input;
using LCVR.Player;

namespace LCVR.Patches;
Expand All @@ -22,8 +23,22 @@ private static void AfterOpenPauseMenu()
/// </summary>
[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.CloseQuickMenu))]
[HarmonyPostfix]
private static void AfterClosePauseMenu()
private static void AfterClosePauseMenu(bool __runOriginal)
{
if (!__runOriginal)
return;

VRSession.Instance.OnPauseMenuClosed();
}

/// <summary>
/// Prevent closing the pause menu under certain conditions
/// </summary>
[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.CloseQuickMenu))]
[HarmonyPrefix]
private static bool BeforeClosePauseMenu()
{
// Disallow during rebinding operation
return KeyRemapManager.Instance == null || !KeyRemapManager.Instance.IsRebinding;
}
}
19 changes: 19 additions & 0 deletions Source/Patches/SettingsOptionPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using HarmonyLib;

namespace LCVR.Patches;

[LCVRPatch]
[HarmonyPatch]
internal static class SettingsOptionPatches
{
/// <summary>
/// When you close the rebinding menu, this function makes sure the binding text is reset to normal for each binding.
/// In VR, we use icons, so this only causes issues for us.
/// </summary>
[HarmonyPatch(typeof(SettingsOption), nameof(SettingsOption.SetBindingToCurrentSetting))]
[HarmonyPrefix]
private static bool IgnoreBindingTextReload()
{
return false;
}
}
4 changes: 4 additions & 0 deletions Source/UI/VRHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ private void Awake()
spectatorLight = Instantiate(AssetManager.SpectatorLight, transform);
spectatorLight.SetActive(false);

// Remove leftover UI
ingamePlayerHud.Find("TopRightCorner").transform.GetChildren().Do(child => child.gameObject.SetActive(false));
ingamePlayerHud.Find("BottomLeftCorner").transform.GetChildren().Do(child => child.gameObject.SetActive(false));

// Prevents CullFactory from culling the light
spectatorLight.hideFlags |= HideFlags.DontSave;

Expand Down
21 changes: 21 additions & 0 deletions Source/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Collections;
using System.Linq;
using GameNetcodeStuff;
using Steamworks;

namespace LCVR;

Expand Down Expand Up @@ -235,4 +236,24 @@ public static IEnumerator NopRoutine()
{
yield break;
}

/// <summary>
/// Execute a function making sure the Steam API is initialized, and immediately shutdown the Steam API if it
/// wasn't already in use. This is required because this variant of Steamworks crashes on multiple Init calls,
/// instead of silently ignoring subsequent init calls.
/// </summary>
public static T ExecuteWithSteamAPI<T>(Func<T> func)
{
var isValid = SteamClient.IsValid;

if (!isValid)
SteamClient.Init(1966720, false);

var result = func();

if (!isValid)
SteamClient.Shutdown();

return result;
}
}

0 comments on commit 7912871

Please sign in to comment.