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
|
|
@ -7,40 +7,42 @@ namespace Server.Guilds
|
|||
{
|
||||
public class WarDeclarationGump : BaseGuildGump
|
||||
{
|
||||
private readonly Guild m_Other;
|
||||
private readonly Guild _other;
|
||||
|
||||
public WarDeclarationGump(PlayerMobile pm, Guild g, Guild otherGuild) : base(pm, g)
|
||||
public WarDeclarationGump(PlayerMobile pm, Guild g, Guild otherGuild) : base(pm, g) => _other = otherGuild;
|
||||
|
||||
protected override bool ShowTabStrip => false;
|
||||
|
||||
protected override void BuildContent(ref DynamicGumpBuilder builder)
|
||||
{
|
||||
m_Other = otherGuild;
|
||||
var war = g.FindPendingWar(otherGuild);
|
||||
var war = Guild.FindPendingWar(_other);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 500, 340, 0x24AE);
|
||||
AddBackground(65, 50, 370, 30, 0x2486);
|
||||
AddHtmlLocalized(75, 55, 370, 26, 1062979, 0x3C00); // <div align=center><i>Declaration of War</i></div>
|
||||
AddImage(410, 45, 0x232C);
|
||||
AddHtmlLocalized(65, 95, 200, 20, 1063009, 0x14AF); // <i>Duration of War</i>
|
||||
AddHtmlLocalized(65, 120, 400, 20, 1063010, 0x0); // Enter the number of hours the war will last.
|
||||
AddBackground(65, 150, 40, 30, 0x2486);
|
||||
AddTextEntry(70, 154, 50, 30, 0x481, 10, war?.WarLength.Hours.ToString() ?? "0");
|
||||
AddHtmlLocalized(65, 195, 200, 20, 1063011, 0x14AF); // <i>Victory Condition</i>
|
||||
AddHtmlLocalized(65, 220, 400, 20, 1063012, 0x0); // Enter the winning number of kills.
|
||||
AddBackground(65, 250, 40, 30, 0x2486);
|
||||
AddTextEntry(70, 254, 50, 30, 0x481, 11, war?.MaxKills.ToString() ?? "0");
|
||||
AddBackground(190, 270, 130, 26, 0x2486);
|
||||
AddButton(195, 275, 0x845, 0x846, 0);
|
||||
AddHtmlLocalized(220, 273, 90, 26, 1006045, 0x0); // Cancel
|
||||
AddBackground(330, 270, 130, 26, 0x2486);
|
||||
AddButton(335, 275, 0x845, 0x846, 1);
|
||||
AddHtmlLocalized(360, 273, 90, 26, 1062989, 0x5000); // Declare War!
|
||||
builder.AddBackground(0, 0, 500, 340, 0x24AE);
|
||||
builder.AddBackground(65, 50, 370, 30, 0x2486);
|
||||
// <div align=center><i>Declaration of War</i></div>
|
||||
builder.AddHtmlLocalized(75, 55, 370, 26, 1062979, 0x3C00);
|
||||
builder.AddImage(410, 45, 0x232C);
|
||||
builder.AddHtmlLocalized(65, 95, 200, 20, 1063009, 0x14AF); // <i>Duration of War</i>
|
||||
builder.AddHtmlLocalized(65, 120, 400, 20, 1063010, 0x0); // Enter the number of hours the war will last.
|
||||
builder.AddBackground(65, 150, 40, 30, 0x2486);
|
||||
builder.AddTextEntry(70, 154, 50, 30, 0x481, 10, $"{war?.WarLength.Hours ?? 0}");
|
||||
builder.AddHtmlLocalized(65, 195, 200, 20, 1063011, 0x14AF); // <i>Victory Condition</i>
|
||||
builder.AddHtmlLocalized(65, 220, 400, 20, 1063012, 0x0); // Enter the winning number of kills.
|
||||
builder.AddBackground(65, 250, 40, 30, 0x2486);
|
||||
builder.AddTextEntry(70, 254, 50, 30, 0x481, 11, $"{war?.MaxKills ?? 0}");
|
||||
builder.AddBackground(190, 270, 130, 26, 0x2486);
|
||||
builder.AddButton(195, 275, 0x845, 0x846, 0);
|
||||
builder.AddHtmlLocalized(220, 273, 90, 26, 1006045, 0x0); // Cancel
|
||||
builder.AddBackground(330, 270, 130, 26, 0x2486);
|
||||
builder.AddButton(335, 275, 0x845, 0x846, 1);
|
||||
builder.AddHtmlLocalized(360, 273, 90, 26, 1062989, 0x5000); // Declare War!
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
var pm = sender.Mobile as PlayerMobile;
|
||||
|
||||
if (!IsMember(pm, guild))
|
||||
if (!IsMember(pm, Guild))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -51,45 +53,38 @@ namespace Server.Guilds
|
|||
{
|
||||
case 1:
|
||||
{
|
||||
var alliance = guild.Alliance;
|
||||
var otherAlliance = m_Other.Alliance;
|
||||
var alliance = Guild.Alliance;
|
||||
var otherAlliance = _other.Alliance;
|
||||
|
||||
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
|
||||
{
|
||||
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
|
||||
}
|
||||
else if (alliance != null && alliance.Leader != guild)
|
||||
else if (alliance != null && alliance.Leader != Guild)
|
||||
{
|
||||
pm.SendLocalizedMessage(
|
||||
1063239,
|
||||
$"{guild.Name}\t{alliance.Name}"
|
||||
); // ~1_val~ is not the leader of the ~2_val~ alliance.
|
||||
pm.SendLocalizedMessage(
|
||||
1070707,
|
||||
alliance.Leader.Name
|
||||
); // You need to negotiate via ~1_val~ instead.
|
||||
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
||||
pm.SendLocalizedMessage(1063239, $"{Guild.Name}\t{alliance.Name}");
|
||||
// You need to negotiate via ~1_val~ instead.
|
||||
pm.SendLocalizedMessage(1070707, alliance.Leader.Name);
|
||||
}
|
||||
else if (otherAlliance != null && otherAlliance.Leader != m_Other)
|
||||
else if (otherAlliance != null && otherAlliance.Leader != _other)
|
||||
{
|
||||
pm.SendLocalizedMessage(
|
||||
1063239,
|
||||
$"{m_Other.Name}\t{otherAlliance.Name}"
|
||||
); // ~1_val~ is not the leader of the ~2_val~ alliance.
|
||||
pm.SendLocalizedMessage(
|
||||
1070707,
|
||||
otherAlliance.Leader.Name
|
||||
); // You need to negotiate via ~1_val~ instead.
|
||||
// ~1_val~ is not the leader of the ~2_val~ alliance.
|
||||
pm.SendLocalizedMessage(1063239, $"{_other.Name}\t{otherAlliance.Name}");
|
||||
// You need to negotiate via ~1_val~ instead.
|
||||
pm.SendLocalizedMessage(1070707, otherAlliance.Leader.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
var activeWar = guild.FindActiveWar(m_Other);
|
||||
var activeWar = Guild.FindActiveWar(_other);
|
||||
|
||||
if (activeWar == null)
|
||||
{
|
||||
var war = guild.FindPendingWar(m_Other);
|
||||
var otherWar = m_Other.FindPendingWar(guild);
|
||||
var war = Guild.FindPendingWar(_other);
|
||||
var otherWar = _other.FindPendingWar(Guild);
|
||||
|
||||
// Note: OSI differs from what it says on website. unlimited war = 0 kills/ 0 hrs. Not > 999. (sidenote: they both cap at 65535, 7.5 years, but, still.)
|
||||
// Note: OSI differs from what it says on website. unlimited war = 0 kills/0 hrs.
|
||||
// Not > 999. (sidenote: they both cap at 65535, 7.5 years, but, still.)
|
||||
var tKills = info.GetTextEntry(11);
|
||||
var tWarLength = info.GetTextEntry(10);
|
||||
|
||||
|
|
@ -110,7 +105,7 @@ namespace Server.Guilds
|
|||
}
|
||||
else
|
||||
{
|
||||
guild.PendingWars.Add(new WarDeclaration(guild, m_Other, maxKills, warLength, true));
|
||||
Guild.PendingWars.Add(new WarDeclaration(Guild, _other, maxKills, warLength, true));
|
||||
}
|
||||
|
||||
if (otherWar != null)
|
||||
|
|
@ -121,7 +116,7 @@ namespace Server.Guilds
|
|||
}
|
||||
else
|
||||
{
|
||||
m_Other.PendingWars.Add(new WarDeclaration(m_Other, guild, maxKills, warLength, false));
|
||||
_other.PendingWars.Add(new WarDeclaration(_other, Guild, maxKills, warLength, false));
|
||||
}
|
||||
|
||||
if (war != null)
|
||||
|
|
@ -130,20 +125,22 @@ namespace Server.Guilds
|
|||
}
|
||||
else
|
||||
{
|
||||
m_Other.GuildMessage(
|
||||
// ~1_val~ has proposed a war.
|
||||
_other.GuildMessage(
|
||||
1070781,
|
||||
guild.Alliance != null
|
||||
? guild.Alliance.Name
|
||||
: guild.Name
|
||||
); // ~1_val~ has proposed a war.
|
||||
Guild.Alliance != null
|
||||
? Guild.Alliance.Name
|
||||
: Guild.Name
|
||||
);
|
||||
}
|
||||
|
||||
// War proposal has been sent to ~1_val~.
|
||||
pm.SendLocalizedMessage(
|
||||
1070751,
|
||||
m_Other.Alliance != null
|
||||
? m_Other.Alliance.Name
|
||||
: m_Other.Name
|
||||
); // War proposal has been sent to ~1_val~.
|
||||
_other.Alliance != null
|
||||
? _other.Alliance.Name
|
||||
: _other.Name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +148,7 @@ namespace Server.Guilds
|
|||
}
|
||||
default:
|
||||
{
|
||||
pm.SendGump(new OtherGuildInfo(pm, guild, m_Other));
|
||||
pm.SendGump(new OtherGuildInfo(pm, Guild, _other));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue