diff --git a/Patches/KeepWindowsOnScreenPatches.cs b/Patches/KeepWindowsOnScreenPatches.cs new file mode 100644 index 0000000..8bb8d8f --- /dev/null +++ b/Patches/KeepWindowsOnScreenPatches.cs @@ -0,0 +1,41 @@ +using Aki.Reflection.Patching; +using EFT.InputSystem; +using EFT.UI; +using HarmonyLib; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace UIFixes.Patches +{ + public static class KeepWindowsOnScreenPatches + { + public static void Enable() + { + new KeepWindowOnScreenPatch(nameof(ItemUiContext.Inspect)).Enable(); + new KeepWindowOnScreenPatch(nameof(ItemUiContext.EditTag)).Enable(); + new KeepWindowOnScreenPatch(nameof(ItemUiContext.OpenInsuranceWindow)).Enable(); + new KeepWindowOnScreenPatch(nameof(ItemUiContext.OpenRepairWindow)).Enable(); + new KeepWindowOnScreenPatch(nameof(ItemUiContext.method_2)).Enable(); // grids + } + + private static void FixNewestWindow(List windows) + { + UIInputNode newWindow = windows.Last() as UIInputNode; + newWindow?.CorrectPosition(); + } + + public class KeepWindowOnScreenPatch(string methodName) : ModulePatch + { + private string methodName = methodName; + + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(ItemUiContext), methodName); + } + + [PatchPostfix] + public static void Postfix(List ____children) => FixNewestWindow(____children); + } + } +} diff --git a/Plugin.cs b/Plugin.cs index 7fed687..9c88417 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,6 +1,7 @@ using BepInEx; using Comfort.Common; using EFT; +using UIFixes.Patches; namespace UIFixes { @@ -45,6 +46,7 @@ namespace UIFixes RememberRepairerPatches.Enable(); new GridWindowButtonsPatch().Enable(); new LoadMagPresetsPatch().Enable(); + KeepWindowsOnScreenPatches.Enable(); } public static bool InRaid()