From 0cea6ffe1012c9dba81f86bc7a1ab561c0a98e3b Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Thu, 21 Jan 2021 14:16:26 +0100 Subject: [PATCH] feat: expose Device and WindowHandle on UiBuilder --- Dalamud/Interface/InterfaceManager.cs | 8 ++++++-- Dalamud/Interface/UiBuilder.cs | 10 ++++++++++ Dalamud/SafeMemory.cs | 4 ++++ lib/ImGuiScene | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Dalamud/Interface/InterfaceManager.cs b/Dalamud/Interface/InterfaceManager.cs index 050fac255..dcad917c8 100644 --- a/Dalamud/Interface/InterfaceManager.cs +++ b/Dalamud/Interface/InterfaceManager.cs @@ -11,6 +11,7 @@ using EasyHook; using ImGuiNET; using ImGuiScene; using Serilog; +using SharpDX.Direct3D11; // general dev notes, here because it's easiest /* @@ -46,6 +47,9 @@ namespace Dalamud.Interface private Dalamud dalamud; private RawDX11Scene scene; + public Device Device => this.scene.Device; + public IntPtr WindowHandlePtr => this.scene.WindowHandle; + private delegate void InstallRTSSHook(); private string rtssPath; @@ -218,9 +222,9 @@ namespace Dalamud.Interface private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags) { - if (this.scene == null) - { + if (this.scene == null) { this.scene = new RawDX11Scene(swapChain); + this.scene.ImGuiIniPath = Path.Combine(Path.GetDirectoryName(this.dalamud.StartInfo.ConfigurationPath), "dalamudUI.ini"); this.scene.OnBuildUI += Display; this.scene.OnNewInputFrame += OnNewInputFrame; diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 5ecfbd101..f5c7370a9 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -19,6 +19,16 @@ namespace Dalamud.Interface public class UiBuilder : IDisposable { private readonly string namespaceName; + /// + /// The game's active Direct3D device. + /// + public Device Device => this.dalamud.InterfaceManager.Device; + + /// + /// The game's main window handle. + /// + public IntPtr WindowHandlePtr => this.dalamud.InterfaceManager.WindowHandlePtr; + /// /// The default Dalamud font based on Noto Sans CJK Medium in 17pt - supporting all game languages and icons. /// diff --git a/Dalamud/SafeMemory.cs b/Dalamud/SafeMemory.cs index e38c2d333..03eb398cd 100644 --- a/Dalamud/SafeMemory.cs +++ b/Dalamud/SafeMemory.cs @@ -12,6 +12,10 @@ namespace Dalamud /// /// Class facilitating safe memory access /// + /// + /// Attention! The performance of these methods is severely worse than regular calls. + /// Please consider using these instead in performance-critical code. + /// public static class SafeMemory { private static readonly IntPtr Handle; diff --git a/lib/ImGuiScene b/lib/ImGuiScene index 97a487c79..facf6b153 160000 --- a/lib/ImGuiScene +++ b/lib/ImGuiScene @@ -1 +1 @@ -Subproject commit 97a487c795b7c8fda6ce5342c88035ba9f40e53d +Subproject commit facf6b1533ea80a76628e1edee3494b61f065e70