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

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;
}
}
@ -295,7 +305,7 @@ internal unsafe class SeStringRenderer : IInternalDisposableService
var link = -1;
foreach (var (breakAt, mandatory) in new LineBreakEnumerator(state.Span, UtfEnumeratorFlags.Utf8SeString))
{
// Might have happened if custom entity was longer than the previous break unit.
// Might have happened if custom entity was longer than the previous break unit.
if (prev > breakAt)
continue;
@ -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);
}