diff --git a/Patches/ConfirmationDialogKeysPatches.cs b/Patches/ConfirmationDialogKeysPatches.cs index cbbe71d..791cff4 100644 --- a/Patches/ConfirmationDialogKeysPatches.cs +++ b/Patches/ConfirmationDialogKeysPatches.cs @@ -4,6 +4,7 @@ using EFT.UI; using HarmonyLib; using System.Reflection; using UnityEngine; +using UnityEngine.UI; namespace UIFixes { @@ -13,6 +14,8 @@ namespace UIFixes { new DialogWindowPatch().Enable(); new SplitDialogPatch().Enable(); + new ClickOutPatch().Enable(); + new ClickOutSplitDialogPatch().Enable(); } public class DialogWindowPatch : ModulePatch @@ -40,6 +43,7 @@ namespace UIFixes } } + // Of course SplitDialogs are a *completely different dialog impelementation* public class SplitDialogPatch : ModulePatch { protected override MethodBase GetTargetMethod() @@ -61,5 +65,58 @@ namespace UIFixes return true; } } + + public class ClickOutPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.DeclaredMethod(typeof(MessageWindow), nameof(MessageWindow.Show)); + } + + [PatchPostfix] + public static void Postfix(MessageWindow __instance) + { + if (!Settings.ClickOutOfDialogs.Value) + { + return; + } + + // Note the space after firewall, because unity doesn't trim names and BSG is incompetent + Button button = __instance.transform.Find("Window/Firewall ")?.gameObject.GetOrAddComponent