## 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.
122 lines
3.3 KiB
C#
122 lines
3.3 KiB
C#
using ModernUO.Serialization;
|
|
using Server.Gumps;
|
|
using Server.Network;
|
|
|
|
namespace Server.Items;
|
|
|
|
[SerializationGenerator(0)]
|
|
public partial class HolidayPottedPlant : Item
|
|
{
|
|
[Constructible]
|
|
public HolidayPottedPlant() : this(Utility.RandomMinMax(0x11C8, 0x11CC))
|
|
{
|
|
}
|
|
|
|
[Constructible]
|
|
public HolidayPottedPlant(int itemID) : base(itemID)
|
|
{
|
|
}
|
|
|
|
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
|
|
}
|
|
|
|
[SerializationGenerator(0)]
|
|
public partial class PottedPlantDeed : Item
|
|
{
|
|
[Constructible]
|
|
public PottedPlantDeed() : base(0x14F0) => LootType = LootType.Blessed;
|
|
|
|
public override int LabelNumber => 1041114; // A deed for a potted plant.
|
|
public override double DefaultWeight => 1.0;
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (IsChildOf(from.Backpack))
|
|
{
|
|
HolidayPottedPlantGump.DisplayTo(from, this);
|
|
}
|
|
else
|
|
{
|
|
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
|
|
}
|
|
}
|
|
|
|
private class HolidayPottedPlantGump : StaticGump<HolidayPottedPlantGump>
|
|
{
|
|
private readonly PottedPlantDeed _deed;
|
|
|
|
public override bool Singleton => true;
|
|
|
|
private HolidayPottedPlantGump(PottedPlantDeed deed) : base(100, 200)
|
|
{
|
|
_deed = deed;
|
|
}
|
|
|
|
public static void DisplayTo(Mobile from, PottedPlantDeed deed)
|
|
{
|
|
if (from?.NetState == null || deed?.Deleted != false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
from.SendGump(new HolidayPottedPlantGump(deed));
|
|
}
|
|
|
|
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
|
{
|
|
builder.AddPage();
|
|
builder.AddBackground(0, 0, 360, 195, 0xA28);
|
|
|
|
builder.AddPage(1);
|
|
builder.AddLabel(45, 15, 0, "Choose a Potted Plant:");
|
|
|
|
builder.AddItem(45, 75, 0x11C8);
|
|
builder.AddButton(55, 50, 0x845, 0x846, 1);
|
|
|
|
builder.AddItem(100, 75, 0x11C9);
|
|
builder.AddButton(115, 50, 0x845, 0x846, 2);
|
|
|
|
builder.AddItem(160, 75, 0x11CA);
|
|
builder.AddButton(175, 50, 0x845, 0x846, 3);
|
|
|
|
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)
|
|
{
|
|
if (_deed?.Deleted != false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var from = sender.Mobile;
|
|
|
|
if (!_deed.IsChildOf(from.Backpack))
|
|
{
|
|
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it
|
|
return;
|
|
}
|
|
|
|
var index = info.ButtonID - 1;
|
|
|
|
if (index >= 0 && index <= 4)
|
|
{
|
|
var plant = new HolidayPottedPlant(0x11C8 + index);
|
|
|
|
if (!from.PlaceInBackpack(plant))
|
|
{
|
|
plant.Delete();
|
|
from.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again.
|
|
}
|
|
else
|
|
{
|
|
_deed.Delete();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|