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
|
|
@ -1035,7 +1035,7 @@ namespace Server.Gumps
|
|||
|
||||
for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < m_List.Count; ++i, ++index)
|
||||
{
|
||||
AddHtml(18, 243 + i * 22, 114, 20, m_List[index].ToString().Color(LabelColor32));
|
||||
AddHtml(18, 243 + i * 22, 114, 20, Html.Color($"{m_List[index]}", LabelColor32));
|
||||
AddButton(130, 242 + i * 22, 0xFA2, 0xFA4, GetButtonID(8, index));
|
||||
AddButton(160, 242 + i * 22, 0xFA8, 0xFAA, GetButtonID(9, index));
|
||||
AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(10, index));
|
||||
|
|
@ -1237,7 +1237,7 @@ namespace Server.Gumps
|
|||
break;
|
||||
}
|
||||
|
||||
AddHtml(10, 125, 400, 20, firewallEntry.ToString().Center(LabelColor32));
|
||||
AddHtml(10, 125, 400, 20, Html.Center($"{firewallEntry}", LabelColor32));
|
||||
|
||||
AddButtonLabeled(20, 150, GetButtonID(6, 3), "Remove");
|
||||
|
||||
|
|
|
|||
|
|
@ -78,114 +78,33 @@ public ref struct DynamicGumpBuilder
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ReadOnlySpan<char> text,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
int x, int y, int width, int height, ReadOnlySpan<char> text, ReadOnlySpan<char> color = default, int size = -1, byte fontStyle = 0,
|
||||
TextAlignment align = TextAlignment.Left, bool background = false, bool scrollbar = false
|
||||
)
|
||||
{
|
||||
WriteInternalizedString(text);
|
||||
if (color.Length > 0 || size != -1 || fontStyle != 0 || align != TextAlignment.Left)
|
||||
{
|
||||
var arr = STArrayPool<char>.Shared.Rent(Html.BuildCharCount(text, color));
|
||||
var bytesWritten = Html.Build(text, arr.AsSpan(), color, size, fontStyle, align);
|
||||
|
||||
WriteInternalizedString(arr.AsSpan(0, bytesWritten));
|
||||
STArrayPool<char>.Shared.Return(arr);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteInternalizedString(text);
|
||||
}
|
||||
|
||||
_gumpBuilder.AddHtml(x, y, width, height, _stringsCount++, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x, int y, int width, int height, ref RawInterpolatedStringHandler handler,
|
||||
bool background = false, bool scrollbar = false
|
||||
int x, int y, int width, int height, ref RawInterpolatedStringHandler handler, ReadOnlySpan<char> color = default, int size = -1,
|
||||
byte fontStyle = 0, TextAlignment align = TextAlignment.Left, bool background = false, bool scrollbar = false
|
||||
)
|
||||
{
|
||||
AddHtml(x, y, width, height, handler.Text, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ReadOnlySpan<char> text,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var handler = text.Color(color);
|
||||
AddHtml(x, y, width, height, ref handler, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ref RawInterpolatedStringHandler handler,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
AddHtml(x, y, width, height, color, handler.Text, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x, int y, int width, int height, ReadOnlySpan<char> text, bool background = false, bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var handler = text.Center();
|
||||
AddHtml(x, y, width, height, ref handler, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ref RawInterpolatedStringHandler handler,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
AddHtmlCentered(x, y, width, height, handler.Text, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ReadOnlySpan<char> text,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var handler = text.Center(color);
|
||||
AddHtml(x, y, width, height, ref handler, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ref RawInterpolatedStringHandler handler,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
AddHtmlCentered(x, y, width, height, color, handler.Text, background, scrollbar);
|
||||
AddHtml(x, y, width, height, handler.Text, color, size, fontStyle, align, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
|
|
@ -201,14 +120,7 @@ public ref struct DynamicGumpBuilder
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlLocalized(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int number,
|
||||
ReadOnlySpan<char> args,
|
||||
int color,
|
||||
bool background = false,
|
||||
int x, int y, int width, int height, int number, ReadOnlySpan<char> args, int color, bool background = false,
|
||||
bool scrollbar = false
|
||||
) => _gumpBuilder.AddHtmlLocalized(x, y, width, height, number, args, color, background, scrollbar);
|
||||
|
||||
|
|
@ -232,18 +144,8 @@ public ref struct DynamicGumpBuilder
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddImageTiledButton(
|
||||
int x,
|
||||
int y,
|
||||
int normalId,
|
||||
int pressedId,
|
||||
int buttonId,
|
||||
GumpButtonType type,
|
||||
int param,
|
||||
int itemId,
|
||||
int hue,
|
||||
int width,
|
||||
int height,
|
||||
int localizedTooltip = -1
|
||||
int x, int y, int normalId, int pressedId, int buttonId, GumpButtonType type, int param, int itemId, int hue,
|
||||
int width, int height, int localizedTooltip = -1
|
||||
) => _gumpBuilder.AddImageTiledButton(
|
||||
x, y, normalId, pressedId, buttonId, type, param, itemId, hue, width, height, localizedTooltip
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2023 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Grid.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Gumps;
|
||||
|
||||
public enum GridHues
|
||||
{
|
||||
White = 2049, // Change to 0x480 if you have old hues.mul
|
||||
Black = 0,
|
||||
}
|
||||
|
||||
public static class GridColors
|
||||
{
|
||||
public const string Gold = "#ffc959";
|
||||
public const string White = "#ffffff";
|
||||
public const string Blue = "#1D63DC";
|
||||
public const string LightBlue = "#7799EE";
|
||||
public const string Green = "#80E732";
|
||||
public const string Orange = "#F28B00";
|
||||
public const string Purple = "#F3ACF6";
|
||||
public const string Red = "#B52B2D";
|
||||
public const string LightGreen = "#E6FFC0";
|
||||
public const string Yellow = "#FFFFBB";
|
||||
}
|
||||
|
||||
public class ListItem
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Index { get; set; }
|
||||
public Col[] Cols { get; set; }
|
||||
}
|
||||
|
||||
public class Col
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int HCenter => X + Width / 2;
|
||||
public int HEnd => X + Width;
|
||||
}
|
||||
|
||||
public class Row
|
||||
{
|
||||
public int Y { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int VCenter => Y + Height / 2;
|
||||
public int VEnd => Y + Height;
|
||||
}
|
||||
|
||||
public class Grid
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Width { get; set; }
|
||||
public List<Col> Columns { get; set; } = new();
|
||||
public List<Row> Rows { get; set; } = new();
|
||||
}
|
||||
|
||||
public class Swap
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public int Size { get; set; }
|
||||
}
|
||||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ public class Gump : BaseGump
|
|||
|
||||
public void AddLabelHtml(int x, int y, int width, int height, string text, string hue, int size = 4, bool center = true)
|
||||
{
|
||||
AddHtml(x, y, width, height, center ? text.Center(hue, size) : text.Color(hue, size));
|
||||
AddHtml(x, y, width, height, Html.Build(text, hue, size, align: center ? TextAlignment.Center : TextAlignment.Left));
|
||||
}
|
||||
|
||||
public void AddLabelCropped(int x, int y, int width, int height, int hue, string text)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2023 - ModernUO Development Team *
|
||||
* Copyright 2019-2025 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: GumpGrid.cs *
|
||||
* *
|
||||
|
|
@ -523,3 +523,63 @@ public class GumpGrid : Gump
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public enum GridHues
|
||||
{
|
||||
White = 2049, // Change to 0x480 if you have old hues.mul
|
||||
Black = 0,
|
||||
}
|
||||
|
||||
public static class GridColors
|
||||
{
|
||||
public const string Gold = "#ffc959";
|
||||
public const string White = "#ffffff";
|
||||
public const string Blue = "#1D63DC";
|
||||
public const string LightBlue = "#7799EE";
|
||||
public const string Green = "#80E732";
|
||||
public const string Orange = "#F28B00";
|
||||
public const string Purple = "#F3ACF6";
|
||||
public const string Red = "#B52B2D";
|
||||
public const string LightGreen = "#E6FFC0";
|
||||
public const string Yellow = "#FFFFBB";
|
||||
}
|
||||
|
||||
public class ListItem
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Index { get; set; }
|
||||
public Col[] Cols { get; set; }
|
||||
}
|
||||
|
||||
public class Col
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int HCenter => X + Width / 2;
|
||||
public int HEnd => X + Width;
|
||||
}
|
||||
|
||||
public class Row
|
||||
{
|
||||
public int Y { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int VCenter => Y + Height / 2;
|
||||
public int VEnd => Y + Height;
|
||||
}
|
||||
|
||||
public class Grid
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Width { get; set; }
|
||||
public List<Col> Columns { get; set; } = new();
|
||||
public List<Row> Rows { get; set; } = new();
|
||||
}
|
||||
|
||||
public class Swap
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public int Size { get; set; }
|
||||
}
|
||||
|
||||
|
|
@ -91,13 +91,7 @@ public ref struct StaticGumpBuilder
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlPlaceholder(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ReadOnlySpan<char> slotKey,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
int x, int y, int width, int height, ReadOnlySpan<char> slotKey, bool background = false, bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var index = _gumpBuilder.AddHtmlPlaceholder(x, y, width, height, background, scrollbar);
|
||||
|
|
@ -106,12 +100,7 @@ public ref struct StaticGumpBuilder
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlPlaceholder(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ref RawInterpolatedStringHandler handler,
|
||||
bool background = false,
|
||||
int x, int y, int width, int height, ref RawInterpolatedStringHandler handler, bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
|
|
@ -121,115 +110,33 @@ public ref struct StaticGumpBuilder
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ReadOnlySpan<char> text,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
int x, int y, int width, int height, ReadOnlySpan<char> text, ReadOnlySpan<char> color = default, int size = -1, byte fontStyle = 0,
|
||||
TextAlignment align = TextAlignment.Left, bool background = false, bool scrollbar = false
|
||||
)
|
||||
{
|
||||
WriteInternalizedString(text);
|
||||
if (color.Length > 0 || size != -1 || fontStyle != 0 || align != TextAlignment.Left)
|
||||
{
|
||||
var arr = STArrayPool<char>.Shared.Rent(Html.BuildCharCount(text, color));
|
||||
var bytesWritten = Html.Build(text, arr.AsSpan(), color, size, fontStyle, align);
|
||||
|
||||
WriteInternalizedString(arr.AsSpan(0, bytesWritten));
|
||||
STArrayPool<char>.Shared.Return(arr);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteInternalizedString(text);
|
||||
}
|
||||
|
||||
_gumpBuilder.AddHtml(x, y, width, height, _stringsCount++, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x, int y, int width, int height, ref RawInterpolatedStringHandler handler,
|
||||
bool background = false, bool scrollbar = false
|
||||
int x, int y, int width, int height, ref RawInterpolatedStringHandler handler, ReadOnlySpan<char> color = default, int size = -1,
|
||||
byte fontStyle = 0, TextAlignment align = TextAlignment.Left, bool background = false, bool scrollbar = false
|
||||
)
|
||||
{
|
||||
AddHtml(x, y, width, height, handler.Text, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ReadOnlySpan<char> text,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var handler = text.Color(color);
|
||||
AddHtml(x, y, width, height, ref handler, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtml(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ref RawInterpolatedStringHandler handler,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
AddHtml(x, y, width, height, color, handler.Text, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x, int y, int width, int height, ReadOnlySpan<char> text, bool background = false, bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var handler = text.Center();
|
||||
AddHtml(x, y, width, height, ref handler, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
ref RawInterpolatedStringHandler handler,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var centerHandler = handler.Text.Center();
|
||||
AddHtml(x, y, width, height, ref centerHandler, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ReadOnlySpan<char> text,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
var handler = text.Center(color);
|
||||
AddHtml(x, y, width, height, ref handler, background, scrollbar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHtmlCentered(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int color,
|
||||
ref RawInterpolatedStringHandler handler,
|
||||
bool background = false,
|
||||
bool scrollbar = false
|
||||
)
|
||||
{
|
||||
AddHtmlCentered(x, y, width, height, color, handler.Text, background, scrollbar);
|
||||
AddHtml(x, y, width, height, handler.Text, color, size, fontStyle, align, background, scrollbar);
|
||||
handler.Clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Server.Gumps
|
|||
var line = 0;
|
||||
|
||||
AddHtml(14, 36 + line * 20, 200, 20, "Address:".Color(LabelColor32));
|
||||
AddHtml(70, 36 + line++ * 20, 200, 20, state.ToString().Color(LabelColor32));
|
||||
AddHtml(70, 36 + line++ * 20, 200, 20, Html.Color($"{state}", LabelColor32));
|
||||
|
||||
AddHtml(14, 36 + line * 20, 200, 20, "Client:".Color(LabelColor32));
|
||||
AddHtml(
|
||||
|
|
@ -75,10 +75,10 @@ namespace Server.Gumps
|
|||
if (m != null)
|
||||
{
|
||||
AddHtml(14, 36 + line * 20, 200, 20, "Mobile:".Color(LabelColor32));
|
||||
AddHtml(72, 36 + line++ * 20, 200, 20, $"{m.Name} ({m.Serial})".Color(LabelColor32));
|
||||
AddHtml(72, 36 + line++ * 20, 200, 20, Html.Color($"{m.Name} ({m.Serial})", LabelColor32));
|
||||
|
||||
AddHtml(14, 36 + line * 20, 200, 20, "Location:".Color(LabelColor32));
|
||||
AddHtml(72, 36 + line++ * 20, 200, 20, $"{m.Location} [{m.Map}]".Color(LabelColor32));
|
||||
AddHtml(72, 36 + line++ * 20, 200, 20, Html.Color($"{m.Location} [{m.Map}]", LabelColor32));
|
||||
|
||||
AddButton(13, 197, 0xFAB, 0xFAD, 1);
|
||||
AddHtml(48, 198, 200, 20, "Send Message".Color(LabelColor32));
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ namespace Server.Guilds
|
|||
}
|
||||
else if (PendingWar)
|
||||
{
|
||||
kills = $"{war.Kills}/{war.MaxKills}".Color(0x990000);
|
||||
time = $"{war.WarLength.Hours:D2}:{DateTime.MinValue + war.WarLength:mm}".Color(0x990000);
|
||||
kills = Html.Color($"{war.Kills}/{war.MaxKills}", 0x990000);
|
||||
time = Html.Color($"{war.WarLength.Hours:D2}:{DateTime.MinValue + war.WarLength:mm}", 0x990000);
|
||||
|
||||
otherWar = m_Other.FindPendingWar(guild);
|
||||
if (otherWar != null)
|
||||
{
|
||||
otherKills = $"{otherWar.Kills}/{otherWar.MaxKills}".Color(0x990000);
|
||||
otherKills = Html.Color($"{otherWar.Kills}/{otherWar.MaxKills}", 0x990000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class PetResurrectGump : StaticGump<PetResurrectGump>
|
|||
|
||||
protected override void BuildStrings(ref GumpStringsBuilder builder)
|
||||
{
|
||||
builder.SetHtmlTextCentered("petName", _pet.Name);
|
||||
builder.SetHtmlText("petName", _pet.Name, align: TextAlignment.Center);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, in RelayInfo info)
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@ public abstract class StaticWarningGump<T> : StaticGump<T> where T : StaticWarni
|
|||
{
|
||||
public virtual int Header => 1060635; // <CENTER>WARNING</CENTER>
|
||||
public virtual int HeaderColor => 0x7800;
|
||||
public virtual int ContentColor => StaticLocalizedContent > 0 ? 0x7F00 : 0xFFC000;
|
||||
public virtual string ContentColor => "#FFC000";
|
||||
public abstract int Width { get; }
|
||||
public abstract int Height { get; }
|
||||
public virtual bool CancelButton => true;
|
||||
|
||||
// If this is overridden, then the content will be localized and cached.
|
||||
public virtual int StaticLocalizedContent => 0;
|
||||
public virtual int StaticLocalizedContentColor => 0x7F00;
|
||||
|
||||
public virtual string Content => null;
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ public abstract class StaticWarningGump<T> : StaticGump<T> where T : StaticWarni
|
|||
width - 20,
|
||||
height - 80,
|
||||
StaticLocalizedContent,
|
||||
(short)ContentColor,
|
||||
StaticLocalizedContentColor,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace Server.Gumps
|
|||
|
||||
var name = FindHouseName(list[i]);
|
||||
|
||||
AddHtml(15, 40 + i % 15 * 20, 20, 20, $"{i + 1}.".Color(White));
|
||||
AddHtml(15, 40 + i % 15 * 20, 20, 20, Html.Color($"{i + 1}.", White));
|
||||
|
||||
if (name.Number > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ public sealed class VirtualCheckGump : Gump, IVirtualCheckGump
|
|||
AddImage(10, 8, 113);
|
||||
AddImage(360, 8, 113);
|
||||
|
||||
AddHtml(40, 15, 320, 20, $"BANK OF {User.RawName.ToUpper()}".Center(0x2F4F4F));
|
||||
AddHtml(40, 15, 320, 20, Html.Center($"BANK OF {User.RawName.ToUpper()}", 0x2F4F4F));
|
||||
|
||||
// Platinum Row
|
||||
AddBackground(15, 60, 175, 20, 9300);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue