Remove unnecessary AddText extension

This commit is contained in:
Haselnussbomber 2025-07-17 01:24:30 +02:00
parent 9956424c13
commit d25b16aa93
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1

View file

@ -1,5 +1,4 @@
using System.Numerics;
using System.Text;
using Dalamud.Bindings.ImGui;
@ -52,36 +51,4 @@ public static class ImGuiExtensions
drawListPtr.AddText(ImGui.GetFont(), ImGui.GetFontSize(), pos, ImGui.GetColorU32(ImGuiCol.Text), text);
}
}
/// <summary>
/// Add text to a draw list.
/// </summary>
/// <param name="drawListPtr">Pointer to the draw list.</param>
/// <param name="font">Font to use.</param>
/// <param name="fontSize">Font size.</param>
/// <param name="pos">Position to draw at.</param>
/// <param name="col">Color to use.</param>
/// <param name="textBegin">Text to draw.</param>
/// <param name="cpuFineClipRect">Clip rect to use.</param>
// TODO: This should go into ImDrawList.Manual.cs in ImGui.NET...
public static unsafe void AddText(this ImDrawListPtr drawListPtr, ImFontPtr font, float fontSize, Vector2 pos, uint col, string textBegin, ref Vector4 cpuFineClipRect)
{
var nativeFont = font.Handle;
var textBeginByteCount = Encoding.UTF8.GetByteCount(textBegin);
var nativeTextBegin = stackalloc byte[textBeginByteCount + 1];
fixed (char* textBeginPtr = textBegin)
{
var nativeTextBeginOffset = Encoding.UTF8.GetBytes(textBeginPtr, textBegin.Length, nativeTextBegin, textBeginByteCount);
nativeTextBegin[nativeTextBeginOffset] = 0;
}
byte* nativeTextEnd = null;
var wrapWidth = 0.0f;
fixed (Vector4* nativeCpuFineClipRect = &cpuFineClipRect)
{
drawListPtr.AddText(nativeFont, fontSize, pos, col, nativeTextBegin, nativeTextEnd, wrapWidth, nativeCpuFineClipRect);
}
}
}