feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257)
> [!IMPORTANT] > **Developer Note** > THIS IS A BREAKING CHANGE TO THE NEW API GUMP. > Please give us feedback in [discord ](https://muo.gg/discord) if you have issues, need help, or have ideas for a better API change! ### Summary * Adds support for size/style to dynamic/static builder. * Drastically simplifies the dynamic/static builder api for AddHtml. * Cleans up some legacy gump files.
This commit is contained in:
parent
ea86d5b2a6
commit
7bd5a853a3
40 changed files with 398 additions and 635 deletions
|
|
@ -66,78 +66,46 @@ public ref struct GumpStringsBuilder
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlText(
|
||||
ref RawInterpolatedStringHandler slotKeyHandler, ref RawInterpolatedStringHandler handler, int color, int size = -1,
|
||||
byte fontStyle = 0
|
||||
ref RawInterpolatedStringHandler slotKeyHandler, ref RawInterpolatedStringHandler handler, ReadOnlySpan<char> color = default, int size = -1,
|
||||
byte fontStyle = 0, TextAlignment align = TextAlignment.Left
|
||||
)
|
||||
{
|
||||
SetHtmlText(ref slotKeyHandler, handler.Text, color, size, fontStyle);
|
||||
SetHtmlText(slotKeyHandler.Text, handler.Text, color, size, fontStyle, align);
|
||||
slotKeyHandler.Clear();
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlText(
|
||||
ref RawInterpolatedStringHandler slotKeyHandler, ReadOnlySpan<char> value, int color, int size = -1, byte fontStyle = 0
|
||||
ref RawInterpolatedStringHandler slotKeyHandler, ReadOnlySpan<char> value, ReadOnlySpan<char> color = default, int size = -1, byte fontStyle = 0,
|
||||
TextAlignment align = TextAlignment.Left
|
||||
)
|
||||
{
|
||||
SetHtmlText(slotKeyHandler.Text, value, color, size, fontStyle);
|
||||
SetHtmlText(slotKeyHandler.Text, value, color, size, fontStyle, align);
|
||||
slotKeyHandler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlText(
|
||||
ReadOnlySpan<char> slotKey, ref RawInterpolatedStringHandler handler, int color, int size = -1, byte fontStyle = 0
|
||||
ReadOnlySpan<char> slotKey, ref RawInterpolatedStringHandler handler, ReadOnlySpan<char> color = default, int size = -1, byte fontStyle = 0,
|
||||
TextAlignment align = TextAlignment.Left
|
||||
)
|
||||
{
|
||||
SetHtmlText(slotKey, handler.Text, color, size, fontStyle);
|
||||
SetHtmlText(slotKey, handler.Text, color, size, fontStyle, align);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlText(
|
||||
ReadOnlySpan<char> slotKey, ReadOnlySpan<char> value, int color, int size = -1, byte fontStyle = 0
|
||||
ReadOnlySpan<char> slotKey, ReadOnlySpan<char> value, ReadOnlySpan<char> color = default, int size = -1, byte fontStyle = 0,
|
||||
TextAlignment align = TextAlignment.Left
|
||||
)
|
||||
{
|
||||
var coloredTextHandler = value.Color(color, size, fontStyle);
|
||||
SetStringSlot(slotKey, ref coloredTextHandler);
|
||||
}
|
||||
var arr = STArrayPool<char>.Shared.Rent(Html.BuildCharCount(value, color));
|
||||
var bytesWritten = Html.Build(value, arr.AsSpan(), color, size, fontStyle, align);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlTextCentered(
|
||||
ref RawInterpolatedStringHandler slotKeyHandler, ref RawInterpolatedStringHandler handler, int color = -1,
|
||||
int size = -1, byte fontStyle = 0
|
||||
)
|
||||
{
|
||||
SetHtmlTextCentered(ref slotKeyHandler, handler.Text, color, size, fontStyle);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlTextCentered(
|
||||
ref RawInterpolatedStringHandler slotKeyHandler, ReadOnlySpan<char> value, int color = -1, int size = -1,
|
||||
byte fontStyle = 0
|
||||
)
|
||||
{
|
||||
SetHtmlTextCentered(slotKeyHandler.Text, value, color, size, fontStyle);
|
||||
slotKeyHandler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlTextCentered(
|
||||
ReadOnlySpan<char> slotKey, ref RawInterpolatedStringHandler handler, int color = -1, int size = -1,
|
||||
byte fontStyle = 0
|
||||
)
|
||||
{
|
||||
SetHtmlTextCentered(slotKey, handler.Text, color, size, fontStyle);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetHtmlTextCentered(
|
||||
ReadOnlySpan<char> slotKey, ReadOnlySpan<char> value, int color = -1, int size = -1, byte fontStyle = 0
|
||||
)
|
||||
{
|
||||
var coloredTextHandler = value.Center(color, size, fontStyle);
|
||||
SetStringSlot(slotKey, ref coloredTextHandler);
|
||||
SetStringSlot(slotKey, arr.AsSpan(0, bytesWritten));
|
||||
STArrayPool<char>.Shared.Return(arr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue