This commit is contained in:
Infi 2026-02-19 20:28:29 +01:00 committed by GitHub
commit 247133f2e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 69 additions and 10 deletions

View file

@ -1,11 +1,10 @@
using System.Runtime.InteropServices;
using Dalamud.Bindings.ImGui;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Text.ReadOnly;
using static Dalamud.Interface.Internal.UiDebug.Utility.Gui;
using static Dalamud.Utility.Util;
using static FFXIVClientStructs.FFXIV.Component.GUI.ComponentType;
@ -92,14 +91,14 @@ internal unsafe class ComponentNodeTree : ResNodeTree
{
case TextInput:
var textInputComponent = (AtkComponentTextInput*)this.Component;
ImGui.Text($"InputBase Text1 (Lumina): {new ReadOnlySeStringSpan(textInputComponent->AtkComponentInputBase.EvaluatedString.AsSpan()).ToMacroString()}");
ImGui.Text($"InputBase Text2 (Lumina): {new ReadOnlySeStringSpan(textInputComponent->AtkComponentInputBase.RawString.AsSpan()).ToMacroString()}");
ImGui.Text($"InputBase Text1: {textInputComponent->AtkComponentInputBase.EvaluatedString.AsReadOnlySeStringSpan().ToMacroString()}");
ImGui.Text($"InputBase Text2: {textInputComponent->AtkComponentInputBase.RawString.AsReadOnlySeStringSpan().ToMacroString()}");
// TODO: Reenable when unknowns have been unprivated / named
// ImGui.Text($"Text1: {new ReadOnlySeStringSpan(textInputComponent->UnkText01.AsSpan()).ToMacroString()}");
// ImGui.Text($"Text2: {new ReadOnlySeStringSpan(textInputComponent->UnkText02.AsSpan()).ToMacroString()}");
ImGui.Text($"AvailableLines: {new ReadOnlySeStringSpan(textInputComponent->AvailableLines.AsSpan()).ToMacroString()}");
ImGui.Text($"HighlightedAutoTranslateOptionColorPrefix: {new ReadOnlySeStringSpan(textInputComponent->HighlightedAutoTranslateOptionColorPrefix.AsSpan()).ToMacroString()}");
ImGui.Text($"HighlightedAutoTranslateOptionColorSuffix: {new ReadOnlySeStringSpan(textInputComponent->HighlightedAutoTranslateOptionColorSuffix.AsSpan()).ToMacroString()}");
// ImGui.Text($"Text1: {textInputComponent->UnkText01.AsReadOnlySeStringSpan().ToMacroString()}");
// ImGui.Text($"Text2: {textInputComponent->UnkText02.AsReadOnlySeStringSpan().ToMacroString()}");
ImGui.Text($"AvailableLines: {textInputComponent->AvailableLines.AsReadOnlySeStringSpan().ToMacroString()}");
ImGui.Text($"HighlightedAutoTranslateOptionColorPrefix: {textInputComponent->HighlightedAutoTranslateOptionColorPrefix.AsReadOnlySeStringSpan().ToMacroString()}");
ImGui.Text($"HighlightedAutoTranslateOptionColorSuffix: {textInputComponent->HighlightedAutoTranslateOptionColorSuffix.AsReadOnlySeStringSpan().ToMacroString()}");
break;
case List:
case TreeList:

View file

@ -45,7 +45,7 @@ public static class CStringExtensions
/// <returns>A new Lumina ReadOnlySeString.</returns>
public static ReadOnlySeString AsReadOnlySeString(this CStringPointer ptr)
{
return new ReadOnlySeString(ptr.AsSpan().ToArray());
return new ReadOnlySeString(ptr.AsSpan());
}
/// <summary>

View file

@ -0,0 +1,60 @@
using Dalamud.Game.Text.SeStringHandling;
using FFXIVClientStructs.FFXIV.Client.System.String;
using Lumina.Text.ReadOnly;
namespace Dalamud.Utility;
/// <summary>
/// A set of helpful utilities for working with <see cref="Utf8String"/>s from ClientStructs.
/// </summary>
/// <remarks>
/// WARNING: Will break if a custom ClientStructs is used. These are here for CONVENIENCE ONLY!.
/// </remarks>
public static class Utf8StringExtensions
{
/// <summary>
/// Convert a Utf8String to a ReadOnlySeStringSpan.
/// </summary>
/// <param name="str">The Utf8String to convert.</param>
/// <returns>A span.</returns>
public static ReadOnlySeStringSpan AsReadOnlySeStringSpan(this Utf8String str)
{
return str.AsSpan();
}
/// <summary>
/// Convert a Utf8String to a Dalamud SeString.
/// </summary>
/// <param name="str">The Utf8String to convert.</param>
/// <returns>A Dalamud-flavored SeString.</returns>
public static SeString AsDalamudSeString(this Utf8String str)
{
return str.AsReadOnlySeStringSpan().ToDalamudString();
}
/// <summary>
/// Get a new ReadOnlySeString that's a <em>copy</em> of the text in this Utf8String.
/// </summary>
/// <remarks>
/// This should be functionally identical to <see cref="AsReadOnlySeStringSpan"/>, but exists
/// for convenience in places that already expect ReadOnlySeString as a type (and where a copy is desired).
/// </remarks>
/// <param name="str">The Utf8String to copy.</param>
/// <returns>A new Lumina ReadOnlySeString.</returns>
public static ReadOnlySeString AsReadOnlySeString(this Utf8String str)
{
return new ReadOnlySeString(str.AsSpan());
}
/// <summary>
/// Extract text from this Utf8String following <see cref="ReadOnlySeStringSpan.ExtractText()"/>'s rules.
/// </summary>
/// <param name="str">The Utf8String to process.</param>
/// <returns>Extracted text.</returns>
public static string ExtractText(this Utf8String str)
{
return str.AsReadOnlySeStringSpan().ExtractText();
}
}