Merge pull request #528 from daemitus/windows

This commit is contained in:
goaaats 2021-09-03 13:34:52 +02:00 committed by GitHub
commit d23b710edf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 12 deletions

View file

@ -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<UiModuleRequestMainCommand>(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<AtkUnitBaseReceiveGlobalEvent>(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<AtkUnitBaseReceiveGlobalEvent>(atkUnitBaseReceiveGlobalEventAddress, this.AtkUnitBaseReceiveGlobalEventDetour);
}
private delegate void AgentHudOpenSystemMenuPrototype(void* thisPtr, AtkValue* atkValueArgs, uint menuSize);

View file

@ -173,16 +173,16 @@ namespace Dalamud.Interface
/// </summary>
/// <param name="filePath">The full filepath to the image.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public TextureWrap LoadImage(string filePath) =>
Service<InterfaceManager>.Get().LoadImage(filePath);
public TextureWrap LoadImage(string filePath)
=> Service<InterfaceManager>.Get().LoadImage(filePath);
/// <summary>
/// Loads an image from a byte stream, such as a png downloaded into memory.
/// </summary>
/// <param name="imageData">A byte array containing the raw image data.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public TextureWrap LoadImage(byte[] imageData) =>
Service<InterfaceManager>.Get().LoadImage(imageData);
public TextureWrap LoadImage(byte[] imageData)
=> Service<InterfaceManager>.Get().LoadImage(imageData);
/// <summary>
/// Loads an image from raw unformatted pixel data, with no type or header information. To load formatted data, use <see cref="LoadImage(byte[])"/>.
@ -192,8 +192,8 @@ namespace Dalamud.Interface
/// <param name="height">The height of the image contained in <paramref name="imageData"/>.</param>
/// <param name="numChannels">The number of channels (bytes per pixel) of the image contained in <paramref name="imageData"/>. This should usually be 4.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels) =>
Service<InterfaceManager>.Get().LoadImageRaw(imageData, width, height, numChannels);
public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels)
=> Service<InterfaceManager>.Get().LoadImageRaw(imageData, width, height, numChannels);
/// <summary>
/// Call this to queue a rebuild of the font atlas.<br/>
@ -226,7 +226,7 @@ namespace Dalamud.Interface
interfaceManager.Draw -= this.OnDraw;
interfaceManager.BuildFonts -= this.OnBuildFonts;
interfaceManager.BuildFonts -= this.OnResizeBuffers;
interfaceManager.ResizeBuffers -= this.OnResizeBuffers;
}
/// <summary>

View file

@ -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<Window> windows = new();
private string lastFocusedWindowName = string.Empty;
/// <summary>
/// Initializes a new instance of the <see cref="WindowSystem"/> class.
/// </summary>
@ -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();