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
|
|
@ -56,7 +56,6 @@ public partial class MistletoeAddon : Item, IDyable, IAddon
|
|||
}
|
||||
|
||||
from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -104,7 +103,7 @@ public partial class MistletoeAddon : Item, IDyable, IAddon
|
|||
|
||||
if (from.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
from.SendGump(new MistletoeAddonGump(from, this));
|
||||
MistletoeAddonGump.DisplayTo(from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -112,27 +111,35 @@ public partial class MistletoeAddon : Item, IDyable, IAddon
|
|||
}
|
||||
}
|
||||
|
||||
private class MistletoeAddonGump : Gump
|
||||
private class MistletoeAddonGump : StaticGump<MistletoeAddonGump>
|
||||
{
|
||||
private readonly MistletoeAddon _addon;
|
||||
private readonly Mobile _from;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public MistletoeAddonGump(Mobile from, MistletoeAddon addon) : base(150, 50)
|
||||
private MistletoeAddonGump(MistletoeAddon addon) : base(150, 50) => _addon = addon;
|
||||
|
||||
public static void DisplayTo(Mobile from, MistletoeAddon addon)
|
||||
{
|
||||
_from = from;
|
||||
_addon = addon;
|
||||
if (from?.NetState == null || addon?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddPage(0);
|
||||
from.SendGump(new MistletoeAddonGump(addon));
|
||||
}
|
||||
|
||||
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);
|
||||
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)
|
||||
|
|
@ -142,14 +149,16 @@ public partial class MistletoeAddon : Item, IDyable, IAddon
|
|||
return;
|
||||
}
|
||||
|
||||
if (_from.InRange(_addon.GetWorldLocation(), 3))
|
||||
var from = sender.Mobile;
|
||||
|
||||
if (from.InRange(_addon.GetWorldLocation(), 3))
|
||||
{
|
||||
_from.AddToBackpack(_addon.Deed);
|
||||
from.AddToBackpack(_addon.Deed);
|
||||
_addon.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
_from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,51 +101,63 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
from.SendGump(new InternalGump(this));
|
||||
StValentinesBearsGump.DisplayTo(from, this);
|
||||
}
|
||||
|
||||
private class InternalGump : Gump
|
||||
private class StValentinesBearsGump : StaticGump<StValentinesBearsGump>
|
||||
{
|
||||
private readonly StValentinesBear m_Bear;
|
||||
private readonly StValentinesBear _bear;
|
||||
|
||||
public InternalGump(StValentinesBear bear)
|
||||
: base(50, 50)
|
||||
public override bool Singleton => true;
|
||||
|
||||
protected override bool Cached => false;
|
||||
|
||||
private StValentinesBearsGump(StValentinesBear bear) : base(50, 50)
|
||||
{
|
||||
m_Bear = bear;
|
||||
_bear = bear;
|
||||
}
|
||||
|
||||
AddPage(0);
|
||||
AddBackground(0, 0, 420, 320, 9300);
|
||||
AddHtml(10, 10, 400, 21, "<CENTER>St. Valentine Bear</CENTER>");
|
||||
AddHtmlLocalized(
|
||||
10,
|
||||
40,
|
||||
400,
|
||||
75,
|
||||
1150293,
|
||||
0
|
||||
); // Enter up to three lines of personalized greeting for your St. Valentine Bear. You many enter up to 25 characters per line. Once you enter text, you will only be able to correct mistakes for 10 minutes.
|
||||
public static void DisplayTo(Mobile from, StValentinesBear bear)
|
||||
{
|
||||
if (from?.NetState == null || bear?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddHtmlLocalized(10, 129, 400, 21, 1150296, 0); // Line 1:
|
||||
AddBackground(10, 150, 400, 24, 9350);
|
||||
AddTextEntry(15, 152, 390, 20, 0, 0, "", 25);
|
||||
from.SendGump(new StValentinesBearsGump(bear));
|
||||
}
|
||||
|
||||
AddHtmlLocalized(10, 179, 400, 21, 1150297, 0); // Line 2:
|
||||
AddBackground(10, 200, 400, 24, 9350);
|
||||
AddTextEntry(15, 202, 390, 20, 0, 1, "", 25);
|
||||
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||
{
|
||||
builder.AddPage();
|
||||
builder.AddBackground(0, 0, 420, 320, 9300);
|
||||
// St. Valentine Bear
|
||||
builder.AddHtmlLocalized(10, 10, 400, 21, 1154645, "#1150294", 0);
|
||||
|
||||
AddHtmlLocalized(10, 229, 400, 21, 1150298, 0); // Line 3:
|
||||
AddBackground(10, 250, 400, 24, 9350);
|
||||
AddTextEntry(15, 252, 390, 20, 0, 2, "", 25);
|
||||
// Enter up to three lines of personalized greeting for your St. Valentine Bear. You many enter up to 25 characters per line. Once you enter text, you will only be able to correct mistakes for 10 minutes.
|
||||
builder.AddHtmlLocalized(10, 40, 400, 75, 1150293, 0);
|
||||
|
||||
AddButton(15, 285, 242, 241, 0);
|
||||
AddButton(335, 285, 247, 248, 1);
|
||||
builder.AddHtmlLocalized(10, 129, 400, 21, 1150296, 0); // Line 1:
|
||||
builder.AddBackground(10, 150, 400, 24, 9350);
|
||||
builder.AddTextEntryLimited(15, 152, 390, 20, 0, 0, "", 25);
|
||||
|
||||
builder.AddHtmlLocalized(10, 179, 400, 21, 1150297, 0); // Line 2:
|
||||
builder.AddBackground(10, 200, 400, 24, 9350);
|
||||
builder.AddTextEntryLimited(15, 202, 390, 20, 0, 1, "", 25);
|
||||
|
||||
builder.AddHtmlLocalized(10, 229, 400, 21, 1150298, 0); // Line 3:
|
||||
builder.AddBackground(10, 250, 400, 24, 9350);
|
||||
builder.AddTextEntryLimited(15, 252, 390, 20, 0, 2, "", 25);
|
||||
|
||||
builder.AddButton(15, 285, 242, 241, 0);
|
||||
builder.AddButton(335, 285, 247, 248, 1);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
var from = sender.Mobile;
|
||||
|
||||
if (m_Bear.Deleted || !m_Bear.IsChildOf(from.Backpack) || !m_Bear.CanSign || info.ButtonID != 1)
|
||||
if (_bear.Deleted || !_bear.IsChildOf(from.Backpack) || !_bear.CanSign || info.ButtonID != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -170,14 +182,14 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
if (!m_Bear.IsSigned)
|
||||
if (!_bear.IsSigned)
|
||||
{
|
||||
m_Bear.EditLimit = Core.Now + TimeSpan.FromMinutes(10);
|
||||
_bear.EditLimit = Core.Now + TimeSpan.FromMinutes(10);
|
||||
}
|
||||
|
||||
m_Bear.Line1 = line1.FixHtml();
|
||||
m_Bear.Line2 = line2.FixHtml();
|
||||
m_Bear.Line3 = line3.FixHtml();
|
||||
_bear.Line1 = line1.FixHtml();
|
||||
_bear.Line2 = line2.FixHtml();
|
||||
_bear.Line3 = line3.FixHtml();
|
||||
|
||||
from.SendMessage("You add the personalized greeting to your St. Valentine Bear.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
from.SendLocalizedMessage(1152318); // You may not use this item out of season.
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue