mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
[SwitchToDesktopOnSteamVRExit] Switched patch implementation because it did not work properly
This commit is contained in:
parent
b42f72d082
commit
e12da22513
2 changed files with 35 additions and 15 deletions
|
@ -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)
|
||||
|
@ -37,4 +52,7 @@ public class SwitchToDesktopOnSteamVRExit : MelonMod
|
|||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Patches
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue