feat: expose Device and WindowHandle on UiBuilder

This commit is contained in:
goat 2021-01-21 14:16:26 +01:00
parent 3fe6e45b68
commit 0cea6ffe10
4 changed files with 21 additions and 3 deletions

View file

@ -11,6 +11,7 @@ using EasyHook;
using ImGuiNET; using ImGuiNET;
using ImGuiScene; using ImGuiScene;
using Serilog; using Serilog;
using SharpDX.Direct3D11;
// general dev notes, here because it's easiest // general dev notes, here because it's easiest
/* /*
@ -46,6 +47,9 @@ namespace Dalamud.Interface
private Dalamud dalamud; private Dalamud dalamud;
private RawDX11Scene scene; private RawDX11Scene scene;
public Device Device => this.scene.Device;
public IntPtr WindowHandlePtr => this.scene.WindowHandle;
private delegate void InstallRTSSHook(); private delegate void InstallRTSSHook();
private string rtssPath; private string rtssPath;
@ -218,9 +222,9 @@ namespace Dalamud.Interface
private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags) private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags)
{ {
if (this.scene == null) if (this.scene == null) {
{
this.scene = new RawDX11Scene(swapChain); this.scene = new RawDX11Scene(swapChain);
this.scene.ImGuiIniPath = Path.Combine(Path.GetDirectoryName(this.dalamud.StartInfo.ConfigurationPath), "dalamudUI.ini"); this.scene.ImGuiIniPath = Path.Combine(Path.GetDirectoryName(this.dalamud.StartInfo.ConfigurationPath), "dalamudUI.ini");
this.scene.OnBuildUI += Display; this.scene.OnBuildUI += Display;
this.scene.OnNewInputFrame += OnNewInputFrame; this.scene.OnNewInputFrame += OnNewInputFrame;

View file

@ -19,6 +19,16 @@ namespace Dalamud.Interface
public class UiBuilder : IDisposable { public class UiBuilder : IDisposable {
private readonly string namespaceName; private readonly string namespaceName;
/// <summary>
/// The game's active Direct3D device.
/// </summary>
public Device Device => this.dalamud.InterfaceManager.Device;
/// <summary>
/// The game's main window handle.
/// </summary>
public IntPtr WindowHandlePtr => this.dalamud.InterfaceManager.WindowHandlePtr;
/// <summary> /// <summary>
/// The default Dalamud font based on Noto Sans CJK Medium in 17pt - supporting all game languages and icons. /// The default Dalamud font based on Noto Sans CJK Medium in 17pt - supporting all game languages and icons.
/// </summary> /// </summary>

View file

@ -12,6 +12,10 @@ namespace Dalamud
/// <summary> /// <summary>
/// Class facilitating safe memory access /// Class facilitating safe memory access
/// </summary> /// </summary>
/// <remarks>
/// Attention! The performance of these methods is severely worse than regular <see cref="Marshal"/> calls.
/// Please consider using these instead in performance-critical code.
/// </remarks>
public static class SafeMemory public static class SafeMemory
{ {
private static readonly IntPtr Handle; private static readonly IntPtr Handle;

@ -1 +1 @@
Subproject commit 97a487c795b7c8fda6ce5342c88035ba9f40e53d Subproject commit facf6b1533ea80a76628e1edee3494b61f065e70