ModernUO/Projects/UOContent/Engines/ML Quests/Gumps/QuestCancelConfirmGump.cs
Kamron Batman b90ac0d481
perf: Migrate Quest gumps to DynamicGump (#2416)
## Summary

Migrates the Quest system gumps from legacy `Gump` to `DynamicGump` / `StaticGump<T>`.

**Renames** `Engines/ML Quests/Gumps/BaseQuestGump` to **`BaseMLQuestGump`** to
disambiguate from the Core quest abstract (`Engines/Quests/Core/QuestSystem.cs`).
Both abstracts now extend `DynamicGump`.

**Abstract bases**:
- `Server.Engines.Quests.BaseQuestGump` (Core) - now `abstract DynamicGump`. Holds constants and a static `AddHtmlObject(ref DynamicGumpBuilder, ...)` helper. Concrete subclasses each provide their own `BuildLayout`.
- `Server.Engines.MLQuests.Gumps.BaseMLQuestGump` (ML, renamed) - now `abstract DynamicGump` with a `protected abstract BuildContent(ref DynamicGumpBuilder)` hook. The base's `BuildLayout` draws shared chrome (background art, frame, label header) and then invokes `BuildContent`; subclasses use `BuildPage`, `SetTitle`, `RegisterButton`, `SetPageCount`, and content helpers (`AddDescription`, `AddObjectives`, `AddObjectivesProgress`, `AddRewardsPage`, `AddRewards`, `AddConversation`).

**Concrete Core gumps** migrated to `DynamicGump`:
- `QuestCancelGump`, `QuestOfferGump` (Core), `QuestObjectivesGump`, `QuestConversationsGump`, `QuestLogUpdatedGump`, `QuestItemInfoGump`, `SheetMusicOfferGump` (Impresario), `PaintedImageGump` (renamed from `PaintedImage.InternalGump`).

**Concrete ML gumps** migrated to `DynamicGump` (extending `BaseMLQuestGump` or directly):
- `InfoNPCGump`, `QuestConversationGump`, `QuestLogDetailedGump`, `QuestLogGump`, `QuestOfferGump` (ML), `QuestReportBackGump`, `QuestRewardGump`, `QuestCancelConfirmGump`, `RaceChangeConfirmGump`.

**`StaticGump<T>` migrations**:
- `ScrollOfAbraxusGump` (Dark Tides). Its layout is a single hard-coded cliloc (1060116) with no per-instance dynamic content - safe to cache.

**Cliloc rule**: Every other quest dialog bakes per-instance cliloc IDs into its layout (quest titles, NPC names, race-specific prompts, era-conditional progress messages, escort destinations). Per the cliloc rule, baking different cliloc numbers into a cached layout would defeat `StaticGump<T>` caching - so all of these are `DynamicGump`.

**Signature changes** to support the migration:
- `QuestObjective.RenderMessage`/`RenderProgress` now take `ref DynamicGumpBuilder builder` (15 overrides updated across Collector, Solen Matriarch, Ambitious Solen Queen, Study of the Solen Hive, Terrible Hatchlings, The Summoning, Uzeraan Turmoil, Witch Apprentice, Emino's Undertaking).
- ML `BaseObjective.WriteToGump` / `BaseObjectiveInstance.WriteToGump` / `BaseReward.WriteToGump` now take `ref DynamicGumpBuilder` (KillObjective, GainSkillObjective, EscortObjective, CollectObjective, DeliverObjective, BaseReward).

**Empty-gump and `Singleton` rules**: All concrete gumps now have private constructors with static `DisplayTo` entry points that null-check the player NetState before allocation. All gumps that shouldn't stack are `Singleton => true`.

**External callers updated**: `MLQuest.SendOffer`/`OnRefuse`, `MLQuestEntry.SendProgressGump`/`SendRewardGump`/`SendReportBackGump`, `MLQuestSystem.QuestGumpRequest` and `ViewQuestsCommand`, `BoonCollector` (Darius/Nedrick), `SirHelper.OnDoubleClick` (no longer caches a single shared `InfoNPCGump` instance - `DisplayTo` constructs one per click and the gump's `Singleton => true` handles deduplication), `RaceChangeDeed.OnDoubleClick`, `PaintedImage.OnDoubleClick`, `ScrollOfAbraxus.OnDoubleClick`, `Impresario.OnTalk`, and `PlayerMobile`'s `BaseQuestGump` alias is now `BaseMLQuestGump`.

**Concrete subclasses found beyond the listed entry points**: `SheetMusicOfferGump` (in Impresario.cs), `PaintedImageGump` (was `PaintedImage.InternalGump`), `QuestObjectivesGump`, `QuestConversationsGump`, `QuestLogUpdatedGump`, `QuestItemInfoGump` (the Core base has these embedded across `QuestSystem.cs`/`QuestObjective.cs`/`QuestConversation.cs`/`QuestItemInfo.cs`).

**Code-standards cleanup**: Renamed legacy `m_X` private fields to `_x` in rewritten files; braces on all control flow.
2026-04-25 20:23:13 -07:00

119 lines
3.9 KiB
C#

using Server.Gumps;
using Server.Network;
namespace Server.Engines.MLQuests.Gumps
{
public class QuestCancelConfirmGump : DynamicGump
{
private readonly bool _closeGumps;
private readonly MLQuestInstance _instance;
public override bool Singleton => true;
private QuestCancelConfirmGump(MLQuestInstance instance, bool closeGumps) : base(120, 50)
{
_instance = instance;
_closeGumps = closeGumps;
}
public static void DisplayTo(Mobile from, MLQuestInstance instance, bool closeGumps = true)
{
if (from?.NetState == null || instance == null)
{
return;
}
if (closeGumps)
{
BaseMLQuestGump.CloseOtherGumps(instance.Player);
}
from.SendGump(new QuestCancelConfirmGump(instance, closeGumps));
}
protected override void BuildLayout(ref DynamicGumpBuilder builder)
{
builder.SetNoClose();
builder.AddPage();
builder.AddImageTiled(0, 0, 348, 262, 0xA8E);
builder.AddAlphaRegion(0, 0, 348, 262);
builder.AddImage(0, 15, 0x27A8);
builder.AddImageTiled(0, 30, 17, 200, 0x27A7);
builder.AddImage(0, 230, 0x27AA);
builder.AddImage(15, 0, 0x280C);
builder.AddImageTiled(30, 0, 300, 17, 0x280A);
builder.AddImage(315, 0, 0x280E);
builder.AddImage(15, 244, 0x280C);
builder.AddImageTiled(30, 244, 300, 17, 0x280A);
builder.AddImage(315, 244, 0x280E);
builder.AddImage(330, 15, 0x27A8);
builder.AddImageTiled(330, 30, 17, 200, 0x27A7);
builder.AddImage(330, 230, 0x27AA);
builder.AddImage(333, 2, 0x2716);
builder.AddImage(333, 248, 0x2716);
builder.AddImage(2, 248, 0x2716);
builder.AddImage(2, 2, 0x2716);
builder.AddHtmlLocalized(25, 22, 200, 20, 1049000, 0x7D00); // Confirm Quest Cancellation
builder.AddImage(25, 40, 0xBBF);
/*
* This quest will give you valuable information, skills
* and equipment that will help you advance in the
* game at a quicker pace.<BR>
* <BR>
* Are you certain you wish to cancel at this time?
*/
builder.AddHtmlLocalized(25, 55, 300, 120, 1060836, 0x7FFF);
var quest = _instance.Quest;
if (quest.IsChainTriggered || quest.NextQuest != null)
{
builder.AddRadio(25, 145, 0x25F8, 0x25FB, false, 2);
builder.AddHtmlLocalized(60, 150, 280, 20, 1075023, 0x7FFF); // Yes, I want to quit this entire chain!
}
builder.AddRadio(25, 180, 0x25F8, 0x25FB, true, 1);
builder.AddHtmlLocalized(60, 185, 280, 20, 1049005, 0x7FFF); // Yes, I really want to quit this quest!
builder.AddRadio(25, 215, 0x25F8, 0x25FB, false, 0);
builder.AddHtmlLocalized(60, 220, 280, 20, 1049006, 0x7FFF); // No, I don't want to quit.
builder.AddButton(265, 220, 0xF7, 0xF8, 7);
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (_instance.Removed)
{
return;
}
switch (info.ButtonID)
{
case 7: // Okay
{
if (info.IsSwitched(2))
{
_instance.Cancel(true);
}
else if (info.IsSwitched(1))
{
_instance.Cancel(false);
}
QuestLogGump.DisplayTo(sender.Mobile, _instance.Player, _closeGumps);
break;
}
}
}
}
}