[SwitchToDesktopOnSteamVRExit] Switched patch implementation because it did not work properly

This commit is contained in:
NotAKidoS 2024-04-23 16:53:00 -05:00
parent b42f72d082
commit e12da22513
2 changed files with 35 additions and 15 deletions

View file

@ -18,13 +18,28 @@ public class SwitchToDesktopOnSteamVRExit : MelonMod
public override void OnInitializeMelon()
{
HarmonyInstance.Patch(
typeof(SteamVR_Behaviour).GetMethod("OnQuit"),
new HarmonyMethod(typeof(SwitchToDesktopOnSteamVRExit).GetMethod(nameof(Prefix_SteamVR_Behaviour_OnQuit),
BindingFlags.NonPublic | BindingFlags.Static))
);
ApplyPatches(typeof(SteamVRBehaviour_Patches));
}
private void ApplyPatches(Type type)
{
try
{
HarmonyInstance.PatchAll(type);
}
catch (Exception e)
{
LoggerInstance.Msg($"Failed while patching {type.Name}!");
LoggerInstance.Error(e);
}
}
#region Patches
private static class SteamVRBehaviour_Patches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(SteamVR_Behaviour), /*nameof(SteamVR_Behaviour.OnQuit)*/ "OnQuit")]
private static bool Prefix_SteamVR_Behaviour_OnQuit()
{
if (!EntryEnabled.Value)
@ -38,3 +53,6 @@ public class SwitchToDesktopOnSteamVRExit : MelonMod
return false;
}
}
#endregion Patches
}

View file

@ -20,6 +20,8 @@ using System.Reflection;
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonColor(255, 52, 152, 219)]
[assembly: MelonAuthorColor(255, 158, 21, 32)]
[assembly: HarmonyDontPatchAll]
namespace NAK.SwitchToDesktopOnSteamVRExit.Properties;