feat: add ResizeBuffers event to UiBuilder

This commit is contained in:
goat 2021-09-02 13:41:09 +02:00
parent 8820f84d2b
commit 395328eb17
No known key found for this signature in database
GPG key ID: F18F057873895461
2 changed files with 22 additions and 3 deletions

View file

@ -133,10 +133,15 @@ namespace Dalamud.Interface.Internal
private delegate void InstallRTSSHook();
/// <summary>
/// This event gets called by a plugin UiBuilder when read
/// This event gets called each frame to facilitate ImGui drawing.
/// </summary>
public event RawDX11Scene.BuildUIDelegate Draw;
/// <summary>
/// This event gets called when ResizeBuffers is called.
/// </summary>
public event Action ResizeBuffers;
/// <summary>
/// Gets or sets an action that is executed when fonts are rebuilt.
/// </summary>
@ -545,6 +550,8 @@ namespace Dalamud.Interface.Internal
Log.Verbose($"Calling resizebuffers swap@{swapChain.ToInt64():X}{bufferCount} {width} {height} {newFormat} {swapChainFlags}");
#endif
this.ResizeBuffers?.Invoke();
// We have to ensure we're working with the main swapchain,
// as viewports might be resizing as well
if (this.scene == null || swapChain != this.scene.SwapChain.NativePointer)

View file

@ -38,14 +38,20 @@ namespace Dalamud.Interface
var interfaceManager = Service<InterfaceManager>.Get();
interfaceManager.Draw += this.OnDraw;
interfaceManager.BuildFonts += this.OnBuildFonts;
interfaceManager.ResizeBuffers += this.OnResizeBuffers;
}
/// <summary>
/// The delegate that gets called when Dalamud is ready to draw your windows or overlays.
/// The event that gets called when Dalamud is ready to draw your windows or overlays.
/// When it is called, you can use static ImGui calls.
/// </summary>
public event Action Draw;
/// <summary>
/// The event that is called when the game's DirectX device is requesting you to resize your buffers.
/// </summary>
public event Action ResizeBuffers;
/// <summary>
/// Event that is fired when the plugin should open its configuration interface.
/// </summary>
@ -219,7 +225,8 @@ namespace Dalamud.Interface
var interfaceManager = Service<InterfaceManager>.Get();
interfaceManager.Draw -= this.OnDraw;
interfaceManager.BuildFonts -= this.BuildFonts;
interfaceManager.BuildFonts -= this.OnBuildFonts;
interfaceManager.BuildFonts -= this.OnResizeBuffers;
}
/// <summary>
@ -292,5 +299,10 @@ namespace Dalamud.Interface
{
this.BuildFonts?.Invoke();
}
private void OnResizeBuffers()
{
this.ResizeBuffers?.Invoke();
}
}
}