fix: Adds missing string interpolation handler for SetStringSlot (#2123)

This commit is contained in:
Kamron Batman 2025-02-13 19:30:47 -08:00 committed by GitHub
parent 899146dcb7
commit 6d7b1b8bee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 7 deletions

View file

@ -71,6 +71,14 @@ public ref struct GumpStringsBuilder
handler.Clear();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetStringSlot(ref RawInterpolatedStringHandler slotKeyHandler, ref RawInterpolatedStringHandler handler)
{
SetStringSlot(slotKeyHandler.Text, handler.Text);
slotKeyHandler.Clear();
handler.Clear();
}
public void SetStringSlot(ReadOnlySpan<char> slotKey, ReadOnlySpan<char> text)
{
var hash = HashUtility.ComputeHash64(slotKey);

View file

@ -1,3 +1,4 @@
using System;
using Server.Mobiles;
using Server.Network;
@ -39,7 +40,8 @@ public class PetResurrectGump : StaticGump<PetResurrectGump>
protected override void BuildStrings(ref GumpStringsBuilder builder)
{
builder.SetStringSlot("petName", $"<CENTER>{_pet.Name}</CENTER>");
var petNameText = _pet.Name.AsSpan().Center();
builder.SetStringSlot("petName", ref petNameText);
}
public override void OnResponse(NetState state, in RelayInfo info)

View file

@ -88,7 +88,8 @@ public abstract class StaticWarningGump<T> : StaticGump<T> where T : StaticWarni
protected sealed override void BuildStrings(ref GumpStringsBuilder builder)
{
builder.SetStringSlot("content", Content.Color(ContentColor));
var contentText = Content.AsSpan().Color(ContentColor);
builder.SetStringSlot("content", ref contentText);
}
public override void OnResponse(NetState sender, in RelayInfo info) => _callback?.Invoke(info.ButtonID == 1);

View file

@ -56,8 +56,8 @@ public class TithingGump : StaticGump<TithingGump>
// Just in case
_offer = Math.Clamp(_offer, 0, totalGold);
builder.SetStringSlot("goldOffer", (totalGold - _offer).ToString("N0"));
builder.SetStringSlot("titheOffer", _offer.ToString("N0"));
builder.SetStringSlot("goldOffer", $"{totalGold - _offer:N0}");
builder.SetStringSlot("titheOffer", $"{_offer:N0}");
}
public override void OnResponse(NetState sender, in RelayInfo info)