[StopClosingMyMenuOnWorldLoad] Initial Release

This commit is contained in:
NotAKidoS 2024-04-23 16:01:55 -05:00
parent 926cdcef66
commit 6c7a3259e7
5 changed files with 135 additions and 0 deletions

View file

@ -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<CodeInstruction> Transpiler_CVRWorld_Start(IEnumerable<CodeInstruction> 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
}

View file

@ -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";
}

View file

@ -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.

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<RootNamespace>StopClosingMyMenusOnWorldLoad</RootNamespace>
</PropertyGroup>
</Project>

View file

@ -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"
}