mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +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;
|
||||
|
||||
ImGui.Text($"{this.AddonName}");
|
||||
ImGui.TextUnformatted($"{this.AddonName}");
|
||||
ImGui.SameLine();
|
||||
|
||||
ImGui.SameLine();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public static class Events
|
|||
}
|
||||
|
||||
using var tree = ImRaii.TreeNode($"Events##{(nint)node:X}eventTree");
|
||||
|
||||
if (tree)
|
||||
{
|
||||
using (ImRaii.Table($"##{(nint)node:X}eventTable", 7, Resizable | SizingFixedFit | Borders | RowBg))
|
||||
|
|
@ -45,15 +46,15 @@ public static class Events
|
|||
while (evt != null)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text($"{i++}");
|
||||
ImGui.TextUnformatted($"{i++}");
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text($"{evt->Type}");
|
||||
ImGui.TextUnformatted($"{evt->Type}");
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text($"{evt->Param}");
|
||||
ImGui.TextUnformatted($"{evt->Param}");
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text($"{evt->Flags}");
|
||||
ImGui.TextUnformatted($"{evt->Flags}");
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text($"{evt->Unk29}");
|
||||
ImGui.TextUnformatted($"{evt->Unk29}");
|
||||
ImGui.TableNextColumn();
|
||||
Gui.ClickToCopyText($"{(nint)evt->Target:X}");
|
||||
ImGui.TableNextColumn();
|
||||
|
|
|
|||
|
|
@ -81,19 +81,19 @@ internal unsafe class ComponentNodeTree : ResNodeTree
|
|||
{
|
||||
case TextInput:
|
||||
var textInputComponent = (AtkComponentTextInput*)this.Component;
|
||||
ImGui.Text(
|
||||
ImGui.TextUnformatted(
|
||||
$"InputBase Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.UnkText1.StringPtr))}");
|
||||
ImGui.Text(
|
||||
ImGui.TextUnformatted(
|
||||
$"InputBase Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.UnkText2.StringPtr))}");
|
||||
ImGui.Text(
|
||||
ImGui.TextUnformatted(
|
||||
$"Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText01.StringPtr))}");
|
||||
ImGui.Text(
|
||||
ImGui.TextUnformatted(
|
||||
$"Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText02.StringPtr))}");
|
||||
ImGui.Text(
|
||||
ImGui.TextUnformatted(
|
||||
$"Text3: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText03.StringPtr))}");
|
||||
ImGui.Text(
|
||||
ImGui.TextUnformatted(
|
||||
$"Text4: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText04.StringPtr))}");
|
||||
ImGui.Text(
|
||||
ImGui.TextUnformatted(
|
||||
$"Text5: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText05.StringPtr))}");
|
||||
break;
|
||||
case List:
|
||||
|
|
|
|||
|
|
@ -370,8 +370,8 @@ internal unsafe partial class TextNodeTree
|
|||
var hAlign = (int)alignment % 3;
|
||||
var vAlign = ((int)alignment - hAlign) / 3;
|
||||
|
||||
var hAlignInput = IconSelectInput($"{label}H", ref hAlign, [0, 1, 2], [AlignLeft, AlignCenter, AlignRight]);
|
||||
var vAlignInput = IconSelectInput($"{label}V", ref vAlign, [0, 1, 2], [ArrowsUpToLine, GripLines, ArrowsDownToLine]);
|
||||
var hAlignInput = IconButtonSelect($"{label}H", ref hAlign, [0, 1, 2], [AlignLeft, AlignCenter, AlignRight]);
|
||||
var vAlignInput = IconButtonSelect($"{label}V", ref vAlign, [0, 1, 2], [ArrowsUpToLine, GripLines, ArrowsDownToLine]);
|
||||
|
||||
if (hAlignInput || vAlignInput)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ internal unsafe partial class ResNodeTree : IDisposable
|
|||
NodeType.ClippingMask => new ClippingMaskNodeTree(node, addonTree),
|
||||
NodeType.Counter => new CounterNodeTree(node, addonTree),
|
||||
NodeType.Collision => new CollisionNodeTree(node, addonTree),
|
||||
_ => new ResNodeTree(node, addonTree)
|
||||
_ => new ResNodeTree(node, addonTree),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -163,7 +163,7 @@ internal unsafe partial class ResNodeTree : IDisposable
|
|||
/// </summary>
|
||||
internal void WriteTreeHeading()
|
||||
{
|
||||
ImGui.Text(this.GetHeaderText());
|
||||
ImGui.TextUnformatted(this.GetHeaderText());
|
||||
this.PrintFieldNames();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
|||
Color = this.TxtNode->TextColor.RGBA,
|
||||
EdgeColor = this.TxtNode->EdgeColor.RGBA,
|
||||
ForceEdgeColor = true,
|
||||
EdgeStrength = 1f
|
||||
EdgeStrength = 1f,
|
||||
};
|
||||
|
||||
#pragma warning disable SeStringRenderer
|
||||
|
|
@ -66,7 +66,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
|||
}
|
||||
catch
|
||||
{
|
||||
ImGui.Text(Marshal.PtrToStringAnsi(new(this.NodeText.StringPtr)) ?? "");
|
||||
ImGui.TextUnformatted(Marshal.PtrToStringAnsi(new(this.NodeText.StringPtr)) ?? string.Empty);
|
||||
}
|
||||
|
||||
PrintFieldValuePairs(
|
||||
|
|
@ -98,7 +98,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
|||
for (var i = 0; i < seString.Payloads.Count; i++)
|
||||
{
|
||||
var payload = seString.Payloads[i];
|
||||
ImGui.Text($"[{i}]");
|
||||
ImGui.TextUnformatted($"[{i}]");
|
||||
ImGui.SameLine();
|
||||
switch (payload.Type)
|
||||
{
|
||||
|
|
@ -110,7 +110,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
|
|||
|
||||
default:
|
||||
{
|
||||
ImGui.Text(payload.ToString());
|
||||
ImGui.TextUnformatted(payload.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public readonly partial struct TimelineTree
|
|||
/// The default print function, if none is specified.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// Adds a value to this column.
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public readonly unsafe partial struct TimelineTree
|
|||
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++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,26 +81,26 @@ internal unsafe class ElementSelector : IDisposable
|
|||
{
|
||||
using (ImRaii.Child("###sidebar_elementSelector", new(250, 0), true))
|
||||
{
|
||||
using var f = ImRaii.PushFont(IconFont);
|
||||
using var col = ImRaii.PushColor(Text, new Vector4(1, 1, 0.2f, 1), this.Active);
|
||||
|
||||
if (ImGui.Button($"{(char)ObjectUngroup}"))
|
||||
using (ImRaii.PushFont(IconFont))
|
||||
{
|
||||
this.Active = !this.Active;
|
||||
}
|
||||
|
||||
if (Countdown > 0)
|
||||
{
|
||||
Countdown -= 1;
|
||||
if (Countdown < 0)
|
||||
using (ImRaii.PushColor(Text, new Vector4(1, 1, 0.2f, 1), this.Active))
|
||||
{
|
||||
Countdown = 0;
|
||||
if (ImGui.Button($"{(char)ObjectUngroup}"))
|
||||
{
|
||||
this.Active = !this.Active;
|
||||
}
|
||||
|
||||
if (Countdown > 0)
|
||||
{
|
||||
Countdown -= 1;
|
||||
if (Countdown < 0)
|
||||
{
|
||||
Countdown = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
col.Pop();
|
||||
f.Pop();
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("Element Selector");
|
||||
|
|
@ -151,67 +151,69 @@ internal unsafe class ElementSelector : IDisposable
|
|||
var mousePos = ImGui.GetMousePos() - MainViewport.Pos;
|
||||
var addonResults = GetAtkUnitBaseAtPosition(mousePos);
|
||||
|
||||
using var col = ImRaii.PushColor(WindowBg, new Vector4(0.5f));
|
||||
using (ImRaii.Child("noClick", new(800, 2000), false, NoInputs | NoBackground | NoScrollWithMouse))
|
||||
using (ImRaii.PushColor(WindowBg, new Vector4(0.5f)))
|
||||
{
|
||||
using (ImRaii.Group())
|
||||
using (ImRaii.Child("noClick", new(800, 2000), false, NoInputs | NoBackground | NoScrollWithMouse))
|
||||
{
|
||||
Gui.PrintFieldValuePair("Mouse Position", $"{mousePos.X}, {mousePos.Y}");
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("RESULTS:\n");
|
||||
|
||||
var i = 0;
|
||||
foreach (var a in addonResults)
|
||||
using (ImRaii.Group())
|
||||
{
|
||||
var name = a.Addon->NameString;
|
||||
ImGui.Text($"[Addon] {name}");
|
||||
ImGui.Indent(15);
|
||||
foreach (var n in a.Nodes)
|
||||
Gui.PrintFieldValuePair("Mouse Position", $"{mousePos.X}, {mousePos.Y}");
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("RESULTS:\n");
|
||||
|
||||
var i = 0;
|
||||
foreach (var a in addonResults)
|
||||
{
|
||||
var nSelected = i++ == this.index;
|
||||
|
||||
PrintNodeHeaderOnly(n.Node, nSelected, a.Addon);
|
||||
|
||||
if (nSelected && ImGui.IsMouseClicked(ImGuiMouseButton.Left))
|
||||
var name = a.Addon->NameString;
|
||||
ImGui.TextUnformatted($"[Addon] {name}");
|
||||
ImGui.Indent(15);
|
||||
foreach (var n in a.Nodes)
|
||||
{
|
||||
this.Active = false;
|
||||
var nSelected = i++ == this.index;
|
||||
|
||||
this.uiDebug2.SelectedAddonName = a.Addon->NameString;
|
||||
PrintNodeHeaderOnly(n.Node, nSelected, a.Addon);
|
||||
|
||||
var ptrList = new List<nint> { (nint)n.Node };
|
||||
|
||||
var nextNode = n.Node->ParentNode;
|
||||
while (nextNode != null)
|
||||
if (nSelected && ImGui.IsMouseClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
ptrList.Add((nint)nextNode);
|
||||
nextNode = nextNode->ParentNode;
|
||||
this.Active = false;
|
||||
|
||||
this.uiDebug2.SelectedAddonName = a.Addon->NameString;
|
||||
|
||||
var ptrList = new List<nint> { (nint)n.Node };
|
||||
|
||||
var nextNode = n.Node->ParentNode;
|
||||
while (nextNode != null)
|
||||
{
|
||||
ptrList.Add((nint)nextNode);
|
||||
nextNode = nextNode->ParentNode;
|
||||
}
|
||||
|
||||
SearchResults = [.. ptrList];
|
||||
Countdown = 100;
|
||||
Scrolled = false;
|
||||
}
|
||||
|
||||
SearchResults = [.. ptrList];
|
||||
Countdown = 100;
|
||||
Scrolled = false;
|
||||
if (nSelected)
|
||||
{
|
||||
n.NodeBounds.DrawFilled(new(1, 1, 0.2f, 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (nSelected)
|
||||
ImGui.Indent(-15);
|
||||
}
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
this.index -= (int)ImGui.GetIO().MouseWheel;
|
||||
while (this.index < 0)
|
||||
{
|
||||
n.NodeBounds.DrawFilled(new(1, 1, 0.2f, 1));
|
||||
this.index += i;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Indent(-15);
|
||||
}
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
this.index -= (int)ImGui.GetIO().MouseWheel;
|
||||
while (this.index < 0)
|
||||
{
|
||||
this.index += i;
|
||||
}
|
||||
|
||||
while (this.index >= i)
|
||||
{
|
||||
this.index -= i;
|
||||
while (this.index >= i)
|
||||
{
|
||||
this.index -= i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -393,8 +395,10 @@ internal unsafe class ElementSelector : IDisposable
|
|||
return;
|
||||
}
|
||||
|
||||
using var col = ImRaii.PushColor(Text, selected ? new Vector4(1, 1, 0.2f, 1) : new(0.6f, 0.6f, 0.6f, 1));
|
||||
ResNodeTree.GetOrCreate(node, tree).WriteTreeHeading();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
private void PerformSearch(nint address)
|
||||
|
|
|
|||
|
|
@ -98,8 +98,6 @@ internal unsafe partial class UiDebug2
|
|||
{
|
||||
this.DrawUnitListOption(unitListBaseAddr, unit);
|
||||
}
|
||||
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System.Collections.Generic;
|
|||
using System.Numerics;
|
||||
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics;
|
||||
|
|
@ -27,20 +26,19 @@ internal static class Gui
|
|||
/// <param name="options">A list of all options.</param>
|
||||
/// <param name="icons">A list of icons corresponding to the options.</param>
|
||||
/// <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;
|
||||
|
||||
for (var i = 0; i < options.Count; i++)
|
||||
{
|
||||
var option = options[i];
|
||||
var icon = icons[i];
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX() - ((ImGui.GetFontSize() / -6f) + 7f));
|
||||
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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>
|
||||
internal static void PrintFieldValuePair(string fieldName, string value, bool copy = true)
|
||||
{
|
||||
ImGui.Text($"{fieldName}:");
|
||||
ImGui.TextUnformatted($"{fieldName}:");
|
||||
ImGui.SameLine();
|
||||
if (copy)
|
||||
{
|
||||
|
|
@ -119,25 +117,37 @@ internal static class Gui
|
|||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
using (ImRaii.Tooltip())
|
||||
{
|
||||
using var f = ImRaii.PushFont(UiBuilder.IconFont);
|
||||
ImGui.Text(FontAwesomeIcon.Copy.ToIconString());
|
||||
f.Pop();
|
||||
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||
{
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.Copy.ToIconString());
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.Text($"{textCopy ?? text}");
|
||||
ImGui.TextUnformatted($"{textCopy}");
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked())
|
||||
{
|
||||
ImGui.SetClipboardText($"{textCopy}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -161,7 +171,7 @@ internal static class Gui
|
|||
|
||||
using (ImRaii.Tooltip())
|
||||
{
|
||||
ImGui.Text(tooltips[index]);
|
||||
ImGui.TextUnformatted(tooltips[index]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue