From 3e1a01879953d884a66fe134a53840d56cab41dd Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 3 Sep 2021 06:13:06 -0400 Subject: [PATCH 1/3] Fix event unsubscription in InterfaceManager --- Dalamud/Interface/UiBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 00ef46260..4d7439025 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -226,7 +226,7 @@ namespace Dalamud.Interface interfaceManager.Draw -= this.OnDraw; interfaceManager.BuildFonts -= this.OnBuildFonts; - interfaceManager.BuildFonts -= this.OnResizeBuffers; + interfaceManager.ResizeBuffers -= this.OnResizeBuffers; } /// From 2c6834b4bab7148b77e281d96810376ddf4f3dba Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 3 Sep 2021 06:39:31 -0400 Subject: [PATCH 2/3] Log windowSystem focus changes --- Dalamud/Interface/Windowing/WindowSystem.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs index 7f143edc3..ccfefd241 100644 --- a/Dalamud/Interface/Windowing/WindowSystem.cs +++ b/Dalamud/Interface/Windowing/WindowSystem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using ImGuiNET; +using Serilog; namespace Dalamud.Interface.Windowing { @@ -15,6 +16,8 @@ namespace Dalamud.Interface.Windowing private readonly List windows = new(); + private string lastFocusedWindowName = string.Empty; + /// /// Initializes a new instance of the class. /// @@ -94,13 +97,28 @@ namespace Dalamud.Interface.Windowing window.DrawInternal(); } - this.HasAnyFocus = this.windows.Any(x => x.IsFocused && x.RespectCloseHotkey); + var focusedWindow = this.windows.FirstOrDefault(x => x.IsFocused && x.RespectCloseHotkey); + this.HasAnyFocus = focusedWindow != default; if (this.HasAnyFocus) { + if (this.lastFocusedWindowName != focusedWindow.WindowName) + { + Log.Verbose($"WindowSystem \"{this.Namespace}\" Window \"{focusedWindow.WindowName}\" has focus now"); + this.lastFocusedWindowName = focusedWindow.WindowName; + } + HasAnyWindowSystemFocus = true; lastAnyFocus = DateTimeOffset.Now; } + else + { + if (this.lastFocusedWindowName != string.Empty) + { + Log.Verbose($"WindowSystem \"{this.Namespace}\" Window \"{this.lastFocusedWindowName}\" lost focus"); + this.lastFocusedWindowName = string.Empty; + } + } if (hasNamespace) ImGui.PopID(); From edc79a7327a90d8c6d29c915d53a5632055a00be Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 3 Sep 2021 06:13:42 -0400 Subject: [PATCH 3/3] formatting --- Dalamud/Game/Internal/DalamudAtkTweaks.cs | 6 ++---- Dalamud/Interface/UiBuilder.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Dalamud/Game/Internal/DalamudAtkTweaks.cs b/Dalamud/Game/Internal/DalamudAtkTweaks.cs index f917e4f57..404eeaf90 100644 --- a/Dalamud/Game/Internal/DalamudAtkTweaks.cs +++ b/Dalamud/Game/Internal/DalamudAtkTweaks.cs @@ -48,10 +48,8 @@ namespace Dalamud.Game.Internal var uiModuleRequestMainCommandAddress = sigScanner.ScanText("40 53 56 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 48 8B 01 8B DA 48 8B F1 FF 90 ?? ?? ?? ??"); this.hookUiModuleRequestMainCommand = new Hook(uiModuleRequestMainCommandAddress, this.UiModuleRequestMainCommandDetour); - var atkUnitBaseReceiveGlobalEventAddress = - sigScanner.ScanText("48 89 5C 24 ?? 48 89 7C 24 ?? 55 41 56 41 57 48 8B EC 48 83 EC 50 44 0F B7 F2 "); - this.hookAtkUnitBaseReceiveGlobalEvent = - new Hook(atkUnitBaseReceiveGlobalEventAddress, this.AtkUnitBaseReceiveGlobalEventDetour); + var atkUnitBaseReceiveGlobalEventAddress = sigScanner.ScanText("48 89 5C 24 ?? 48 89 7C 24 ?? 55 41 56 41 57 48 8B EC 48 83 EC 50 44 0F B7 F2 "); + this.hookAtkUnitBaseReceiveGlobalEvent = new Hook(atkUnitBaseReceiveGlobalEventAddress, this.AtkUnitBaseReceiveGlobalEventDetour); } private delegate void AgentHudOpenSystemMenuPrototype(void* thisPtr, AtkValue* atkValueArgs, uint menuSize); diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 4d7439025..ab0ad6f6e 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -173,16 +173,16 @@ namespace Dalamud.Interface /// /// The full filepath to the image. /// A object wrapping the created image. Use inside ImGui.Image(). - public TextureWrap LoadImage(string filePath) => - Service.Get().LoadImage(filePath); + public TextureWrap LoadImage(string filePath) + => Service.Get().LoadImage(filePath); /// /// Loads an image from a byte stream, such as a png downloaded into memory. /// /// A byte array containing the raw image data. /// A object wrapping the created image. Use inside ImGui.Image(). - public TextureWrap LoadImage(byte[] imageData) => - Service.Get().LoadImage(imageData); + public TextureWrap LoadImage(byte[] imageData) + => Service.Get().LoadImage(imageData); /// /// Loads an image from raw unformatted pixel data, with no type or header information. To load formatted data, use . @@ -192,8 +192,8 @@ namespace Dalamud.Interface /// The height of the image contained in . /// The number of channels (bytes per pixel) of the image contained in . This should usually be 4. /// A object wrapping the created image. Use inside ImGui.Image(). - public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels) => - Service.Get().LoadImageRaw(imageData, width, height, numChannels); + public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels) + => Service.Get().LoadImageRaw(imageData, width, height, numChannels); /// /// Call this to queue a rebuild of the font atlas.