From 6c7a3259e7a74131d3d24fedc80aec7cd099892c Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:01:55 -0500 Subject: [PATCH] [StopClosingMyMenuOnWorldLoad] Initial Release --- StopClosingMyMenuOnWorldLoad/Main.cs | 57 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 30 ++++++++++ StopClosingMyMenuOnWorldLoad/README.md | 18 ++++++ .../StopClosingMyMenuOnWorldLoad.csproj | 7 +++ StopClosingMyMenuOnWorldLoad/format.json | 23 ++++++++ 5 files changed, 135 insertions(+) create mode 100644 StopClosingMyMenuOnWorldLoad/Main.cs create mode 100644 StopClosingMyMenuOnWorldLoad/Properties/AssemblyInfo.cs create mode 100644 StopClosingMyMenuOnWorldLoad/README.md create mode 100644 StopClosingMyMenuOnWorldLoad/StopClosingMyMenuOnWorldLoad.csproj create mode 100644 StopClosingMyMenuOnWorldLoad/format.json diff --git a/StopClosingMyMenuOnWorldLoad/Main.cs b/StopClosingMyMenuOnWorldLoad/Main.cs new file mode 100644 index 0000000..55eb850 --- /dev/null +++ b/StopClosingMyMenuOnWorldLoad/Main.cs @@ -0,0 +1,57 @@ +using System.Reflection; +using System.Reflection.Emit; +using ABI.CCK.Components; +using HarmonyLib; +using MelonLoader; + +namespace NAK.StopClosingMyMenuOnWorldLoad; + +public class StopClosingMyMenuOnWorldLoad : MelonMod +{ + public override void OnInitializeMelon() + { + ApplyPatches(typeof(CVRWorld_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 CVRWorld_Patches + { + // prevents CVRWorld from closing menus when world transitioning, cause cool (taken from MenuScalePatch, kafe originally made the transpiler patch) + [HarmonyTranspiler] + [HarmonyPatch(typeof(CVRWorld), nameof(CVRWorld.Start), MethodType.Enumerator)] + private static IEnumerable Transpiler_CVRWorld_Start(IEnumerable instructions, ILGenerator il) + { + var patchedInstructions = new CodeMatcher(instructions).MatchForward(false, + new CodeMatch(OpCodes.Ldsfld), + new CodeMatch(OpCodes.Ldc_I4_0), + new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "ForceUiStatus" })) + .RemoveInstructions(3) + .InstructionEnumeration(); + + patchedInstructions = new CodeMatcher(patchedInstructions).MatchForward(false, + new CodeMatch(OpCodes.Ldsfld), + new CodeMatch(OpCodes.Ldc_I4_0), + new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "ToggleQuickMenu" })) + .RemoveInstructions(3) + .InstructionEnumeration(); + + return patchedInstructions; + } + } + + #endregion Patches +} \ No newline at end of file diff --git a/StopClosingMyMenuOnWorldLoad/Properties/AssemblyInfo.cs b/StopClosingMyMenuOnWorldLoad/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7af4f8e --- /dev/null +++ b/StopClosingMyMenuOnWorldLoad/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using NAK.StopClosingMyMenuOnWorldLoad.Properties; +using MelonLoader; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.StopClosingMyMenuOnWorldLoad))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.StopClosingMyMenuOnWorldLoad))] + +[assembly: MelonInfo( + typeof(NAK.StopClosingMyMenuOnWorldLoad.StopClosingMyMenuOnWorldLoad), + nameof(NAK.StopClosingMyMenuOnWorldLoad), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/StopClosingMyMenuOnWorldLoad" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] +[assembly: HarmonyDontPatchAll] + +namespace NAK.StopClosingMyMenuOnWorldLoad.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "1.0.0"; + public const string Author = "NotAKidoS"; +} \ No newline at end of file diff --git a/StopClosingMyMenuOnWorldLoad/README.md b/StopClosingMyMenuOnWorldLoad/README.md new file mode 100644 index 0000000..e9c82e1 --- /dev/null +++ b/StopClosingMyMenuOnWorldLoad/README.md @@ -0,0 +1,18 @@ +# StopClosingMyMenuOnWorldLoad + +Simple mod that prevents the menu from closing when a world is loaded. + +This does not handle keeping the menu open when commiting an action that would normally close it, such as respawning via the menu. As of a recent ChilloutVR update, actions that are not initiated by the player will not close the menu, ie. death in combat or forced teleport/respawn, so this is not too much of a concern. + +Nicked the old patch from MenuScalePatch [Kafeijao](https://github.com/kafeijao) made me and threw it into it's own mod. Still works. + +--- + +Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI. +https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games + +> This mod is an independent creation not affiliated with, supported by, or approved by Alpha Blend Interactive. + +> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use. + +> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive. diff --git a/StopClosingMyMenuOnWorldLoad/StopClosingMyMenuOnWorldLoad.csproj b/StopClosingMyMenuOnWorldLoad/StopClosingMyMenuOnWorldLoad.csproj new file mode 100644 index 0000000..dbd305b --- /dev/null +++ b/StopClosingMyMenuOnWorldLoad/StopClosingMyMenuOnWorldLoad.csproj @@ -0,0 +1,7 @@ + + + + net48 + StopClosingMyMenusOnWorldLoad + + diff --git a/StopClosingMyMenuOnWorldLoad/format.json b/StopClosingMyMenuOnWorldLoad/format.json new file mode 100644 index 0000000..55c1892 --- /dev/null +++ b/StopClosingMyMenuOnWorldLoad/format.json @@ -0,0 +1,23 @@ +{ + "_id": -1, + "name": "Stop Closing My Menus On World Load", + "modversion": "1.0.0", + "gameversion": "2024r175", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Simple patch that prevents your menus from being closed when a world is loaded.", + "searchtags": [ + "menu", + "close", + "dont", + "meow" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r25/StopClosingMyMenusOnWorldLoad.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/StopClosingMyMenusOnWorldLoad/", + "changelog": "- Initial Release", + "embedcolor": "#b589ec" +} \ No newline at end of file