first commit

This commit is contained in:
2025-07-06 00:23:46 +02:00
commit 38f50c8819
1788 changed files with 112878 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
using System.Reflection;
using NitroxClient.MonoBehaviours.Gui.Modals;
using NitroxModel.Helper;
namespace NitroxPatcher.Patches.Dynamic;
/// <summary>
/// Disable the possibility of escaping a modal by clicking outside of its box or pressing the escape for the modals that want it
/// </summary>
public sealed partial class IngameMenu_OnDeselect_Patch : NitroxPatch, IDynamicPatch
{
private static MethodInfo TARGET_METHOD = Reflect.Method((IngameMenu t) => t.OnDeselect());
// OnDeselect happens when you deselect the modal (by clicking outside or pressing escape)
// Therefore, if we prevent it from happening it certain cases, it will force the user to click one of the buttons of the modal
public static bool Prefix()
{
// Cancel if the modal is set to be non-avoidable (IsAvoidable) and if it's not the modal that wants to close itself (IsAvoidableBypass)
if (Modal.CurrentModal != null && !Modal.CurrentModal.IsAvoidable && !Modal.CurrentModal.IsAvoidableBypass)
{
return false;
}
if (Modal.CurrentModal != null)
{
Modal.CurrentModal.OnDeselect();
}
Modal.CurrentModal = null;
return true;
}
}