perf: Migrate Old Guild System gumps to DynamicGump (#2420)
## Summary Migrates the Old Guild System (pre-AOS guild stones) gumps from the legacy `Gump` class to `DynamicGump`, following the same pattern used for the Quest gump migration in #2416. All concrete gumps now have private constructors gated by static `DisplayTo` entry points (empty-gump rule), and `Singleton => true` is set across the board so reopening a sibling dialog automatically closes the previous one. **Migrated gumps:** - `GuildGump` - main guild dialog - `GuildmasterGump` - guildmaster functions - `GuildCharterGump` - charter and website display - `GuildWarGump` - warfare status (kept as player-facing) - `GuildWarAdminGump` - war menu (retained as player-facing - reachable from `GuildmasterGump`'s WAR button by guildmasters) - `GuildChangeTypeGump` - Standard/Order/Chaos selection **Abstract bases:** `GuildListGump` and `GuildMobileListGump` keep their shared list-rendering chrome inside a single concrete `BuildLayout` on the abstract class and expose a `protected abstract void BuildHeader(ref DynamicGumpBuilder builder)` hook for subclasses (replacing the old `Design()` override). This mirrors the abstract-base treatment used for the ML quest base in the quest-gump migration PR. **Concrete subclasses migrated alongside the abstract bases:** - `GuildListGump` subclasses: `GuildAcceptWarGump`, `GuildDeclarePeaceGump`, `GuildDeclareWarGump`, `GuildRejectWarGump`, `GuildRescindDeclarationGump` - `GuildMobileListGump` subclasses: `DeclareFealtyGump`, `GrantGuildTitleGump`, `GuildAdminCandidatesGump`, `GuildCandidatesGump`, `GuildDismissGump`, `GuildRosterGump` **Cliloc rule:** Every gump bakes per-instance dynamic content (guild names, member names, war declarations, candidate lists), which would defeat `StaticGump<T>` caching. Per the cliloc rule, all are `DynamicGump`. **External callers updated:** the prompt files (`GuildAbbrvPrompt`, `GuildCharterPrompt`, `GuildDeclareWarPrompt`, `GuildNamePrompt`, `GuildTitlePrompt`, `GuildWebsitePrompt`), `RecruitTarget`, the `Guildstone` item, and the New Guild System `GuildInfoGump`'s Order/Chaos handler all now go through static `DisplayTo` entry points instead of `new XGump(...)`.
This commit is contained in:
parent
70a69d3efe
commit
15e506ffc2
33 changed files with 848 additions and 761 deletions
|
|
@ -4,93 +4,105 @@ using Server.Network;
|
|||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class GuildmasterGump : Gump
|
||||
public class GuildmasterGump : DynamicGump
|
||||
{
|
||||
private readonly Guild m_Guild;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly Guild _guild;
|
||||
|
||||
public GuildmasterGump(Mobile from, Guild guild) : base(20, 30)
|
||||
public override bool Singleton => true;
|
||||
|
||||
private GuildmasterGump(Guild guild) : base(20, 30) => _guild = guild;
|
||||
|
||||
public static void DisplayTo(Mobile from, Guild guild)
|
||||
{
|
||||
m_Mobile = from;
|
||||
m_Guild = guild;
|
||||
if (from?.NetState == null || guild == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Draggable = false;
|
||||
GuildGump.EnsureClosed(from);
|
||||
from.SendGump(new GuildmasterGump(guild));
|
||||
}
|
||||
|
||||
AddPage(0);
|
||||
AddBackground(0, 0, 550, 400, 5054);
|
||||
AddBackground(10, 10, 530, 380, 3000);
|
||||
protected override void BuildLayout(ref DynamicGumpBuilder builder)
|
||||
{
|
||||
builder.SetNoMove();
|
||||
|
||||
AddHtmlLocalized(20, 15, 510, 35, 1011121); // <center>GUILDMASTER FUNCTIONS</center>
|
||||
builder.AddPage();
|
||||
builder.AddBackground(0, 0, 550, 400, 5054);
|
||||
builder.AddBackground(10, 10, 530, 380, 3000);
|
||||
|
||||
AddButton(20, 40, 4005, 4007, 2);
|
||||
AddHtmlLocalized(55, 40, 470, 30, 1011107); // Set the guild name.
|
||||
builder.AddHtmlLocalized(20, 15, 510, 35, 1011121); // <center>GUILDMASTER FUNCTIONS</center>
|
||||
|
||||
AddButton(20, 70, 4005, 4007, 3);
|
||||
AddHtmlLocalized(55, 70, 470, 30, 1011109); // Set the guild's abbreviation.
|
||||
builder.AddButton(20, 40, 4005, 4007, 2);
|
||||
builder.AddHtmlLocalized(55, 40, 470, 30, 1011107); // Set the guild name.
|
||||
|
||||
builder.AddButton(20, 70, 4005, 4007, 3);
|
||||
builder.AddHtmlLocalized(55, 70, 470, 30, 1011109); // Set the guild's abbreviation.
|
||||
|
||||
if (Guild.OrderChaos)
|
||||
{
|
||||
AddButton(20, 100, 4005, 4007, 4);
|
||||
builder.AddButton(20, 100, 4005, 4007, 4);
|
||||
|
||||
switch (m_Guild.Type)
|
||||
switch (_guild.Type)
|
||||
{
|
||||
case GuildType.Regular:
|
||||
{
|
||||
AddHtmlLocalized(55, 100, 470, 30, 1013059); // Change guild type: Currently Standard
|
||||
builder.AddHtmlLocalized(55, 100, 470, 30, 1013059); // Change guild type: Currently Standard
|
||||
break;
|
||||
}
|
||||
case GuildType.Order:
|
||||
{
|
||||
AddHtmlLocalized(55, 100, 470, 30, 1013057); // Change guild type: Currently Order
|
||||
builder.AddHtmlLocalized(55, 100, 470, 30, 1013057); // Change guild type: Currently Order
|
||||
break;
|
||||
}
|
||||
case GuildType.Chaos:
|
||||
{
|
||||
AddHtmlLocalized(55, 100, 470, 30, 1013058); // Change guild type: Currently Chaos
|
||||
builder.AddHtmlLocalized(55, 100, 470, 30, 1013058); // Change guild type: Currently Chaos
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddButton(20, 130, 4005, 4007, 5);
|
||||
AddHtmlLocalized(55, 130, 470, 30, 1011112); // Set the guild's charter.
|
||||
builder.AddButton(20, 130, 4005, 4007, 5);
|
||||
builder.AddHtmlLocalized(55, 130, 470, 30, 1011112); // Set the guild's charter.
|
||||
|
||||
AddButton(20, 160, 4005, 4007, 6);
|
||||
AddHtmlLocalized(55, 160, 470, 30, 1011113); // Dismiss a member.
|
||||
builder.AddButton(20, 160, 4005, 4007, 6);
|
||||
builder.AddHtmlLocalized(55, 160, 470, 30, 1011113); // Dismiss a member.
|
||||
|
||||
AddButton(20, 190, 4005, 4007, 7);
|
||||
AddHtmlLocalized(55, 190, 470, 30, 1011114); // Go to the WAR menu.
|
||||
builder.AddButton(20, 190, 4005, 4007, 7);
|
||||
builder.AddHtmlLocalized(55, 190, 470, 30, 1011114); // Go to the WAR menu.
|
||||
|
||||
if (m_Guild.Candidates.Count > 0)
|
||||
if (_guild.Candidates.Count > 0)
|
||||
{
|
||||
AddButton(20, 220, 4005, 4007, 8);
|
||||
AddHtmlLocalized(55, 220, 470, 30, 1013056); // Administer the list of candidates
|
||||
builder.AddButton(20, 220, 4005, 4007, 8);
|
||||
builder.AddHtmlLocalized(55, 220, 470, 30, 1013056); // Administer the list of candidates
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(20, 220, 4020);
|
||||
AddHtmlLocalized(55, 220, 470, 30, 1013031); // There are currently no candidates for membership.
|
||||
builder.AddImage(20, 220, 4020);
|
||||
builder.AddHtmlLocalized(55, 220, 470, 30, 1013031); // There are currently no candidates for membership.
|
||||
}
|
||||
|
||||
AddButton(20, 250, 4005, 4007, 9);
|
||||
AddHtmlLocalized(55, 250, 470, 30, 1011117); // Set the guildmaster's title.
|
||||
builder.AddButton(20, 250, 4005, 4007, 9);
|
||||
builder.AddHtmlLocalized(55, 250, 470, 30, 1011117); // Set the guildmaster's title.
|
||||
|
||||
AddButton(20, 280, 4005, 4007, 10);
|
||||
AddHtmlLocalized(55, 280, 470, 30, 1011118); // Grant a title to another member.
|
||||
builder.AddButton(20, 280, 4005, 4007, 10);
|
||||
builder.AddHtmlLocalized(55, 280, 470, 30, 1011118); // Grant a title to another member.
|
||||
|
||||
AddButton(20, 310, 4005, 4007, 11);
|
||||
AddHtmlLocalized(55, 310, 470, 30, 1011119); // Move this guildstone.
|
||||
builder.AddButton(20, 310, 4005, 4007, 11);
|
||||
builder.AddHtmlLocalized(55, 310, 470, 30, 1011119); // Move this guildstone.
|
||||
|
||||
AddButton(20, 360, 4005, 4007, 1);
|
||||
AddHtmlLocalized(55, 360, 245, 30, 1011120); // Return to the main menu.
|
||||
builder.AddButton(20, 360, 4005, 4007, 1);
|
||||
builder.AddHtmlLocalized(55, 360, 245, 30, 1011120); // Return to the main menu.
|
||||
|
||||
AddButton(300, 360, 4005, 4007, 0);
|
||||
AddHtmlLocalized(335, 360, 100, 30, 1011441); // EXIT
|
||||
builder.AddButton(300, 360, 4005, 4007, 0);
|
||||
builder.AddHtmlLocalized(335, 360, 100, 30, 1011441); // EXIT
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, in RelayInfo info)
|
||||
{
|
||||
if (GuildGump.BadLeader(m_Mobile, m_Guild))
|
||||
var from = state.Mobile;
|
||||
if (GuildGump.BadLeader(from, _guild))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -99,23 +111,19 @@ namespace Server.Gumps
|
|||
{
|
||||
case 1: // Main menu
|
||||
{
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild));
|
||||
|
||||
GuildGump.DisplayTo(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 2: // Set guild name
|
||||
{
|
||||
m_Mobile.SendLocalizedMessage(1013060); // Enter new guild name (40 characters max):
|
||||
m_Mobile.Prompt = new GuildNamePrompt(m_Mobile, m_Guild);
|
||||
|
||||
from.SendLocalizedMessage(1013060); // Enter new guild name (40 characters max):
|
||||
from.Prompt = new GuildNamePrompt(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 3: // Set guild abbreviation
|
||||
{
|
||||
m_Mobile.SendLocalizedMessage(1013061); // Enter new guild abbreviation (3 characters max):
|
||||
m_Mobile.Prompt = new GuildAbbrvPrompt(m_Mobile, m_Guild);
|
||||
|
||||
from.SendLocalizedMessage(1013061); // Enter new guild abbreviation (3 characters max):
|
||||
from.Prompt = new GuildAbbrvPrompt(_guild);
|
||||
break;
|
||||
}
|
||||
case 4: // Change guild type
|
||||
|
|
@ -125,72 +133,57 @@ namespace Server.Gumps
|
|||
return;
|
||||
}
|
||||
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GuildChangeTypeGump(m_Mobile, m_Guild));
|
||||
|
||||
GuildChangeTypeGump.DisplayTo(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 5: // Set charter
|
||||
{
|
||||
m_Mobile.SendLocalizedMessage(1013071); // Enter the new guild charter (50 characters max):
|
||||
m_Mobile.Prompt = new GuildCharterPrompt(m_Mobile, m_Guild);
|
||||
|
||||
from.SendLocalizedMessage(1013071); // Enter the new guild charter (50 characters max):
|
||||
from.Prompt = new GuildCharterPrompt(_guild);
|
||||
break;
|
||||
}
|
||||
case 6: // Dismiss member
|
||||
{
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GuildDismissGump(m_Mobile, m_Guild));
|
||||
|
||||
GuildDismissGump.DisplayTo(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 7: // War menu
|
||||
{
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GuildWarAdminGump(m_Mobile, m_Guild));
|
||||
|
||||
GuildWarAdminGump.DisplayTo(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 8: // Administer candidates
|
||||
{
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild));
|
||||
|
||||
GuildAdminCandidatesGump.DisplayTo(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 9: // Set guildmaster's title
|
||||
{
|
||||
m_Mobile.SendLocalizedMessage(1013073); // Enter new guildmaster title (20 characters max):
|
||||
m_Mobile.Prompt = new GuildTitlePrompt(m_Mobile, m_Mobile, m_Guild);
|
||||
|
||||
from.SendLocalizedMessage(1013073); // Enter new guildmaster title (20 characters max):
|
||||
from.Prompt = new GuildTitlePrompt(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 10: // Grant title
|
||||
{
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GrantGuildTitleGump(m_Mobile, m_Guild));
|
||||
|
||||
GrantGuildTitleGump.DisplayTo(from, _guild);
|
||||
break;
|
||||
}
|
||||
case 11: // Move guildstone
|
||||
{
|
||||
if (m_Guild.Guildstone != null)
|
||||
if (_guild.Guildstone != null)
|
||||
{
|
||||
var item = new GuildTeleporter(m_Guild.Guildstone);
|
||||
var item = new GuildTeleporter(_guild.Guildstone);
|
||||
|
||||
m_Guild.Teleporter?.Delete();
|
||||
_guild.Teleporter?.Delete();
|
||||
|
||||
m_Mobile.SendLocalizedMessage(
|
||||
501133
|
||||
); // Use the teleporting object placed in your backpack to move this guildstone.
|
||||
// Use the teleporting object placed in your backpack to move this guildstone.
|
||||
from.SendLocalizedMessage(501133);
|
||||
|
||||
m_Mobile.AddToBackpack(item);
|
||||
m_Guild.Teleporter = item;
|
||||
from.AddToBackpack(item);
|
||||
_guild.Teleporter = item;
|
||||
}
|
||||
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild));
|
||||
|
||||
DisplayTo(from, _guild);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue