mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
major cleanup
This commit is contained in:
parent
b33e15377f
commit
e5242f76c7
85 changed files with 584 additions and 571 deletions
|
@ -6,7 +6,7 @@ using Valve.VR;
|
|||
|
||||
namespace NAK.DesktopVRSwitch;
|
||||
|
||||
public class DesktopVRSwitch : MonoBehaviour
|
||||
public class DesktopVRSwitcher : MonoBehaviour
|
||||
{
|
||||
//Debug Settings
|
||||
public bool _reloadLocalAvatar = true;
|
||||
|
@ -52,7 +52,7 @@ public class DesktopVRSwitch : MonoBehaviour
|
|||
yield return null; //wait a frame before checking
|
||||
if (!string.IsNullOrEmpty(XRSettings.loadedDeviceName))
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Starting SteamVR...");
|
||||
DesktopVRSwitch.Logger.Msg("Starting SteamVR...");
|
||||
XRSettings.enabled = true;
|
||||
//force steamvr to reinitialize input
|
||||
//this does SteamVR_Input.actionSets[0].Activate() for us (we deactivate in StopVR())
|
||||
|
@ -63,7 +63,7 @@ public class DesktopVRSwitch : MonoBehaviour
|
|||
PostVRModeSwitch(true);
|
||||
yield break;
|
||||
}
|
||||
DesktopVRSwitchMod.Logger.Error("Initializing VR Failed. Is there no VR device connected?");
|
||||
DesktopVRSwitch.Logger.Error("Initializing VR Failed. Is there no VR device connected?");
|
||||
FailedVRModeSwitch(true);
|
||||
yield break;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class DesktopVRSwitch : MonoBehaviour
|
|||
PostVRModeSwitch(false);
|
||||
yield break;
|
||||
}
|
||||
DesktopVRSwitchMod.Logger.Error("Attempted to exit VR without a VR device loaded.");
|
||||
DesktopVRSwitch.Logger.Error("Attempted to exit VR without a VR device loaded.");
|
||||
FailedVRModeSwitch(false);
|
||||
yield break;
|
||||
}
|
|
@ -19,11 +19,11 @@ internal class PlayerSetupPatches
|
|||
{
|
||||
if (CheckVR.Instance != null)
|
||||
{
|
||||
CheckVR.Instance.gameObject.AddComponent<DesktopVRSwitch>();
|
||||
CheckVR.Instance.gameObject.AddComponent<DesktopVRSwitcher>();
|
||||
return;
|
||||
}
|
||||
__instance.gameObject.AddComponent<DesktopVRSwitch>();
|
||||
DesktopVRSwitchMod.Logger.Error("CheckVR not found. Reverting to fallback method. This should never happen!");
|
||||
__instance.gameObject.AddComponent<DesktopVRSwitcher>();
|
||||
DesktopVRSwitch.Logger.Error("CheckVR not found. Reverting to fallback method. This should never happen!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,21 +15,19 @@
|
|||
|
||||
namespace NAK.DesktopVRSwitch;
|
||||
|
||||
public class DesktopVRSwitchMod : MelonMod
|
||||
public class DesktopVRSwitch : MelonMod
|
||||
{
|
||||
internal const string SettingsCategory = "DesktopVRSwitch";
|
||||
internal static MelonPreferences_Category mCategory;
|
||||
internal static MelonLogger.Instance Logger;
|
||||
|
||||
internal static MelonPreferences_Entry<bool>
|
||||
mSetting_EnterCalibrationOnSwitch;
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(nameof(DesktopVRSwitch));
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnterCalibrationOnSwitch =
|
||||
Category.CreateEntry("Enter Calibration on Switch", true, "Should you automatically be placed into calibration after switch if FBT is available? Overridden by Save Calibration IK setting.");
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
Logger = LoggerInstance;
|
||||
mCategory = MelonPreferences.CreateCategory(SettingsCategory);
|
||||
mSetting_EnterCalibrationOnSwitch = mCategory.CreateEntry<bool>("Enter Calibration on Switch", true, description: "Should you automatically be placed into calibration after switch if FBT is available? Overridden by Save Calibration IK setting.");
|
||||
|
||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
ApplyPatches(typeof(HarmonyPatches.CVRPickupObjectPatches));
|
||||
ApplyPatches(typeof(HarmonyPatches.CVRWorldPatches));
|
||||
|
|
|
@ -45,7 +45,7 @@ public class IKSystemTracker : MonoBehaviour
|
|||
}
|
||||
|
||||
//make it so you dont instantly end up in FBT from Desktop
|
||||
IKSystem.firstAvatarLoaded = DesktopVRSwitchMod.mSetting_EnterCalibrationOnSwitch.Value;
|
||||
IKSystem.firstAvatarLoaded = DesktopVRSwitch.EntryEnterCalibrationOnSwitch.Value;
|
||||
//turn of finger tracking just in case user switched controllers
|
||||
ikSystem.FingerSystem.controlActive = false;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ internal class ReferenceCameraPatch
|
|||
|
||||
internal static void CopyToInactiveCam(Camera activeCam, Camera inactiveCam)
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Copying active camera settings & components to inactive camera.");
|
||||
DesktopVRSwitch.Logger.Msg("Copying active camera settings & components to inactive camera.");
|
||||
|
||||
//steal basic settings
|
||||
inactiveCam.farClipPlane = activeCam.farClipPlane;
|
||||
|
|
|
@ -14,7 +14,7 @@ public class VRModeSwitchTracker
|
|||
{
|
||||
TryCatchHell.TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnPreVRModeSwitch.");
|
||||
DesktopVRSwitch.Logger.Msg("Invoking VRModeSwitchTracker.OnPreVRModeSwitch.");
|
||||
Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||
VRModeSwitchTracker.OnPreVRModeSwitch?.Invoke(isVR, activeCamera);
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ public class VRModeSwitchTracker
|
|||
{
|
||||
TryCatchHell.TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnPostVRModeSwitch.");
|
||||
DesktopVRSwitch.Logger.Msg("Invoking VRModeSwitchTracker.OnPostVRModeSwitch.");
|
||||
Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||
VRModeSwitchTracker.OnPostVRModeSwitch?.Invoke(isVR, activeCamera);
|
||||
},
|
||||
|
@ -36,7 +36,7 @@ public class VRModeSwitchTracker
|
|||
{
|
||||
TryCatchHell.TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Invoking VRModeSwitchTracker.OnFailVRModeSwitch.");
|
||||
DesktopVRSwitch.Logger.Msg("Invoking VRModeSwitchTracker.OnFailVRModeSwitch.");
|
||||
Camera activeCamera = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||
VRModeSwitchTracker.OnFailVRModeSwitch?.Invoke(isVR, activeCamera);
|
||||
},
|
||||
|
|
|
@ -10,11 +10,11 @@ using System.Reflection;
|
|||
[assembly: AssemblyProduct(nameof(NAK.DesktopVRSwitch))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.DesktopVRSwitch.DesktopVRSwitchMod),
|
||||
typeof(NAK.DesktopVRSwitch.DesktopVRSwitch),
|
||||
nameof(NAK.DesktopVRSwitch),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/DesktopVRSwitch"
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/DesktopVRSwitch"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
|
|
|
@ -20,8 +20,8 @@ internal class TryCatchHell
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Error(string.Format(errorMsg, msgArgs));
|
||||
DesktopVRSwitchMod.Logger.Msg(ex.Message);
|
||||
DesktopVRSwitch.Logger.Error(string.Format(errorMsg, msgArgs));
|
||||
DesktopVRSwitch.Logger.Msg(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Closing ViewManager & CVR_MenuManager menus.");
|
||||
DesktopVRSwitch.Logger.Msg("Closing ViewManager & CVR_MenuManager menus.");
|
||||
ViewManager.Instance.UiStateToggle(false);
|
||||
CVR_MenuManager.Instance.ToggleQuickMenu(false);
|
||||
},
|
||||
|
@ -40,7 +40,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg($"Setting CheckVR hasVrDeviceLoaded to {isVR}.");
|
||||
DesktopVRSwitch.Logger.Msg($"Setting CheckVR hasVrDeviceLoaded to {isVR}.");
|
||||
CheckVR.Instance.hasVrDeviceLoaded = isVR;
|
||||
},
|
||||
"Setting CheckVR hasVrDeviceLoaded failed.");
|
||||
|
@ -50,7 +50,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg($"Setting MetaPort isUsingVr to {isVR}.");
|
||||
DesktopVRSwitch.Logger.Msg($"Setting MetaPort isUsingVr to {isVR}.");
|
||||
MetaPort.Instance.isUsingVr = isVR;
|
||||
},
|
||||
"Setting MetaPort isUsingVr failed.");
|
||||
|
@ -60,7 +60,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Configuring new hud affinity for CohtmlHud.");
|
||||
DesktopVRSwitch.Logger.Msg("Configuring new hud affinity for CohtmlHud.");
|
||||
CohtmlHud.Instance.gameObject.transform.parent = isVR ? PlayerSetup.Instance.vrCamera.transform : PlayerSetup.Instance.desktopCamera.transform;
|
||||
CVRTools.ConfigureHudAffinity();
|
||||
CohtmlHud.Instance.gameObject.transform.localScale = new Vector3(1.2f, 1f, 1.2f);
|
||||
|
@ -72,7 +72,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Switching HudOperations worldLoadingItem & worldLoadStatus.");
|
||||
DesktopVRSwitch.Logger.Msg("Switching HudOperations worldLoadingItem & worldLoadStatus.");
|
||||
HudOperations.Instance.worldLoadingItem = isVR ? HudOperations.Instance.worldLoadingItemVr : HudOperations.Instance.worldLoadingItemDesktop;
|
||||
HudOperations.Instance.worldLoadStatus = isVR ? HudOperations.Instance.worldLoadStatusVr : HudOperations.Instance.worldLoadStatusDesktop;
|
||||
},
|
||||
|
@ -83,7 +83,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Forcing PortableCamera canvas mirroring off.");
|
||||
DesktopVRSwitch.Logger.Msg("Forcing PortableCamera canvas mirroring off.");
|
||||
//tell the game we are in mirror mode so itll disable it (if enabled)
|
||||
PortableCamera.Instance.mode = MirroringMode.Mirror;
|
||||
PortableCamera.Instance.ChangeMirroring();
|
||||
|
@ -95,7 +95,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Switching active PlayerSetup camera rigs. Updating Desktop camera FOV.");
|
||||
DesktopVRSwitch.Logger.Msg("Switching active PlayerSetup camera rigs. Updating Desktop camera FOV.");
|
||||
PlayerSetup.Instance.desktopCameraRig.SetActive(!isVR);
|
||||
PlayerSetup.Instance.vrCameraRig.SetActive(isVR);
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
|
@ -110,7 +110,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg($"Setting CVRInputManager inputEnabled & CVR_InteractableManager enableInteractions to {!toggle}");
|
||||
DesktopVRSwitch.Logger.Msg($"Setting CVRInputManager inputEnabled & CVR_InteractableManager enableInteractions to {!toggle}");
|
||||
CVRInputManager.Instance.inputEnabled = !toggle;
|
||||
CVR_InteractableManager.enableInteractions = !toggle;
|
||||
},
|
||||
|
@ -121,7 +121,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Resetting CVRInputManager inputs.");
|
||||
DesktopVRSwitch.Logger.Msg("Resetting CVRInputManager inputs.");
|
||||
//just in case
|
||||
CVRInputManager.Instance.blockedByUi = false;
|
||||
//sometimes head can get stuck, so just in case
|
||||
|
@ -141,7 +141,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Attempting to reload current local avatar from GUID.");
|
||||
DesktopVRSwitch.Logger.Msg("Attempting to reload current local avatar from GUID.");
|
||||
AssetManagement.Instance.LoadLocalAvatar(MetaPort.Instance.currentAvatarGuid);
|
||||
},
|
||||
"Failed to reload local avatar.");
|
||||
|
@ -153,13 +153,13 @@ internal class TryCatchHell
|
|||
{
|
||||
if (MetaPort.Instance.settings.GetSettingsBool("ImplementationRichPresenceDiscordEnabled", true))
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Forcing Discord Rich Presence update.");
|
||||
DesktopVRSwitch.Logger.Msg("Forcing Discord Rich Presence update.");
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceDiscordEnabled", false);
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceDiscordEnabled", true);
|
||||
}
|
||||
if (MetaPort.Instance.settings.GetSettingsBool("ImplementationRichPresenceSteamEnabled", true))
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Forcing Steam Rich Presence update.");
|
||||
DesktopVRSwitch.Logger.Msg("Forcing Steam Rich Presence update.");
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceSteamEnabled", false);
|
||||
MetaPort.Instance.settings.SetSettingsBool("ImplementationRichPresenceSteamEnabled", true);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Updating CVRGestureRecognizer _camera to active camera.");
|
||||
DesktopVRSwitch.Logger.Msg("Updating CVRGestureRecognizer _camera to active camera.");
|
||||
Traverse.Create(CVRGestureRecognizer.Instance).Field("_camera").SetValue(PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>());
|
||||
},
|
||||
"Failed to update CVRGestureRecognizer camera.");
|
||||
|
@ -181,7 +181,7 @@ internal class TryCatchHell
|
|||
{
|
||||
TryCatchWrapper(() =>
|
||||
{
|
||||
DesktopVRSwitchMod.Logger.Msg("Updating CVR_Menu_Data core data.");
|
||||
DesktopVRSwitch.Logger.Msg("Updating CVR_Menu_Data core data.");
|
||||
CVR_MenuManager.Instance.coreData.core.inVr = isVR;
|
||||
},
|
||||
"Failed to update CVR_Menu_Data core data.");
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/DesktopVRSwitch/releases/download/v4.3.5/DesktopVRSwitch.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/DesktopVRSwitch/",
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/DesktopVRSwitch.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/DesktopVRSwitch/",
|
||||
"changelog": "- Reinitialize SteamVR input on switch. Correct fixedDeltaTime when entering Desktop.\n- Tweak to initial switch position for correcting offsets.\n- Fixed FBT tracking point initial size.\n- Update core menu data so QM Recalibrate/SeatedPlay button works.",
|
||||
"embedcolor": "3498db"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue