Skip to content

Commit

Permalink
upgrade cimgui, fix IME and image rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Dec 27, 2024
1 parent 3f3f5f4 commit 55bfe9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
27 changes: 9 additions & 18 deletions Dalamud/Interface/Internal/DalamudIme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, string> WmNames =
Expand Down Expand Up @@ -69,11 +66,6 @@ internal sealed unsafe class DalamudIme : IInternalDisposableService
UnicodeRanges.HangulJamoExtendedB,
};

private static readonly delegate* unmanaged<ImGuiInputTextState*, StbTextEditState*, int, int, int, void>
StbTextMakeUndoReplace;

private static readonly delegate* unmanaged<ImGuiInputTextState*, StbTextEditState*, void> StbTextUndo;

[ServiceManager.ServiceDependency]
private readonly DalamudConfiguration dalamudConfiguration = Service<DalamudConfiguration>.Get();

Expand Down Expand Up @@ -134,13 +126,6 @@ static DalamudIme()
{
return;
}

StbTextMakeUndoReplace =
(delegate* unmanaged<ImGuiInputTextState*, StbTextEditState*, int, int, int, void>)
(cimgui + CImGuiStbTextCreateUndoOffset);
StbTextUndo =
(delegate* unmanaged<ImGuiInputTextState*, StbTextEditState*, void>)
(cimgui + CImGuiStbTextUndoOffset);
}

[ServiceManager.ServiceConstructor]
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1116,9 +1101,15 @@ public bool InsertChars(int pos, ReadOnlySpan<char> 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
}

Expand Down
2 changes: 1 addition & 1 deletion lib/cimgui
Submodule cimgui updated 2 files
+11 −0 cimgui_impl.cpp
+1 −1 imgui

0 comments on commit 55bfe9e

Please sign in to comment.