ModernUO/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs
Kamron Batman ec85d97482
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.
2026-04-25 17:22:41 -07:00

108 lines
2.9 KiB
C#

using ModernUO.Serialization;
using Server.Targeting;
namespace Server.Items
{
[SerializationGenerator(0, false)]
public partial class CupidsArrow : Item
{
[InternString]
[InvalidateProperties]
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private string _from;
[InternString]
[InvalidateProperties]
[SerializableField(1)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private string _to;
[Constructible]
public CupidsArrow() : base(0x4F7F) => LootType = LootType.Blessed;
// TODO: Check messages
public override int LabelNumber => 1152270; // Cupid's Arrow 2012
public bool IsSigned => _from != null && _to != null;
public override void AddNameProperty(IPropertyList list)
{
base.AddNameProperty(list);
if (IsSigned)
{
list.Add(1152273, $"{_from}\t{_to}"); // ~1_val~ is madly in love with ~2_val~
}
}
public static bool CheckSeason(Mobile from)
{
if (Core.Now.Month == 2)
{
return true;
}
from.SendLocalizedMessage(1152318); // You may not use this item out of season.
return true;
}
public override void OnSingleClick(Mobile from)
{
base.OnSingleClick(from);
if (IsSigned)
{
LabelTo(from, 1152273, $"{_from}\t{_to}"); // ~1_val~ is madly in love with ~2_val~
}
}
public override void OnDoubleClick(Mobile from)
{
if (IsSigned || !CheckSeason(from))
{
return;
}
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1080063); // This must be in your backpack to use it.
return;
}
from.BeginTarget(10, false, TargetFlags.None, OnTarget);
from.SendMessage("Who do you wish to use this on?");
}
private void OnTarget(Mobile from, object targeted)
{
if (IsSigned || !IsChildOf(from.Backpack))
{
return;
}
if (targeted is Mobile m)
{
if (!m.Alive)
{
from.SendLocalizedMessage(
1152269
); // That target is dead and even Cupid's arrow won't make them love you.
return;
}
From = from.Name;
To = m.Name;
InvalidateProperties();
from.SendMessage("You inscribe the arrow.");
}
else
{
from.SendMessage("That is not a person.");
}
}
}
}