ModernUO/Projects/UOContent/Engines/ConPVP/Gumps/BeginGump.cs
Kamron Batman a74c7f9d4e
perf: Migrates ConPVP lobby gumps from legacy Gump. (#2423)
## Summary

Migrates 14 ConPVP lobby/tournament gumps from legacy `Gump` to modern `DynamicGump`/`StaticGump<T>`. Layouts move into `BuildLayout(ref DynamicGumpBuilder)`, constructors become private, and validation moves into static `DisplayTo` entry points (empty-gump rule).

**Per-gump base type decisions:**

- `BeginGump` → `StaticGump<BeginGump>`: layout is fully fixed (no dynamic content). All other gumps below are `DynamicGump` because they bake dynamic player names, guild abbreviations, ruleset titles, arena names, tournament participant names, ladder rankings, or per-instance rule modifications. Per the cliloc/dynamic-text rule, dynamic content forces `DynamicGump`.
- `ReadyGump`, `ReadyUpGump` → `DynamicGump` (per-instance participant rosters).
- `AcceptDuelGump`, `AcceptTeamGump`, `ConfirmSignupGump` → `DynamicGump` (challenger/registrar/team names, dynamic rule modifications).
- `PickRulesetGump`, `RulesetGump` → `DynamicGump` (ruleset titles and option labels per instance).
- `ParticipantGump`, `DuelContextGump` → `DynamicGump` (player rosters/team labels).
- `LadderGump` → `DynamicGump` (ladder entries: ranks, levels, guild abbrs, names, wins/losses).
- `ArenaGump` → `DynamicGump` (arena names with active player names).
- `PreferencesGump` → `DynamicGump` (arena name list).
- `TournamentBracketGump` (~1k LOC) → `DynamicGump`. The whole gump is one type-switched view that re-renders on every button press across `Index`, `Rules_Info`, `Participant_List`, `Participant_Info`, `Round_List`, `Round_Info`, `Match_Info`, `Player_Info`. All branches bake per-instance content.

**Refresh-via-this conversions (the big perf wins):**

- `LadderGump`: page +/- now mutates `_page` and calls `from.SendGump(this)` instead of allocating a new `LadderGump`.
- `PickRulesetGump`: ruleset apply / flavor toggle now refreshes via `this`.
- `ParticipantGump`: increase/decrease team size, remove player, target failure all refresh via `this`.
- `DuelContextGump`: failed-start and add-participant refresh via `this`.
- `ConfirmSignupGump`: every signup-validation rejection branch in `OnResponse` and every `AddPlayer_OnTarget` rejection branch refreshes via `this` (was allocating a new gump per branch).
- `TournamentBracketGump`: every navigation button (back/forward, type change, page change, drill-down) mutates `_type`/`_object`/`_list`/`_page` and refreshes via `this`. Previously each click allocated a new 1k LOC gump.

All gumps are `Singleton`, use private constructors with static `DisplayTo` entry points that null-check `NetState` before allocation. External callers in `DuelContext`, `TournamentBracketItem`, `TournamentController`, `TournamentSignupItem`, and the cross-references between `AcceptDuelGump`/`ParticipantGump`/`AcceptTeamGump`/`ConfirmSignupGump` are all updated to use `DisplayTo`. Legacy `m_X` fields renamed to `_x` per coding standards.
2026-05-03 01:06:04 -07:00

65 lines
2.1 KiB
C#

using Server.Gumps;
namespace Server.Engines.ConPVP;
public class BeginGump : StaticGump<BeginGump>
{
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000008;
public override bool Singleton => true;
private BeginGump() : base(50, 50)
{
}
public static void DisplayTo(Mobile from, int count)
{
if (from?.NetState == null)
{
return;
}
from.SendGump(new BeginGump());
}
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddPage();
const int offset = 50;
builder.AddBackground(1, 1, 398, 202 - offset, 3600);
builder.AddImageTiled(16, 15, 369, 173 - offset, 3604);
builder.AddAlphaRegion(16, 15, 369, 173 - offset);
builder.AddImage(215, -43, 0xEE40);
var duelCountdownBlack = "Duel Countdown".Center(BlackColor32);
builder.AddHtml(22 - 1, 22, 294, 20, duelCountdownBlack);
builder.AddHtml(22 + 1, 22, 294, 20, duelCountdownBlack);
builder.AddHtml(22, 22 - 1, 294, 20, duelCountdownBlack);
builder.AddHtml(22, 22 + 1, 294, 20, duelCountdownBlack);
builder.AddHtml(22, 22, 294, 20, "Duel Countdown".Center(LabelColor32));
var beginMessageBlack =
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends."
.Color(BlackColor32);
builder.AddHtml(22 - 1, 50, 294, 80, beginMessageBlack);
builder.AddHtml(22 + 1, 50, 294, 80, beginMessageBlack);
builder.AddHtml(22, 50 - 1, 294, 80, beginMessageBlack);
builder.AddHtml(22, 50 + 1, 294, 80, beginMessageBlack);
builder.AddHtml(
22,
50,
294,
80,
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends."
.Color(0xFFCC66)
);
builder.AddButton(314 - 50, 157 - offset, 247, 248, 1);
}
}