mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-25 06:01:49 +01:00
- Add Utf8String extesions (copy of CStringExtension)
- Remove debug notes in Nodetree
This commit is contained in:
parent
bef50438f5
commit
6a9e0cc31c
2 changed files with 68 additions and 9 deletions
|
|
@ -1,11 +1,10 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
|
using Dalamud.Utility;
|
||||||
|
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
||||||
using Lumina.Text.ReadOnly;
|
|
||||||
|
|
||||||
using static Dalamud.Interface.Internal.UiDebug.Utility.Gui;
|
using static Dalamud.Interface.Internal.UiDebug.Utility.Gui;
|
||||||
using static Dalamud.Utility.Util;
|
using static Dalamud.Utility.Util;
|
||||||
using static FFXIVClientStructs.FFXIV.Component.GUI.ComponentType;
|
using static FFXIVClientStructs.FFXIV.Component.GUI.ComponentType;
|
||||||
|
|
@ -92,14 +91,14 @@ internal unsafe class ComponentNodeTree : ResNodeTree
|
||||||
{
|
{
|
||||||
case TextInput:
|
case TextInput:
|
||||||
var textInputComponent = (AtkComponentTextInput*)this.Component;
|
var textInputComponent = (AtkComponentTextInput*)this.Component;
|
||||||
ImGui.Text($"InputBase Text1 (Lumina): {new ReadOnlySeStringSpan(textInputComponent->AtkComponentInputBase.EvaluatedString.AsSpan()).ToMacroString()}");
|
ImGui.Text($"InputBase Text1: {textInputComponent->AtkComponentInputBase.EvaluatedString.AsReadOnlySeStringSpan().ToMacroString()}");
|
||||||
ImGui.Text($"InputBase Text2 (Lumina): {new ReadOnlySeStringSpan(textInputComponent->AtkComponentInputBase.RawString.AsSpan()).ToMacroString()}");
|
ImGui.Text($"InputBase Text2: {textInputComponent->AtkComponentInputBase.RawString.AsReadOnlySeStringSpan().ToMacroString()}");
|
||||||
// TODO: Reenable when unknowns have been unprivated / named
|
// TODO: Reenable when unknowns have been unprivated / named
|
||||||
// ImGui.Text($"Text1: {new ReadOnlySeStringSpan(textInputComponent->UnkText01.AsSpan()).ToMacroString()}");
|
// ImGui.Text($"Text1: {textInputComponent->UnkText01.AsReadOnlySeStringSpan().ToMacroString()}");
|
||||||
// ImGui.Text($"Text2: {new ReadOnlySeStringSpan(textInputComponent->UnkText02.AsSpan()).ToMacroString()}");
|
// ImGui.Text($"Text2: {textInputComponent->UnkText02.AsReadOnlySeStringSpan().ToMacroString()}");
|
||||||
ImGui.Text($"AvailableLines: {new ReadOnlySeStringSpan(textInputComponent->AvailableLines.AsSpan()).ToMacroString()}");
|
ImGui.Text($"AvailableLines: {textInputComponent->AvailableLines.AsReadOnlySeStringSpan().ToMacroString()}");
|
||||||
ImGui.Text($"HighlightedAutoTranslateOptionColorPrefix: {new ReadOnlySeStringSpan(textInputComponent->HighlightedAutoTranslateOptionColorPrefix.AsSpan()).ToMacroString()}");
|
ImGui.Text($"HighlightedAutoTranslateOptionColorPrefix: {textInputComponent->HighlightedAutoTranslateOptionColorPrefix.AsReadOnlySeStringSpan().ToMacroString()}");
|
||||||
ImGui.Text($"HighlightedAutoTranslateOptionColorSuffix: {new ReadOnlySeStringSpan(textInputComponent->HighlightedAutoTranslateOptionColorSuffix.AsSpan()).ToMacroString()}");
|
ImGui.Text($"HighlightedAutoTranslateOptionColorSuffix: {textInputComponent->HighlightedAutoTranslateOptionColorSuffix.AsReadOnlySeStringSpan().ToMacroString()}");
|
||||||
break;
|
break;
|
||||||
case List:
|
case List:
|
||||||
case TreeList:
|
case TreeList:
|
||||||
|
|
|
||||||
60
Dalamud/Utility/Utf8StringExtensions.cs
Normal file
60
Dalamud/Utility/Utf8StringExtensions.cs
Normal 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().ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue