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.
This commit is contained in:
Kamron Batman 2026-04-25 20:23:13 -07:00 • committed by GitHub
parent ab5f615840
commit b90ac0d481
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 1023 additions and 706 deletions

View file

@ -11,7 +11,7 @@ namespace Server.Engines.MLQuests.Objectives
public virtual bool CanOffer(IQuestGiver quester, PlayerMobile pm, bool message) => true;
public abstract void WriteToGump(Gump g, ref int y);
public abstract void WriteToGump(ref DynamicGumpBuilder builder, ref int y);
public virtual BaseObjectiveInstance CreateInstance(MLQuestInstance instance) => null;
}
@ -46,18 +46,18 @@ namespace Server.Engines.MLQuests.Objectives
public virtual DataType ExtraDataType => DataType.None;
public virtual void WriteToGump(Gump g, ref int y)
public virtual void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
if (IsTimed)
{
WriteTimeRemaining(g, ref y, Utility.Max(EndTime - Core.Now, TimeSpan.Zero));
WriteTimeRemaining(ref builder, ref y, Utility.Max(EndTime - Core.Now, TimeSpan.Zero));
}
}
public static void WriteTimeRemaining(Gump g, ref int y, TimeSpan timeRemaining)
public static void WriteTimeRemaining(ref DynamicGumpBuilder builder, ref int y, TimeSpan timeRemaining)
{
g.AddHtmlLocalized(103, y, 120, 16, 1062379, 0x5F90); // Est. time remaining:
g.AddLabel(223, y, 0x481, timeRemaining.TotalSeconds.ToString("F0"));
builder.AddHtmlLocalized(103, y, 120, 16, 1062379, 0x5F90); // Est. time remaining:
builder.AddLabel(223, y, 0x481, $"{timeRemaining.TotalSeconds:F0}");
y += 16;
}

View file

@ -44,34 +44,34 @@ namespace Server.Engines.MLQuests.Objectives
return label - 1078872;
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
if (ShowDetailed)
{
var amount = DesiredAmount.ToString();
g.AddHtmlLocalized(98, y, 350, 16, 1072205, 0x5F90); // Obtain
g.AddLabel(143, y, 0x481, amount);
builder.AddHtmlLocalized(98, y, 350, 16, 1072205, 0x5F90); // Obtain
builder.AddLabel(143, y, 0x481, amount);
if (Name.Number > 0)
{
g.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF);
g.AddItem(350, y, LabelToItemID(Name.Number));
builder.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF);
builder.AddItem(350, y, LabelToItemID(Name.Number));
}
else if (Name.String != null)
{
g.AddLabel(143 + amount.Length * 15, y, 0x481, Name.String);
builder.AddLabel(143 + amount.Length * 15, y, 0x481, Name.String);
}
}
else
{
if (Name.Number > 0)
{
g.AddHtmlLocalized(98, y, 312, 32, Name.Number, 0x5F90);
builder.AddHtmlLocalized(98, y, 312, 32, Name.Number, 0x5F90);
}
else if (Name.String != null)
{
g.AddLabel(98, y, 0x481, Name.String);
builder.AddLabel(98, y, 0x481, Name.String);
}
}
@ -199,21 +199,21 @@ namespace Server.Engines.MLQuests.Objectives
// No message
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
Objective.WriteToGump(g, ref y);
Objective.WriteToGump(ref builder, ref y);
y -= 16;
if (Objective.ShowDetailed)
{
base.WriteToGump(g, ref y);
base.WriteToGump(ref builder, ref y);
g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x5F90); // Total
g.AddLabel(223, y, 0x481, GetCurrentTotal().ToString());
builder.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x5F90); // Total
builder.AddLabel(223, y, 0x481, $"{GetCurrentTotal()}");
y += 16;
g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x5F90); // Return to
g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType));
builder.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x5F90); // Return to
builder.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType));
y += 16;
}
}

View file

@ -70,27 +70,27 @@ namespace Server.Engines.MLQuests.Objectives
}
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
var amount = Amount.ToString();
g.AddHtmlLocalized(98, y, 312, 16, 1072207, 0x5F90); // Deliver
g.AddLabel(143, y, 0x481, amount);
builder.AddHtmlLocalized(98, y, 312, 16, 1072207, 0x5F90); // Deliver
builder.AddLabel(143, y, 0x481, amount);
if (Name.Number > 0)
{
g.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF);
g.AddItem(350, y, CollectObjective.LabelToItemID(Name.Number));
builder.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF);
builder.AddItem(350, y, CollectObjective.LabelToItemID(Name.Number));
}
else if (Name.String != null)
{
g.AddLabel(143 + amount.Length * 15, y, 0x481, Name.String);
builder.AddLabel(143 + amount.Length * 15, y, 0x481, Name.String);
}
y += 32;
g.AddHtmlLocalized(103, y, 120, 16, 1072379, 0x5F90); // Deliver to
g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Destination));
builder.AddHtmlLocalized(103, y, 120, 16, 1072379, 0x5F90); // Deliver to
builder.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Destination));
y += 16;
}
@ -225,11 +225,11 @@ namespace Server.Engines.MLQuests.Objectives
Instance.Player.SendLocalizedMessage(1074813); // You have failed to complete your delivery.
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
Objective.WriteToGump(g, ref y);
Objective.WriteToGump(ref builder, ref y);
base.WriteToGump(g, ref y);
base.WriteToGump(ref builder, ref y);
// No extra instance stuff printed for this objective
}

View file

@ -63,17 +63,17 @@ namespace Server.Engines.MLQuests.Objectives
return true;
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
g.AddHtmlLocalized(98, y, 312, 16, 1072206, 0x5F90); // Escort to
builder.AddHtmlLocalized(98, y, 312, 16, 1072206, 0x5F90); // Escort to
if (Destination.Name.Number > 0)
{
g.AddHtmlLocalized(173, y, 312, 20, Destination.Name.Number, 0x7FFF);
builder.AddHtmlLocalized(173, y, 312, 20, Destination.Name.Number, 0x7FFF);
}
else if (Destination.Name.String != null)
{
g.AddLabel(173, y, 0x481, Destination.Name.String);
builder.AddLabel(173, y, 0x481, Destination.Name.String);
}
y += 16;
@ -275,11 +275,11 @@ namespace Server.Engines.MLQuests.Objectives
Abandon();
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
m_Objective.WriteToGump(g, ref y);
m_Objective.WriteToGump(ref builder, ref y);
base.WriteToGump(g, ref y);
base.WriteToGump(ref builder, ref y);
// No extra instance stuff printed for this objective
}

View file

@ -68,12 +68,12 @@ namespace Server.Engines.MLQuests.Objectives
return true;
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
var skillLabel = AosSkillBonuses.GetLabel(Skill);
var args = $"#{skillLabel}\t{ThresholdFixed / 10.0:0.#}";
g.AddHtmlLocalized(98, y, 312, 16, 1077485, args, 0x5F90); // Increase ~1_SKILL~ to ~2_VALUE~
builder.AddHtmlLocalized(98, y, 312, 16, 1077485, args, 0x5F90); // Increase ~1_SKILL~ to ~2_VALUE~
y += 16;
}
@ -150,15 +150,15 @@ namespace Server.Engines.MLQuests.Objectives
OnQuestCancelled();
}
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
Objective.WriteToGump(g, ref y);
Objective.WriteToGump(ref builder, ref y);
base.WriteToGump(g, ref y);
base.WriteToGump(ref builder, ref y);
if (IsCompleted())
{
g.AddHtmlLocalized(113, y, 312, 20, 1055121, 0x7FFF); // Complete
builder.AddHtmlLocalized(113, y, 312, 20, 1055121, 0x7FFF); // Complete
y += 16;
}
}

View file

@ -23,35 +23,35 @@ namespace Server.Engines.MLQuests.Objectives
public QuestArea Area { get; set; }
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
var amount = DesiredAmount.ToString();
g.AddHtmlLocalized(98, y, 312, 16, 1072204, 0x5F90); // Slay
g.AddLabel(133, y, 0x481, amount);
builder.AddHtmlLocalized(98, y, 312, 16, 1072204, 0x5F90); // Slay
builder.AddLabel(133, y, 0x481, amount);
if (Name.Number > 0)
{
g.AddHtmlLocalized(133 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF);
builder.AddHtmlLocalized(133 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF);
}
else if (Name.String != null)
{
g.AddLabel(133 + amount.Length * 15, y, 0x481, Name.String);
builder.AddLabel(133 + amount.Length * 15, y, 0x481, Name.String);
}
y += 16;
if (Area != null)
{
g.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x5F90); // Location
builder.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x5F90); // Location
if (Area.Name.Number > 0)
{
g.AddHtmlLocalized(223, y, 312, 20, Area.Name.Number, 0x7FFF);
builder.AddHtmlLocalized(223, y, 312, 20, Area.Name.Number, 0x7FFF);
}
else if (Area.Name.String != null)
{
g.AddLabel(223, y, 0x481, Area.Name.String);
builder.AddLabel(223, y, 0x481, Area.Name.String);
}
y += 16;
@ -121,18 +121,18 @@ namespace Server.Engines.MLQuests.Objectives
public override bool IsCompleted() => Slain >= Objective.DesiredAmount;
public override void WriteToGump(Gump g, ref int y)
public override void WriteToGump(ref DynamicGumpBuilder builder, ref int y)
{
Objective.WriteToGump(g, ref y);
Objective.WriteToGump(ref builder, ref y);
base.WriteToGump(g, ref y);
base.WriteToGump(ref builder, ref y);
g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x5F90); // Total
g.AddLabel(223, y, 0x481, Slain.ToString());
builder.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x5F90); // Total
builder.AddLabel(223, y, 0x481, $"{Slain}");
y += 16;
g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x5F90); // Return to
g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType));
builder.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x5F90); // Return to
builder.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType));
y += 16;
}