fix: Consolidates Color/Center html (#1762)

### Summary
- Fixes bad color in virtual check gump
- Consolidates the Color/Center html strings for all gumps
This commit is contained in:
Kamron Batman 2024-05-07 23:56:32 -07:00 committed by GitHub
parent 05535ec9d1
commit 26dfde19ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
109 changed files with 473 additions and 752 deletions

View file

@ -15,7 +15,6 @@
using System.Collections.Generic;
using Server.Network;
using Server.Utilities;
namespace Server.Gumps;

View file

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System.Drawing;
using ModernUO.Serialization;
using Server.Gumps;
using Server.Network;
@ -268,10 +269,7 @@ public sealed partial class VirtualCheck : Item
AddImage(10, 8, 113);
AddImage(360, 8, 113);
var title =
$"<BASEFONT COLOR=#FF2F4F4F><CENTER>BANK OF {User.RawName.ToUpper()}</CENTER>";
AddHtml(40, 15, 320, 20, title);
AddHtml(40, 15, 320, 20, $"BANK OF {User.RawName.ToUpper()}".Center(0x2F4F4F));
// Platinum Row
AddBackground(15, 60, 175, 20, 9300);

View file

@ -15,7 +15,6 @@ using Server.Network;
using Server.Prompts;
using Server.Targeting;
using Server.Text;
using Server.Utilities;
using CalcMoves = Server.Movement.Movement;
namespace Server;

View file

@ -19,6 +19,106 @@ namespace Server;
public static class TextDefinitionExtensions
{
public static void AddHtmlText(
this TextDefinition def,
ref DynamicGumpBuilder builder,
int x,
int y,
int width,
int height,
bool back = false,
bool scroll = false,
int numberColor = -1,
int stringColor = -1
)
{
if (def == null)
{
return;
}
if (def.Number > 0)
{
if (numberColor >= 0) // 5 bits per RGB component (15 bit RGB)
{
builder.AddHtmlLocalized(x, y, width, height, def.Number, numberColor, back, scroll);
}
else
{
builder.AddHtmlLocalized(x, y, width, height, def.Number, back, scroll);
}
}
else if (def.String != null)
{
if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB)
{
builder.AddHtml(
x,
y,
width,
height,
def.String.Color(stringColor),
back,
scroll
);
}
else
{
builder.AddHtml(x, y, width, height, def.String, back, scroll);
}
}
}
public static void AddHtmlText(
this TextDefinition def,
ref StaticGumpBuilder builder,
int x,
int y,
int width,
int height,
bool back = false,
bool scroll = false,
int numberColor = -1,
int stringColor = -1
)
{
if (def == null)
{
return;
}
if (def.Number > 0)
{
if (numberColor >= 0) // 5 bits per RGB component (15 bit RGB)
{
builder.AddHtmlLocalized(x, y, width, height, def.Number, numberColor, back, scroll);
}
else
{
builder.AddHtmlLocalized(x, y, width, height, def.Number, back, scroll);
}
}
else if (def.String != null)
{
if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB)
{
builder.AddHtml(
x,
y,
width,
height,
def.String.Color(stringColor),
back,
scroll
);
}
else
{
builder.AddHtml(x, y, width, height, def.String, back, scroll);
}
}
}
public static void AddHtmlText(
this TextDefinition def,
Gump g,
@ -57,7 +157,7 @@ public static class TextDefinitionExtensions
y,
width,
height,
$"<BASEFONT COLOR=#{stringColor:X6}>{def.String}</BASEFONT>",
def.String.Color(stringColor),
back,
scroll
);
@ -102,7 +202,7 @@ public static class TextDefinitionExtensions
y,
width,
height,
$"<BASEFONT COLOR=#{stringColor:X6}>{string.Format(def.String, args)}</BASEFONT>",
string.Format(def.String, args).Color(stringColor),
back,
scroll
);

View file

@ -16,7 +16,7 @@
using System;
using System.Reflection;
namespace Server.Utilities;
namespace Server;
public static class ActivatorExtensions
{

View file

@ -16,7 +16,7 @@
using System;
using System.Reflection;
namespace Server.Utilities;
namespace Server;
public static class EntityActivatorExtensions
{

View file

@ -16,7 +16,7 @@
using System.Runtime.CompilerServices;
using System.Text;
namespace Server.Utilities;
namespace Server;
public static class Html
{
@ -47,6 +47,21 @@ public static class Html
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Center(this string text, string color, int size) => $"<BASEFONT COLOR={color} SIZE={size}><CENTER>{text}</CENTER></BASEFONT>";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Right(this string text) => $"<RIGHT>{text}</RIGHT>";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Right(this string text, int color) => $"<BASEFONT COLOR=#{color:X6}><RIGHT>{text}</RIGHT></BASEFONT>";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Right(this string text, int color, int size) => $"<BASEFONT COLOR=#{color:X6} SIZE={size}><RIGHT>{text}</RIGHT></BASEFONT>";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Right(this string text, string color) => $"<BASEFONT COLOR={color}><RIGHT>{text}</RIGHT></BASEFONT>";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Right(this string text, string color, int size) => $"<BASEFONT COLOR={color} SIZE={size}><RIGHT>{text}</RIGHT></BASEFONT>";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string EscapeHtml(this string input) =>
new StringBuilder(input.Length).Append(input)