From b5742a89985c2ea5b12fc887965aa9e31791be14 Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 3 Sep 2021 23:15:03 -0400 Subject: [PATCH 1/5] Rename OnNetworkMessage --- Dalamud/Game/Network/GameNetwork.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dalamud/Game/Network/GameNetwork.cs b/Dalamud/Game/Network/GameNetwork.cs index d75865d50..e4feac4d0 100644 --- a/Dalamud/Game/Network/GameNetwork.cs +++ b/Dalamud/Game/Network/GameNetwork.cs @@ -58,7 +58,7 @@ namespace Dalamud.Game.Network /// /// Event that is called when a network message is sent/received. /// - public event OnNetworkMessageDelegate OnNetworkMessage; + public event OnNetworkMessageDelegate NetworkMessage; /// /// Enable this module. @@ -109,7 +109,7 @@ namespace Dalamud.Game.Network try { // Call events - this.OnNetworkMessage?.Invoke(dataPtr + 0x20, (ushort)Marshal.ReadInt16(dataPtr, 0x12), 0, targetId, NetworkMessageDirection.ZoneDown); + this.NetworkMessage?.Invoke(dataPtr + 0x20, (ushort)Marshal.ReadInt16(dataPtr, 0x12), 0, targetId, NetworkMessageDirection.ZoneDown); this.processZonePacketDownHook.Original(a, targetId, dataPtr + 0x10); } @@ -139,7 +139,7 @@ namespace Dalamud.Game.Network { // Call events // TODO: Implement actor IDs - this.OnNetworkMessage?.Invoke(dataPtr + 0x20, (ushort)Marshal.ReadInt16(dataPtr), 0x0, 0x0, NetworkMessageDirection.ZoneUp); + this.NetworkMessage?.Invoke(dataPtr + 0x20, (ushort)Marshal.ReadInt16(dataPtr), 0x0, 0x0, NetworkMessageDirection.ZoneUp); } catch (Exception ex) { From cd314529ae223de90cc083fbb09abc27aee18ca7 Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 3 Sep 2021 23:20:49 -0400 Subject: [PATCH 2/5] Update all the places --- Dalamud/Game/Network/Internal/NetworkHandlers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Game/Network/Internal/NetworkHandlers.cs b/Dalamud/Game/Network/Internal/NetworkHandlers.cs index c27fd2a97..586c602f4 100644 --- a/Dalamud/Game/Network/Internal/NetworkHandlers.cs +++ b/Dalamud/Game/Network/Internal/NetworkHandlers.cs @@ -37,7 +37,7 @@ namespace Dalamud.Game.Network.Internal this.uploader = new UniversalisMarketBoardUploader(); - Service.Get().OnNetworkMessage += this.OnNetworkMessage; + Service.Get().NetworkMessage += this.OnNetworkMessage; } /// From 7ad2de95793311421d44d24b880db5104b79244c Mon Sep 17 00:00:00 2001 From: Raymond Date: Sat, 4 Sep 2021 10:04:31 -0400 Subject: [PATCH 3/5] null check dpi dispose --- Dalamud/Plugin/Internal/LocalPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Plugin/Internal/LocalPlugin.cs b/Dalamud/Plugin/Internal/LocalPlugin.cs index ef8367f27..26ab31402 100644 --- a/Dalamud/Plugin/Internal/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalPlugin.cs @@ -183,7 +183,7 @@ namespace Dalamud.Plugin.Internal this.instance?.Dispose(); this.instance = null; - this.DalamudInterface.Dispose(); + this.DalamudInterface?.Dispose(); this.DalamudInterface = null; this.pluginType = null; From ad144cf7f4aa835d6e87f222b8a7e5a857646a63 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sat, 4 Sep 2021 14:19:23 -0400 Subject: [PATCH 4/5] Add more escape-button logging --- Dalamud/Game/Internal/DalamudAtkTweaks.cs | 6 ++++++ Dalamud/Interface/Internal/InterfaceManager.cs | 1 + Dalamud/Interface/Windowing/WindowSystem.cs | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Dalamud/Game/Internal/DalamudAtkTweaks.cs b/Dalamud/Game/Internal/DalamudAtkTweaks.cs index 404eeaf90..2e081e9a6 100644 --- a/Dalamud/Game/Internal/DalamudAtkTweaks.cs +++ b/Dalamud/Game/Internal/DalamudAtkTweaks.cs @@ -78,7 +78,10 @@ namespace Dalamud.Game.Internal // "Close Addon" if (cmd == 12 && WindowSystem.HasAnyWindowSystemFocus) + { + Log.Verbose($"Cancelling global event CloseAddon command due to WindowSystem {WindowSystem.FocusedWindowSystemNamespace}"); return IntPtr.Zero; + } return this.hookAtkUnitBaseReceiveGlobalEvent.Original(thisPtr, cmd, a3, a4, a5); } @@ -86,7 +89,10 @@ namespace Dalamud.Game.Internal private void AgentHudOpenSystemMenuDetour(void* thisPtr, AtkValue* atkValueArgs, uint menuSize) { if (WindowSystem.HasAnyWindowSystemFocus) + { + Log.Verbose($"Cancelling OpenSystemMenu due to WindowSystem {WindowSystem.FocusedWindowSystemNamespace}"); return; + } var configuration = Service.Get(); diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index ea730669e..fe0af1a9d 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -648,6 +648,7 @@ namespace Dalamud.Interface.Internal this.lastWantCapture = this.LastImGuiIoPtr.WantCaptureMouse; WindowSystem.HasAnyWindowSystemFocus = false; + WindowSystem.FocusedWindowSystemNamespace = string.Empty; this.Draw?.Invoke(); Service.Get().Draw(); diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs index ccfefd241..4d3a03a0d 100644 --- a/Dalamud/Interface/Windowing/WindowSystem.cs +++ b/Dalamud/Interface/Windowing/WindowSystem.cs @@ -31,7 +31,12 @@ namespace Dalamud.Interface.Windowing /// Gets a value indicating whether any contains any /// that has focus and is not marked to be excluded from consideration. /// - public static bool HasAnyWindowSystemFocus { get; internal set; } + public static bool HasAnyWindowSystemFocus { get; internal set; } = false; + + /// + /// Gets the name of the currently focused window system that is redirecting normal escape functionality. + /// + public static string FocusedWindowSystemNamespace { get; internal set; } = string.Empty; /// /// Gets the timespan since the last time any window was focused. @@ -109,6 +114,8 @@ namespace Dalamud.Interface.Windowing } HasAnyWindowSystemFocus = true; + FocusedWindowSystemNamespace = this.Namespace; + lastAnyFocus = DateTimeOffset.Now; } else From b6d4ac54ff5d621e950f34c225868dbc6b1f63bb Mon Sep 17 00:00:00 2001 From: Raymond Date: Sat, 4 Sep 2021 22:01:15 -0400 Subject: [PATCH 5/5] Add ToArray to prevent iteration error --- Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs index 6da0d4cbf..9e8bcf913 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs @@ -1184,7 +1184,10 @@ namespace Dalamud.Interface.Internal.Windows // Available commands (if loaded) if (plugin.IsLoaded) { - var commands = commandManager.Commands.Where(cInfo => cInfo.Value.ShowInHelp && cInfo.Value.LoaderAssemblyName == plugin.Manifest.InternalName); + var commands = commandManager.Commands + .Where(cInfo => cInfo.Value.ShowInHelp && cInfo.Value.LoaderAssemblyName == plugin.Manifest.InternalName) + .ToArray(); + if (commands.Any()) { ImGui.Dummy(ImGuiHelpers.ScaledVector2(10f, 10f));