## 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.
157 lines
7.2 KiB
C#
157 lines
7.2 KiB
C#
using System;
|
|
using Server.Gumps;
|
|
using Server.Mobiles;
|
|
using Server.Network;
|
|
|
|
namespace Server.Guilds
|
|
{
|
|
public class WarDeclarationGump : BaseGuildGump
|
|
{
|
|
private readonly Guild _other;
|
|
|
|
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)
|
|
{
|
|
var war = Guild.FindPendingWar(_other);
|
|
|
|
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))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var playerRank = pm!.GuildRank;
|
|
|
|
switch (info.ButtonID)
|
|
{
|
|
case 1:
|
|
{
|
|
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)
|
|
{
|
|
// ~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 != _other)
|
|
{
|
|
// ~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(_other);
|
|
|
|
if (activeWar == null)
|
|
{
|
|
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.)
|
|
var tKills = info.GetTextEntry(11);
|
|
var tWarLength = info.GetTextEntry(10);
|
|
|
|
var maxKills = tKills == null
|
|
? 0
|
|
: Math.Clamp(Utility.ToInt32(tKills), 0, 0xFFFF);
|
|
var warLength = TimeSpan.FromHours(
|
|
tWarLength == null
|
|
? 0
|
|
: Math.Clamp(Utility.ToInt32(tWarLength), 0, 0xFFFF)
|
|
);
|
|
|
|
if (war != null)
|
|
{
|
|
war.MaxKills = maxKills;
|
|
war.WarLength = warLength;
|
|
war.WarRequester = true;
|
|
}
|
|
else
|
|
{
|
|
Guild.PendingWars.Add(new WarDeclaration(Guild, _other, maxKills, warLength, true));
|
|
}
|
|
|
|
if (otherWar != null)
|
|
{
|
|
otherWar.MaxKills = maxKills;
|
|
otherWar.WarLength = warLength;
|
|
otherWar.WarRequester = false;
|
|
}
|
|
else
|
|
{
|
|
_other.PendingWars.Add(new WarDeclaration(_other, Guild, maxKills, warLength, false));
|
|
}
|
|
|
|
if (war != null)
|
|
{
|
|
pm.SendLocalizedMessage(1070752); // The proposal has been updated.
|
|
}
|
|
else
|
|
{
|
|
// ~1_val~ has proposed a war.
|
|
_other.GuildMessage(
|
|
1070781,
|
|
Guild.Alliance != null
|
|
? Guild.Alliance.Name
|
|
: Guild.Name
|
|
);
|
|
}
|
|
|
|
// War proposal has been sent to ~1_val~.
|
|
pm.SendLocalizedMessage(
|
|
1070751,
|
|
_other.Alliance != null
|
|
? _other.Alliance.Name
|
|
: _other.Name
|
|
);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
pm.SendGump(new OtherGuildInfo(pm, Guild, _other));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|