mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2026-03-28 09:36:43 +00:00
[ESCBothMenus] Initial release
This commit is contained in:
parent
b4b392d20d
commit
798336f409
4 changed files with 109 additions and 0 deletions
52
ESCBothMenus/Main.cs
Normal file
52
ESCBothMenus/Main.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using System.Reflection;
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using ABI_RC.Systems.Movement;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.ESCBothMenus;
|
||||
|
||||
public class ESCBothMenusMod : MelonMod
|
||||
{
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
HarmonyInstance.Patch(
|
||||
typeof(ViewManager).GetMethod(nameof(ViewManager.Update),
|
||||
BindingFlags.NonPublic | BindingFlags.Instance),
|
||||
prefix: new HarmonyMethod(typeof(ESCBothMenusMod).GetMethod(nameof(OnPreViewManagerUpdate),
|
||||
BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
}
|
||||
|
||||
private static float _timer = -1f;
|
||||
private static bool _main;
|
||||
|
||||
private static void OnPreViewManagerUpdate()
|
||||
{
|
||||
if (CVRInputManager.Instance.mainMenuButton
|
||||
&& !BetterBetterCharacterController.Instance.IsSittingOnControlSeat())
|
||||
{
|
||||
if (_timer < 0f) _timer = 0.2f;
|
||||
else _main = true;
|
||||
}
|
||||
|
||||
if (_timer >= 0f && (_timer -= Time.deltaTime) <= 0f)
|
||||
{
|
||||
var vm = ViewManager.Instance;
|
||||
var qm = CVR_MenuManager.Instance;
|
||||
|
||||
if (vm.IsViewShown) vm.UiStateToggle(false);
|
||||
else if (qm.IsViewShown) qm.ToggleQuickMenu(false);
|
||||
else if (_main) vm.UiStateToggle(true);
|
||||
else qm.ToggleQuickMenu(true);
|
||||
|
||||
_timer = -1f;
|
||||
_main = false;
|
||||
}
|
||||
|
||||
// consume so original logic doesn't fire
|
||||
CVRInputManager.Instance.mainMenuButton = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue