From a9c60d33e71d3c1c98a011ac58147f287a41d204 Mon Sep 17 00:00:00 2001 From: Tyfon <29051038+tyfon7@users.noreply.github.com> Date: Fri, 31 May 2024 15:32:32 -0700 Subject: [PATCH] Keep messages open after transfer --- Patches/KeepMessagesOpenPatches.cs | 55 ++++++++++++++++++++++++++++++ Plugin.cs | 1 + Settings.cs | 10 ++++++ UIFixes.csproj | 3 ++ 4 files changed, 69 insertions(+) create mode 100644 Patches/KeepMessagesOpenPatches.cs diff --git a/Patches/KeepMessagesOpenPatches.cs b/Patches/KeepMessagesOpenPatches.cs new file mode 100644 index 0000000..c32dfe3 --- /dev/null +++ b/Patches/KeepMessagesOpenPatches.cs @@ -0,0 +1,55 @@ +using Aki.Reflection.Patching; +using EFT.UI; +using EFT.UI.Chat; +using EFT.UI.Screens; +using HarmonyLib; +using System.Reflection; + +namespace UIFixes +{ + public static class KeepMessagesOpenPatches + { + private static bool ReopenMessages = false; + + public static void Enable() + { + new SniffChatPanelClosePatch().Enable(); + new ReopenMessagesPatch().Enable(); + } + + public class SniffChatPanelClosePatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(ChatScreen), nameof(ChatScreen.method_6)); + } + + [PatchPostfix] + public static void Postfix() + { + if (Settings.KeepMessagesOpen.Value) + { + ReopenMessages = true; + } + } + } + + public class ReopenMessagesPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_0)); + } + + [PatchPostfix] + public static void Postfix(MainMenuController __instance, EEftScreenType eftScreenType) + { + if (Settings.KeepMessagesOpen.Value && eftScreenType != EEftScreenType.TransferItems && ReopenMessages) + { + ReopenMessages = false; + __instance.ShowScreen(EMenuType.Chat, true); + } + } + } + } +} diff --git a/Plugin.cs b/Plugin.cs index a7f2f3c..f179c89 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -40,6 +40,7 @@ namespace UIFixes InsureContextMenuPatches.Enable(); TradingAutoSwitchPatches.Enable(); AddOfferRememberAutoselectPatches.Enable(); + KeepMessagesOpenPatches.Enable(); } public static bool InRaid() diff --git a/Settings.cs b/Settings.cs index 68ebc4d..20dc1c5 100644 --- a/Settings.cs +++ b/Settings.cs @@ -32,6 +32,7 @@ namespace UIFixes // General public static ConfigEntry ShowPresetConfirmations { get; set; } public static ConfigEntry ShowTransferConfirmations { get; set; } + public static ConfigEntry KeepMessagesOpen { get; set; } public static ConfigEntry AutofillQuestTurnIns { get; set; } public static ConfigEntry AutoSwitchTrading { get; set; } @@ -93,6 +94,15 @@ namespace UIFixes null, new ConfigurationManagerAttributes { }))); + configEntries.Add(KeepMessagesOpen = config.Bind( + GeneralSection, + "Keep Messages Window Open After Transfer", + true, + new ConfigDescription( + "After receiving items from a transfer, reopen the messages window where you left off", + null, + new ConfigurationManagerAttributes { }))); + configEntries.Add(AutofillQuestTurnIns = config.Bind( GeneralSection, "Autofill Quest Item Turn-ins", diff --git a/UIFixes.csproj b/UIFixes.csproj index 232c503..cecda4c 100644 --- a/UIFixes.csproj +++ b/UIFixes.csproj @@ -33,6 +33,9 @@ $(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.dll + + $(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.Unity.dll + $(PathToSPT)\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll