## 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.
116 lines
3 KiB
C#
116 lines
3 KiB
C#
using Server.Gumps;
|
|
using Server.Mobiles;
|
|
using Server.Network;
|
|
|
|
namespace Server.Engines.MLQuests.Gumps
|
|
{
|
|
public class QuestLogGump : BaseMLQuestGump
|
|
{
|
|
private readonly bool _closeGumps;
|
|
private readonly PlayerMobile _owner;
|
|
|
|
public override bool Singleton => true;
|
|
|
|
private QuestLogGump(PlayerMobile pm, bool closeGumps)
|
|
: base(1046026) // Quest Log
|
|
{
|
|
_owner = pm;
|
|
_closeGumps = closeGumps;
|
|
|
|
RegisterButton(ButtonPosition.Right, ButtonGraphic.Okay, 3);
|
|
|
|
SetPageCount(1);
|
|
}
|
|
|
|
public static void DisplayTo(Mobile from, PlayerMobile pm, bool closeGumps = true)
|
|
{
|
|
if (from?.NetState == null || pm == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (closeGumps)
|
|
{
|
|
pm.CloseGump<QuestLogDetailedGump>();
|
|
}
|
|
|
|
from.SendGump(new QuestLogGump(pm, closeGumps));
|
|
}
|
|
|
|
public static void DisplayTo(PlayerMobile pm)
|
|
{
|
|
if (pm?.NetState == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
pm.CloseGump<QuestLogDetailedGump>();
|
|
pm.SendGump(new QuestLogGump(pm, true));
|
|
}
|
|
|
|
protected override void BuildContent(ref DynamicGumpBuilder builder)
|
|
{
|
|
BuildPage(ref builder);
|
|
|
|
int numberColor, stringColor;
|
|
|
|
var context = MLQuestSystem.GetContext(_owner);
|
|
|
|
if (context != null)
|
|
{
|
|
var instances = context.QuestInstances;
|
|
|
|
for (var i = 0; i < instances.Count; ++i)
|
|
{
|
|
if (instances[i].Failed)
|
|
{
|
|
numberColor = 0x3C00;
|
|
stringColor = 0x7B0000;
|
|
}
|
|
else
|
|
{
|
|
numberColor = stringColor = 0xFFFFFF;
|
|
}
|
|
|
|
instances[i].Quest.Title.AddHtmlText(
|
|
ref builder,
|
|
98,
|
|
140 + 21 * i,
|
|
270,
|
|
21,
|
|
false,
|
|
false,
|
|
numberColor,
|
|
stringColor
|
|
);
|
|
builder.AddButton(368, 140 + 21 * i, 0x26B0, 0x26B1, 6 + i, GumpButtonType.Reply, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnResponse(NetState sender, in RelayInfo info)
|
|
{
|
|
if (info.ButtonID < 6)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var context = MLQuestSystem.GetContext(_owner);
|
|
|
|
if (context == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var instances = context.QuestInstances;
|
|
var index = info.ButtonID - 6;
|
|
|
|
if (index >= instances.Count)
|
|
{
|
|
return;
|
|
}
|
|
|
|
QuestLogDetailedGump.DisplayTo(sender.Mobile, instances[index], _closeGumps);
|
|
}
|
|
}
|
|
}
|