[DesktopVRSwitch] Minor changes

This commit is contained in:
NotAKidoS 2023-08-03 00:05:45 -05:00
parent 6d17085f21
commit 4c09f9bd57
25 changed files with 359 additions and 205 deletions

View file

@ -8,22 +8,7 @@ namespace NAK.DesktopVRSwitch;
public class DesktopVRSwitch : MelonMod
{
internal static MelonLogger.Instance Logger;
public static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(nameof(DesktopVRSwitch));
public static readonly MelonPreferences_Entry<bool> EntryEnterCalibrationOnSwitch =
Category.CreateEntry("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.");
public static readonly MelonPreferences_Entry<bool> EntryUseTransitionOnSwitch =
Category.CreateEntry("Use Transition on Switch", true, description: "Should the world transition play on VRMode switch?");
//public static readonly MelonPreferences_Entry<bool> EntryRenderVRGameView =
// Category.CreateEntry("Render VR Game View", true, description: "Should the VR view be displayed in the game window after VRMode switch?");
public static readonly MelonPreferences_Entry<bool> EntrySwitchToDesktopOnExit =
Category.CreateEntry("Switch to Desktop on SteamVR Exit", false, description: "Should the game switch to Desktop when SteamVR quits?");
public override void OnInitializeMelon()
{
Logger = LoggerInstance;
@ -40,9 +25,14 @@ public class DesktopVRSwitch : MelonMod
ApplyPatches(typeof(HarmonyPatches.IKSystemPatches));
// post processing fixes
ApplyPatches(typeof(HarmonyPatches.CVRWorldPatches));
// fuck you
ApplyPatches(typeof(HarmonyPatches.CohtmlUISystemPatches));
// prevent steamvr behaviour from closing game
ApplyPatches(typeof(HarmonyPatches.SteamVRBehaviourPatches));
InitializeIntegration("BTKUILib", Integrations.BTKUIAddon.Initialize);
}
public override void OnUpdate()
@ -83,6 +73,15 @@ public class DesktopVRSwitch : MelonMod
// CVRWorld tracker - Must come after PlayerSetupTracker
VRModeSwitchManager.RegisterVRModeTracker(new CVRWorldTracker());
}
private static void InitializeIntegration(string modName, Action integrationAction)
{
if (RegisteredMelons.All(it => it.Info.Name != modName))
return;
Logger.Msg($"Initializing {modName} integration.");
integrationAction.Invoke();
}
private void ApplyPatches(Type type)
{