ModernUO/Projects/UOContent/Gumps/Guilds/GuildWarGump.cs
Kamron Batman 15e506ffc2
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(...)`.
2026-04-26 10:44:11 -07:00

119 lines
3.7 KiB
C#

using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildWarGump : DynamicGump
{
private readonly Guild _guild;
public override bool Singleton => true;
private GuildWarGump(Guild guild) : base(20, 30) => _guild = guild;
public static void DisplayTo(Mobile from, Guild guild)
{
if (from?.NetState == null || guild == null)
{
return;
}
GuildGump.EnsureClosed(from);
from.SendGump(new GuildWarGump(guild));
}
protected override void BuildLayout(ref DynamicGumpBuilder builder)
{
builder.SetNoMove();
builder.AddPage();
builder.AddBackground(0, 0, 550, 440, 5054);
builder.AddBackground(10, 10, 530, 420, 3000);
builder.AddHtmlLocalized(20, 10, 500, 35, 1011133); // <center>WARFARE STATUS</center>
builder.AddButton(20, 400, 4005, 4007, 1);
builder.AddHtmlLocalized(55, 400, 300, 35, 1011120); // Return to the main menu.
builder.AddPage(1);
builder.AddButton(375, 375, 5224, 5224, 0, GumpButtonType.Page, 2);
builder.AddHtmlLocalized(410, 373, 100, 25, 1011066); // Next page
builder.AddHtmlLocalized(20, 45, 400, 20, 1011134); // We are at war with:
var enemies = _guild.Enemies;
if (enemies.Count == 0)
{
builder.AddHtmlLocalized(20, 65, 400, 20, 1013033); // No current wars
}
else
{
for (var i = 0; i < enemies.Count; ++i)
{
builder.AddHtml(20, 65 + i * 20, 300, 20, enemies[i].Name);
}
}
builder.AddPage(2);
builder.AddButton(375, 375, 5224, 5224, 0, GumpButtonType.Page, 3);
builder.AddHtmlLocalized(410, 373, 100, 25, 1011066); // Next page
builder.AddButton(30, 375, 5223, 5223, 0, GumpButtonType.Page, 1);
builder.AddHtmlLocalized(65, 373, 150, 25, 1011067); // Previous page
builder.AddHtmlLocalized(20, 45, 400, 20, 1011136); // Guilds that we have declared war on:
var declared = _guild.WarDeclarations;
if (declared.Count == 0)
{
builder.AddHtmlLocalized(20, 65, 400, 20, 1018012); // No current invitations received for war.
}
else
{
for (var i = 0; i < declared.Count; ++i)
{
builder.AddHtml(20, 65 + i * 20, 300, 20, declared[i].Name);
}
}
builder.AddPage(3);
builder.AddButton(30, 375, 5223, 5223, 0, GumpButtonType.Page, 2);
builder.AddHtmlLocalized(65, 373, 150, 25, 1011067); // Previous page
builder.AddHtmlLocalized(20, 45, 400, 20, 1011135); // Guilds that have declared war on us:
var invites = _guild.WarInvitations;
if (invites.Count == 0)
{
builder.AddHtmlLocalized(20, 65, 400, 20, 1013055); // No current war declarations
}
else
{
for (var i = 0; i < invites.Count; ++i)
{
builder.AddHtml(20, 65 + i * 20, 300, 20, invites[i].Name);
}
}
}
public override void OnResponse(NetState state, in RelayInfo info)
{
var from = state.Mobile;
if (GuildGump.BadMember(from, _guild))
{
return;
}
if (info.ButtonID == 1)
{
GuildGump.DisplayTo(from, _guild);
}
}
}
}