perf: Migrate Holiday and Decorative gumps to DynamicGump/StaticGump (#2413)
## Summary Migrates 10 player-facing legacy `Gump` subclasses for holiday and decorative items to the modern `DynamicGump` / `StaticGump<T>` system. All migrated gumps are `Singleton`, use private constructors gated by static `DisplayTo(...)` entry points (empty-gump rule, CLAUDE.md §13), and replace legacy `m_X` fields with `_x` per coding standards. Per-gump base type and rationale: - **Mistletoe.cs** — `MistletoeAddonGump` -> `StaticGump<MistletoeAddonGump>`. Fixed re-deed confirmation layout. - **StValentinesBears.cs** — Renamed `InternalGump` -> `StValentinesBearsGump`, base `StaticGump<T>`. Fixed sign-bear layout with three text entries; legacy `m_Bear` -> `_bear`. Switched legacy `AddTextEntry(..., size)` -> `AddTextEntryLimited(...)` (modern API split). - **Wreath.cs** — `WreathAddonGump` -> `StaticGump<WreathAddonGump>`. Fixed re-deed confirmation layout. - **HolidayPottedPlant.cs** — Renamed `InternalGump` -> `HolidayPottedPlantGump`, base `StaticGump<T>`. Fixed plant-picker layout. - **SnowStatue.cs** — Renamed `InternalGump` -> `SnowStatueGump`, base `StaticGump<T>`. Fixed statue-picker layout. Dropped unused `Mobile from` ctor arg. - **TapestryOfSosaria.cs** — Renamed `InternalGump` -> `TapestryOfSosariaGump`, base `StaticGump<T>`. Single image, fixed. - **HouseRaffleDeed.cs** — `WritOfLeaseGump` -> `DynamicGump`. Description HTML is computed per-instance from deed expiration / days-left, so layout text varies per instance. Added `Singleton => true` (was missing implicitly via legacy default). - **SpecialScroll.cs** — Renamed `InternalGump` -> `SpecialScrollGump`, base `DynamicGump`. **Cliloc rule**: `_scroll.Message`, `_scroll.Title`, `_scroll.SkillLabel` are dynamic cliloc numbers per scroll type — `AddHtmlLocalized` bakes the cliloc number into the cached layout, so `StaticGump<T>` cannot cache it. - **BallotBox.cs** — Renamed `InternalGump` -> `BallotBoxGump`, base `DynamicGump`. Layout shape varies: variable topic-line count, owner-vs-voter buttons, and vote-tally bars all add/remove elements. Legacy `m_Box` -> `_box`. Updated the `TopicPrompt` callbacks to call `BallotBoxGump.DisplayTo(...)` instead of allocating a new gump directly. - **AquariumGump.cs** — `AquariumGump` -> `DynamicGump`. Per-page layout depends on each item's `LabelNumber` and (for `BaseFish`) `GetDescription()` cliloc — those vary per fish/decoration. Two `DisplayTo` overloads (auto-detect access vs explicit edit flag) to mirror the original two call sites in `Aquarium.cs`. Legacy `m_Aquarium` -> `_aquarium`. ### Skipped - **HouseRaffleManagementGump.cs** — Skipped as **staff-only**. Only invoked via `ManagementEntry` context entry inside `HouseRaffleStone.cs`, gated by `from.AccessLevel >= AccessLevel.Seer`. Per task instructions, staff-only gumps are out of scope for this PR. ### External callers updated - `Aquarium.cs` — Two `new AquariumGump(...)` sites swapped to `AquariumGump.DisplayTo(...)`. All other migrated inner classes were nested in the same file and only had local references, which were updated to call the new `DisplayTo(...)` static entry point.
This commit is contained in:
parent
83f771c99a
commit
ec85d97482
12 changed files with 422 additions and 317 deletions
|
|
@ -36,7 +36,7 @@ public partial class TapestryOfSosaria : Item, ISecurable
|
|||
{
|
||||
if (from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.SendGump(new InternalGump());
|
||||
TapestryOfSosariaGump.DisplayTo(from);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -49,13 +49,28 @@ public partial class TapestryOfSosaria : Item, ISecurable
|
|||
Level = (SecureLevel)reader.ReadEncodedInt();
|
||||
}
|
||||
|
||||
private class InternalGump : Gump
|
||||
private class TapestryOfSosariaGump : StaticGump<TapestryOfSosariaGump>
|
||||
{
|
||||
public override bool Singleton => true;
|
||||
|
||||
public InternalGump() : base(50, 50)
|
||||
private TapestryOfSosariaGump() : base(50, 50)
|
||||
{
|
||||
AddImage(0, 0, 0x2C95);
|
||||
}
|
||||
|
||||
public static void DisplayTo(Mobile from)
|
||||
{
|
||||
if (from?.NetState == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
from.SendGump(new TapestryOfSosariaGump());
|
||||
}
|
||||
|
||||
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||
{
|
||||
builder.AddPage();
|
||||
builder.AddImage(0, 0, 0x2C95);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public partial class PottedPlantDeed : Item
|
|||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendGump(new InternalGump(this));
|
||||
HolidayPottedPlantGump.DisplayTo(from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -41,41 +41,49 @@ public partial class PottedPlantDeed : Item
|
|||
}
|
||||
}
|
||||
|
||||
private class InternalGump : Gump
|
||||
private class HolidayPottedPlantGump : StaticGump<HolidayPottedPlantGump>
|
||||
{
|
||||
private readonly PottedPlantDeed _deed;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public InternalGump(PottedPlantDeed deed) : base(100, 200)
|
||||
private HolidayPottedPlantGump(PottedPlantDeed deed) : base(100, 200)
|
||||
{
|
||||
_deed = deed;
|
||||
}
|
||||
|
||||
Closable = true;
|
||||
Disposable = true;
|
||||
Draggable = true;
|
||||
Resizable = false;
|
||||
public static void DisplayTo(Mobile from, PottedPlantDeed deed)
|
||||
{
|
||||
if (from?.NetState == null || deed?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddPage(0);
|
||||
AddBackground(0, 0, 360, 195, 0xA28);
|
||||
from.SendGump(new HolidayPottedPlantGump(deed));
|
||||
}
|
||||
|
||||
AddPage(1);
|
||||
AddLabel(45, 15, 0, "Choose a Potted Plant:");
|
||||
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||
{
|
||||
builder.AddPage();
|
||||
builder.AddBackground(0, 0, 360, 195, 0xA28);
|
||||
|
||||
AddItem(45, 75, 0x11C8);
|
||||
AddButton(55, 50, 0x845, 0x846, 1);
|
||||
builder.AddPage(1);
|
||||
builder.AddLabel(45, 15, 0, "Choose a Potted Plant:");
|
||||
|
||||
AddItem(100, 75, 0x11C9);
|
||||
AddButton(115, 50, 0x845, 0x846, 2);
|
||||
builder.AddItem(45, 75, 0x11C8);
|
||||
builder.AddButton(55, 50, 0x845, 0x846, 1);
|
||||
|
||||
AddItem(160, 75, 0x11CA);
|
||||
AddButton(175, 50, 0x845, 0x846, 3);
|
||||
builder.AddItem(100, 75, 0x11C9);
|
||||
builder.AddButton(115, 50, 0x845, 0x846, 2);
|
||||
|
||||
AddItem(225, 75, 0x11CB);
|
||||
AddButton(235, 50, 0x845, 0x846, 4);
|
||||
builder.AddItem(160, 75, 0x11CA);
|
||||
builder.AddButton(175, 50, 0x845, 0x846, 3);
|
||||
|
||||
AddItem(280, 75, 0x11CC);
|
||||
AddButton(295, 50, 0x845, 0x846, 5);
|
||||
builder.AddItem(225, 75, 0x11CB);
|
||||
builder.AddButton(235, 50, 0x845, 0x846, 4);
|
||||
|
||||
builder.AddItem(280, 75, 0x11CC);
|
||||
builder.AddButton(295, 50, 0x845, 0x846, 5);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public partial class SnowStatueDeed : Item
|
|||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendGump(new InternalGump(from, this));
|
||||
SnowStatueGump.DisplayTo(from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -73,38 +73,46 @@ public partial class SnowStatueDeed : Item
|
|||
}
|
||||
}
|
||||
|
||||
private class InternalGump : Gump
|
||||
private class SnowStatueGump : StaticGump<SnowStatueGump>
|
||||
{
|
||||
private readonly SnowStatueDeed _deed;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public InternalGump(Mobile from, SnowStatueDeed deed) : base(100, 200)
|
||||
private SnowStatueGump(SnowStatueDeed deed) : base(100, 200)
|
||||
{
|
||||
_deed = deed;
|
||||
}
|
||||
|
||||
Closable = true;
|
||||
Disposable = true;
|
||||
Draggable = true;
|
||||
Resizable = false;
|
||||
public static void DisplayTo(Mobile from, SnowStatueDeed deed)
|
||||
{
|
||||
if (from?.NetState == null || deed?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddPage(0);
|
||||
AddBackground(0, 0, 360, 225, 0xA28);
|
||||
from.SendGump(new SnowStatueGump(deed));
|
||||
}
|
||||
|
||||
AddPage(1);
|
||||
AddHtmlLocalized(45, 15, 200, 20, 1156487); // Select One:
|
||||
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||
{
|
||||
builder.AddPage();
|
||||
builder.AddBackground(0, 0, 360, 225, 0xA28);
|
||||
|
||||
AddItem(35, 75, 0x456E);
|
||||
AddButton(65, 50, 0x845, 0x846, 1);
|
||||
builder.AddPage(1);
|
||||
builder.AddHtmlLocalized(45, 15, 200, 20, 1156487); // Select One:
|
||||
|
||||
AddItem(120, 75, 0x4578);
|
||||
AddButton(135, 50, 0x845, 0x846, 2);
|
||||
builder.AddItem(35, 75, 0x456E);
|
||||
builder.AddButton(65, 50, 0x845, 0x846, 1);
|
||||
|
||||
AddItem(190, 75, 0x457A);
|
||||
AddButton(205, 50, 0x845, 0x846, 3);
|
||||
builder.AddItem(120, 75, 0x4578);
|
||||
builder.AddButton(135, 50, 0x845, 0x846, 2);
|
||||
|
||||
AddItem(250, 75, 0x457C);
|
||||
AddButton(275, 50, 0x845, 0x846, 4);
|
||||
builder.AddItem(190, 75, 0x457A);
|
||||
builder.AddButton(205, 50, 0x845, 0x846, 3);
|
||||
|
||||
builder.AddItem(250, 75, 0x457C);
|
||||
builder.AddButton(275, 50, 0x845, 0x846, 4);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ public partial class WreathAddon : Item, IDyable, IAddon
|
|||
}
|
||||
|
||||
from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -99,7 +98,7 @@ public partial class WreathAddon : Item, IDyable, IAddon
|
|||
|
||||
if (from.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
from.SendGump(new WreathAddonGump(from, this));
|
||||
WreathAddonGump.DisplayTo(from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -107,47 +106,54 @@ public partial class WreathAddon : Item, IDyable, IAddon
|
|||
}
|
||||
}
|
||||
|
||||
private class WreathAddonGump : Gump
|
||||
private class WreathAddonGump : StaticGump<WreathAddonGump>
|
||||
{
|
||||
private readonly WreathAddon _addon;
|
||||
private readonly Mobile _from;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public WreathAddonGump(Mobile from, WreathAddon addon) : base(150, 50)
|
||||
private WreathAddonGump(WreathAddon addon) : base(150, 50) => _addon = addon;
|
||||
|
||||
public static void DisplayTo(Mobile from, WreathAddon addon)
|
||||
{
|
||||
_from = from;
|
||||
_addon = addon;
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 220, 170, 0x13BE);
|
||||
AddBackground(10, 10, 200, 150, 0xBB8);
|
||||
AddHtmlLocalized(20, 30, 180, 60, 1062839); // Do you wish to re-deed this decoration?
|
||||
AddHtmlLocalized(55, 100, 160, 25, 1011011); // CONTINUE
|
||||
AddButton(20, 100, 0xFA5, 0xFA7, 1);
|
||||
AddHtmlLocalized(55, 125, 160, 25, 1011012); // CANCEL
|
||||
AddButton(20, 125, 0xFA5, 0xFA7, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
if (_addon.Deleted)
|
||||
if (from?.NetState == null || addon?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.ButtonID == 1)
|
||||
from.SendGump(new WreathAddonGump(addon));
|
||||
}
|
||||
|
||||
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||
{
|
||||
builder.AddPage();
|
||||
|
||||
builder.AddBackground(0, 0, 220, 170, 0x13BE);
|
||||
builder.AddBackground(10, 10, 200, 150, 0xBB8);
|
||||
builder.AddHtmlLocalized(20, 30, 180, 60, 1062839); // Do you wish to re-deed this decoration?
|
||||
builder.AddHtmlLocalized(55, 100, 160, 25, 1011011); // CONTINUE
|
||||
builder.AddButton(20, 100, 0xFA5, 0xFA7, 1);
|
||||
builder.AddHtmlLocalized(55, 125, 160, 25, 1011012); // CANCEL
|
||||
builder.AddButton(20, 125, 0xFA5, 0xFA7, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
if (_addon.Deleted || info.ButtonID != 1)
|
||||
{
|
||||
if (_from.InRange(_addon.GetWorldLocation(), 3))
|
||||
{
|
||||
_from.AddToBackpack(_addon.Deed);
|
||||
_addon.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
_from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var from = sender.Mobile;
|
||||
|
||||
if (from.InRange(_addon.GetWorldLocation(), 3))
|
||||
{
|
||||
from.AddToBackpack(_addon.Deed);
|
||||
_addon.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public partial class HouseRaffleDeed : Item
|
|||
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendGump(new WritOfLeaseGump(this));
|
||||
WritOfLeaseGump.DisplayTo(from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -92,32 +92,49 @@ public partial class HouseRaffleDeed : Item
|
|||
}
|
||||
}
|
||||
|
||||
private class WritOfLeaseGump : Gump
|
||||
private class WritOfLeaseGump : DynamicGump
|
||||
{
|
||||
private readonly HouseRaffleDeed _deed;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public WritOfLeaseGump(HouseRaffleDeed deed) : base(150, 50)
|
||||
private WritOfLeaseGump(HouseRaffleDeed deed) : base(150, 50)
|
||||
{
|
||||
AddPage(0);
|
||||
_deed = deed;
|
||||
}
|
||||
|
||||
AddImage(0, 0, 9380);
|
||||
AddImage(114, 0, 9381);
|
||||
AddImage(171, 0, 9382);
|
||||
AddImage(0, 140, 9383);
|
||||
AddImage(114, 140, 9384);
|
||||
AddImage(171, 140, 9385);
|
||||
AddImage(0, 182, 9383);
|
||||
AddImage(114, 182, 9384);
|
||||
AddImage(171, 182, 9385);
|
||||
AddImage(0, 224, 9383);
|
||||
AddImage(114, 224, 9384);
|
||||
AddImage(171, 224, 9385);
|
||||
AddImage(0, 266, 9386);
|
||||
AddImage(114, 266, 9387);
|
||||
AddImage(171, 266, 9388);
|
||||
public static void DisplayTo(Mobile from, HouseRaffleDeed deed)
|
||||
{
|
||||
if (from?.NetState == null || deed?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddHtmlLocalized(30, 48, 229, 20, 1150484, 200); // WRIT OF LEASE
|
||||
AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true);
|
||||
from.SendGump(new WritOfLeaseGump(deed));
|
||||
}
|
||||
|
||||
protected override void BuildLayout(ref DynamicGumpBuilder builder)
|
||||
{
|
||||
builder.AddPage();
|
||||
|
||||
builder.AddImage(0, 0, 9380);
|
||||
builder.AddImage(114, 0, 9381);
|
||||
builder.AddImage(171, 0, 9382);
|
||||
builder.AddImage(0, 140, 9383);
|
||||
builder.AddImage(114, 140, 9384);
|
||||
builder.AddImage(171, 140, 9385);
|
||||
builder.AddImage(0, 182, 9383);
|
||||
builder.AddImage(114, 182, 9384);
|
||||
builder.AddImage(171, 182, 9385);
|
||||
builder.AddImage(0, 224, 9383);
|
||||
builder.AddImage(114, 224, 9384);
|
||||
builder.AddImage(171, 224, 9385);
|
||||
builder.AddImage(0, 266, 9386);
|
||||
builder.AddImage(114, 266, 9387);
|
||||
builder.AddImage(171, 266, 9388);
|
||||
|
||||
builder.AddHtmlLocalized(30, 48, 229, 20, 1150484, 200); // WRIT OF LEASE
|
||||
builder.AddHtml(28, 75, 231, 280, FormatDescription(_deed), background: false, scrollbar: true);
|
||||
}
|
||||
|
||||
private static string FormatDescription(HouseRaffleDeed deed)
|
||||
|
|
|
|||
|
|
@ -73,52 +73,60 @@ public abstract partial class SpecialScroll : Item
|
|||
return;
|
||||
}
|
||||
|
||||
from.SendGump(new InternalGump(from, this));
|
||||
SpecialScrollGump.DisplayTo(from, this);
|
||||
}
|
||||
|
||||
public class InternalGump : Gump
|
||||
public class SpecialScrollGump : DynamicGump
|
||||
{
|
||||
private readonly Mobile _mobile;
|
||||
private readonly SpecialScroll _scroll;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public InternalGump(Mobile mobile, SpecialScroll scroll) : base(25, 50)
|
||||
private SpecialScrollGump(SpecialScroll scroll) : base(25, 50) => _scroll = scroll;
|
||||
|
||||
public static void DisplayTo(Mobile from, SpecialScroll scroll)
|
||||
{
|
||||
_mobile = mobile;
|
||||
_scroll = scroll;
|
||||
if (from?.NetState == null || scroll?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddPage(0);
|
||||
from.SendGump(new SpecialScrollGump(scroll));
|
||||
}
|
||||
|
||||
AddBackground(25, 10, 420, 200, 5054);
|
||||
protected override void BuildLayout(ref DynamicGumpBuilder builder)
|
||||
{
|
||||
builder.AddPage();
|
||||
|
||||
AddImageTiled(33, 20, 401, 181, 2624);
|
||||
AddAlphaRegion(33, 20, 401, 181);
|
||||
builder.AddBackground(25, 10, 420, 200, 5054);
|
||||
|
||||
AddHtmlLocalized(40, 48, 387, 100, _scroll.Message, true, true);
|
||||
builder.AddImageTiled(33, 20, 401, 181, 2624);
|
||||
builder.AddAlphaRegion(33, 20, 401, 181);
|
||||
|
||||
AddHtmlLocalized(125, 148, 200, 20, 1049478, 0x7FFF); // Do you wish to use this scroll?
|
||||
builder.AddHtmlLocalized(40, 48, 387, 100, _scroll.Message, true, true);
|
||||
|
||||
AddButton(100, 172, 4005, 4007, 1);
|
||||
AddHtmlLocalized(135, 172, 120, 20, 1046362, 0x7FFF); // Yes
|
||||
builder.AddHtmlLocalized(125, 148, 200, 20, 1049478, 0x7FFF); // Do you wish to use this scroll?
|
||||
|
||||
AddButton(275, 172, 4005, 4007, 0);
|
||||
AddHtmlLocalized(310, 172, 120, 20, 1046363, 0x7FFF); // No
|
||||
builder.AddButton(100, 172, 4005, 4007, 1);
|
||||
builder.AddHtmlLocalized(135, 172, 120, 20, 1046362, 0x7FFF); // Yes
|
||||
|
||||
builder.AddButton(275, 172, 4005, 4007, 0);
|
||||
builder.AddHtmlLocalized(310, 172, 120, 20, 1046363, 0x7FFF); // No
|
||||
|
||||
if (_scroll.Title != 0)
|
||||
{
|
||||
AddHtmlLocalized(40, 20, 260, 20, _scroll.Title, 0x7FFF);
|
||||
builder.AddHtmlLocalized(40, 20, 260, 20, _scroll.Title, 0x7FFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(40, 20, 260, 20, _scroll.DefaultTitle);
|
||||
builder.AddHtml(40, 20, 260, 20, _scroll.DefaultTitle);
|
||||
}
|
||||
|
||||
var skillLabel = _scroll.SkillLabel;
|
||||
|
||||
if (skillLabel > 0)
|
||||
{
|
||||
AddHtmlLocalized(310, 20, 120, 20, skillLabel, 0x7FFF);
|
||||
builder.AddHtmlLocalized(310, 20, 120, 20, skillLabel, 0x7FFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +134,7 @@ public abstract partial class SpecialScroll : Item
|
|||
{
|
||||
if (info.ButtonID == 1)
|
||||
{
|
||||
_scroll.Use(_mobile);
|
||||
_scroll.Use(state.Mobile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue