From 55bfe9eeb0e021c015cc12229d431a13bee0cc02 Mon Sep 17 00:00:00 2001 From: goat Date: Fri, 27 Dec 2024 18:19:45 +0100 Subject: [PATCH] upgrade cimgui, fix IME and image rendering --- Dalamud/Interface/Internal/DalamudIme.cs | 27 ++++++++---------------- lib/cimgui | 2 +- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Dalamud/Interface/Internal/DalamudIme.cs b/Dalamud/Interface/Internal/DalamudIme.cs index 7beb5e58b..a1c4a0a95 100644 --- a/Dalamud/Interface/Internal/DalamudIme.cs +++ b/Dalamud/Interface/Internal/DalamudIme.cs @@ -37,9 +37,6 @@ namespace Dalamud.Interface.Internal; [ServiceManager.EarlyLoadedService] internal sealed unsafe class DalamudIme : IInternalDisposableService { - private const int CImGuiStbTextCreateUndoOffset = 0xB57A0; - private const int CImGuiStbTextUndoOffset = 0xB59C0; - private const int ImePageSize = 9; private static readonly Dictionary WmNames = @@ -69,11 +66,6 @@ internal sealed unsafe class DalamudIme : IInternalDisposableService UnicodeRanges.HangulJamoExtendedB, }; - private static readonly delegate* unmanaged - StbTextMakeUndoReplace; - - private static readonly delegate* unmanaged StbTextUndo; - [ServiceManager.ServiceDependency] private readonly DalamudConfiguration dalamudConfiguration = Service.Get(); @@ -134,13 +126,6 @@ static DalamudIme() { return; } - - StbTextMakeUndoReplace = - (delegate* unmanaged) - (cimgui + CImGuiStbTextCreateUndoOffset); - StbTextUndo = - (delegate* unmanaged) - (cimgui + CImGuiStbTextUndoOffset); } [ServiceManager.ServiceConstructor] @@ -1031,14 +1016,14 @@ public void SanitizeSelectionRange() (s, e) = (e, s); } - public void Undo() => StbTextUndo(this.ThisPtr, &this.ThisPtr->Stb); + public void Undo() => CustomNativeFunctions.igCustom_StbTextUndo(this.ThisPtr); public bool MakeUndoReplace(int offset, int oldLength, int newLength) { if (oldLength == 0 && newLength == 0) return false; - StbTextMakeUndoReplace(this.ThisPtr, &this.ThisPtr->Stb, offset, oldLength, newLength); + CustomNativeFunctions.igCustom_StbTextMakeUndoReplace(this.ThisPtr, offset, oldLength, newLength); return true; } @@ -1116,9 +1101,15 @@ public bool InsertChars(int pos, ReadOnlySpan newText) private static class CustomNativeFunctions { - [DllImport("cimgui")] #pragma warning disable SA1300 + [DllImport("cimgui")] public static extern ImGuiInputTextState* igCustom_GetInputTextState(); + + [DllImport("cimgui")] + public static extern void igCustom_StbTextMakeUndoReplace(ImGuiInputTextState* str, int where, int old_length, int new_length); + + [DllImport("cimgui")] + public static extern void igCustom_StbTextUndo(ImGuiInputTextState* str); #pragma warning restore SA1300 } diff --git a/lib/cimgui b/lib/cimgui index fd2377934..7002b2884 160000 --- a/lib/cimgui +++ b/lib/cimgui @@ -1 +1 @@ -Subproject commit fd2377934f2cc007982e21ab82e54b41955cb658 +Subproject commit 7002b2884e9216d8bef3e792722d88abe31788f8