mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 20:54:16 +01:00
Switch to TextUnformatted()
Plus other noodling with GUI business. I considered adding some of the helper features I use here to `ImGuiComponents`, but it would have quickly started expanding into a separate project of its own, and I didn't really want to entangle that with this PR right now.
This commit is contained in:
parent
552aafd70d
commit
8fc93c4c52
11 changed files with 116 additions and 103 deletions
|
|
@ -114,7 +114,7 @@ public unsafe partial class AddonTree : IDisposable
|
||||||
|
|
||||||
var isVisible = addon->IsVisible;
|
var isVisible = addon->IsVisible;
|
||||||
|
|
||||||
ImGui.Text($"{this.AddonName}");
|
ImGui.TextUnformatted($"{this.AddonName}");
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ public static class Events
|
||||||
}
|
}
|
||||||
|
|
||||||
using var tree = ImRaii.TreeNode($"Events##{(nint)node:X}eventTree");
|
using var tree = ImRaii.TreeNode($"Events##{(nint)node:X}eventTree");
|
||||||
|
|
||||||
if (tree)
|
if (tree)
|
||||||
{
|
{
|
||||||
using (ImRaii.Table($"##{(nint)node:X}eventTable", 7, Resizable | SizingFixedFit | Borders | RowBg))
|
using (ImRaii.Table($"##{(nint)node:X}eventTable", 7, Resizable | SizingFixedFit | Borders | RowBg))
|
||||||
|
|
@ -45,15 +46,15 @@ public static class Events
|
||||||
while (evt != null)
|
while (evt != null)
|
||||||
{
|
{
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{i++}");
|
ImGui.TextUnformatted($"{i++}");
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{evt->Type}");
|
ImGui.TextUnformatted($"{evt->Type}");
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{evt->Param}");
|
ImGui.TextUnformatted($"{evt->Param}");
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{evt->Flags}");
|
ImGui.TextUnformatted($"{evt->Flags}");
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text($"{evt->Unk29}");
|
ImGui.TextUnformatted($"{evt->Unk29}");
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
Gui.ClickToCopyText($"{(nint)evt->Target:X}");
|
Gui.ClickToCopyText($"{(nint)evt->Target:X}");
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
|
||||||
|
|
@ -81,19 +81,19 @@ internal unsafe class ComponentNodeTree : ResNodeTree
|
||||||
{
|
{
|
||||||
case TextInput:
|
case TextInput:
|
||||||
var textInputComponent = (AtkComponentTextInput*)this.Component;
|
var textInputComponent = (AtkComponentTextInput*)this.Component;
|
||||||
ImGui.Text(
|
ImGui.TextUnformatted(
|
||||||
$"InputBase Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.UnkText1.StringPtr))}");
|
$"InputBase Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.UnkText1.StringPtr))}");
|
||||||
ImGui.Text(
|
ImGui.TextUnformatted(
|
||||||
$"InputBase Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.UnkText2.StringPtr))}");
|
$"InputBase Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.UnkText2.StringPtr))}");
|
||||||
ImGui.Text(
|
ImGui.TextUnformatted(
|
||||||
$"Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText01.StringPtr))}");
|
$"Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText01.StringPtr))}");
|
||||||
ImGui.Text(
|
ImGui.TextUnformatted(
|
||||||
$"Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText02.StringPtr))}");
|
$"Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText02.StringPtr))}");
|
||||||
ImGui.Text(
|
ImGui.TextUnformatted(
|
||||||
$"Text3: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText03.StringPtr))}");
|
$"Text3: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText03.StringPtr))}");
|
||||||
ImGui.Text(
|
ImGui.TextUnformatted(
|
||||||
$"Text4: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText04.StringPtr))}");
|
$"Text4: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText04.StringPtr))}");
|
||||||
ImGui.Text(
|
ImGui.TextUnformatted(
|
||||||
$"Text5: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText05.StringPtr))}");
|
$"Text5: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText05.StringPtr))}");
|
||||||
break;
|
break;
|
||||||
case List:
|
case List:
|
||||||
|
|
|
||||||
|
|
@ -370,8 +370,8 @@ internal unsafe partial class TextNodeTree
|
||||||
var hAlign = (int)alignment % 3;
|
var hAlign = (int)alignment % 3;
|
||||||
var vAlign = ((int)alignment - hAlign) / 3;
|
var vAlign = ((int)alignment - hAlign) / 3;
|
||||||
|
|
||||||
var hAlignInput = IconSelectInput($"{label}H", ref hAlign, [0, 1, 2], [AlignLeft, AlignCenter, AlignRight]);
|
var hAlignInput = IconButtonSelect($"{label}H", ref hAlign, [0, 1, 2], [AlignLeft, AlignCenter, AlignRight]);
|
||||||
var vAlignInput = IconSelectInput($"{label}V", ref vAlign, [0, 1, 2], [ArrowsUpToLine, GripLines, ArrowsDownToLine]);
|
var vAlignInput = IconButtonSelect($"{label}V", ref vAlign, [0, 1, 2], [ArrowsUpToLine, GripLines, ArrowsDownToLine]);
|
||||||
|
|
||||||
if (hAlignInput || vAlignInput)
|
if (hAlignInput || vAlignInput)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ internal unsafe partial class ResNodeTree : IDisposable
|
||||||
NodeType.ClippingMask => new ClippingMaskNodeTree(node, addonTree),
|
NodeType.ClippingMask => new ClippingMaskNodeTree(node, addonTree),
|
||||||
NodeType.Counter => new CounterNodeTree(node, addonTree),
|
NodeType.Counter => new CounterNodeTree(node, addonTree),
|
||||||
NodeType.Collision => new CollisionNodeTree(node, addonTree),
|
NodeType.Collision => new CollisionNodeTree(node, addonTree),
|
||||||
_ => new ResNodeTree(node, addonTree)
|
_ => new ResNodeTree(node, addonTree),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -163,7 +163,7 @@ internal unsafe partial class ResNodeTree : IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void WriteTreeHeading()
|
internal void WriteTreeHeading()
|
||||||
{
|
{
|
||||||
ImGui.Text(this.GetHeaderText());
|
ImGui.TextUnformatted(this.GetHeaderText());
|
||||||
this.PrintFieldNames();
|
this.PrintFieldNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
||||||
Color = this.TxtNode->TextColor.RGBA,
|
Color = this.TxtNode->TextColor.RGBA,
|
||||||
EdgeColor = this.TxtNode->EdgeColor.RGBA,
|
EdgeColor = this.TxtNode->EdgeColor.RGBA,
|
||||||
ForceEdgeColor = true,
|
ForceEdgeColor = true,
|
||||||
EdgeStrength = 1f
|
EdgeStrength = 1f,
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma warning disable SeStringRenderer
|
#pragma warning disable SeStringRenderer
|
||||||
|
|
@ -66,7 +66,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
ImGui.Text(Marshal.PtrToStringAnsi(new(this.NodeText.StringPtr)) ?? "");
|
ImGui.TextUnformatted(Marshal.PtrToStringAnsi(new(this.NodeText.StringPtr)) ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintFieldValuePairs(
|
PrintFieldValuePairs(
|
||||||
|
|
@ -98,7 +98,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
||||||
for (var i = 0; i < seString.Payloads.Count; i++)
|
for (var i = 0; i < seString.Payloads.Count; i++)
|
||||||
{
|
{
|
||||||
var payload = seString.Payloads[i];
|
var payload = seString.Payloads[i];
|
||||||
ImGui.Text($"[{i}]");
|
ImGui.TextUnformatted($"[{i}]");
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
switch (payload.Type)
|
switch (payload.Type)
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +110,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ImGui.Text(payload.ToString());
|
ImGui.TextUnformatted(payload.ToString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public readonly partial struct TimelineTree
|
||||||
/// The default print function, if none is specified.
|
/// The default print function, if none is specified.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The value to print.</param>
|
/// <param name="value">The value to print.</param>
|
||||||
public static void PlainTextCell(T value) => ImGui.Text($"{value}");
|
public static void PlainTextCell(T value) => ImGui.TextUnformatted($"{value}");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a value to this column.
|
/// Adds a value to this column.
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ public readonly unsafe partial struct TimelineTree
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rotColumn = new KeyGroupColumn<float>("Rotation", static r => ImGui.Text($"{r * (180d / Math.PI):F1}°"));
|
var rotColumn = new KeyGroupColumn<float>("Rotation", static r => ImGui.TextUnformatted($"{r * (180d / Math.PI):F1}°"));
|
||||||
|
|
||||||
for (var f = 0; f < keyGroup.KeyFrameCount; f++)
|
for (var f = 0; f < keyGroup.KeyFrameCount; f++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,10 @@ internal unsafe class ElementSelector : IDisposable
|
||||||
{
|
{
|
||||||
using (ImRaii.Child("###sidebar_elementSelector", new(250, 0), true))
|
using (ImRaii.Child("###sidebar_elementSelector", new(250, 0), true))
|
||||||
{
|
{
|
||||||
using var f = ImRaii.PushFont(IconFont);
|
using (ImRaii.PushFont(IconFont))
|
||||||
using var col = ImRaii.PushColor(Text, new Vector4(1, 1, 0.2f, 1), this.Active);
|
{
|
||||||
|
using (ImRaii.PushColor(Text, new Vector4(1, 1, 0.2f, 1), this.Active))
|
||||||
|
{
|
||||||
if (ImGui.Button($"{(char)ObjectUngroup}"))
|
if (ImGui.Button($"{(char)ObjectUngroup}"))
|
||||||
{
|
{
|
||||||
this.Active = !this.Active;
|
this.Active = !this.Active;
|
||||||
|
|
@ -97,9 +98,8 @@ internal unsafe class ElementSelector : IDisposable
|
||||||
Countdown = 0;
|
Countdown = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
col.Pop();
|
}
|
||||||
f.Pop();
|
|
||||||
|
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +151,8 @@ internal unsafe class ElementSelector : IDisposable
|
||||||
var mousePos = ImGui.GetMousePos() - MainViewport.Pos;
|
var mousePos = ImGui.GetMousePos() - MainViewport.Pos;
|
||||||
var addonResults = GetAtkUnitBaseAtPosition(mousePos);
|
var addonResults = GetAtkUnitBaseAtPosition(mousePos);
|
||||||
|
|
||||||
using var col = ImRaii.PushColor(WindowBg, new Vector4(0.5f));
|
using (ImRaii.PushColor(WindowBg, new Vector4(0.5f)))
|
||||||
|
{
|
||||||
using (ImRaii.Child("noClick", new(800, 2000), false, NoInputs | NoBackground | NoScrollWithMouse))
|
using (ImRaii.Child("noClick", new(800, 2000), false, NoInputs | NoBackground | NoScrollWithMouse))
|
||||||
{
|
{
|
||||||
using (ImRaii.Group())
|
using (ImRaii.Group())
|
||||||
|
|
@ -164,7 +165,7 @@ internal unsafe class ElementSelector : IDisposable
|
||||||
foreach (var a in addonResults)
|
foreach (var a in addonResults)
|
||||||
{
|
{
|
||||||
var name = a.Addon->NameString;
|
var name = a.Addon->NameString;
|
||||||
ImGui.Text($"[Addon] {name}");
|
ImGui.TextUnformatted($"[Addon] {name}");
|
||||||
ImGui.Indent(15);
|
ImGui.Indent(15);
|
||||||
foreach (var n in a.Nodes)
|
foreach (var n in a.Nodes)
|
||||||
{
|
{
|
||||||
|
|
@ -217,6 +218,7 @@ internal unsafe class ElementSelector : IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static List<AddonResult> GetAtkUnitBaseAtPosition(Vector2 position)
|
private static List<AddonResult> GetAtkUnitBaseAtPosition(Vector2 position)
|
||||||
{
|
{
|
||||||
|
|
@ -393,9 +395,11 @@ internal unsafe class ElementSelector : IDisposable
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using var col = ImRaii.PushColor(Text, selected ? new Vector4(1, 1, 0.2f, 1) : new(0.6f, 0.6f, 0.6f, 1));
|
using (ImRaii.PushColor(Text, selected ? new Vector4(1, 1, 0.2f, 1) : new(0.6f, 0.6f, 0.6f, 1)))
|
||||||
|
{
|
||||||
ResNodeTree.GetOrCreate(node, tree).WriteTreeHeading();
|
ResNodeTree.GetOrCreate(node, tree).WriteTreeHeading();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void PerformSearch(nint address)
|
private void PerformSearch(nint address)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,6 @@ internal unsafe partial class UiDebug2
|
||||||
{
|
{
|
||||||
this.DrawUnitListOption(unitListBaseAddr, unit);
|
this.DrawUnitListOption(unitListBaseAddr, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Utility;
|
|
||||||
using Dalamud.Interface.Utility.Raii;
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
|
||||||
using FFXIVClientStructs.FFXIV.Client.Graphics;
|
using FFXIVClientStructs.FFXIV.Client.Graphics;
|
||||||
|
|
@ -27,20 +26,19 @@ internal static class Gui
|
||||||
/// <param name="options">A list of all options.</param>
|
/// <param name="options">A list of all options.</param>
|
||||||
/// <param name="icons">A list of icons corresponding to the options.</param>
|
/// <param name="icons">A list of icons corresponding to the options.</param>
|
||||||
/// <returns>true if a button is clicked.</returns>
|
/// <returns>true if a button is clicked.</returns>
|
||||||
internal static unsafe bool IconSelectInput<T>(string label, ref T val, List<T> options, List<FontAwesomeIcon> icons)
|
internal static unsafe bool IconButtonSelect<T>(string label, ref T val, List<T> options, List<FontAwesomeIcon> icons)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
|
|
||||||
for (var i = 0; i < options.Count; i++)
|
for (var i = 0; i < options.Count; i++)
|
||||||
{
|
{
|
||||||
var option = options[i];
|
|
||||||
var icon = icons[i];
|
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
ImGui.SameLine();
|
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX() - ((ImGui.GetFontSize() / -6f) + 7f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var option = options[i];
|
||||||
|
var icon = icons.Count > i ? icons[i] : FontAwesomeIcon.Question;
|
||||||
var color = *ImGui.GetStyleColorVec4(val is not null && val.Equals(option) ? ButtonActive : Button);
|
var color = *ImGui.GetStyleColorVec4(val is not null && val.Equals(option) ? ButtonActive : Button);
|
||||||
|
|
||||||
if (ImGuiComponents.IconButton($"{label}{option}{i}", icon, color))
|
if (ImGuiComponents.IconButton($"{label}{option}{i}", icon, color))
|
||||||
|
|
@ -61,7 +59,7 @@ internal static class Gui
|
||||||
/// <param name="copy">Whether to enable click-to-copy.</param>
|
/// <param name="copy">Whether to enable click-to-copy.</param>
|
||||||
internal static void PrintFieldValuePair(string fieldName, string value, bool copy = true)
|
internal static void PrintFieldValuePair(string fieldName, string value, bool copy = true)
|
||||||
{
|
{
|
||||||
ImGui.Text($"{fieldName}:");
|
ImGui.TextUnformatted($"{fieldName}:");
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (copy)
|
if (copy)
|
||||||
{
|
{
|
||||||
|
|
@ -119,24 +117,36 @@ internal static class Gui
|
||||||
0.5f) * vector4.W;
|
0.5f) * vector4.W;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="ImGuiHelpers.ClickToCopyText"/>
|
/// <summary>
|
||||||
|
/// Print out text that can be copied when clicked.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">The text to show.</param>
|
||||||
|
/// <param name="textCopy">The text to copy when clicked.</param>
|
||||||
internal static void ClickToCopyText(string text, string? textCopy = null)
|
internal static void ClickToCopyText(string text, string? textCopy = null)
|
||||||
{
|
{
|
||||||
using (ImRaii.PushColor(Text, new Vector4(0.6f, 0.6f, 0.6f, 1)))
|
using (ImRaii.PushColor(Text, new Vector4(0.6f, 0.6f, 0.6f, 1)))
|
||||||
{
|
{
|
||||||
ImGuiHelpers.ClickToCopyText(text, textCopy);
|
textCopy ??= text;
|
||||||
|
ImGui.TextUnformatted($"{text}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
{
|
{
|
||||||
using (ImRaii.Tooltip())
|
using (ImRaii.Tooltip())
|
||||||
{
|
{
|
||||||
using var f = ImRaii.PushFont(UiBuilder.IconFont);
|
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||||
ImGui.Text(FontAwesomeIcon.Copy.ToIconString());
|
{
|
||||||
f.Pop();
|
ImGui.TextUnformatted(FontAwesomeIcon.Copy.ToIconString());
|
||||||
ImGui.SameLine();
|
|
||||||
ImGui.Text($"{textCopy ?? text}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
ImGui.TextUnformatted($"{textCopy}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.IsItemClicked())
|
||||||
|
{
|
||||||
|
ImGui.SetClipboardText($"{textCopy}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +171,7 @@ internal static class Gui
|
||||||
|
|
||||||
using (ImRaii.Tooltip())
|
using (ImRaii.Tooltip())
|
||||||
{
|
{
|
||||||
ImGui.Text(tooltips[index]);
|
ImGui.TextUnformatted(tooltips[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue