ModernUO/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs
Kamron Batman 9c2ac2b8ea
perf: Migrates New Guild System gumps from legacy Gump. (#2422)
## Summary

Migrates the eight concrete New Guild System gumps (CreateGuild, GuildInfo,
GuildMemberInfo, GuildRoster, GuildDiplomacy, WarDeclaration,
GuildAdvancedSearch, GuildInvitationRequest) and three abstract bases
(BaseGuildGump, BaseGuildListGump, OtherGuildInfo) from the legacy `Gump`
class to `DynamicGump`. Layout work moves from constructor-side `AddX(...)`
calls into `BuildLayout(ref DynamicGumpBuilder builder)` — the abstract
`BaseGuildGump` now provides a `BuildContent` callout for shared
tab-strip chrome, and `BaseGuildListGump<T>` adds another
`BuildListExtras` hook so subclasses can paint highlighted titles after
the filter/sort/pagination chrome.

The headline win is the **self-refresh pattern** on the list gumps and
diplomacy advanced search. Previously each filter/sort/back/forward
click allocated a brand new gump via `GetResentGump`. After migration,
those handlers mutate `_filter`, `_startNumber`, `_comparer`, `_ascending`,
or `_display` on the existing gump and call `from.SendGump(this)`,
letting the singleton path in `NetStateGumps.Send` swap in the same
instance with the new layout. The original list is preserved separately
from the per-render filtered/sorted `_displayList`, so refreshes pick up
the latest state without losing the source list.

All guild gumps deal with per-instance dynamic strings (guild names,
member names, war declarations, alliance names), which would defeat
`StaticGump<T>` caching per the cliloc rule, so every concrete subclass
migrates to `DynamicGump`. `AllianceRosterGump` (in `Misc/Guild.cs`)
is a `GuildDiplomacyGump` subclass and inherits the new behavior; its
unused override and stored alliance reference were dropped along with
the now-obsolete `GetResentGump` abstract.
2026-05-03 00:09:22 -07:00

64 lines
2.3 KiB
C#

using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Guilds
{
public class GuildInvitationRequest : BaseGuildGump
{
private readonly PlayerMobile _inviter;
public GuildInvitationRequest(PlayerMobile pm, Guild g, PlayerMobile inviter) : base(pm, g)
{
_inviter = inviter;
}
protected override bool ShowTabStrip => false;
protected override void BuildContent(ref DynamicGumpBuilder builder)
{
builder.AddBackground(0, 0, 350, 170, 0x2422);
// <center>You have been invited to join a guild! (Warning: Accepting will make you attackable!)</center>
builder.AddHtmlLocalized(25, 20, 300, 45, 1062946, 0x0, true);
builder.AddHtml(25, 75, 300, 25, $"<center>{Guild.Name}</center>", background: true);
builder.AddButton(265, 130, 0xF7, 0xF8, 1);
builder.AddButton(195, 130, 0xF2, 0xF1, 0);
builder.AddButton(20, 130, 0xD2, 0xD3, 2);
builder.AddHtmlLocalized(45, 130, 150, 30, 1062943, 0x0); // <i>Ignore Guild Invites</i>
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (Guild.Disbanded || Player.Guild != null)
{
return;
}
switch (info.ButtonID)
{
case 0:
{
// ~1_val~ has declined your invitation to join ~2_val~.
_inviter.SendLocalizedMessage(1063250, $"{Player.Name}\t{Guild.Name}");
break;
}
case 1:
{
Guild.AddMember(Player);
Player.SendLocalizedMessage(1063056, Guild.Name); // You have joined ~1_val~.
// ~1_val~ has accepted your invitation to join ~2_val~.
_inviter.SendLocalizedMessage(1063249, $"{Player.Name}\t{Guild.Name}");
break;
}
case 2:
{
Player.AcceptGuildInvites = false;
Player.SendLocalizedMessage(1070698); // You are now ignoring guild invitations.
break;
}
}
}
}
}