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
|
|
@ -1,85 +1,83 @@
|
|||
using System;
|
||||
using Server.Guilds;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class GuildCharterGump : Gump
|
||||
public class GuildCharterGump : DynamicGump
|
||||
{
|
||||
private const string DefaultWebsite = "https://www.modernuo.com";
|
||||
private readonly Guild m_Guild;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly Guild _guild;
|
||||
|
||||
public GuildCharterGump(Mobile from, Guild guild) : base(20, 30)
|
||||
public override bool Singleton => true;
|
||||
|
||||
private GuildCharterGump(Guild guild) : base(20, 30) => _guild = guild;
|
||||
|
||||
public static void DisplayTo(Mobile from, Guild guild)
|
||||
{
|
||||
m_Mobile = from;
|
||||
m_Guild = guild;
|
||||
|
||||
Draggable = false;
|
||||
|
||||
AddPage(0);
|
||||
AddBackground(0, 0, 550, 400, 5054);
|
||||
AddBackground(10, 10, 530, 380, 3000);
|
||||
|
||||
AddButton(20, 360, 4005, 4007, 1);
|
||||
AddHtmlLocalized(55, 360, 300, 35, 1011120); // Return to the main menu.
|
||||
|
||||
string charter;
|
||||
|
||||
if ((charter = guild.Charter) == null || (charter = charter.Trim()).Length <= 0)
|
||||
{
|
||||
AddHtmlLocalized(20, 20, 400, 35, 1013032); // No charter has been defined.
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(20, 20, 510, 75, charter, true, true);
|
||||
}
|
||||
|
||||
AddButton(20, 200, 4005, 4007, 2);
|
||||
AddHtmlLocalized(55, 200, 300, 20, 1011122); // Visit the guild website :
|
||||
|
||||
string website;
|
||||
|
||||
if ((website = guild.Website) == null || (website = website.Trim()).Length <= 0)
|
||||
{
|
||||
website = DefaultWebsite;
|
||||
}
|
||||
|
||||
AddHtml(55, 220, 300, 20, website);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, in RelayInfo info)
|
||||
{
|
||||
if (GuildGump.BadMember(m_Mobile, m_Guild))
|
||||
if (from?.NetState == null || guild == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (info.ButtonID)
|
||||
GuildGump.EnsureClosed(from);
|
||||
from.SendGump(new GuildCharterGump(guild));
|
||||
}
|
||||
|
||||
protected override void BuildLayout(ref DynamicGumpBuilder builder)
|
||||
{
|
||||
builder.SetNoMove();
|
||||
|
||||
builder.AddPage();
|
||||
builder.AddBackground(0, 0, 550, 400, 5054);
|
||||
builder.AddBackground(10, 10, 530, 380, 3000);
|
||||
|
||||
builder.AddButton(20, 360, 4005, 4007, 1);
|
||||
builder.AddHtmlLocalized(55, 360, 300, 35, 1011120); // Return to the main menu.
|
||||
|
||||
string charter;
|
||||
|
||||
if ((charter = _guild.Charter) == null || (charter = charter.Trim()).Length <= 0)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
return; // Close
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
break; // Return to main menu
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
string website;
|
||||
|
||||
if ((website = m_Guild.Website) == null || (website = website.Trim()).Length <= 0)
|
||||
{
|
||||
website = DefaultWebsite;
|
||||
}
|
||||
|
||||
m_Mobile.LaunchBrowser(website);
|
||||
break;
|
||||
}
|
||||
builder.AddHtmlLocalized(20, 20, 400, 35, 1013032); // No charter has been defined.
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddHtml(20, 20, 510, 75, charter, background: true, scrollbar: true);
|
||||
}
|
||||
|
||||
GuildGump.EnsureClosed(m_Mobile);
|
||||
m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild));
|
||||
builder.AddButton(20, 200, 4005, 4007, 2);
|
||||
builder.AddHtmlLocalized(55, 200, 300, 20, 1011122); // Visit the guild website :
|
||||
|
||||
var website = _guild.Website != null ? _guild.Website.AsSpan().Trim() : "";
|
||||
if (website.Length <= 0)
|
||||
{
|
||||
website = DefaultWebsite;
|
||||
}
|
||||
|
||||
builder.AddHtml(55, 220, 300, 20, website);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, in RelayInfo info)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
if (info.ButtonID == 0 || GuildGump.BadMember(from, _guild))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.ButtonID == 2)
|
||||
{
|
||||
var website = _guild.Website != null ? _guild.Website.AsSpan().Trim() : "";
|
||||
if (website.Length <= 0)
|
||||
{
|
||||
website = DefaultWebsite;
|
||||
}
|
||||
|
||||
from.LaunchBrowser(website);
|
||||
}
|
||||
|
||||
GuildGump.DisplayTo(from, _guild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue