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.
This commit is contained in:
parent
598c3c125c
commit
9c2ac2b8ea
12 changed files with 642 additions and 689 deletions
|
|
@ -9,7 +9,7 @@ namespace Server.Guilds
|
|||
{
|
||||
public class GuildRosterGump : BaseGuildListGump<PlayerMobile>
|
||||
{
|
||||
private static readonly InfoField<PlayerMobile>[] m_Fields =
|
||||
private static readonly InfoField<PlayerMobile>[] _fields =
|
||||
[
|
||||
new(1062955, 130, NameComparer.Instance), // Name
|
||||
new(1062956, 80, RankComparer.Instance), // Rank
|
||||
|
|
@ -33,33 +33,30 @@ namespace Server.Guilds
|
|||
ascending,
|
||||
filter,
|
||||
startNumber,
|
||||
m_Fields
|
||||
_fields
|
||||
)
|
||||
{
|
||||
PopulateGump();
|
||||
}
|
||||
|
||||
public override void PopulateGump()
|
||||
protected override void BuildListExtras(ref DynamicGumpBuilder builder)
|
||||
{
|
||||
base.PopulateGump();
|
||||
|
||||
AddHtmlLocalized(266, 43, 110, 26, 1062974, 0xF); // Guild Roster
|
||||
builder.AddHtmlLocalized(266, 43, 110, 26, 1062974, 0xF); // Guild Roster
|
||||
}
|
||||
|
||||
public override void DrawEndingEntry(int itemNumber)
|
||||
protected override void DrawEndingEntry(ref DynamicGumpBuilder builder, int itemNumber)
|
||||
{
|
||||
AddBackground(225, 148 + itemNumber * 28, 150, 26, 0x2486);
|
||||
AddButton(230, 153 + itemNumber * 28, 0x845, 0x846, 8);
|
||||
AddHtmlLocalized(255, 151 + itemNumber * 28, 110, 26, 1062992, 0x0); // Invite Player
|
||||
builder.AddBackground(225, 148 + itemNumber * 28, 150, 26, 0x2486);
|
||||
builder.AddButton(230, 153 + itemNumber * 28, 0x845, 0x846, 8);
|
||||
builder.AddHtmlLocalized(255, 151 + itemNumber * 28, 110, 26, 1062992, 0x0); // Invite Player
|
||||
}
|
||||
|
||||
protected override TextDefinition[] GetValuesFor(PlayerMobile pm, int aryLength)
|
||||
{
|
||||
var defs = new TextDefinition[aryLength];
|
||||
|
||||
var name = $"{pm.Name}{(player.GuildFealty == pm && player.GuildFealty != guild.Leader ? " *" : "")}";
|
||||
var name = $"{pm.Name}{(Player.GuildFealty == pm && Player.GuildFealty != Guild.Leader ? " *" : "")}";
|
||||
|
||||
if (pm == player)
|
||||
if (pm == Player)
|
||||
{
|
||||
name = name.Color(0x006600);
|
||||
}
|
||||
|
|
@ -86,20 +83,14 @@ namespace Server.Guilds
|
|||
return !pm.Name.InsensitiveContains(filter);
|
||||
}
|
||||
|
||||
public override Gump GetResentGump(
|
||||
PlayerMobile pm, Guild g, IComparer<PlayerMobile> comparer, bool ascending,
|
||||
string filter, int startNumber
|
||||
) =>
|
||||
new GuildRosterGump(pm, g, comparer, ascending, filter, startNumber);
|
||||
|
||||
public override Gump GetObjectInfoGump(PlayerMobile pm, Guild g, PlayerMobile o) =>
|
||||
public override BaseGump GetObjectInfoGump(PlayerMobile pm, Guild g, PlayerMobile o) =>
|
||||
new GuildMemberInfoGump(pm, g, o, false, false);
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
base.OnResponse(sender, info);
|
||||
|
||||
if (sender.Mobile is not PlayerMobile pm || !IsMember(pm, guild))
|
||||
if (sender.Mobile is not PlayerMobile pm || !IsMember(pm, Guild))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -109,7 +100,7 @@ namespace Server.Guilds
|
|||
if (pm.GuildRank.GetFlag(RankFlags.CanInvitePlayer))
|
||||
{
|
||||
pm.SendLocalizedMessage(1063048); // Whom do you wish to invite into your guild?
|
||||
pm.BeginTarget(-1, false, TargetFlags.None, InvitePlayer_Callback, guild);
|
||||
pm.BeginTarget(-1, false, TargetFlags.None, InvitePlayer_Callback, Guild);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -129,7 +120,7 @@ namespace Server.Guilds
|
|||
var guildFaction = guildState?.Faction;
|
||||
var targetFaction = targetState?.Faction;
|
||||
|
||||
if (pm == null || !IsMember(pm, guild) || !pm.GuildRank.GetFlag(RankFlags.CanInvitePlayer))
|
||||
if (pm == null || !IsMember(pm, Guild) || !pm.GuildRank.GetFlag(RankFlags.CanInvitePlayer))
|
||||
{
|
||||
from.SendLocalizedMessage(503301); // You don't have permission to do that.
|
||||
}
|
||||
|
|
@ -181,7 +172,7 @@ namespace Server.Guilds
|
|||
else
|
||||
{
|
||||
pm.SendLocalizedMessage(1063053, targ.Name); // You invite ~1_val~ to join your guild.
|
||||
targ.SendGump(new GuildInvitationRequest(targ, guild, pm));
|
||||
targ.SendGump(new GuildInvitationRequest(targ, Guild, pm));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue