diff --git a/Dalamud/Interface/Internal/UiDebug2/Browsing/Events.cs b/Dalamud/Interface/Internal/UiDebug2/Browsing/Events.cs
index e091187d5..a943858be 100644
--- a/Dalamud/Interface/Internal/UiDebug2/Browsing/Events.cs
+++ b/Dalamud/Interface/Internal/UiDebug2/Browsing/Events.cs
@@ -57,11 +57,11 @@ public static class Events
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{evt->State.StateFlags}");
ImGui.TableNextColumn();
- ImGui.TextUnformatted($"{evt->State.UnkFlags1}");
+ ImGui.TextUnformatted($"{evt->State.ReturnFlags}");
ImGui.TableNextColumn();
- ImGuiHelpers.ClickToCopyText($"{(nint)evt->Target:X}", null, new Vector4(0.6f, 0.6f, 0.6f, 1));
+ ImGuiHelpers.ClickToCopyText($"{(nint)evt->Target:X}", default, new Vector4(0.6f, 0.6f, 0.6f, 1));
ImGui.TableNextColumn();
- ImGuiHelpers.ClickToCopyText($"{(nint)evt->Listener:X}", null, new Vector4(0.6f, 0.6f, 0.6f, 1));
+ ImGuiHelpers.ClickToCopyText($"{(nint)evt->Listener:X}", default, new Vector4(0.6f, 0.6f, 0.6f, 1));
evt = evt->NextEvent;
}
}
diff --git a/Dalamud/Interface/Internal/UiDebug2/Utility/Gui.cs b/Dalamud/Interface/Internal/UiDebug2/Utility/Gui.cs
index 759c75587..094150f4c 100644
--- a/Dalamud/Interface/Internal/UiDebug2/Utility/Gui.cs
+++ b/Dalamud/Interface/Internal/UiDebug2/Utility/Gui.cs
@@ -28,7 +28,7 @@ internal static class Gui
var grey60 = new Vector4(0.6f, 0.6f, 0.6f, 1);
if (copy)
{
- ImGuiHelpers.ClickToCopyText(value, null, grey60);
+ ImGuiHelpers.ClickToCopyText(value, default, grey60);
}
else
{
diff --git a/Dalamud/Interface/Utility/ImGuiHelpers.cs b/Dalamud/Interface/Utility/ImGuiHelpers.cs
index b4cd269d7..4a2f36bc3 100644
--- a/Dalamud/Interface/Utility/ImGuiHelpers.cs
+++ b/Dalamud/Interface/Utility/ImGuiHelpers.cs
@@ -136,11 +136,7 @@ public static partial class ImGuiHelpers
/// The name/ID of the window.
/// The position of the window.
/// When to set the position.
- public static void SetWindowPosRelativeMainViewport(string name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
- => ImGui.SetWindowPos(name, position + MainViewport.Pos, condition);
-
- ///
- public static void SetWindowPosRelativeMainViewport(ReadOnlySpan name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
+ public static void SetWindowPosRelativeMainViewport(ImU8String name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
=> ImGui.SetWindowPos(name, position + MainViewport.Pos, condition);
///
@@ -166,11 +162,7 @@ public static partial class ImGuiHelpers
///
/// Text in the button.
/// with the size of the button.
- public static Vector2 GetButtonSize(string text)
- => ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
-
- ///
- public static Vector2 GetButtonSize(ReadOnlySpan text)
+ public static Vector2 GetButtonSize(ImU8String text)
=> ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
///
@@ -179,11 +171,8 @@ public static partial class ImGuiHelpers
/// The text to show.
/// The text to copy when clicked.
/// The color of the text.
- public static void ClickToCopyText(string text, string? textCopy = null, Vector4? color = null)
+ public static void ClickToCopyText(ImU8String text, ImU8String textCopy = default, Vector4? color = null)
{
- text ??= string.Empty;
- textCopy ??= text;
-
using (var col = new ImRaii.Color())
{
if (color.HasValue)
@@ -191,7 +180,7 @@ public static partial class ImGuiHelpers
col.Push(ImGuiCol.Text, color.Value);
}
- ImGui.TextUnformatted(text);
+ ImGui.TextUnformatted(text.Span);
}
if (ImGui.IsItemHovered())
@@ -206,52 +195,17 @@ public static partial class ImGuiHelpers
}
ImGui.SameLine();
- ImGui.TextUnformatted(textCopy);
+ ImGui.TextUnformatted(textCopy.IsNull ? text.Span : textCopy.Span);
}
}
if (ImGui.IsItemClicked())
{
- ImGui.SetClipboardText(textCopy);
- }
- }
-
- ///
- public static void ClickToCopyText(ReadOnlySpan text, ReadOnlySpan textCopy = default, Vector4? color = null)
- {
- if (textCopy.IsEmpty)
- textCopy = text;
-
- using (var col = new ImRaii.Color())
- {
- if (color.HasValue)
- {
- col.Push(ImGuiCol.Text, color.Value);
- }
-
- ImGui.TextUnformatted(text);
+ ImGui.SetClipboardText(textCopy.IsNull ? text.Span : textCopy.Span);
}
- if (ImGui.IsItemHovered())
- {
- ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
-
- using (ImRaii.Tooltip())
- {
- using (ImRaii.PushFont(UiBuilder.IconFont))
- {
- ImGui.TextUnformatted(FontAwesomeIcon.Copy.ToIconString());
- }
-
- ImGui.SameLine();
- ImGui.TextUnformatted(textCopy);
- }
- }
-
- if (ImGui.IsItemClicked())
- {
- ImGui.SetClipboardText(textCopy);
- }
+ text.Dispose();
+ textCopy.Dispose();
}
/// Draws a SeString.
@@ -285,32 +239,14 @@ public static partial class ImGuiHelpers
/// Write unformatted text wrapped.
///
/// The text to write.
- public static void SafeTextWrapped(string text) => ImGui.TextWrapped(text.Replace("%", "%%"));
-
- ///
- public static void SafeTextWrapped(ReadOnlySpan text)
- {
- if (text.Contains((byte)'%'))
- ImGui.TextWrapped(Encoding.UTF8.GetString(text).Replace("%", "%%"));
- else
- ImGui.TextWrapped(text);
- }
+ public static void SafeTextWrapped(ImU8String text) => ImGui.TextWrapped(text);
///
/// Write unformatted text wrapped.
///
/// The color of the text.
/// The text to write.
- public static void SafeTextColoredWrapped(Vector4 color, string text)
- {
- using (ImRaii.PushColor(ImGuiCol.Text, color))
- {
- SafeTextWrapped(text);
- }
- }
-
- ///
- public static void SafeTextColoredWrapped(Vector4 color, ReadOnlySpan text)
+ public static void SafeTextColoredWrapped(Vector4 color, ImU8String text)
{
using (ImRaii.PushColor(ImGuiCol.Text, color))
{
@@ -510,16 +446,9 @@ public static partial class ImGuiHelpers
/// Show centered text.
///
/// Text to show.
- public static void CenteredText(string text)
+ public static void CenteredText(ImU8String text)
{
- CenterCursorForText(text);
- ImGui.TextUnformatted(text);
- }
-
- ///
- public static void CenteredText(ReadOnlySpan text)
- {
- CenterCursorForText(text);
+ CenterCursorForText(text.Span);
ImGui.TextUnformatted(text);
}
@@ -527,11 +456,7 @@ public static partial class ImGuiHelpers
/// Center the ImGui cursor for a certain text.
///
/// The text to center for.
- public static void CenterCursorForText(string text)
- => CenterCursorFor(ImGui.CalcTextSize(text).X);
-
- ///
- public static void CenterCursorForText(ReadOnlySpan text)
+ public static void CenterCursorForText(ImU8String text)
=> CenterCursorFor(ImGui.CalcTextSize(text).X);
///
diff --git a/Dalamud/Interface/Utility/Raii/EndObjects.cs b/Dalamud/Interface/Utility/Raii/EndObjects.cs
index cdc31bb1e..f84844dda 100644
--- a/Dalamud/Interface/Utility/Raii/EndObjects.cs
+++ b/Dalamud/Interface/Utility/Raii/EndObjects.cs
@@ -1,5 +1,4 @@
using System.Numerics;
-using System.Text;
using Dalamud.Bindings.ImGui;
@@ -11,28 +10,16 @@ public static partial class ImRaii
{
private static int disabledCount = 0;
- public static IEndObject Child(string strId)
+ public static IEndObject Child(ImU8String strId)
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId));
- public static IEndObject Child(ReadOnlySpan strId)
- => new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId));
-
- public static IEndObject Child(string strId, Vector2 size)
+ public static IEndObject Child(ImU8String strId, Vector2 size)
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size));
- public static IEndObject Child(ReadOnlySpan strId, Vector2 size)
- => new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size));
-
- public static IEndObject Child(string strId, Vector2 size, bool border)
+ public static IEndObject Child(ImU8String strId, Vector2 size, bool border)
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border));
- public static IEndObject Child(ReadOnlySpan strId, Vector2 size, bool border)
- => new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border));
-
- public static IEndObject Child(string strId, Vector2 size, bool border, ImGuiWindowFlags flags)
- => new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border, flags));
-
- public static IEndObject Child(ReadOnlySpan strId, Vector2 size, bool border, ImGuiWindowFlags flags)
+ public static IEndObject Child(ImU8String strId, Vector2 size, bool border, ImGuiWindowFlags flags)
=> new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId, size, border, flags));
public static IEndObject DragDropTarget()
@@ -44,88 +31,40 @@ public static partial class ImRaii
public static IEndObject DragDropSource(ImGuiDragDropFlags flags)
=> new EndConditionally(ImGui.EndDragDropSource, ImGui.BeginDragDropSource(flags));
- public static IEndObject Popup(string id)
+ public static IEndObject Popup(ImU8String id)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id));
- public static IEndObject Popup(ReadOnlySpan id)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id));
-
- public static IEndObject Popup(string id, ImGuiWindowFlags flags)
+ public static IEndObject Popup(ImU8String id, ImGuiWindowFlags flags)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id, flags));
- public static IEndObject Popup(ReadOnlySpan id, ImGuiWindowFlags flags)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopup(id, flags));
-
- public static IEndObject PopupModal(string id)
+ public static IEndObject PopupModal(ImU8String id)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id));
- public static IEndObject PopupModal(ReadOnlySpan id)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id));
-
- public static IEndObject PopupModal(string id, ref bool open)
+ public static IEndObject PopupModal(ImU8String id, ref bool open)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open));
- public static IEndObject PopupModal(ReadOnlySpan id, ref bool open)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open));
-
- public static IEndObject PopupModal(string id, ref bool open, ImGuiWindowFlags flags)
+ public static IEndObject PopupModal(ImU8String id, ref bool open, ImGuiWindowFlags flags)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open, flags));
- public static IEndObject PopupModal(ReadOnlySpan id, ref bool open, ImGuiWindowFlags flags)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupModal(id, ref open, flags));
-
- public static IEndObject ContextPopup(string id)
+ public static IEndObject ContextPopup(ImU8String id)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id));
- public static IEndObject ContextPopup(ReadOnlySpan id)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id));
-
- public static IEndObject ContextPopup(string id, ImGuiPopupFlags flags)
+ public static IEndObject ContextPopup(ImU8String id, ImGuiPopupFlags flags)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id, flags));
- public static IEndObject ContextPopup(ReadOnlySpan id, ImGuiPopupFlags flags)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextWindow(id, flags));
-
- public static IEndObject ContextPopupItem(string id)
+ public static IEndObject ContextPopupItem(ImU8String id)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id));
- public static IEndObject ContextPopupItem(ReadOnlySpan id)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id));
-
- public static IEndObject ContextPopupItem(string id, ImGuiPopupFlags flags)
+ public static IEndObject ContextPopupItem(ImU8String id, ImGuiPopupFlags flags)
=> new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id, flags));
- public static IEndObject ContextPopupItem(ReadOnlySpan id, ImGuiPopupFlags flags)
- => new EndConditionally(ImGui.EndPopup, ImGui.BeginPopupContextItem(id, flags));
-
- public static IEndObject Combo(string label, string previewValue)
+ public static IEndObject Combo(ImU8String label, ImU8String previewValue)
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
- public static IEndObject Combo(ReadOnlySpan label, string previewValue)
- => new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
-
- public static IEndObject Combo(string label, ReadOnlySpan previewValue)
- => new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
-
- public static IEndObject Combo(ReadOnlySpan label, ReadOnlySpan previewValue)
- => new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue));
-
- public static IEndObject Combo(string label, string previewValue, ImGuiComboFlags flags)
+ public static IEndObject Combo(ImU8String label, ImU8String previewValue, ImGuiComboFlags flags)
=> new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
- public static IEndObject Combo(ReadOnlySpan label, string previewValue, ImGuiComboFlags flags)
- => new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
-
- public static IEndObject Combo(string label, ReadOnlySpan previewValue, ImGuiComboFlags flags)
- => new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
-
- public static IEndObject Combo(ReadOnlySpan label, ReadOnlySpan previewValue, ImGuiComboFlags flags)
- => new EndConditionally(ImGui.EndCombo, ImGui.BeginCombo(label, previewValue, flags));
-
- public static IEndObject Menu(string label)
- => new EndConditionally(ImGui.EndMenu, ImGui.BeginMenu(label));
-
- public static IEndObject Menu(ReadOnlySpan label)
+ public static IEndObject Menu(ImU8String label)
=> new EndConditionally(ImGui.EndMenu, ImGui.BeginMenu(label));
public static IEndObject MenuBar()
@@ -170,91 +109,49 @@ public static partial class ImRaii
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
}
- public static IEndObject ListBox(string label)
+ public static IEndObject ListBox(ImU8String label)
=> new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label));
- public static IEndObject ListBox(ReadOnlySpan label)
- => new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label));
-
- public static IEndObject ListBox(string label, Vector2 size)
+ public static IEndObject ListBox(ImU8String label, Vector2 size)
=> new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label, size));
- public static IEndObject ListBox(ReadOnlySpan label, Vector2 size)
- => new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label, size));
-
- public static IEndObject Table(string table, int numColumns)
+ public static IEndObject Table(ImU8String table, int numColumns)
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns));
- public static IEndObject Table(ReadOnlySpan table, int numColumns)
- => new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns));
-
- public static IEndObject Table(string table, int numColumns, ImGuiTableFlags flags)
+ public static IEndObject Table(ImU8String table, int numColumns, ImGuiTableFlags flags)
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags));
- public static IEndObject Table(ReadOnlySpan table, int numColumns, ImGuiTableFlags flags)
- => new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags));
-
- public static IEndObject Table(string table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize)
+ public static IEndObject Table(ImU8String table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize)
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize));
- public static IEndObject Table(ReadOnlySpan table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize)
- => new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize));
-
- public static IEndObject Table(string table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize, float innerWidth)
+ public static IEndObject Table(ImU8String table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize, float innerWidth)
=> new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize, innerWidth));
- public static IEndObject Table(ReadOnlySpan table, int numColumns, ImGuiTableFlags flags, Vector2 outerSize, float innerWidth)
- => new EndConditionally(ImGui.EndTable, ImGui.BeginTable(table, numColumns, flags, outerSize, innerWidth));
-
- public static IEndObject TabBar(string label)
+ public static IEndObject TabBar(ImU8String label)
=> new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label));
- public static IEndObject TabBar(ReadOnlySpan label)
- => new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label));
-
- public static IEndObject TabBar(string label, ImGuiTabBarFlags flags)
+ public static IEndObject TabBar(ImU8String label, ImGuiTabBarFlags flags)
=> new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label, flags));
- public static IEndObject TabBar(ReadOnlySpan label, ImGuiTabBarFlags flags)
- => new EndConditionally(ImGui.EndTabBar, ImGui.BeginTabBar(label, flags));
-
- public static IEndObject TabItem(string label)
- => new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label));
-
- public static IEndObject TabItem(ReadOnlySpan label)
+ public static IEndObject TabItem(ImU8String label)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label));
public static unsafe IEndObject TabItem(byte* label, ImGuiTabItemFlags flags)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
- public static unsafe IEndObject TabItem(string label, ImGuiTabItemFlags flags)
+ public static unsafe IEndObject TabItem(ImU8String label, ImGuiTabItemFlags flags)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
- public static unsafe IEndObject TabItem(ReadOnlySpan label, ImGuiTabItemFlags flags)
- => new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
-
- public static IEndObject TabItem(string label, ref bool open)
+ public static IEndObject TabItem(ImU8String label, ref bool open)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open));
- public static IEndObject TabItem(ReadOnlySpan label, ref bool open)
- => new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open));
-
- public static IEndObject TabItem(string label, ref bool open, ImGuiTabItemFlags flags)
+ public static IEndObject TabItem(ImU8String label, ref bool open, ImGuiTabItemFlags flags)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open, flags));
- public static IEndObject TabItem(ReadOnlySpan label, ref bool open, ImGuiTabItemFlags flags)
- => new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open, flags));
-
- public static IEndObject TreeNode(string label)
+ public static IEndObject TreeNode(ImU8String label)
=> new EndConditionally(ImGui.TreePop, ImGui.TreeNodeEx(label));
- public static IEndObject TreeNode(ReadOnlySpan label)
- => new EndConditionally(ImGui.TreePop, ImGui.TreeNodeEx(label));
-
- public static IEndObject TreeNode(string label, ImGuiTreeNodeFlags flags)
- => new EndConditionally(flags.HasFlag(ImGuiTreeNodeFlags.NoTreePushOnOpen) ? Nop : ImGui.TreePop, ImGui.TreeNodeEx(label, flags));
-
- public static IEndObject TreeNode(ReadOnlySpan label, ImGuiTreeNodeFlags flags)
+ public static IEndObject TreeNode(ImU8String label, ImGuiTreeNodeFlags flags)
=> new EndConditionally(flags.HasFlag(ImGuiTreeNodeFlags.NoTreePushOnOpen) ? Nop : ImGui.TreePop, ImGui.TreeNodeEx(label, flags));
public static IEndObject Disabled()
diff --git a/Dalamud/Interface/Utility/Raii/Id.cs b/Dalamud/Interface/Utility/Raii/Id.cs
index 0cde4639a..7fab495ae 100644
--- a/Dalamud/Interface/Utility/Raii/Id.cs
+++ b/Dalamud/Interface/Utility/Raii/Id.cs
@@ -6,10 +6,7 @@ namespace Dalamud.Interface.Utility.Raii;
// If condition is false, no id is pushed.
public static partial class ImRaii
{
- public static Id PushId(string id, bool enabled = true)
- => enabled ? new Id().Push(id) : new Id();
-
- public static Id PushId(ReadOnlySpan id, bool enabled = true)
+ public static Id PushId(ImU8String id, bool enabled = true)
=> enabled ? new Id().Push(id) : new Id();
public static Id PushId(int id, bool enabled = true)
@@ -22,18 +19,7 @@ public static partial class ImRaii
{
private int count;
- public Id Push(string id, bool condition = true)
- {
- if (condition)
- {
- ImGui.PushID(id);
- ++this.count;
- }
-
- return this;
- }
-
- public Id Push(ReadOnlySpan id, bool condition = true)
+ public Id Push(ImU8String id, bool condition = true)
{
if (condition)
{