mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Manual overloads for ImGui functions accepting text (#2319)
* wip2 * Implement AutoUtf8Buffer * reformat * Work on manual bindings * restructure * Name scripts properly * Update utility functions to use ImU8String * add overloads * Add more overloads * Use ImGuiWindow from gen, support AddCallback * Use LibraryImport for custom ImGuiNative functinos * Make manual overloads for string-returning functinos * Make all overloads with self as its first parameter extension methods * Fix overload resolution by removing unnecessary * in => scoped in * Fix compilation errors
This commit is contained in:
parent
0c63541864
commit
c69329f592
293 changed files with 61312 additions and 754 deletions
73
imgui/Dalamud.Bindings.ImGui/Custom/ImGui.StringReturns.cs
Normal file
73
imgui/Dalamud.Bindings.ImGui/Custom/ImGui.StringReturns.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Dalamud.Bindings.ImGui;
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public unsafe partial class ImGui
|
||||
{
|
||||
public static ReadOnlySpan<byte> GetVersionU8() =>
|
||||
MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetVersion());
|
||||
|
||||
public static ReadOnlySpan<byte> TableGetColumnNameU8(int columnN = -1) =>
|
||||
MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.TableGetColumnName(columnN));
|
||||
|
||||
public static ReadOnlySpan<byte> GetStyleColorNameU8(this ImGuiCol idx) =>
|
||||
MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetStyleColorName(idx));
|
||||
|
||||
public static ReadOnlySpan<byte> GetKeyNameU8(this ImGuiKey key) =>
|
||||
MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetKeyName(key));
|
||||
|
||||
public static ReadOnlySpan<byte> GetClipboardTextU8() =>
|
||||
MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetClipboardText());
|
||||
|
||||
public static ReadOnlySpan<byte> SaveIniSettingsToMemoryU8()
|
||||
{
|
||||
nuint len;
|
||||
var ptr = ImGuiNative.SaveIniSettingsToMemory(&len);
|
||||
return new(ptr, (int)len);
|
||||
}
|
||||
|
||||
public static ref byte begin(this ImGuiTextBufferPtr self) => ref *ImGuiNative.begin(self.Handle);
|
||||
|
||||
public static ref byte begin(this in ImGuiTextBuffer self)
|
||||
{
|
||||
fixed (ImGuiTextBuffer* selfPtr = &self)
|
||||
return ref *ImGuiNative.begin(selfPtr);
|
||||
}
|
||||
|
||||
public static ref byte end(this ImGuiTextBufferPtr self) => ref *ImGuiNative.end(self.Handle);
|
||||
|
||||
public static ref byte end(this in ImGuiTextBuffer self)
|
||||
{
|
||||
fixed (ImGuiTextBuffer* selfPtr = &self)
|
||||
return ref *ImGuiNative.end(selfPtr);
|
||||
}
|
||||
|
||||
public static ReadOnlySpan<byte> c_str(this ImGuiTextBufferPtr self) => self.Handle->c_str();
|
||||
|
||||
public static ReadOnlySpan<byte> c_str(this scoped in ImGuiTextBuffer self)
|
||||
{
|
||||
fixed (ImGuiTextBuffer* selfPtr = &self)
|
||||
return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.c_str(selfPtr));
|
||||
}
|
||||
|
||||
public static ReadOnlySpan<byte> GetDebugNameU8(this ImFontPtr self) =>
|
||||
MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetDebugName(self.Handle));
|
||||
|
||||
public static ReadOnlySpan<byte> GetDebugNameU8(this scoped in ImFont self)
|
||||
{
|
||||
fixed (ImFont* selfPtr = &self)
|
||||
return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetDebugName(selfPtr));
|
||||
}
|
||||
|
||||
public static string GetVersion() => Encoding.UTF8.GetString(GetVersionU8());
|
||||
public static string TableGetColumnName(int columnN = -1) => Encoding.UTF8.GetString(TableGetColumnNameU8(columnN));
|
||||
public static string GetStyleColorName(this ImGuiCol idx) => Encoding.UTF8.GetString(GetStyleColorNameU8(idx));
|
||||
public static string GetKeyName(this ImGuiKey key) => Encoding.UTF8.GetString(GetKeyNameU8(key));
|
||||
public static string GetClipboardText() => Encoding.UTF8.GetString(GetClipboardTextU8());
|
||||
public static string SaveIniSettingsToMemory() => Encoding.UTF8.GetString(SaveIniSettingsToMemoryU8());
|
||||
public static string GetDebugName(this ImFontPtr self) => Encoding.UTF8.GetString(GetDebugNameU8(self));
|
||||
public static string GetDebugName(this scoped in ImFont self) => Encoding.UTF8.GetString(GetDebugNameU8(self));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue