Dalamud/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiStorage.Custom.cs
srkizer c69329f592
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
2025-08-04 11:14:00 -07:00

60 lines
2.2 KiB
C#

namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiStorage
{
public readonly ref bool GetBoolRef(uint key, bool defaultValue = false)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetBoolRef(thisPtr, key, defaultValue);
}
public readonly ref float GetFloatRef(uint key, float defaultValue = 0.0f)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetFloatRef(thisPtr, key, defaultValue);
}
public readonly ref int GetIntRef(uint key, int defaultValue = 0)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetIntRef(thisPtr, key, defaultValue);
}
public readonly ref void* GetVoidPtrRef(uint key, void* defaultValue = null)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetVoidPtrRef(thisPtr, key, defaultValue);
}
public readonly ref T* GetPtrRef<T>(uint key, T* defaultValue = null) where T : unmanaged
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetPtrRef(thisPtr, key, defaultValue);
}
public readonly ref T GetRef<T>(uint key, T defaultValue = default) where T : unmanaged
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetRef(thisPtr, key, defaultValue);
}
}
public unsafe partial struct ImGuiStoragePtr
{
public readonly ref bool GetBoolRef(uint key, bool defaultValue = false) =>
ref ImGui.GetBoolRef(this, key, defaultValue);
public readonly ref float GetFloatRef(uint key, float defaultValue = 0.0f) =>
ref ImGui.GetFloatRef(this, key, defaultValue);
public readonly ref int GetIntRef(uint key, int defaultValue = 0) => ref ImGui.GetIntRef(this, key, defaultValue);
public readonly ref void* GetVoidPtrRef(uint key, void* defaultValue = null) =>
ref ImGui.GetVoidPtrRef(this, key, defaultValue);
public readonly ref T* GetPtrRef<T>(uint key, T* defaultValue = null) where T : unmanaged =>
ref ImGui.GetPtrRef(this, key, defaultValue);
public readonly ref T GetRef<T>(uint key, T defaultValue = default) where T : unmanaged =>
ref ImGui.GetRef(this, key, defaultValue);
}