mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
SeString renderer: fix colors, add link support (#1983)
* Add coloring options * Add link support * simplify * fixes * Prevent EncodeString from causing crashes * Fix link range application and add link example * Fix test widget * Make DalamudLinkPayload backward compatible * make it better to use * make it better to use * Mark SeString rendering functions experimental via comments * rename * Simplify * Make sestring draw functions take in draw params * Improvements
This commit is contained in:
parent
5fdd88b488
commit
b6eb18d550
25 changed files with 2009 additions and 766 deletions
|
|
@ -1,4 +1,9 @@
|
|||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Interface.ImGuiSeStringRenderer.Internal;
|
||||
|
||||
using DSeString = Dalamud.Game.Text.SeStringHandling.SeString;
|
||||
using DSeStringBuilder = Dalamud.Game.Text.SeStringHandling.SeStringBuilder;
|
||||
using LSeString = Lumina.Text.SeString;
|
||||
using LSeStringBuilder = Lumina.Text.SeStringBuilder;
|
||||
|
||||
namespace Dalamud.Utility;
|
||||
|
||||
|
|
@ -13,7 +18,51 @@ public static class SeStringExtensions
|
|||
/// </summary>
|
||||
/// <param name="originalString">The original Lumina SeString.</param>
|
||||
/// <returns>The re-parsed Dalamud SeString.</returns>
|
||||
public static SeString ToDalamudString(this Lumina.Text.SeString originalString) => SeString.Parse(originalString.RawData);
|
||||
public static DSeString ToDalamudString(this LSeString originalString) => DSeString.Parse(originalString.RawData);
|
||||
|
||||
/// <summary>Compiles and appends a macro string.</summary>
|
||||
/// <param name="ssb">Target SeString builder.</param>
|
||||
/// <param name="macroString">Macro string in UTF-8 to compile and append to <paramref name="ssb"/>.</param>
|
||||
/// <returns><c>this</c> for method chaining.</returns>
|
||||
/// <remarks>Must be called from the main thread.</remarks>
|
||||
public static LSeStringBuilder AppendMacroString(this LSeStringBuilder ssb, ReadOnlySpan<byte> macroString)
|
||||
{
|
||||
ThreadSafety.AssertMainThread();
|
||||
return ssb.Append(Service<SeStringRenderer>.Get().Compile(macroString));
|
||||
}
|
||||
|
||||
/// <summary>Compiles and appends a macro string.</summary>
|
||||
/// <param name="ssb">Target SeString builder.</param>
|
||||
/// <param name="macroString">Macro string in UTF-16 to compile and append to <paramref name="ssb"/>.</param>
|
||||
/// <returns><c>this</c> for method chaining.</returns>
|
||||
/// <remarks>Must be called from the main thread.</remarks>
|
||||
public static LSeStringBuilder AppendMacroString(this LSeStringBuilder ssb, ReadOnlySpan<char> macroString)
|
||||
{
|
||||
ThreadSafety.AssertMainThread();
|
||||
return ssb.Append(Service<SeStringRenderer>.Get().Compile(macroString));
|
||||
}
|
||||
|
||||
/// <summary>Compiles and appends a macro string.</summary>
|
||||
/// <param name="ssb">Target SeString builder.</param>
|
||||
/// <param name="macroString">Macro string in UTF-8 to compile and append to <paramref name="ssb"/>.</param>
|
||||
/// <returns><c>this</c> for method chaining.</returns>
|
||||
/// <remarks>Must be called from the main thread.</remarks>
|
||||
public static DSeStringBuilder AppendMacroString(this DSeStringBuilder ssb, ReadOnlySpan<byte> macroString)
|
||||
{
|
||||
ThreadSafety.AssertMainThread();
|
||||
return ssb.Append(DSeString.Parse(Service<SeStringRenderer>.Get().Compile(macroString)));
|
||||
}
|
||||
|
||||
/// <summary>Compiles and appends a macro string.</summary>
|
||||
/// <param name="ssb">Target SeString builder.</param>
|
||||
/// <param name="macroString">Macro string in UTF-16 to compile and append to <paramref name="ssb"/>.</param>
|
||||
/// <returns><c>this</c> for method chaining.</returns>
|
||||
/// <remarks>Must be called from the main thread.</remarks>
|
||||
public static DSeStringBuilder AppendMacroString(this DSeStringBuilder ssb, ReadOnlySpan<char> macroString)
|
||||
{
|
||||
ThreadSafety.AssertMainThread();
|
||||
return ssb.Append(DSeString.Parse(Service<SeStringRenderer>.Get().Compile(macroString)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate if character name is valid.
|
||||
|
|
@ -24,8 +73,5 @@ public static class SeStringExtensions
|
|||
/// </summary>
|
||||
/// <param name="value">character name to validate.</param>
|
||||
/// <returns>indicator if character is name is valid.</returns>
|
||||
public static bool IsValidCharacterName(this SeString value)
|
||||
{
|
||||
return value.ToString().IsValidCharacterName();
|
||||
}
|
||||
public static bool IsValidCharacterName(this DSeString value) => value.ToString().IsValidCharacterName();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue