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
|
|
@ -157,7 +157,7 @@ public class BOBGump : DynamicGump
|
|||
builder.AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor); // Set
|
||||
|
||||
builder.AddButton(450, 416, 4005, 4007, 4);
|
||||
builder.AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>");
|
||||
builder.AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</BASEFONT>");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Text;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
|
|
@ -82,7 +83,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
AddImage(215, -43, 0xEE40);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
using var sb = ValueStringBuilder.Create(128);
|
||||
|
||||
if (tourney.TourneyType == TourneyType.FreeForAll)
|
||||
{
|
||||
|
|
@ -117,12 +118,13 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if (tourney.EventController != null)
|
||||
{
|
||||
sb.Append(' ').Append(tourney.EventController.Title);
|
||||
sb.Append(' ');
|
||||
sb.Append(tourney.EventController.Title);
|
||||
}
|
||||
|
||||
sb.Append(" Tournament Invitation");
|
||||
|
||||
AddBorderedText(22, 22, 294, 20, sb.ToString().Center(), LabelColor32, BlackColor32);
|
||||
AddBorderedText(22, 22, 294, 20, sb.AsSpan().Center(), LabelColor32, BlackColor32);
|
||||
|
||||
AddBorderedText(
|
||||
22,
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ namespace Server.Engines.ConPVP
|
|||
AddBorderedText(x + 5, y + 5, 325 - 5, sb.ToString(), color, 0);
|
||||
x += 325;
|
||||
|
||||
AddBorderedText(x, y + 5, 40, ar.Spectators.ToString().Center(), color, 0);
|
||||
AddBorderedText(x, y + 5, 40, Html.Center($"{ar.Spectators}"), color, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Server.Gumps;
|
|||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
using Server.Text;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
|
|
@ -92,7 +93,7 @@ namespace Server.Engines.ConPVP
|
|||
AddImage(215, -43, 0xEE40);
|
||||
// AddImage( 330, 141, 0x8BA );
|
||||
|
||||
var sb = new StringBuilder();
|
||||
using var sb = ValueStringBuilder.Create(128);
|
||||
|
||||
if (tourney.TourneyType == TourneyType.FreeForAll)
|
||||
{
|
||||
|
|
@ -127,12 +128,13 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if (tourney.EventController != null)
|
||||
{
|
||||
sb.Append(' ').Append(tourney.EventController.Title);
|
||||
sb.Append(' ');
|
||||
sb.Append(tourney.EventController.Title);
|
||||
}
|
||||
|
||||
sb.Append(" Tournament Signup");
|
||||
|
||||
AddBorderedText(22, 22, 294, 20, sb.ToString().Center(), LabelColor32, BlackColor32);
|
||||
AddBorderedText(22, 22, 294, 20, sb.AsSpan().Center(), LabelColor32, BlackColor32);
|
||||
AddBorderedText(
|
||||
22,
|
||||
50,
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ namespace Server.Engines.ConPVP
|
|||
height - 12 - 2 - 18,
|
||||
400,
|
||||
20,
|
||||
$"Top {lc} of {m_List.Count:N0} duelists, page {page + 1} of {(lc + 14) / 15}".Color(0xFFC000)
|
||||
Html.Color($"Top {lc} of {m_List.Count:N0} duelists, page {page + 1} of {(lc + 14) / 15}", 0xFFC000)
|
||||
);
|
||||
|
||||
AddColumnHeader(75, "Rank");
|
||||
|
|
@ -174,7 +174,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
// AddImageTiled( 21, y + 6, width, 8, 0x2617 );
|
||||
AddImageTiled(x + 3, y + 4, width, 11, 0x806);
|
||||
AddBorderedText(x, y, 115, level.ToString().Center(), 0xFFFFFF, 0);
|
||||
AddBorderedText(x, y, 115, Html.Center($"{level}"), 0xFFFFFF, 0);
|
||||
x += 115;
|
||||
|
||||
var mob = entry.Mobile;
|
||||
|
|
@ -189,10 +189,10 @@ namespace Server.Engines.ConPVP
|
|||
AddBorderedText(x + 5, y, 115 - 5, mob.Name, 0xFFFFFF, 0);
|
||||
x += 115;
|
||||
|
||||
AddBorderedText(x, y, 60, entry.Wins.ToString().Center(), 0xFFFFFF, 0);
|
||||
AddBorderedText(x, y, 60, Html.Center($"{entry.Wins}"), 0xFFFFFF, 0);
|
||||
x += 60;
|
||||
|
||||
AddBorderedText(x, y, 60, entry.Losses.ToString().Center(), 0xFFFFFF, 0);
|
||||
AddBorderedText(x, y, 60, Html.Center($"{entry.Losses}"), 0xFFFFFF, 0);
|
||||
x += 60;
|
||||
|
||||
// AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Text;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
|
|
@ -51,7 +52,7 @@ namespace Server.Engines.ConPVP
|
|||
AddPage(0);
|
||||
AddBackground(0, 0, 300, 300, 9380);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
using var sb = ValueStringBuilder.Create(128);
|
||||
|
||||
if (tourney.TourneyType == TourneyType.FreeForAll)
|
||||
{
|
||||
|
|
@ -86,12 +87,13 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if (tourney.EventController != null)
|
||||
{
|
||||
sb.Append(' ').Append(tourney.EventController.Title);
|
||||
sb.Append(' ');
|
||||
sb.Append(tourney.EventController.Title);
|
||||
}
|
||||
|
||||
sb.Append(" Tournament Bracket");
|
||||
|
||||
AddHtml(25, 35, 250, 20, sb.ToString().Center());
|
||||
AddHtml(25, 35, 250, 20, sb.AsSpan().Center());
|
||||
|
||||
AddRightArrow(25, 53, ToButtonID(0, 4), "Rules");
|
||||
AddRightArrow(25, 71, ToButtonID(0, 1), "Participants");
|
||||
|
|
@ -278,7 +280,7 @@ namespace Server.Engines.ConPVP
|
|||
?? new List<TourneyParticipant>(tourney.Participants);
|
||||
|
||||
AddLeftArrow(25, 11, ToButtonID(0, 0));
|
||||
AddHtml(25, 35, 250, 20, $"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}".Center());
|
||||
AddHtml(25, 35, 250, 20, Html.Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}"));
|
||||
|
||||
StartPage(out var index, out var count, out var y, 12);
|
||||
|
||||
|
|
@ -347,7 +349,7 @@ namespace Server.Engines.ConPVP
|
|||
AddHtml(25, y, 200, 20, "Log:");
|
||||
y += 20;
|
||||
|
||||
var sb = new StringBuilder();
|
||||
using var sb = ValueStringBuilder.Create();
|
||||
|
||||
for (var i = 0; i < part.Log.Count; ++i)
|
||||
{
|
||||
|
|
@ -364,7 +366,7 @@ namespace Server.Engines.ConPVP
|
|||
sb.Append("Nothing logged yet.");
|
||||
}
|
||||
|
||||
AddHtml(25, y, 250, 150, sb.ToString().Color(BlackColor32), false, true);
|
||||
AddHtml(25, y, 250, 150, sb.AsSpan().Color(BlackColor32), false, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class ElectionManagementGump : Gump
|
|||
AddHtml(145, 35, 100, 20, (candidate.Mobile == null ? "null" : candidate.Mobile.Name).Color(LabelColor));
|
||||
|
||||
AddHtml(45, 55, 100, 20, "Vote Count:".Color(LabelColor));
|
||||
AddHtml(145, 55, 100, 20, candidate.Votes.ToString().Color(LabelColor));
|
||||
AddHtml(145, 55, 100, 20, Html.Color($"{candidate.Votes}", LabelColor));
|
||||
|
||||
AddButton(12, 73, 4005, 4007, 1);
|
||||
AddHtml(45, 75, 100, 20, "Drop Candidate".Color(LabelColor));
|
||||
|
|
@ -88,9 +88,9 @@ public class ElectionManagementGump : Gump
|
|||
AddHtml(x + 2, 140 + idx * 20, 150, 20, mobile.Name.Color(LabelColor));
|
||||
x += 150;
|
||||
}
|
||||
else if (obj is IPAddress)
|
||||
else if (obj is IPAddress ip)
|
||||
{
|
||||
AddHtml(x, 140 + idx * 20, 100, 20, obj.ToString().Center(LabelColor));
|
||||
AddHtml(x, 140 + idx * 20, 100, 20, Html.Center($"{ip}", LabelColor));
|
||||
x += 100;
|
||||
}
|
||||
else if (obj is DateTime time)
|
||||
|
|
@ -106,7 +106,7 @@ public class ElectionManagementGump : Gump
|
|||
}
|
||||
else if (obj is int i1)
|
||||
{
|
||||
AddHtml(x, 140 + idx * 20, 60, 20, $"{i1}%".Center(LabelColor));
|
||||
AddHtml(x, 140 + idx * 20, 60, 20, Html.Center($"{i1}%", LabelColor));
|
||||
x += 60;
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ public class ElectionManagementGump : Gump
|
|||
AddHtml(10, 10, 268, 20, "Election Management".Center(LabelColor));
|
||||
|
||||
AddHtml(45, 35, 100, 20, "Current State:".Color(LabelColor));
|
||||
AddHtml(145, 35, 100, 20, election.State.ToString().Color(LabelColor));
|
||||
AddHtml(145, 35, 100, 20, Html.Color($"{election.State}", LabelColor));
|
||||
|
||||
AddButton(12, 53, 4005, 4007, 1);
|
||||
AddHtml(45, 55, 100, 20, "Transition Time:".Color(LabelColor));
|
||||
|
|
@ -147,7 +147,7 @@ public class ElectionManagementGump : Gump
|
|||
|
||||
AddButton(13, 118 + i * 20, 4005, 4007, 2 + i);
|
||||
AddHtml(47, 120 + i * 20, 150, 20, mob.Name.Color(LabelColor));
|
||||
AddHtml(195, 120 + i * 20, 80, 20, cd.Votes.ToString().Center(LabelColor));
|
||||
AddHtml(195, 120 + i * 20, 80, 20, Html.Center($"{cd.Votes}", LabelColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -200,4 +200,4 @@ public class ElectionManagementGump : Gump
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public sealed class PageResponseGump : StaticGump<PageResponseGump>
|
|||
// <CENTER><U>Ultima Online Help Response</U></CENTER>
|
||||
builder.AddHtmlLocalized(150, 40, 360, 40, 1062610);
|
||||
|
||||
builder.AddHtml(80, 90, 480, 290, $"{_name} tells {_from.Name}: {_text}", true, true);
|
||||
builder.AddHtml(80, 90, 480, 290, $"{_name} tells {_from.Name}: {_text}", background: true, scrollbar: true);
|
||||
|
||||
// Clicking the OKAY button will remove the response you have received.
|
||||
builder.AddHtmlLocalized(80, 390, 480, 40, 1062611);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace Server.Engines.Help
|
|||
10,
|
||||
280,
|
||||
20,
|
||||
$"SPEECH LOG - {playerName} (<i>{playerAccount.FixHtmlFormattable()}</i>)".Center(0xA0A0FF)
|
||||
Html.Center($"SPEECH LOG - {playerName} (<i>{playerAccount.FixHtmlFormattable()}</i>)", 0xA0A0FF)
|
||||
);
|
||||
|
||||
var lastPage = (log.Count - 1) / MaxEntriesPerPage;
|
||||
|
|
|
|||
|
|
@ -693,7 +693,7 @@ namespace Server.Engines.Quests
|
|||
}
|
||||
else
|
||||
{
|
||||
AddHtml(x, y, width, height, message.ToString().Color(color.C16216()), back, scroll);
|
||||
AddHtml(x, y, width, height, Html.Color($"{message}", color.C16216()), back, scroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,8 +167,8 @@ public class SpawnerGump : Gump
|
|||
totalWeight += spawnerEntry.SpawnedProbability;
|
||||
}
|
||||
|
||||
AddHtml(270, 308 + offset, 35, 20, totalSpawns.ToString().Center(0xF4F4F4));
|
||||
AddHtml(308, 308 + offset, 35, 20, totalWeight.ToString().Center(0xF4F4F4));
|
||||
AddHtml(270, 308 + offset, 35, 20, Html.Center($"{totalSpawns}", 0xF4F4F4));
|
||||
AddHtml(308, 308 + offset, 35, 20, Html.Center($"{totalWeight}",0xF4F4F4));
|
||||
|
||||
AddHtml(5, 1, 161, 20, $"<BASEFONT COLOR=#FFEA00>{spawner.Name}</BASEFONT><BASEFONT COLOR={GetCountColor(totalSpawned, spawner.Count)}> ({totalSpawned}/{spawner.Count})</BASEFONT>");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue