wip bindings upgrade

This commit is contained in:
goaaats 2025-04-06 20:59:23 +02:00
parent bd7e56850a
commit 0690cce995
272 changed files with 139041 additions and 1541 deletions

3
.gitignore vendored
View file

@ -328,3 +328,6 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# HexaGen generated files
imgui/**/Generated/**/*

View file

@ -38,9 +38,6 @@
<ProjectReference Include="..\Dalamud\Dalamud.csproj">
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\lib\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj">
<Private>false</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>

View file

@ -2,7 +2,7 @@ using System;
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.CorePlugin
{

View file

@ -440,7 +440,7 @@ namespace Dalamud.Injector
#region Methods
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
public static extern void BuildExplicitAccessWithName(
ref EXPLICIT_ACCESS pExplicitAccess,
string pTrusteeName,
@ -448,26 +448,26 @@ namespace Dalamud.Injector
uint accessMode,
uint inheritance);
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
public static extern int SetEntriesInAcl(
int cCountOfExplicitEntries,
ref EXPLICIT_ACCESS pListOfExplicitEntries,
IntPtr oldAcl,
out IntPtr newAcl);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool InitializeSecurityDescriptor(
out SECURITY_DESCRIPTOR pSecurityDescriptor,
uint dwRevision);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool SetSecurityDescriptorDacl(
ref SECURITY_DESCRIPTOR pSecurityDescriptor,
bool bDaclPresent,
IntPtr pDacl,
bool bDaclDefaulted);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern bool CreateProcess(
string lpApplicationName,
string lpCommandLine,
@ -480,39 +480,39 @@ namespace Dalamud.Injector
[In] ref STARTUPINFO lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr hObject);
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll")]
public static extern uint ResumeThread(IntPtr hThread);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool ImpersonateSelf(
SECURITY_IMPERSONATION_LEVEL impersonationLevel);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool OpenProcessToken(
IntPtr processHandle,
UInt32 desiredAccess,
out IntPtr tokenHandle);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool OpenThreadToken(
IntPtr threadHandle,
uint desiredAccess,
bool openAsSelf,
out IntPtr tokenHandle);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool LookupPrivilegeValue(string lpSystemName, string lpName, ref LUID lpLuid);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool PrivilegeCheck(
IntPtr clientToken,
ref PRIVILEGE_SET requiredPrivileges,
out bool pfResult);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern bool AdjustTokenPrivileges(
IntPtr tokenHandle,
bool disableAllPrivileges,
@ -521,7 +521,7 @@ namespace Dalamud.Injector
IntPtr previousState,
IntPtr cbOutPreviousState);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern uint GetSecurityInfo(
IntPtr handle,
SE_OBJECT_TYPE objectType,
@ -532,7 +532,7 @@ namespace Dalamud.Injector
IntPtr pSacl,
IntPtr pSecurityDescriptor);
[DllImport("advapi32.dll", SetLastError = true)]
[DllImport("advapi32.dll")]
public static extern uint SetSecurityInfo(
IntPtr handle,
SE_OBJECT_TYPE objectType,
@ -542,16 +542,16 @@ namespace Dalamud.Injector
IntPtr pDacl,
IntPtr pSacl);
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll")]
public static extern IntPtr GetCurrentProcess();
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll")]
public static extern IntPtr GetCurrentThread();
[DllImport("user32.dll", SetLastError = true)]
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr hWndChildAfter, string className, IntPtr windowTitle);
[DllImport("user32.dll", SetLastError = true)]
[DllImport("user32.dll")]
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
[DllImport("user32.dll")]

View file

@ -62,7 +62,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cimplot", "external\cimplot
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cimguizmo", "external\cimguizmo\cimguizmo.vcxproj", "{F258347D-31BE-4605-98CE-40E43BDF6F9D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGui.NET-472", "lib\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj", "{A0A3C0AC-18D9-4C74-8CFC-14E53512846D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dalamud.ImGui", "imgui\Dalamud.ImGui\Dalamud.ImGui.csproj", "{B0AA8737-33A3-4766-8CBE-A48F2EF283BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dalamud.ImGuizmo", "imgui\Dalamud.ImGuizmo\Dalamud.ImGuizmo.csproj", "{5E6EDD75-AE95-43A6-9D67-95B840EB4B71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dalamud.ImPlot", "imgui\Dalamud.ImPlot\Dalamud.ImPlot.csproj", "{9C70BD06-D52C-425E-9C14-5D66BC6046EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bindings", "Bindings", "{A217B3DF-607A-4EFB-B107-3C4809348043}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -138,10 +144,18 @@ Global
{F258347D-31BE-4605-98CE-40E43BDF6F9D}.Debug|Any CPU.Build.0 = Debug|x64
{F258347D-31BE-4605-98CE-40E43BDF6F9D}.Release|Any CPU.ActiveCfg = Release|x64
{F258347D-31BE-4605-98CE-40E43BDF6F9D}.Release|Any CPU.Build.0 = Release|x64
{A0A3C0AC-18D9-4C74-8CFC-14E53512846D}.Debug|Any CPU.ActiveCfg = Debug|x64
{A0A3C0AC-18D9-4C74-8CFC-14E53512846D}.Debug|Any CPU.Build.0 = Debug|x64
{A0A3C0AC-18D9-4C74-8CFC-14E53512846D}.Release|Any CPU.ActiveCfg = Release|x64
{A0A3C0AC-18D9-4C74-8CFC-14E53512846D}.Release|Any CPU.Build.0 = Release|x64
{B0AA8737-33A3-4766-8CBE-A48F2EF283BA}.Debug|Any CPU.ActiveCfg = Debug|x64
{B0AA8737-33A3-4766-8CBE-A48F2EF283BA}.Debug|Any CPU.Build.0 = Debug|x64
{B0AA8737-33A3-4766-8CBE-A48F2EF283BA}.Release|Any CPU.ActiveCfg = Release|x64
{B0AA8737-33A3-4766-8CBE-A48F2EF283BA}.Release|Any CPU.Build.0 = Release|x64
{5E6EDD75-AE95-43A6-9D67-95B840EB4B71}.Debug|Any CPU.ActiveCfg = Debug|x64
{5E6EDD75-AE95-43A6-9D67-95B840EB4B71}.Debug|Any CPU.Build.0 = Debug|x64
{5E6EDD75-AE95-43A6-9D67-95B840EB4B71}.Release|Any CPU.ActiveCfg = Release|x64
{5E6EDD75-AE95-43A6-9D67-95B840EB4B71}.Release|Any CPU.Build.0 = Release|x64
{9C70BD06-D52C-425E-9C14-5D66BC6046EF}.Debug|Any CPU.ActiveCfg = Debug|x64
{9C70BD06-D52C-425E-9C14-5D66BC6046EF}.Debug|Any CPU.Build.0 = Debug|x64
{9C70BD06-D52C-425E-9C14-5D66BC6046EF}.Release|Any CPU.ActiveCfg = Release|x64
{9C70BD06-D52C-425E-9C14-5D66BC6046EF}.Release|Any CPU.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -160,7 +174,9 @@ Global
{8BBACF2D-7AB8-4610-A115-0E363D35C291} = {E15BDA6D-E881-4482-94BA-BE5527E917FF}
{76CAA246-C405-4A8C-B0AE-F4A0EF3D4E16} = {DBE5345E-6594-4A59-B183-1C3D5592269D}
{F258347D-31BE-4605-98CE-40E43BDF6F9D} = {DBE5345E-6594-4A59-B183-1C3D5592269D}
{A0A3C0AC-18D9-4C74-8CFC-14E53512846D} = {DBE5345E-6594-4A59-B183-1C3D5592269D}
{B0AA8737-33A3-4766-8CBE-A48F2EF283BA} = {A217B3DF-607A-4EFB-B107-3C4809348043}
{5E6EDD75-AE95-43A6-9D67-95B840EB4B71} = {A217B3DF-607A-4EFB-B107-3C4809348043}
{9C70BD06-D52C-425E-9C14-5D66BC6046EF} = {A217B3DF-607A-4EFB-B107-3C4809348043}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {79B65AC9-C940-410E-AB61-7EA7E12C7599}

3
Dalamud/AssemblyInfo.cs Normal file
View file

@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;
//[assembly: DisableRuntimeMarshalling]

View file

@ -66,7 +66,7 @@
<PackageReference Include="Lumina" Version="$(LuminaVersion)" />
<PackageReference Include="Lumina.Excel" Version="$(LuminaExcelVersion)" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="9.0.0-preview.1.24081.5" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.46-beta">
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.183">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MinSharp" Version="1.0.4" />
@ -103,8 +103,10 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dalamud.Common\Dalamud.Common.csproj" />
<ProjectReference Include="..\imgui\Dalamud.ImGuizmo\Dalamud.ImGuizmo.csproj" />
<ProjectReference Include="..\imgui\Dalamud.ImGui\Dalamud.ImGui.csproj" />
<ProjectReference Include="..\imgui\Dalamud.ImPlot\Dalamud.ImPlot.csproj" />
<ProjectReference Include="..\lib\FFXIVClientStructs\FFXIVClientStructs\FFXIVClientStructs.csproj" />
<ProjectReference Include="..\lib\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj" />
<ProjectReference Include="..\lib\FFXIVClientStructs\InteropGenerator.Runtime\InteropGenerator.Runtime.csproj" />
</ItemGroup>

View file

@ -1,10 +1,14 @@
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;
using Dalamud.Common;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Internal.Windows;
@ -58,7 +62,7 @@ public sealed class EntryPoint
var info = JsonConvert.DeserializeObject<DalamudStartInfo>(infoStr)!;
if ((info.BootWaitMessageBox & 4) != 0)
MessageBoxW(IntPtr.Zero, "Press OK to continue (BeforeDalamudConstruct)", "Dalamud Boot", MessageBoxType.Ok);
Windows.Win32.PInvoke.MessageBox(HWND.Null, "Press OK to continue (BeforeDalamudConstruct)", "Dalamud Boot", MESSAGEBOX_STYLE.MB_OK);
new Thread(() => RunThread(info, mainThreadContinueEvent)).Start();
}
@ -135,6 +139,8 @@ public sealed class EntryPoint
/// <param name="mainThreadContinueEvent">Event used to signal the main thread to continue.</param>
private static void RunThread(DalamudStartInfo info, IntPtr mainThreadContinueEvent)
{
NativeLibrary.Load(Path.Combine(info.WorkingDirectory!, "cimgui.dll"));
// Setup logger
InitLogging(info.LogPath!, info.BootShowConsole, true, info.LogName);
SerilogEventSink.Instance.LogLine += SerilogOnLogLine;
@ -304,14 +310,14 @@ public sealed class EntryPoint
// ignored
}
const MessageBoxType flags = NativeFunctions.MessageBoxType.YesNo | NativeFunctions.MessageBoxType.IconError | NativeFunctions.MessageBoxType.SystemModal;
var result = MessageBoxW(
Process.GetCurrentProcess().MainWindowHandle,
const MESSAGEBOX_STYLE flags = MESSAGEBOX_STYLE.MB_YESNO | MESSAGEBOX_STYLE.MB_ICONERROR | MESSAGEBOX_STYLE.MB_SYSTEMMODAL;
var result = Windows.Win32.PInvoke.MessageBox(
new HWND(Process.GetCurrentProcess().MainWindowHandle),
$"An internal error in a Dalamud plugin occurred.\nThe game must close.\n\n{ex.GetType().Name}\n{info}\n\n{pluginInfo}More information has been recorded separately{supportText}.\n\nDo you want to disable all plugins the next time you start the game?",
"Dalamud",
flags);
if (result == (int)User32.MessageBoxResult.IDYES)
if (result == MESSAGEBOX_RESULT.IDYES)
{
Log.Information("User chose to disable plugins on next launch...");
var config = Service<DalamudConfiguration>.Get();

View file

@ -7,7 +7,7 @@ using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.System.Input;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Serilog;
namespace Dalamud.Game.ClientState.GamePad;

View file

@ -18,7 +18,7 @@ using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Common.Component.BGCollision;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Vector2 = System.Numerics.Vector2;
using Vector3 = System.Numerics.Vector3;

View file

@ -1,18 +1,23 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using Windows.Win32.System.Memory;
using Dalamud.Memory;
using JetBrains.Annotations;
using PInvoke;
using Win32Exception = System.ComponentModel.Win32Exception;
namespace Dalamud.Hooking.Internal;
/// <summary>
/// Manages a hook with MinHook.
/// </summary>
/// <typeparam name="T">Delegate type to represents a function prototype. This must be the same prototype as original function do.</typeparam>
internal class FunctionPointerVariableHook<T> : Hook<T>
internal unsafe class FunctionPointerVariableHook<T> : Hook<T>
where T : Delegate
{
private readonly nint pfnDetour;
@ -55,11 +60,11 @@ internal class FunctionPointerVariableHook<T> : Hook<T>
// Note: WINE seemingly tries to clean up all heap allocations on process exit.
// We want our allocation to be kept there forever, until no running thread remains.
// Therefore we're using VirtualAlloc instead of HeapCreate/HeapAlloc.
var pfnThunkBytes = (byte*)NativeFunctions.VirtualAlloc(
0,
var pfnThunkBytes = (byte*)Windows.Win32.PInvoke.VirtualAlloc(
null,
12,
NativeFunctions.AllocationType.Reserve | NativeFunctions.AllocationType.Commit,
MemoryProtection.ExecuteReadWrite);
VIRTUAL_ALLOCATION_TYPE.MEM_RESERVE | VIRTUAL_ALLOCATION_TYPE.MEM_COMMIT,
PAGE_PROTECTION_FLAGS.PAGE_EXECUTE_READWRITE);
if (pfnThunkBytes == null)
{
throw new OutOfMemoryException("Failed to allocate memory for import hooks.");
@ -78,10 +83,10 @@ internal class FunctionPointerVariableHook<T> : Hook<T>
this.ppfnThunkJumpTarget = this.pfnThunk + 2;
if (!NativeFunctions.VirtualProtect(
this.Address,
if (!Windows.Win32.PInvoke.VirtualProtect(
this.Address.ToPointer(),
(UIntPtr)Marshal.SizeOf<IntPtr>(),
MemoryProtection.ExecuteReadWrite,
PAGE_PROTECTION_FLAGS.PAGE_EXECUTE_READWRITE,
out var oldProtect))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
@ -93,7 +98,7 @@ internal class FunctionPointerVariableHook<T> : Hook<T>
Marshal.WriteIntPtr(this.Address, this.pfnThunk);
// This really should not fail, but then even if it does, whatever.
NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf<IntPtr>(), oldProtect, out _);
Windows.Win32.PInvoke.VirtualProtect(this.Address.ToPointer(), (UIntPtr)Marshal.SizeOf<IntPtr>(), oldProtect, out _);
// Add afterwards, so the hookIdent starts at 0.
indexList.Add(this);

View file

@ -3,7 +3,7 @@ using System.Numerics;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -2,7 +2,7 @@ using System.Numerics;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -2,7 +2,7 @@ using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Common.Math;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -3,7 +3,7 @@ using System.Numerics;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -4,7 +4,7 @@ using System.Numerics;
using Dalamud.Interface.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -1,4 +1,4 @@
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -1,6 +1,6 @@
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -1,6 +1,6 @@
using System.Numerics;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Components;

View file

@ -5,7 +5,7 @@ using Dalamud.Interface.Internal;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Serilog;
namespace Dalamud.Interface.DragDrop;
@ -103,7 +103,7 @@ internal partial class DragDropManager : IInternalDisposableService, IDragDropMa
}
/// <inheritdoc cref="IDragDropManager.CreateImGuiSource(string, Func{IDragDropManager, bool}, Func{IDragDropManager, bool})"/>
public void CreateImGuiSource(string label, Func<IDragDropManager, bool> validityCheck, Func<IDragDropManager, bool> tooltipBuilder)
public unsafe void CreateImGuiSource(string label, Func<IDragDropManager, bool> validityCheck, Func<IDragDropManager, bool> tooltipBuilder)
{
if (!this.IsDragging && !this.IsDropping())
{
@ -115,7 +115,7 @@ internal partial class DragDropManager : IInternalDisposableService, IDragDropMa
return;
}
ImGui.SetDragDropPayload(label, nint.Zero, 0);
ImGui.SetDragDropPayload(label, null, 0);
if (this.CheckTooltipFrame(out var frame) && tooltipBuilder(this))
{
this.lastTooltipFrame = frame;
@ -136,7 +136,7 @@ internal partial class DragDropManager : IInternalDisposableService, IDragDropMa
unsafe
{
if (ImGui.AcceptDragDropPayload(label, ImGuiDragDropFlags.AcceptBeforeDelivery).NativePtr != null && this.IsDropping())
if (ImGui.AcceptDragDropPayload(label, ImGuiDragDropFlags.AcceptBeforeDelivery).Handle != null && this.IsDropping())
{
this.lastDropFrame = -2;
files = this.Files;

View file

@ -5,7 +5,7 @@ using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Serilog;
namespace Dalamud.Interface.DragDrop;

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using Dalamud.Interface.ManagedFontAtlas;
using Dalamud.Storage.Assets;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;

View file

@ -2,7 +2,7 @@ using System.Collections.Generic;
using Dalamud.Interface.ManagedFontAtlas;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using Dalamud.Interface.GameFonts;
using Dalamud.Interface.ManagedFontAtlas;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;

View file

@ -1,6 +1,6 @@
using Dalamud.Interface.ManagedFontAtlas;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.FontIdentifier;

View file

@ -1,6 +1,6 @@
using Dalamud.Interface.ManagedFontAtlas;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.FontIdentifier;

View file

@ -6,7 +6,7 @@ using System.Text;
using Dalamud.Interface.ManagedFontAtlas;
using Dalamud.Interface.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;

View file

@ -5,7 +5,7 @@ using System.Linq;
using Dalamud.Interface.ManagedFontAtlas;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Numerics;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.GameFonts;

View file

@ -1,15 +1,19 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImGuizmo;
using Dalamud.Bindings.ImPlot;
using Dalamud.Interface.ImGuiBackend.Helpers;
using Dalamud.Interface.ImGuiBackend.InputHandler;
using Dalamud.Interface.ImGuiBackend.Renderers;
using Dalamud.Utility;
using ImGuiNET;
using ImGuizmoNET;
using ImPlotNET;
using Serilog;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@ -67,6 +71,58 @@ internal sealed unsafe class Dx11Win32Backend : IWin32Backend
this.WindowHandle = desc.OutputWindow;
var ctx = ImGui.CreateContext();
Debug.Assert(!ctx.IsNull);
var windowOff = Marshal.OffsetOf<ImGuiContext>("CurrentWindow");
//Debug.Assert(windowOff == 16368);
/*
void ShowOffset<T>(string name)
{
// var off = Marshal.OffsetOf<T>(name);
var fieldInfo = typeof(T).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
var off = fieldInfo?.GetFieldOffset();
Log.Information($"{name} {typeof(T).Name} {off}");
}
//Util.Fatal($"{Marshal.SizeOf<Test>()} - {sizeof(Test)}", "", false);
ShowOffset<ImGuiIO>("ClipboardUserData");
ShowOffset<ImGuiIO>("MouseDrawCursor");
ShowOffset<ImGuiIO>("MouseDelta");
ShowOffset<ImGuiIO>("KeysDown_0");
ShowOffset<ImGuiIO>("MousePos");
ShowOffset<ImGuiIO>("KeyMods");
*/
void ShowAllFields<T>()
{
var fields = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (var field in fields)
{
var off = field.GetFieldOffset();
Log.Information($"{field.Name} {typeof(T).Name} {off}");
}
}
ShowAllFields<ImGuiIO>();
var contextSize = Unsafe.SizeOf<ImGuiContext>();
var ioSize = Unsafe.SizeOf<ImGuiIO>();
var platformIoSize = Unsafe.SizeOf<ImGuiPlatformIO>();
//Debug.Assert(contextSize == 22688);
//Debug.Assert(ioSize == 14352);
//Debug.Assert(platformIoSize == 216);
//var platformIoOff = Unsafe.OffsetOf<ImGuiContext>("PlatformIO");
//Debug.Assert(platformIoOff == 14360);
Util.Fatal("bleh", "bleh", false);
ImGuizmo.SetImGuiContext(ctx);
ImPlot.SetImGuiContext(ctx);
ImPlot.CreateContext();
@ -234,8 +290,8 @@ internal sealed unsafe class Dx11Win32Backend : IWin32Backend
if (this.device.IsEmpty())
return;
this.imguiRenderer.Dispose();
this.imguiInput.Dispose();
this.imguiRenderer?.Dispose();
this.imguiInput?.Dispose();
ImGui.DestroyContext();
@ -245,3 +301,4 @@ internal sealed unsafe class Dx11Win32Backend : IWin32Backend
this.swapChainPossiblyWrapped.Dispose();
}
}

View file

@ -3,7 +3,7 @@ using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using TerraFX.Interop.Windows;

View file

@ -1,6 +1,6 @@
using System.Runtime.CompilerServices;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using TerraFX.Interop.Windows;
@ -75,16 +75,16 @@ internal sealed partial class Win32InputHandler
VK.VK_RMENU => ImGuiKey.RightAlt,
VK.VK_RWIN => ImGuiKey.RightSuper,
VK.VK_APPS => ImGuiKey.Menu,
'0' => ImGuiKey._0,
'1' => ImGuiKey._1,
'2' => ImGuiKey._2,
'3' => ImGuiKey._3,
'4' => ImGuiKey._4,
'5' => ImGuiKey._5,
'6' => ImGuiKey._6,
'7' => ImGuiKey._7,
'8' => ImGuiKey._8,
'9' => ImGuiKey._9,
'0' => ImGuiKey.Key0,
'1' => ImGuiKey.Key1,
'2' => ImGuiKey.Key2,
'3' => ImGuiKey.Key3,
'4' => ImGuiKey.Key4,
'5' => ImGuiKey.Key5,
'6' => ImGuiKey.Key6,
'7' => ImGuiKey.Key7,
'8' => ImGuiKey.Key8,
'9' => ImGuiKey.Key9,
'A' => ImGuiKey.A,
'B' => ImGuiKey.B,
'C' => ImGuiKey.C,
@ -190,16 +190,16 @@ internal sealed partial class Win32InputHandler
ImGuiKey.RightAlt => VK.VK_RMENU,
ImGuiKey.RightSuper => VK.VK_RWIN,
ImGuiKey.Menu => VK.VK_APPS,
ImGuiKey._0 => '0',
ImGuiKey._1 => '1',
ImGuiKey._2 => '2',
ImGuiKey._3 => '3',
ImGuiKey._4 => '4',
ImGuiKey._5 => '5',
ImGuiKey._6 => '6',
ImGuiKey._7 => '7',
ImGuiKey._8 => '8',
ImGuiKey._9 => '9',
ImGuiKey.Key0 => '0',
ImGuiKey.Key1 => '1',
ImGuiKey.Key2 => '2',
ImGuiKey.Key3 => '3',
ImGuiKey.Key4 => '4',
ImGuiKey.Key5 => '5',
ImGuiKey.Key6 => '6',
ImGuiKey.Key7 => '7',
ImGuiKey.Key8 => '8',
ImGuiKey.Key9 => '9',
ImGuiKey.A => 'A',
ImGuiKey.B => 'B',
ImGuiKey.C => 'C',
@ -274,14 +274,14 @@ internal sealed partial class Win32InputHandler
private static void UpAllKeys()
{
var io = ImGui.GetIO();
for (var i = (int)ImGuiKey.NamedKey_BEGIN; i < (int)ImGuiKey.NamedKey_END; i++)
for (var i = (int)ImGuiKey.NamedKeyBegin; i < (int)ImGuiKey.NamedKeyEnd; i++)
io.AddKeyEvent((ImGuiKey)i, false);
}
private static void UpAllMouseButton()
{
var io = ImGui.GetIO();
for (var i = 0; i < io.MouseDown.Count; i++)
for (var i = 0; i < io.MouseDown.Length; i++)
io.MouseDown[i] = false;
}

View file

@ -6,7 +6,9 @@ using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Serilog;
using TerraFX.Interop.Windows;
@ -51,7 +53,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
public Win32InputHandler(HWND hWnd)
{
var io = ImGui.GetIO();
if (ImGui.GetIO().NativePtr->BackendPlatformName is not null)
if (ImGui.GetIO().Handle->BackendPlatformName is not null)
throw new InvalidOperationException("ImGui backend platform seems to be have been already attached.");
this.hWnd = hWnd;
@ -66,7 +68,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
ImGuiBackendFlags.PlatformHasViewports;
this.platformNamePtr = Marshal.StringToHGlobalAnsi("imgui_impl_win32_c#");
io.NativePtr->BackendPlatformName = (byte*)this.platformNamePtr;
io.Handle->BackendPlatformName = (byte*)this.platformNamePtr;
var mainViewport = ImGui.GetMainViewport();
mainViewport.PlatformHandle = mainViewport.PlatformHandleRaw = hWnd;
@ -79,10 +81,10 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
this.cursors[(int)ImGuiMouseCursor.Arrow] = LoadCursorW(default, IDC.IDC_ARROW);
this.cursors[(int)ImGuiMouseCursor.TextInput] = LoadCursorW(default, IDC.IDC_IBEAM);
this.cursors[(int)ImGuiMouseCursor.ResizeAll] = LoadCursorW(default, IDC.IDC_SIZEALL);
this.cursors[(int)ImGuiMouseCursor.ResizeEW] = LoadCursorW(default, IDC.IDC_SIZEWE);
this.cursors[(int)ImGuiMouseCursor.ResizeNS] = LoadCursorW(default, IDC.IDC_SIZENS);
this.cursors[(int)ImGuiMouseCursor.ResizeNESW] = LoadCursorW(default, IDC.IDC_SIZENESW);
this.cursors[(int)ImGuiMouseCursor.ResizeNWSE] = LoadCursorW(default, IDC.IDC_SIZENWSE);
this.cursors[(int)ImGuiMouseCursor.ResizeEw] = LoadCursorW(default, IDC.IDC_SIZEWE);
this.cursors[(int)ImGuiMouseCursor.ResizeNs] = LoadCursorW(default, IDC.IDC_SIZENS);
this.cursors[(int)ImGuiMouseCursor.ResizeNesw] = LoadCursorW(default, IDC.IDC_SIZENESW);
this.cursors[(int)ImGuiMouseCursor.ResizeNwse] = LoadCursorW(default, IDC.IDC_SIZENWSE);
this.cursors[(int)ImGuiMouseCursor.Hand] = LoadCursorW(default, IDC.IDC_HAND);
this.cursors[(int)ImGuiMouseCursor.NotAllowed] = LoadCursorW(default, IDC.IDC_NO);
}
@ -136,7 +138,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
this.iniPathPtr = newAlloc;
}
ImGui.GetIO().NativePtr->IniFilename = (byte*)this.iniPathPtr;
ImGui.GetIO().Handle->IniFilename = (byte*)this.iniPathPtr;
}
}
@ -199,7 +201,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
// would become unresponsive
if (!io.WantCaptureMouse)
{
for (var i = 0; i < io.MouseDown.Count; i++)
for (var i = 0; i < io.MouseDown.Length; i++)
{
io.MouseDown[i] = false;
}
@ -216,7 +218,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
/// <returns>Return value, if not doing further processing.</returns>
public LRESULT? ProcessWndProcW(HWND hWndCurrent, uint msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui.GetCurrentContext() == nint.Zero)
if (ImGui.GetCurrentContext().IsNull)
return null;
var io = ImGui.GetIO();
@ -469,7 +471,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
// See: https://github.com/goatcorp/ImGuiScene/pull/13
// > GetForegroundWindow from winuser.h is a surprisingly expensive function.
var isForeground = GetForegroundWindow() == this.hWnd;
for (var i = (int)ImGuiKey.NamedKey_BEGIN; i < (int)ImGuiKey.NamedKey_END; i++)
for (var i = (int)ImGuiKey.NamedKeyBegin; i < (int)ImGuiKey.NamedKeyEnd; i++)
{
// Skip raising modifier keys if the game is focused.
// This allows us to raise the keys when one is held and the window becomes unfocused,
@ -495,11 +497,11 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
// The message wasn't handled, but it's a platform window
// So we have to handle some messages ourselves
// BUT we might have disposed the context, so check that
if (ImGui.GetCurrentContext() == nint.Zero)
if (ImGui.GetCurrentContext().IsNull)
return DefWindowProcW(hWndCurrent, msg, wParam, lParam);
var viewport = ImGui.FindViewportByPlatformHandle(hWndCurrent);
if (viewport.NativePtr == null)
if (viewport.Handle == null)
return DefWindowProcW(hWndCurrent, msg, wParam, lParam);
switch (msg)
@ -556,14 +558,14 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
this.cursors.AsSpan().Clear();
if (ImGui.GetIO().NativePtr->BackendPlatformName == (void*)this.platformNamePtr)
ImGui.GetIO().NativePtr->BackendPlatformName = null;
if (ImGui.GetIO().Handle->BackendPlatformName == (void*)this.platformNamePtr)
ImGui.GetIO().Handle->BackendPlatformName = null;
if (this.platformNamePtr != nint.Zero)
Marshal.FreeHGlobal(this.platformNamePtr);
if (this.iniPathPtr != nint.Zero)
{
ImGui.GetIO().NativePtr->IniFilename = null;
ImGui.GetIO().Handle->IniFilename = null;
Marshal.FreeHGlobal(this.iniPathPtr);
this.iniPathPtr = nint.Zero;
}
@ -587,20 +589,20 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
this.classNamePtr = Marshal.StringToHGlobalUni("ImGui Platform");
var pio = ImGui.GetPlatformIO();
pio.Platform_CreateWindow = this.RegisterFunctionPointer<CreateWindowDelegate>(this.OnCreateWindow);
pio.Platform_DestroyWindow = this.RegisterFunctionPointer<DestroyWindowDelegate>(this.OnDestroyWindow);
pio.Platform_ShowWindow = this.RegisterFunctionPointer<ShowWindowDelegate>(this.OnShowWindow);
pio.Platform_SetWindowPos = this.RegisterFunctionPointer<SetWindowPosDelegate>(this.OnSetWindowPos);
pio.Platform_GetWindowPos = this.RegisterFunctionPointer<GetWindowPosDelegate>(this.OnGetWindowPos);
pio.Platform_SetWindowSize = this.RegisterFunctionPointer<SetWindowSizeDelegate>(this.OnSetWindowSize);
pio.Platform_GetWindowSize = this.RegisterFunctionPointer<GetWindowSizeDelegate>(this.OnGetWindowSize);
pio.Platform_SetWindowFocus = this.RegisterFunctionPointer<SetWindowFocusDelegate>(this.OnSetWindowFocus);
pio.Platform_GetWindowFocus = this.RegisterFunctionPointer<GetWindowFocusDelegate>(this.OnGetWindowFocus);
pio.Platform_GetWindowMinimized =
pio.PlatformCreateWindow = this.RegisterFunctionPointer<CreateWindowDelegate>(this.OnCreateWindow);
pio.PlatformDestroyWindow = this.RegisterFunctionPointer<DestroyWindowDelegate>(this.OnDestroyWindow);
pio.PlatformShowWindow = this.RegisterFunctionPointer<ShowWindowDelegate>(this.OnShowWindow);
pio.PlatformSetWindowPos = this.RegisterFunctionPointer<SetWindowPosDelegate>(this.OnSetWindowPos);
pio.PlatformGetWindowPos = this.RegisterFunctionPointer<GetWindowPosDelegate>(this.OnGetWindowPos);
pio.PlatformSetWindowSize = this.RegisterFunctionPointer<SetWindowSizeDelegate>(this.OnSetWindowSize);
pio.PlatformGetWindowSize = this.RegisterFunctionPointer<GetWindowSizeDelegate>(this.OnGetWindowSize);
pio.PlatformSetWindowFocus = this.RegisterFunctionPointer<SetWindowFocusDelegate>(this.OnSetWindowFocus);
pio.PlatformGetWindowFocus = this.RegisterFunctionPointer<GetWindowFocusDelegate>(this.OnGetWindowFocus);
pio.PlatformGetWindowMinimized =
this.RegisterFunctionPointer<GetWindowMinimizedDelegate>(this.OnGetWindowMinimized);
pio.Platform_SetWindowTitle = this.RegisterFunctionPointer<SetWindowTitleDelegate>(this.OnSetWindowTitle);
pio.Platform_SetWindowAlpha = this.RegisterFunctionPointer<SetWindowAlphaDelegate>(this.OnSetWindowAlpha);
pio.Platform_UpdateWindow = this.RegisterFunctionPointer<UpdateWindowDelegate>(this.OnUpdateWindow);
pio.PlatformSetWindowTitle = this.RegisterFunctionPointer<SetWindowTitleDelegate>(this.OnSetWindowTitle);
pio.PlatformSetWindowAlpha = this.RegisterFunctionPointer<SetWindowAlphaDelegate>(this.OnSetWindowAlpha);
pio.PlatformUpdateWindow = this.RegisterFunctionPointer<UpdateWindowDelegate>(this.OnUpdateWindow);
// pio.Platform_SetImeInputPos = this.RegisterFunctionPointer<SetImeInputPosDelegate>(this.OnSetImeInputPos);
// pio.Platform_GetWindowDpiScale = this.RegisterFunctionPointer<GetWindowDpiScaleDelegate>(this.OnGetWindowDpiScale);
// pio.Platform_ChangedViewport = this.RegisterFunctionPointer<ChangedViewportDelegate>(this.OnChangedViewport);
@ -624,7 +626,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
var mainViewport = ImGui.GetMainViewport();
var data = (ImGuiViewportDataWin32*)Marshal.AllocHGlobal(Marshal.SizeOf<ImGuiViewportDataWin32>());
mainViewport.PlatformUserData = (nint)data;
mainViewport.PlatformUserData = data;
data->Hwnd = this.input.hWnd;
data->HwndOwned = false;
mainViewport.PlatformHandle = this.input.hWnd;
@ -637,12 +639,12 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
var pio = ImGui.GetPlatformIO();
if (ImGui.GetPlatformIO().NativePtr->Monitors.Data != 0)
if (ImGui.GetPlatformIO().Handle->Monitors.Data != null)
{
// We allocated the platform monitor data in OnUpdateMonitors ourselves,
// so we have to free it ourselves to ImGui doesn't try to, or else it will crash
Marshal.FreeHGlobal(ImGui.GetPlatformIO().NativePtr->Monitors.Data);
ImGui.GetPlatformIO().NativePtr->Monitors = default;
Marshal.FreeHGlobal(new IntPtr(ImGui.GetPlatformIO().Handle->Monitors.Data));
ImGui.GetPlatformIO().Handle->Monitors = default;
}
if (this.classNamePtr != 0)
@ -652,19 +654,19 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
this.classNamePtr = 0;
}
pio.Platform_CreateWindow = nint.Zero;
pio.Platform_DestroyWindow = nint.Zero;
pio.Platform_ShowWindow = nint.Zero;
pio.Platform_SetWindowPos = nint.Zero;
pio.Platform_GetWindowPos = nint.Zero;
pio.Platform_SetWindowSize = nint.Zero;
pio.Platform_GetWindowSize = nint.Zero;
pio.Platform_SetWindowFocus = nint.Zero;
pio.Platform_GetWindowFocus = nint.Zero;
pio.Platform_GetWindowMinimized = nint.Zero;
pio.Platform_SetWindowTitle = nint.Zero;
pio.Platform_SetWindowAlpha = nint.Zero;
pio.Platform_UpdateWindow = nint.Zero;
pio.PlatformCreateWindow = null;
pio.PlatformDestroyWindow = null;
pio.PlatformShowWindow = null;
pio.PlatformSetWindowPos = null;
pio.PlatformGetWindowPos = null;
pio.PlatformSetWindowSize = null;
pio.PlatformGetWindowSize = null;
pio.PlatformSetWindowFocus = null;
pio.PlatformGetWindowFocus = null;
pio.PlatformGetWindowMinimized = null;
pio.PlatformSetWindowTitle = null;
pio.PlatformSetWindowAlpha = null;
pio.PlatformUpdateWindow = null;
// pio.Platform_SetImeInputPos = nint.Zero;
// pio.Platform_GetWindowDpiScale = nint.Zero;
// pio.Platform_ChangedViewport = nint.Zero;
@ -685,15 +687,15 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
var pio = ImGui.GetPlatformIO();
var numMonitors = GetSystemMetrics(SM.SM_CMONITORS);
var data = Marshal.AllocHGlobal(Marshal.SizeOf<ImGuiPlatformMonitor>() * numMonitors);
if (pio.NativePtr->Monitors.Data != 0)
Marshal.FreeHGlobal(pio.NativePtr->Monitors.Data);
pio.NativePtr->Monitors = new(numMonitors, numMonitors, data);
if (pio.Handle->Monitors.Data != null)
Marshal.FreeHGlobal(new IntPtr(pio.Handle->Monitors.Data));
pio.Handle->Monitors = new(numMonitors, numMonitors, (ImGuiPlatformMonitor*)data.ToPointer());
// ImGuiPlatformIOPtr platformIO = ImGui.GetPlatformIO();
// Marshal.FreeHGlobal(platformIO.NativePtr->Monitors.Data);
// Marshal.FreeHGlobal(platformIO.Handle->Monitors.Data);
// int numMonitors = GetSystemMetrics(SystemMetric.SM_CMONITORS);
// nint data = Marshal.AllocHGlobal(Marshal.SizeOf<ImGuiPlatformMonitor>() * numMonitors);
// platformIO.NativePtr->Monitors = new ImVector(numMonitors, numMonitors, data);
// platformIO.Handle->Monitors = new ImVector(numMonitors, numMonitors, data);
var monitorIndex = -1;
var enumfn = new MonitorEnumProcDelegate(
@ -710,7 +712,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
var workRb = new Vector2(info.rcWork.right, info.rcWork.bottom);
// Give ImGui the info for this display
var imMonitor = ImGui.GetPlatformIO().Monitors[monitorIndex];
ref var imMonitor = ref ImGui.GetPlatformIO().Monitors.Ref(monitorIndex);
imMonitor.MainPos = monitorLt;
imMonitor.MainSize = monitorRb - monitorLt;
imMonitor.WorkPos = workLt;
@ -723,18 +725,31 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
null,
(delegate* unmanaged<HMONITOR, HDC, RECT*, LPARAM, BOOL>)Marshal.GetFunctionPointerForDelegate(enumfn),
default);
Log.Information("Monitors set up!");
for (var i = 0; i < numMonitors; i++)
{
var monitor = pio.Handle->Monitors[i];
Log.Information(
"Monitor {Index}: {MainPos} {MainSize} {WorkPos} {WorkSize}",
i,
monitor.MainPos,
monitor.MainSize,
monitor.WorkPos,
monitor.WorkSize);
}
}
private nint RegisterFunctionPointer<T>(T obj)
private void* RegisterFunctionPointer<T>(T obj)
{
this.delegateReferences.Add(obj);
return Marshal.GetFunctionPointerForDelegate(obj);
return Marshal.GetFunctionPointerForDelegate(obj).ToPointer();
}
private void OnCreateWindow(ImGuiViewportPtr viewport)
{
var data = (ImGuiViewportDataWin32*)Marshal.AllocHGlobal(Marshal.SizeOf<ImGuiViewportDataWin32>());
viewport.PlatformUserData = (nint)data;
viewport.PlatformUserData = data;
viewport.Flags =
ImGuiViewportFlags.NoTaskBarIcon |
ImGuiViewportFlags.NoFocusOnClick |
@ -784,7 +799,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
private void OnDestroyWindow(ImGuiViewportPtr viewport)
{
// This is also called on the main viewport for some reason, and we never set that viewport's PlatformUserData
if (viewport.PlatformUserData == nint.Zero) return;
if (viewport.PlatformUserData == null) return;
var data = (ImGuiViewportDataWin32*)viewport.PlatformUserData;
@ -807,8 +822,8 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
}
data->Hwnd = default;
Marshal.FreeHGlobal(viewport.PlatformUserData);
viewport.PlatformUserData = viewport.PlatformHandle = nint.Zero;
Marshal.FreeHGlobal(new IntPtr(viewport.PlatformUserData));
viewport.PlatformUserData = viewport.PlatformHandle = null;
}
private void OnShowWindow(ImGuiViewportPtr viewport)

View file

@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using Dalamud.Interface.ImGuiBackend.Helpers;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@ -36,11 +36,11 @@ internal unsafe partial class Dx11Renderer
this.renderer = renderer;
var pio = ImGui.GetPlatformIO();
pio.Renderer_CreateWindow = Marshal.GetFunctionPointerForDelegate(this.cwd = this.OnCreateWindow);
pio.Renderer_DestroyWindow = (nint)(delegate* unmanaged<ImGuiViewportPtr, void>)&OnDestroyWindow;
pio.Renderer_SetWindowSize = (nint)(delegate* unmanaged<ImGuiViewportPtr, Vector2, void>)&OnSetWindowSize;
pio.Renderer_RenderWindow = (nint)(delegate* unmanaged<ImGuiViewportPtr, nint, void>)&OnRenderWindow;
pio.Renderer_SwapBuffers = (nint)(delegate* unmanaged<ImGuiViewportPtr, nint, void>)&OnSwapBuffers;
pio.RendererCreateWindow = Marshal.GetFunctionPointerForDelegate(this.cwd = this.OnCreateWindow).ToPointer();
pio.RendererDestroyWindow = (delegate* unmanaged<ImGuiViewportPtr, void>)&OnDestroyWindow;
pio.RendererSetWindowSize = (delegate* unmanaged<ImGuiViewportPtr, Vector2, void>)&OnSetWindowSize;
pio.RendererRenderWindow = (delegate* unmanaged<ImGuiViewportPtr, nint, void>)&OnRenderWindow;
pio.RendererSwapBuffers = (delegate* unmanaged<ImGuiViewportPtr, nint, void>)&OnSwapBuffers;
}
~ViewportHandler() => ReleaseUnmanagedResources();
@ -54,20 +54,20 @@ internal unsafe partial class Dx11Renderer
private static void ReleaseUnmanagedResources()
{
var pio = ImGui.GetPlatformIO();
pio.Renderer_CreateWindow = nint.Zero;
pio.Renderer_DestroyWindow = nint.Zero;
pio.Renderer_SetWindowSize = nint.Zero;
pio.Renderer_RenderWindow = nint.Zero;
pio.Renderer_SwapBuffers = nint.Zero;
pio.RendererCreateWindow = null;
pio.RendererDestroyWindow = null;
pio.RendererSetWindowSize = null;
pio.RendererRenderWindow = null;
pio.RendererSwapBuffers = null;
}
[UnmanagedCallersOnly]
private static void OnDestroyWindow(ImGuiViewportPtr viewport)
{
if (viewport.RendererUserData == nint.Zero)
if (viewport.RendererUserData == null)
return;
ViewportData.Attach(viewport.RendererUserData).Dispose();
viewport.RendererUserData = nint.Zero;
viewport.RendererUserData = null;
}
[UnmanagedCallersOnly]
@ -87,7 +87,7 @@ internal unsafe partial class Dx11Renderer
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
// Some backend will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND.
var hWnd = viewport.PlatformHandleRaw;
if (hWnd == 0)
if (hWnd == null)
hWnd = viewport.PlatformHandle;
try
{
@ -135,12 +135,12 @@ internal unsafe partial class Dx11Renderer
public IDXGISwapChain* SwapChain => this.swapChain;
public nint Handle => GCHandle.ToIntPtr(this.selfGcHandle);
public void* Handle => GCHandle.ToIntPtr(this.selfGcHandle).ToPointer();
private DXGI_FORMAT RtvFormat => this.parent.rtvFormat;
public static ViewportData Attach(nint handle) =>
(ViewportData)GCHandle.FromIntPtr(handle).Target ?? throw new InvalidOperationException();
public static ViewportData Attach(void* handle) =>
(ViewportData)GCHandle.FromIntPtr(new IntPtr(handle)).Target ?? throw new InvalidOperationException();
public static ViewportData Create(
Dx11Renderer renderer,

View file

@ -15,7 +15,7 @@ using Dalamud.Interface.Textures.TextureWraps.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@ -67,7 +67,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
public Dx11Renderer(IDXGISwapChain* swapChain, ID3D11Device* device, ID3D11DeviceContext* context)
{
var io = ImGui.GetIO();
if (ImGui.GetIO().NativePtr->BackendRendererName is not null)
if (ImGui.GetIO().Handle->BackendRendererName is not null)
throw new InvalidOperationException("ImGui backend renderer seems to be have been already attached.");
try
{
@ -81,7 +81,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
io.BackendFlags |= ImGuiBackendFlags.RendererHasVtxOffset | ImGuiBackendFlags.RendererHasViewports;
this.renderNamePtr = Marshal.StringToHGlobalAnsi("imgui_impl_dx11_c#");
io.NativePtr->BackendRendererName = (byte*)this.renderNamePtr;
io.Handle->BackendRendererName = (byte*)this.renderNamePtr;
if (io.ConfigFlags.HasFlag(ImGuiConfigFlags.ViewportsEnable))
{
@ -102,7 +102,8 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
}
this.mainViewport = ViewportData.Create(this, swapChain, null, null);
ImGui.GetPlatformIO().Viewports[0].RendererUserData = this.mainViewport.Handle;
var vp = ImGui.GetPlatformIO().Viewports[0];
vp.RendererUserData = this.mainViewport.Handle;
}
catch
{
@ -243,7 +244,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
if (!drawData.Valid || drawData.CmdListsCount == 0)
return;
var cmdLists = new Span<ImDrawListPtr>(drawData.NativePtr->CmdLists, drawData.NativePtr->CmdListsCount);
var cmdLists = new Span<ImDrawListPtr>(drawData.Handle->CmdLists, drawData.Handle->CmdListsCount);
// Create and grow vertex/index buffers if needed
if (this.vertexBufferSize < drawData.TotalVtxCount)
@ -298,8 +299,8 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
var targetIndices = new Span<ushort>(indexData.pData, this.indexBufferSize);
foreach (ref var cmdList in cmdLists)
{
var vertices = new ImVectorWrapper<ImDrawVert>(&cmdList.NativePtr->VtxBuffer);
var indices = new ImVectorWrapper<ushort>(&cmdList.NativePtr->IdxBuffer);
var vertices = new ImVectorWrapper<ImDrawVert>(cmdList.Handle->VtxBuffer.ToUntyped());
var indices = new ImVectorWrapper<ushort>(cmdList.Handle->IdxBuffer.ToUntyped());
vertices.DataSpan.CopyTo(targetVertices);
indices.DataSpan.CopyTo(targetIndices);
@ -346,7 +347,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
var clipOff = new Vector4(drawData.DisplayPos, drawData.DisplayPos.X, drawData.DisplayPos.Y);
foreach (ref var cmdList in cmdLists)
{
var cmds = new ImVectorWrapper<ImDrawCmd>(&cmdList.NativePtr->CmdBuffer);
var cmds = new ImVectorWrapper<ImDrawCmd>(cmdList.Handle->CmdBuffer.ToUntyped());
foreach (ref var cmd in cmds.DataSpan)
{
var clipV4 = cmd.ClipRect - clipOff;
@ -358,10 +359,10 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
this.context.Get()->RSSetScissorRects(1, &clipRect);
if (cmd.UserCallback == nint.Zero)
if (cmd.UserCallback != null)
{
// Bind texture and draw
var srv = (ID3D11ShaderResourceView*)cmd.TextureId;
var srv = (ID3D11ShaderResourceView*)cmd.TextureId.Handle;
this.context.Get()->PSSetShader(this.pixelShader, null, 0);
this.context.Get()->PSSetSamplers(0, 1, this.sampler.GetAddressOf());
this.context.Get()->PSSetShaderResources(0, 1, &srv);
@ -397,13 +398,16 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
textureIndex < textureCount;
textureIndex++)
{
int width = 0, height = 0, bytespp = 0;
byte* fontPixels = null;
// Build texture atlas
io.Fonts.GetTexDataAsRGBA32(
textureIndex,
out byte* fontPixels,
out var width,
out var height,
out var bytespp);
&fontPixels,
ref width,
ref height,
ref bytespp);
var tex = this.CreateTexture2D(
new(fontPixels, width * height * bytespp),
@ -630,14 +634,15 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
this.releaseUnmanagedResourceCalled = true;
this.mainViewport.Dispose();
ImGui.GetPlatformIO().Viewports[0].RendererUserData = nint.Zero;
var vp = ImGui.GetPlatformIO().Viewports[0];
vp.RendererUserData = null;
ImGui.DestroyPlatformWindows();
this.viewportHandler.Dispose();
var io = ImGui.GetIO();
if (io.NativePtr->BackendRendererName == (void*)this.renderNamePtr)
io.NativePtr->BackendRendererName = null;
if (io.Handle->BackendRendererName == (void*)this.renderNamePtr)
io.Handle->BackendRendererName = null;
if (this.renderNamePtr != 0)
Marshal.FreeHGlobal(this.renderNamePtr);
@ -645,7 +650,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
fontResourceView.Dispose();
foreach (var i in Enumerable.Range(0, io.Fonts.Textures.Size))
io.Fonts.SetTexID(i, nint.Zero);
io.Fonts.SetTexID(i, ImTextureID.Null);
this.device.Reset();
this.context.Reset();

View file

@ -3,7 +3,7 @@
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.ImGuiBackend.Renderers;

View file

@ -5,7 +5,7 @@ using System.Numerics;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.ImGuiFileDialog;
@ -397,7 +397,7 @@ public partial class FileDialog
ImGuiListClipperPtr clipper;
unsafe
{
clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
lock (this.filesLock)

View file

@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.ImGuiFileDialog;

View file

@ -1,6 +1,6 @@
using System.Collections.Generic;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.ImGuiFileDialog;

View file

@ -5,6 +5,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Interface.FontIdentifier;
@ -12,9 +13,6 @@ using Dalamud.Interface.ManagedFontAtlas;
using Dalamud.Interface.ManagedFontAtlas.Internals;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@ -432,7 +430,7 @@ public sealed class SingleFontChooserDialog : IDisposable
this.firstDrawAfterRefresh = false;
}
private static float GetDistanceFromMonitor(Vector2 point, ImGuiPlatformMonitorPtr monitor)
private static float GetDistanceFromMonitor(Vector2 point, ImGuiPlatformMonitor monitor)
{
var lt = monitor.MainPos;
var rb = monitor.MainPos + monitor.MainSize;
@ -565,7 +563,7 @@ public sealed class SingleFontChooserDialog : IDisposable
fixed (byte* buf = this.fontPreviewText)
fixed (byte* label = "##fontPreviewText"u8)
{
ImGuiNative.igInputTextMultiline(
ImGui.InputTextMultiline(
label,
buf,
(uint)this.fontPreviewText.Length,
@ -691,7 +689,7 @@ public sealed class SingleFontChooserDialog : IDisposable
if (ImGui.BeginChild("##familyList", ImGui.GetContentRegionAvail()))
{
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
var lineHeight = ImGui.GetTextLineHeightWithSpacing();
if ((changed || this.firstDrawAfterRefresh) && this.selectedFamilyIndex != -1)
@ -858,7 +856,7 @@ public sealed class SingleFontChooserDialog : IDisposable
if (ImGui.BeginChild("##fontList"))
{
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
var lineHeight = ImGui.GetTextLineHeightWithSpacing();
if ((changed || this.firstDrawAfterRefresh) && this.selectedFontIndex != -1)
@ -962,7 +960,7 @@ public sealed class SingleFontChooserDialog : IDisposable
if (ImGui.BeginChild("##fontSizeList"))
{
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
var lineHeight = ImGui.GetTextLineHeightWithSpacing();
if (changed && this.selectedFontIndex != -1)

View file

@ -5,7 +5,7 @@ using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.ImGuiNotification.Internal;
@ -88,7 +88,11 @@ internal sealed partial class ActiveNotification
if (!isTakingKeyboardInput && !isHovered && isFocused)
{
ImGui.SetWindowFocus(null);
unsafe
{
ImGui.SetWindowFocus((byte*)null);
}
isFocused = false;
}
@ -529,9 +533,9 @@ internal sealed partial class ActiveNotification
verts[vertPtr++] = lastOff;
unsafe
{
var dlist = ImGui.GetWindowDrawList().NativePtr;
var dlist = ImGui.GetWindowDrawList().Handle;
fixed (Vector2* pvert = verts)
ImGuiNative.ImDrawList_AddConvexPolyFilled(dlist, pvert, vertPtr, color);
dlist->AddConvexPolyFilled(pvert, vertPtr, color);
}
}

View file

@ -11,7 +11,7 @@ using Dalamud.IoC.Internal;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Plugin.Services;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.ImGuiNotification.Internal;

View file

@ -13,7 +13,7 @@ using Dalamud.Interface.Utility;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Storage.Assets;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.ImGuiNotification;
@ -56,7 +56,7 @@ public static class NotificationUtilities
using (fontHandle.Push())
{
var font = ImGui.GetFont();
var glyphPtr = (ImGuiHelpers.ImFontGlyphReal*)font.FindGlyphNoFallback(c).NativePtr;
var glyphPtr = (ImGuiHelpers.ImFontGlyphReal*)font.FindGlyphNoFallback(c);
if (glyphPtr is null)
return false;

View file

@ -15,7 +15,7 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Client.UI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Lumina.Excel.Sheets;
using Lumina.Text;
@ -58,7 +58,7 @@ internal unsafe class SeStringRenderer : IInternalDisposableService
private readonly SeStringColorStackSet colorStackSet;
/// <summary>Splits a draw list so that different layers of a single glyph can be drawn out of order.</summary>
private ImDrawListSplitter* splitter = ImGuiNative.ImDrawListSplitter_ImDrawListSplitter();
private ImDrawListSplitter* splitter = ImGui.ImDrawListSplitter();
[ServiceManager.ServiceConstructor]
private SeStringRenderer(DataManager dm, TargetSigScanner sigScanner)
@ -146,15 +146,25 @@ internal unsafe class SeStringRenderer : IInternalDisposableService
size = Vector2.Max(size, fragment.Offset + new Vector2(fragment.VisibleWidth, state.LineHeight));
// If we're not drawing at all, stop further processing.
if (state.DrawList.NativePtr is null)
if (state.DrawList.Handle is null)
return new() { Size = size };
state.SplitDrawList();
// Handle cases where ImGui.AlignTextToFramePadding has been called.
var pCurrentWindow = *(nint*)(ImGui.GetCurrentContext() + ImGuiContextCurrentWindowOffset);
var pWindowDc = pCurrentWindow + ImGuiWindowDcOffset;
var currLineTextBaseOffset = *(float*)(pWindowDc + ImGuiWindowTempDataCurrLineTextBaseOffset);
var context = ImGui.GetCurrentContext();
var currLineTextBaseOffset = 0f;
/*
if (!context.IsNull)
{
var currentWindow = context.CurrentWindow;
if (!currentWindow.IsNull)
{
currLineTextBaseOffset = currentWindow.DC.CurrLineTextBaseOffset;
}
}
*/
var itemSize = size;
if (currLineTextBaseOffset != 0f)
{
@ -280,7 +290,7 @@ internal unsafe class SeStringRenderer : IInternalDisposableService
{
if (this.splitter is not null)
{
ImGuiNative.ImDrawListSplitter_destroy(this.splitter);
this.splitter->Destroy();
this.splitter = null;
}
}
@ -487,7 +497,7 @@ internal unsafe class SeStringRenderer : IInternalDisposableService
if (gfdTextureSrv != 0)
{
state.Draw(
gfdTextureSrv,
new ImTextureID(gfdTextureSrv),
offset + new Vector2(x, MathF.Round((state.LineHeight - size.Y) / 2)),
size,
useHq ? gfdEntry.HqUv0 : gfdEntry.Uv0,

View file

@ -1,6 +1,6 @@
using System.Numerics;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Lumina.Text.Payloads;
@ -105,8 +105,8 @@ public record struct SeStringDrawParams
/// <summary>Gets the effective font.</summary>
internal readonly unsafe ImFont* EffectiveFont =>
(this.Font ?? ImGui.GetFont()) is var f && f.NativePtr is not null
? f.NativePtr
(this.Font ?? ImGui.GetFont()) is var f && f.Handle is not null
? f.Handle
: throw new ArgumentException("Specified font is empty.");
/// <summary>Gets the effective line height in pixels.</summary>

View file

@ -8,7 +8,7 @@ using Dalamud.Interface.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Lumina.Text.Payloads;
using Lumina.Text.ReadOnly;
@ -150,7 +150,7 @@ public unsafe ref struct SeStringDrawState
/// <param name="channelIndex">Channel to switch to.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void SetCurrentChannel(SeStringDrawChannel channelIndex) =>
ImGuiNative.ImDrawListSplitter_SetCurrentChannel(this.splitter, this.drawList, (int)channelIndex);
this.splitter->SetCurrentChannel(this.drawList, (int)channelIndex);
/// <summary>Draws a single texture.</summary>
/// <param name="igTextureId">ImGui texture ID to draw from.</param>
@ -160,7 +160,7 @@ public unsafe ref struct SeStringDrawState
/// <param name="uv1">Right bottom corner of the glyph w.r.t. its glyph origin in the source texture.</param>
/// <param name="color">Color of the glyph in RGBA.</param>
public readonly void Draw(
nint igTextureId,
ImTextureID igTextureId,
Vector2 offset,
Vector2 size,
Vector2 uv0,
@ -193,7 +193,7 @@ public unsafe ref struct SeStringDrawState
/// top and bottom pixels to apply faux italicization by <see cref="Vector2.X"/> and <see cref="Vector2.Y"/>
/// respectively.</param>
public readonly void Draw(
nint igTextureId,
ImTextureID igTextureId,
Vector2 offset,
Vector2 xy0,
Vector2 xy1,
@ -305,7 +305,7 @@ public unsafe ref struct SeStringDrawState
internal readonly ref ImGuiHelpers.ImFontGlyphReal FindGlyph(Rune rune)
{
var p = rune.Value is >= ushort.MinValue and < ushort.MaxValue
? ImGuiNative.ImFont_FindGlyph(this.Font, (ushort)rune.Value)
? this.Font->FindGlyph((ushort)rune.Value)
: this.Font->FallbackGlyph;
return ref *(ImGuiHelpers.ImFontGlyphReal*)p;
}
@ -340,8 +340,7 @@ public unsafe ref struct SeStringDrawState
return 0;
return MathF.Round(
ImGuiNative.ImFont_GetDistanceAdjustmentForPair(
this.Font,
this.Font->GetDistanceAdjustmentForPair(
(ushort)left.Value,
(ushort)right.Value) * this.FontSizeScale);
}
@ -398,9 +397,9 @@ public unsafe ref struct SeStringDrawState
/// <summary>Splits the draw list.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal readonly void SplitDrawList() =>
ImGuiNative.ImDrawListSplitter_Split(this.splitter, this.drawList, ChannelCount);
this.splitter->Split(this.drawList, ChannelCount);
/// <summary>Merges the draw list.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal readonly void MergeDrawList() => ImGuiNative.ImDrawListSplitter_Merge(this.splitter, this.drawList);
internal readonly void MergeDrawList() => this.splitter->Merge(this.drawList);
}

View file

@ -140,12 +140,6 @@ internal class DalamudCommands : IServiceType
"Open Dalamud's startup timing profiler."),
});
commandManager.AddHandler("/imdebug", new CommandInfo(this.OnDebugImInfoCommand)
{
HelpMessage = "ImGui DEBUG",
ShowInHelp = false,
});
commandManager.AddHandler("/xlcopylog", new CommandInfo(this.OnCopyLogCommand)
{
HelpMessage = Loc.Localize(
@ -300,29 +294,6 @@ internal class DalamudCommands : IServiceType
Service<DalamudInterface>.Get().ToggleLogWindow();
}
private void OnDebugImInfoCommand(string command, string arguments)
{
var io = Service<InterfaceManager>.Get().LastImGuiIoPtr;
var info = $"WantCaptureKeyboard: {io.WantCaptureKeyboard}\n";
info += $"WantCaptureMouse: {io.WantCaptureMouse}\n";
info += $"WantSetMousePos: {io.WantSetMousePos}\n";
info += $"WantTextInput: {io.WantTextInput}\n";
info += $"WantSaveIniSettings: {io.WantSaveIniSettings}\n";
info += $"BackendFlags: {(int)io.BackendFlags}\n";
info += $"DeltaTime: {io.DeltaTime}\n";
info += $"DisplaySize: {io.DisplaySize.X} {io.DisplaySize.Y}\n";
info += $"Framerate: {io.Framerate}\n";
info += $"MetricsActiveWindows: {io.MetricsActiveWindows}\n";
info += $"MetricsRenderWindows: {io.MetricsRenderWindows}\n";
info += $"MousePos: {io.MousePos.X} {io.MousePos.Y}\n";
info += $"MouseClicked: {io.MouseClicked}\n";
info += $"MouseDown: {io.MouseDown}\n";
info += $"NavActive: {io.NavActive}\n";
info += $"NavVisible: {io.NavVisible}\n";
Log.Information(info);
}
private void OnVersionInfoCommand(string command, string arguments)
{
var chatGui = Service<ChatGui>.Get();

View file

@ -19,7 +19,7 @@ using Dalamud.Interface.GameFonts;
using Dalamud.Interface.ManagedFontAtlas.Internals;
using Dalamud.Interface.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
#if IMEDEBUG
using Serilog;
@ -136,7 +136,8 @@ internal sealed unsafe class DalamudIme : IInternalDisposableService
this.interfaceManager = imws.Manager;
this.setPlatformImeDataDelegate = this.ImGuiSetPlatformImeData;
ImGui.GetIO().SetPlatformImeDataFn = Marshal.GetFunctionPointerForDelegate(this.setPlatformImeDataDelegate);
var io = ImGui.GetIO();
io.SetPlatformImeDataFn = Marshal.GetFunctionPointerForDelegate(this.setPlatformImeDataDelegate).ToPointer();
this.interfaceManager.Draw += this.Draw;
this.wndProcHookManager.PreWndProc += this.WndProcHookManagerOnPreWndProc;
}
@ -278,7 +279,10 @@ internal sealed unsafe class DalamudIme : IInternalDisposableService
private void ReleaseUnmanagedResources()
{
if (ImGuiHelpers.IsImGuiInitialized)
ImGui.GetIO().SetPlatformImeDataFn = nint.Zero;
{
var io = ImGui.GetIO();
io.SetPlatformImeDataFn = null;
}
}
private void WndProcHookManagerOnPreWndProc(WndProcEventArgs args)
@ -670,7 +674,7 @@ internal sealed unsafe class DalamudIme : IInternalDisposableService
return;
var viewport = ime.associatedViewport;
if (viewport.NativePtr is null)
if (viewport.Handle is null)
return;
var drawCand = ime.candidateStrings.Count != 0;

View file

@ -40,9 +40,9 @@ using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImPlot;
using ImPlotNET;
using PInvoke;
using Serilog.Events;
@ -580,7 +580,10 @@ internal class DalamudInterface : IInternalDisposableService
var io = ImGui.GetIO();
if (!io.WantCaptureMouse && (User32.GetKeyState((int)User32.VirtualKey.VK_LBUTTON) & 0x8000) != 0)
{
ImGui.SetWindowFocus(null);
unsafe
{
ImGui.SetWindowFocus((byte*)null);
}
}
}
catch (Exception ex)
@ -661,7 +664,7 @@ internal class DalamudInterface : IInternalDisposableService
}
}
private void DrawDevMenu()
private unsafe void DrawDevMenu()
{
if (this.isImGuiDrawDevMenu)
{
@ -702,7 +705,7 @@ internal class DalamudInterface : IInternalDisposableService
}
var logSynchronously = this.configuration.LogSynchronously;
if (ImGui.MenuItem("Log Synchronously", null, ref logSynchronously))
if (ImGui.MenuItem("Log Synchronously", (byte*)null, ref logSynchronously))
{
this.configuration.LogSynchronously = logSynchronously;
this.configuration.QueueSave();
@ -715,7 +718,7 @@ internal class DalamudInterface : IInternalDisposableService
}
var antiDebug = Service<AntiDebug>.Get();
if (ImGui.MenuItem("Disable Debugging Protections", null, antiDebug.IsEnabled))
if (ImGui.MenuItem("Disable Debugging Protections", (byte*)null, antiDebug.IsEnabled))
{
var newEnabled = !antiDebug.IsEnabled;
if (newEnabled)
@ -854,7 +857,7 @@ internal class DalamudInterface : IInternalDisposableService
ImGui.EndMenu();
}
if (ImGui.MenuItem("Report crashes at shutdown", null, this.configuration.ReportShutdownCrashes))
if (ImGui.MenuItem("Report crashes at shutdown", (byte*)null, this.configuration.ReportShutdownCrashes))
{
this.configuration.ReportShutdownCrashes = !this.configuration.ReportShutdownCrashes;
this.configuration.QueueSave();
@ -896,7 +899,7 @@ internal class DalamudInterface : IInternalDisposableService
}
var assertsEnabled = this.configuration.ImGuiAssertsEnabledAtStartup ?? false;
if (ImGui.MenuItem("Enable asserts at startup", null, assertsEnabled))
if (ImGui.MenuItem("Enable asserts at startup", (byte*)null, assertsEnabled))
{
this.configuration.ImGuiAssertsEnabledAtStartup = !assertsEnabled;
this.configuration.QueueSave();
@ -906,7 +909,7 @@ internal class DalamudInterface : IInternalDisposableService
if (ImGui.MenuItem("Clear focus"))
{
ImGui.SetWindowFocus(null);
ImGui.SetWindowFocus((byte*)null);
}
if (ImGui.MenuItem("Clear stacks"))
@ -947,7 +950,7 @@ internal class DalamudInterface : IInternalDisposableService
Log.Information(info);
}
if (ImGui.MenuItem("Show dev bar info", null, this.configuration.ShowDevBarInfo))
if (ImGui.MenuItem("Show dev bar info", (byte*)null, this.configuration.ShowDevBarInfo))
{
this.configuration.ShowDevBarInfo = !this.configuration.ShowDevBarInfo;
}
@ -1018,12 +1021,12 @@ internal class DalamudInterface : IInternalDisposableService
ImGui.Separator();
if (ImGui.MenuItem("Load all API levels (ONLY FOR DEVELOPERS!!!)", null, pluginManager.LoadAllApiLevels))
if (ImGui.MenuItem("Load all API levels", (byte*)null, pluginManager.LoadAllApiLevels))
{
pluginManager.LoadAllApiLevels = !pluginManager.LoadAllApiLevels;
}
if (ImGui.MenuItem("Load blacklisted plugins", null, pluginManager.LoadBannedPlugins))
if (ImGui.MenuItem("Load blacklisted plugins", (byte*)null, pluginManager.LoadBannedPlugins))
{
pluginManager.LoadBannedPlugins = !pluginManager.LoadBannedPlugins;
}

View file

@ -4,7 +4,7 @@ using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.DesignSystem;

View file

@ -9,7 +9,7 @@ using Dalamud.Plugin.Internal;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.DesignSystem;

View file

@ -8,7 +8,7 @@ using Dalamud.Game.Gui.Toast;
using Dalamud.Interface.Utility;
using Dalamud.Logging.Internal;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using TerraFX.Interop.Windows;
@ -38,9 +38,9 @@ namespace Dalamud.Interface.Internal;
internal sealed unsafe class ImGuiClipboardFunctionProvider : IInternalDisposableService
{
private static readonly ModuleLog Log = new(nameof(ImGuiClipboardFunctionProvider));
private readonly nint clipboardUserDataOriginal;
private readonly nint setTextOriginal;
private readonly nint getTextOriginal;
private readonly void* clipboardUserDataOriginal;
private readonly void* setTextOriginal;
private readonly void* getTextOriginal;
[ServiceManager.ServiceDependency]
private readonly ToastGui toastGui = Service<ToastGui>.Get();
@ -58,9 +58,9 @@ internal sealed unsafe class ImGuiClipboardFunctionProvider : IInternalDisposabl
this.clipboardUserDataOriginal = io.ClipboardUserData;
this.setTextOriginal = io.SetClipboardTextFn;
this.getTextOriginal = io.GetClipboardTextFn;
io.ClipboardUserData = GCHandle.ToIntPtr(this.clipboardUserData = GCHandle.Alloc(this));
io.SetClipboardTextFn = (nint)(delegate* unmanaged<nint, byte*, void>)&StaticSetClipboardTextImpl;
io.GetClipboardTextFn = (nint)(delegate* unmanaged<nint, byte*>)&StaticGetClipboardTextImpl;
io.ClipboardUserData = GCHandle.ToIntPtr(this.clipboardUserData = GCHandle.Alloc(this)).ToPointer();
io.SetClipboardTextFn = (delegate* unmanaged<nint, byte*, void>)&StaticSetClipboardTextImpl;
io.GetClipboardTextFn = (delegate* unmanaged<nint, byte*>)&StaticGetClipboardTextImpl;
this.clipboardData = new(0);
return;

View file

@ -37,7 +37,7 @@ using Dalamud.Utility.Timing;
using FFXIVClientStructs.FFXIV.Client.Graphics.Environment;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using JetBrains.Annotations;
@ -826,7 +826,7 @@ internal partial class InterfaceManager : IInternalDisposableService
() =>
{
// Update the ImGui default font.
ImGui.GetIO().NativePtr->FontDefault = fontLocked.ImFont;
ImGui.GetIO().Handle->FontDefault = fontLocked.ImFont;
// Update the reference to the resources of the default font.
this.defaultFontResourceLock?.Dispose();

View file

@ -10,7 +10,7 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Lumina.Text.ReadOnly;
@ -213,7 +213,7 @@ internal unsafe class UiDebug
ImGui.SameLine();
Service<SeStringRenderer>.Get().Draw(textNode->NodeText);
ImGui.InputText($"Replace Text##{(ulong)textNode:X}", new IntPtr(textNode->NodeText.StringPtr), (uint)textNode->NodeText.BufSize);
ImGui.InputText($"Replace Text##{(ulong)textNode:X}", textNode->NodeText.StringPtr, (uint)textNode->NodeText.BufSize);
ImGui.SameLine();
if (ImGui.Button($"Encode##{(ulong)textNode:X}"))
@ -301,7 +301,7 @@ internal unsafe class UiDebug
if (ImGui.TreeNode($"Texture##{(ulong)kernelTexture->D3D11ShaderResourceView:X}"))
{
ImGui.Image(
new IntPtr(kernelTexture->D3D11ShaderResourceView),
new ImTextureID(kernelTexture->D3D11ShaderResourceView),
new Vector2(kernelTexture->ActualWidth, kernelTexture->ActualHeight));
ImGui.TreePop();
}
@ -312,7 +312,7 @@ internal unsafe class UiDebug
$"Texture##{(ulong)textureInfo->AtkTexture.KernelTexture->D3D11ShaderResourceView:X}"))
{
ImGui.Image(
new IntPtr(textureInfo->AtkTexture.KernelTexture->D3D11ShaderResourceView),
new ImTextureID(textureInfo->AtkTexture.KernelTexture->D3D11ShaderResourceView),
new Vector2(
textureInfo->AtkTexture.KernelTexture->ActualWidth,
textureInfo->AtkTexture.KernelTexture->ActualHeight));

View file

@ -5,7 +5,7 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;

View file

@ -5,7 +5,7 @@ using System.Numerics;
using Dalamud.Interface.Components;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.FontAwesomeIcon;
using static Dalamud.Interface.Internal.UiDebug2.ElementSelector;

View file

@ -4,10 +4,10 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static ImGuiNET.ImGuiTableColumnFlags;
using static ImGuiNET.ImGuiTableFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableColumnFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableFlags;
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;

View file

@ -1,7 +1,7 @@
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Utility.Util;

View file

@ -6,16 +6,16 @@ using Dalamud.Interface.Internal.UiDebug2.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.ColorHelpers;
using static Dalamud.Interface.FontAwesomeIcon;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Interface.Utility.ImGuiHelpers;
using static ImGuiNET.ImGuiColorEditFlags;
using static ImGuiNET.ImGuiInputTextFlags;
using static ImGuiNET.ImGuiTableColumnFlags;
using static ImGuiNET.ImGuiTableFlags;
using static Dalamud.Bindings.ImGui.ImGuiColorEditFlags;
using static Dalamud.Bindings.ImGui.ImGuiInputTextFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableColumnFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableFlags;
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;
@ -266,7 +266,7 @@ internal unsafe partial class NineGridNodeTree
ImGui.Text("Ninegrid Offsets:");
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(150);
if (ImGui.DragFloat2($"##{(nint)this.Node:X}ngOffsetLR", ref lr, 1, 0))
if (ImGui.DragFloat2($"##{(nint)this.Node:X}ngOffsetLR", ref lr, 1f, 0f))
{
this.NgNode->LeftOffset = (short)Math.Max(0, lr.X);
this.NgNode->RightOffset = (short)Math.Max(0, lr.Y);
@ -278,7 +278,7 @@ internal unsafe partial class NineGridNodeTree
ImGui.TableNextColumn();
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(150);
if (ImGui.DragFloat2($"##{(nint)this.Node:X}ngOffsetTB", ref tb, 1, 0))
if (ImGui.DragFloat2($"##{(nint)this.Node:X}ngOffsetTB", ref tb, 1f, 0f))
{
this.NgNode->TopOffset = (short)Math.Max(0, tb.X);
this.NgNode->BottomOffset = (short)Math.Max(0, tb.Y);

View file

@ -5,15 +5,15 @@ using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.ColorHelpers;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Utility.Util;
using static FFXIVClientStructs.FFXIV.Component.GUI.TextureType;
using static ImGuiNET.ImGuiTableColumnFlags;
using static ImGuiNET.ImGuiTableFlags;
using static ImGuiNET.ImGuiTreeNodeFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableColumnFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableFlags;
using static Dalamud.Bindings.ImGui.ImGuiTreeNodeFlags;
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;

View file

@ -1,7 +1,7 @@
using Dalamud.Interface.Internal.UiDebug2.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.ColorHelpers;
using static Dalamud.Utility.Util;

View file

@ -2,13 +2,14 @@ using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Components;
using Dalamud.Interface.Internal.UiDebug2.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using static Dalamud.Bindings.ImGui.ImGuiCol;
using static Dalamud.Bindings.ImGui.ImGuiTreeNodeFlags;
using static Dalamud.Interface.ColorHelpers;
using static Dalamud.Interface.FontAwesomeIcon;
using static Dalamud.Interface.Internal.UiDebug2.Browsing.Events;
@ -18,9 +19,6 @@ using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Utility.Util;
using static FFXIVClientStructs.FFXIV.Component.GUI.NodeFlags;
using static ImGuiNET.ImGuiCol;
using static ImGuiNET.ImGuiTreeNodeFlags;
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;
/// <summary>

View file

@ -9,7 +9,7 @@ using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.ColorHelpers;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;

View file

@ -1,6 +1,6 @@
using System.Collections.Generic;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;

View file

@ -7,15 +7,15 @@ using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.Graphics;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.ColorHelpers;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Utility.Util;
using static FFXIVClientStructs.FFXIV.Component.GUI.NodeType;
using static ImGuiNET.ImGuiTableColumnFlags;
using static ImGuiNET.ImGuiTableFlags;
using static ImGuiNET.ImGuiTreeNodeFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableColumnFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableFlags;
using static Dalamud.Bindings.ImGui.ImGuiTreeNodeFlags;
// ReSharper disable SuggestBaseTypeForParameter
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;

View file

@ -9,7 +9,7 @@ using Dalamud.Interface.Internal.UiDebug2.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static System.Globalization.NumberFormatInfo;
@ -18,8 +18,8 @@ using static Dalamud.Interface.Internal.UiDebug2.UiDebug2;
using static Dalamud.Interface.UiBuilder;
using static Dalamud.Interface.Utility.ImGuiHelpers;
using static FFXIVClientStructs.FFXIV.Component.GUI.NodeFlags;
using static ImGuiNET.ImGuiCol;
using static ImGuiNET.ImGuiWindowFlags;
using static Dalamud.Bindings.ImGui.ImGuiCol;
using static Dalamud.Bindings.ImGui.ImGuiWindowFlags;
// ReSharper disable StructLacksIEquatable.Global
#pragma warning disable CS0659

View file

@ -3,7 +3,7 @@ using System.Numerics;
using Dalamud.Interface.Internal.UiDebug2.Browsing;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.UiDebug2;

View file

@ -4,7 +4,7 @@ using Dalamud.Interface.Internal.UiDebug2.Browsing;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.Internal.UiDebug2.UiDebug2;

View file

@ -6,7 +6,7 @@ using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static System.StringComparison;
using static Dalamud.Interface.FontAwesomeIcon;

View file

@ -9,9 +9,9 @@ using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static ImGuiNET.ImGuiWindowFlags;
using static Dalamud.Bindings.ImGui.ImGuiWindowFlags;
namespace Dalamud.Interface.Internal.UiDebug2;

View file

@ -4,10 +4,10 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.Graphics;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static Dalamud.Interface.ColorHelpers;
using static ImGuiNET.ImGuiCol;
using static Dalamud.Bindings.ImGui.ImGuiCol;
namespace Dalamud.Interface.Internal.UiDebug2.Utility;

View file

@ -4,7 +4,7 @@ using System.Numerics;
using Dalamud.Interface.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using static System.MathF;
using static Dalamud.Interface.ColorHelpers;

View file

@ -11,7 +11,7 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;
using Dalamud.Networking.Http;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;
namespace Dalamud.Interface.Internal.Windows;

View file

@ -25,7 +25,7 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows;

View file

@ -5,7 +5,7 @@ using System.Reflection;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows;

View file

@ -7,7 +7,7 @@ using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows;

View file

@ -22,7 +22,7 @@ using Dalamud.Plugin.Internal;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Serilog;
using Serilog.Events;
@ -116,7 +116,7 @@ internal class ConsoleWindow : Window, IDisposable
unsafe
{
this.clipperPtr = new(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
this.clipperPtr = new(ImGui.ImGuiListClipper());
}
}
@ -1103,7 +1103,7 @@ internal class ConsoleWindow : Window, IDisposable
charOffsets[charOffsetsIndex++] = line.Length;
var screenPos = ImGui.GetCursorScreenPos();
var drawList = ImGui.GetWindowDrawList().NativePtr;
var drawList = ImGui.GetWindowDrawList().Handle;
var font = ImGui.GetFont();
var size = ImGui.GetFontSize();
var scale = size / font.FontSize;

View file

@ -8,7 +8,7 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Serilog;
namespace Dalamud.Interface.Internal.Windows.Data;

View file

@ -3,7 +3,7 @@ using System.Numerics;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Interface.ImGuiNotification.Internal;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data;
@ -50,7 +50,7 @@ internal static class DataWindowWidgetExtensions
{
ImGui.SetClipboardText(s);
Service<NotificationManager>.Get().AddNotification(
$"Copied {ImGui.TableGetColumnName()} to clipboard.",
$"Copied {ImGui.TableGetColumnNameS()} to clipboard.",
widget.DisplayName,
NotificationType.Success);
}

View file

@ -8,7 +8,7 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Logging.Internal;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Serilog.Events;

View file

@ -1,6 +1,6 @@
using Dalamud.Interface.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data;

View file

@ -5,7 +5,7 @@ using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -1,7 +1,7 @@
using Dalamud.Game.Gui;
using Dalamud.Memory;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -3,7 +3,7 @@
using Dalamud.Game;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -1,6 +1,6 @@
using Dalamud.Game.ClientState.Aetherytes;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -6,7 +6,7 @@ using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Lumina.Text.ReadOnly;

View file

@ -1,6 +1,6 @@
using Dalamud.Game.ClientState.Buddy;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -3,7 +3,7 @@
using Dalamud.Game.Command;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -1,7 +1,7 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -11,7 +11,7 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Plugin.Ipc.Internal;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;
@ -124,13 +124,13 @@ internal class DataShareWidget : IDataWindowWidget
if (ImGui.Button("Copy"))
{
fixed (byte* pData = data)
ImGuiNative.igSetClipboardText(pData);
ImGui.SetClipboardText(pData);
}
fixed (byte* pLabel = "text"u8)
fixed (byte* pData = data)
{
ImGuiNative.igInputTextMultiline(
ImGui.InputTextMultiline(
pLabel,
pData,
(uint)data.Length,
@ -245,7 +245,7 @@ internal class DataShareWidget : IDataWindowWidget
{
ImGui.SetClipboardText(tooltip?.Invoke() ?? s);
Service<NotificationManager>.Get().AddNotification(
$"Copied {ImGui.TableGetColumnName()} to clipboard.",
$"Copied {ImGui.TableGetColumnNameS()} to clipboard.",
this.DisplayName,
NotificationType.Success);
}

View file

@ -5,7 +5,7 @@ using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.Gui.Dtr;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -3,7 +3,7 @@ using Dalamud.Interface.Textures.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -2,7 +2,7 @@
using Dalamud.Game.Gui.FlyText;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -3,7 +3,7 @@ using System.Linq;
using System.Numerics;
using Dalamud.Interface.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -2,9 +2,11 @@
using System.Collections.Immutable;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Bindings.ImGui;
using Dalamud.Game;
using Dalamud.Interface.FontIdentifier;
using Dalamud.Interface.GameFonts;
@ -13,9 +15,6 @@ using Dalamud.Interface.ManagedFontAtlas;
using Dalamud.Interface.ManagedFontAtlas.Internals;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
using Serilog;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -66,10 +65,10 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
this.ClearAtlas();
fixed (byte* labelPtr = "Global Scale for Atlas"u8)
{
var v = (byte)(this.atlasScaleMode ? 1 : 0);
if (ImGuiNative.igCheckbox(labelPtr, &v) != 0)
var v = this.atlasScaleMode;
if (ImGui.Checkbox(labelPtr, ref v))
{
this.atlasScaleMode = v != 0;
this.atlasScaleMode = v;
this.ClearAtlas();
}
}
@ -77,18 +76,18 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
ImGui.SameLine();
fixed (byte* labelPtr = "Word Wrap"u8)
{
var v = (byte)(this.useWordWrap ? 1 : 0);
if (ImGuiNative.igCheckbox(labelPtr, &v) != 0)
this.useWordWrap = v != 0;
var v = this.useWordWrap;
if (ImGui.Checkbox(labelPtr, &v))
this.useWordWrap = v;
}
ImGui.SameLine();
fixed (byte* labelPtr = "Italic"u8)
{
var v = (byte)(this.useItalic ? 1 : 0);
if (ImGuiNative.igCheckbox(labelPtr, &v) != 0)
var v = this.useItalic;
if (ImGui.Checkbox(labelPtr, &v))
{
this.useItalic = v != 0;
this.useItalic = v;
this.ClearAtlas();
}
}
@ -96,10 +95,10 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
ImGui.SameLine();
fixed (byte* labelPtr = "Bold"u8)
{
var v = (byte)(this.useBold ? 1 : 0);
if (ImGuiNative.igCheckbox(labelPtr, &v) != 0)
var v = this.useBold;
if (ImGui.Checkbox(labelPtr, &v))
{
this.useBold = v != 0;
this.useBold = v;
this.ClearAtlas();
}
}
@ -107,10 +106,10 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
ImGui.SameLine();
fixed (byte* labelPtr = "Minimum Range"u8)
{
var v = (byte)(this.useMinimumBuild ? 1 : 0);
if (ImGuiNative.igCheckbox(labelPtr, &v) != 0)
var v = this.useMinimumBuild;
if (ImGui.Checkbox(labelPtr, &v))
{
this.useMinimumBuild = v != 0;
this.useMinimumBuild = v;
this.ClearAtlas();
}
}
@ -211,17 +210,17 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
fixed (byte* labelPtr = "Test Input"u8)
{
if (!this.atlasScaleMode)
ImGuiNative.igSetWindowFontScale(1 / ImGuiHelpers.GlobalScale);
ImGui.SetWindowFontScale(1 / ImGuiHelpers.GlobalScale);
using (this.fontDialogHandle.Push())
{
if (ImGuiNative.igInputTextMultiline(
if (ImGui.InputTextMultiline(
labelPtr,
this.testStringBuffer.Data,
(uint)this.testStringBuffer.Capacity,
new(ImGui.GetContentRegionAvail().X, ImGui.GetTextLineHeight() * 3),
0,
null,
null) != 0)
null))
{
var len = this.testStringBuffer.StorageSpan.IndexOf((byte)0);
if (len + 4 >= this.testStringBuffer.Capacity)
@ -238,7 +237,7 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
}
if (!this.atlasScaleMode)
ImGuiNative.igSetWindowFontScale(1);
ImGui.SetWindowFontScale(1);
}
this.fontHandles ??=
@ -285,7 +284,7 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
{
ImGui.TextUnformatted($"{gfs.SizePt}pt");
ImGui.SameLine(offsetX);
ImGuiNative.igPushTextWrapPos(this.useWordWrap ? 0f : -1f);
ImGui.PushTextWrapPos(this.useWordWrap ? 0f : -1f);
try
{
if (handle.Value.LoadException is { } exc)
@ -295,23 +294,23 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
else if (!handle.Value.Available)
{
fixed (byte* labelPtr = "Loading..."u8)
ImGuiNative.igTextUnformatted(labelPtr, labelPtr + 8 + ((Environment.TickCount / 200) % 3));
ImGui.TextUnformatted(labelPtr, labelPtr + 8 + ((Environment.TickCount / 200) % 3));
}
else
{
if (!this.atlasScaleMode)
ImGuiNative.igSetWindowFontScale(1 / ImGuiHelpers.GlobalScale);
ImGui.SetWindowFontScale(1 / ImGuiHelpers.GlobalScale);
if (counter++ % 2 == 0)
{
using var pushPop = handle.Value.Push();
ImGuiNative.igTextUnformatted(
ImGui.TextUnformatted(
this.testStringBuffer.Data,
this.testStringBuffer.Data + this.testStringBuffer.Length);
}
else
{
handle.Value.Push();
ImGuiNative.igTextUnformatted(
ImGui.TextUnformatted(
this.testStringBuffer.Data,
this.testStringBuffer.Data + this.testStringBuffer.Length);
handle.Value.Pop();
@ -320,8 +319,8 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
}
finally
{
ImGuiNative.igSetWindowFontScale(1);
ImGuiNative.igPopTextWrapPos();
ImGui.SetWindowFontScale(1);
ImGui.PopTextWrapPos();
}
}
}
@ -385,7 +384,7 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
var dim = default(Vector2);
var test = "Test string"u8;
fixed (byte* pTest = test)
ImGuiNative.ImFont_CalcTextSizeA(&dim, fontPtr, fontPtr.FontSize, float.MaxValue, 0, pTest, null, null);
ImGui.CalcTextSizeA(ref dim, fontPtr, fontPtr.FontSize, float.MaxValue, 0f, pTest, (string)null, null);
Log.Information($"{nameof(GamePrebakedFontsTestWidget)}: {handle} => {dim}");
}
}

View file

@ -1,7 +1,7 @@
using Dalamud.Game.ClientState.GamePad;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -2,7 +2,7 @@ using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.JobGauge;
using Dalamud.Game.ClientState.JobGauge.Types;
using Dalamud.Utility;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -1,7 +1,10 @@
using System.Runtime.InteropServices;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;
using Dalamud.Hooking;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
using PInvoke;
using Serilog;
@ -19,7 +22,7 @@ internal class HookWidget : IDataWindowWidget
IntPtr hWnd,
[MarshalAs(UnmanagedType.LPWStr)] string text,
[MarshalAs(UnmanagedType.LPWStr)] string caption,
NativeFunctions.MessageBoxType type);
MESSAGEBOX_STYLE type);
/// <inheritdoc/>
public string DisplayName { get; init; } = "Hook";
@ -53,7 +56,7 @@ internal class HookWidget : IDataWindowWidget
this.messageBoxMinHook?.Disable();
if (ImGui.Button("Call Original"))
this.messageBoxMinHook?.Original(IntPtr.Zero, "Hello from .Original", "Hook Test", NativeFunctions.MessageBoxType.Ok);
this.messageBoxMinHook?.Original(IntPtr.Zero, "Hello from .Original", "Hook Test", MESSAGEBOX_STYLE.MB_OK);
if (ImGui.Button("Dispose"))
{
@ -62,7 +65,7 @@ internal class HookWidget : IDataWindowWidget
}
if (ImGui.Button("Test"))
_ = NativeFunctions.MessageBoxW(IntPtr.Zero, "Hi", "Hello", NativeFunctions.MessageBoxType.Ok);
_ = global::Windows.Win32.PInvoke.MessageBox(HWND.Null, "Hi", "Hello", MESSAGEBOX_STYLE.MB_OK);
if (this.messageBoxMinHook != null)
ImGui.Text("Enabled: " + this.messageBoxMinHook?.IsEnabled);
@ -73,11 +76,11 @@ internal class HookWidget : IDataWindowWidget
}
}
private int MessageBoxWDetour(IntPtr hwnd, string text, string caption, NativeFunctions.MessageBoxType type)
private int MessageBoxWDetour(IntPtr hwnd, string text, string caption, MESSAGEBOX_STYLE type)
{
Log.Information("[DATAHOOK] {Hwnd} {Text} {Caption} {Type}", hwnd, text, caption, type);
var result = this.messageBoxMinHook!.Original(hwnd, "Cause Access Violation?", caption, NativeFunctions.MessageBoxType.YesNo);
var result = this.messageBoxMinHook!.Original(hwnd, "Cause Access Violation?", caption, MESSAGEBOX_STYLE.MB_YESNO);
if (result == (int)User32.MessageBoxResult.IDYES)
{

View file

@ -8,7 +8,7 @@ using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Internal;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

View file

@ -11,7 +11,7 @@ using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Windowing;
using Dalamud.Storage.Assets;
using ImGuiNET;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -457,7 +457,7 @@ internal class ImGuiWidget : IDataWindowWidget
public DisposeLoggingTextureWrap(IDalamudTextureWrap inner) => this.inner = inner;
public nint ImGuiHandle => this.inner.ImGuiHandle;
public ImTextureID ImGuiHandle => this.inner.ImGuiHandle;
public int Width => this.inner.Width;

Some files were not shown because too many files have changed in this diff Show more