Merge pull request #2428 from Haselnussbomber/lumina-ssb-atktweaks
Some checks are pending
Build Dalamud / Build on Windows (push) Waiting to run
Build Dalamud / Check API Compatibility (push) Blocked by required conditions
Build Dalamud / Deploy dalamud-distrib staging (push) Blocked by required conditions
Tag Build / Tag Build (push) Successful in 2s

Use Luminas SeStringBuilder in DalamudAtkTweaks
This commit is contained in:
goat 2025-10-16 00:46:06 +02:00 committed by GitHub
commit 49eac894a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 12 deletions

View file

@ -1,12 +1,12 @@
using CheapLoc; using CheapLoc;
using Dalamud.Configuration.Internal; using Dalamud.Configuration.Internal;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Hooking; using Dalamud.Hooking;
using Dalamud.Interface.Internal; using Dalamud.Interface.Internal;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Logging.Internal; using Dalamud.Logging.Internal;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
@ -185,17 +185,23 @@ internal sealed unsafe class DalamudAtkTweaks : IInternalDisposableService
secondStringEntry->ChangeType(ValueType.String); secondStringEntry->ChangeType(ValueType.String);
const int color = 539; const int color = 539;
var strPlugins = new SeString().Append(new UIForegroundPayload(color))
.Append($"{SeIconChar.BoxedLetterD.ToIconString()} ")
.Append(new UIForegroundPayload(0))
.Append(this.locDalamudPlugins).Encode();
var strSettings = new SeString().Append(new UIForegroundPayload(color))
.Append($"{SeIconChar.BoxedLetterD.ToIconString()} ")
.Append(new UIForegroundPayload(0))
.Append(this.locDalamudSettings).Encode();
firstStringEntry->SetManagedString(strPlugins); using var rssb = new RentedSeStringBuilder();
secondStringEntry->SetManagedString(strSettings);
firstStringEntry->SetManagedString(rssb.Builder
.PushColorType(color)
.Append($"{SeIconChar.BoxedLetterD.ToIconString()} ")
.PopColorType()
.Append(this.locDalamudPlugins)
.GetViewAsSpan());
rssb.Builder.Clear();
secondStringEntry->SetManagedString(rssb.Builder
.PushColorType(color)
.Append($"{SeIconChar.BoxedLetterD.ToIconString()} ")
.PopColorType()
.Append(this.locDalamudSettings)
.GetViewAsSpan());
// open menu with new size // open menu with new size
var sizeEntry = &atkValueArgs[4]; var sizeEntry = &atkValueArgs[4];

View file

@ -0,0 +1,19 @@
using Lumina.Text;
namespace Dalamud.Utility;
/// <summary>
/// Provides a temporarily rented <see cref="SeStringBuilder"/> from a shared pool.
/// </summary>
public readonly struct RentedSeStringBuilder() : IDisposable
{
/// <summary>
/// Gets the rented <see cref="SeStringBuilder"/> value from the shared pool.
/// </summary>
public SeStringBuilder Builder { get; } = SeStringBuilder.SharedPool.Get();
/// <summary>
/// Returns the rented <see cref="SeStringBuilder"/> to the shared pool.
/// </summary>
public void Dispose() => SeStringBuilder.SharedPool.Return(this.Builder);
}