docs(quest): plan Campaign QT, and add the layout search that found the panel

H.3's roadmap line ("122 EmoteType x 39 Trigger mini-VM") describes the
SERVER's job. The retail client never stores a quest flag, never evaluates an
emote, and is never told a flag changed — so most of H.3 was never client work
at all. Measuring what we already have narrows the remaining scope to one
thing: the contract tracker, the only structured view of quest state a client
ever gets. The user confirmed NPC dialogue works live.

LayoutDump could only dump a layout you already knew the id of, but the decomp
hands you a CLASS id with no layout attached (UIElement::RegisterElementClass),
so the gap between the two was crossed by guessing. --find closes it, and it
searches the element's TYPE as well as its id because registration keys on
Type — searching only the id finds a real element with the same number and
quietly answers the wrong question, which is exactly what it did on the first
run here.

The plan records the wire layout, the panel's authored children, and
FillProgressString in full, including the three things a reimplementation
would get wrong: TimeWhenDone is never read, the countdown anchor is not on
the wire, and DescriptionProgress is a printf format rather than a string.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-21 14:36:04 +02:00
parent 0e0a77c9b1
commit 730662f819
2 changed files with 204 additions and 0 deletions

View file

@ -18,6 +18,7 @@ using SysEnv = System.Environment;
if (args.Length == 0)
{
Console.WriteLine("usage: LayoutDump <layoutId> [rootElementId] [--states]");
Console.WriteLine(" LayoutDump --find <elementIdOrType>");
return 1;
}
@ -34,6 +35,85 @@ string datDir = SysEnv.GetEnvironmentVariable("ACDREAM_DAT_DIR")
using var dats = new DatCollection(datDir, DatAccessType.Read);
using var adapter = new DatCollectionAdapter(dats);
int findAt = Array.IndexOf(args, "--find");
if (findAt >= 0)
{
// "Which layout owns this element?" -- the question every panel port
// starts with, and the one this tool could not answer. Retail registers a
// panel class against an ELEMENT id (UIElement::RegisterElementClass), so
// the decomp hands you an id with no layout attached to it; without a scan
// the only way across that gap is guessing at 0x21xxxxxx ids.
uint wantedElement = findAt + 1 < args.Length
? Convert.ToUInt32(args[findAt + 1], 16)
: 0u;
if (wantedElement == 0)
{
Console.WriteLine("--find needs an element id");
return 1;
}
int scanned = 0;
int hits = 0;
foreach (uint layoutId in dats.GetAllIdsOfType<DatReaderWriter.DBObjs.LayoutDesc>().OrderBy(i => i))
{
scanned++;
ElementInfo? candidate;
try
{
candidate = LayoutImporter.ImportInfos(adapter, layoutId);
}
catch (Exception e)
{
// A layout this importer cannot read is a finding, not a stop --
// the whole point is to sweep every one of them.
Console.WriteLine($" layout 0x{layoutId:X8}: FAILED TO IMPORT ({e.GetType().Name})");
continue;
}
if (candidate is null)
continue;
if (FindElement(candidate, wantedElement, out string path))
{
hits++;
Console.WriteLine($"layout 0x{layoutId:X8} {path}");
}
}
Console.WriteLine();
Console.WriteLine($"element 0x{wantedElement:X8}: {hits} hit(s) across {scanned} layouts");
return hits > 0 ? 0 : 2;
// Matches an element's ID or its TYPE. Retail's
// UIElement::RegisterElementClass keys a panel class on the TYPE field
// (0xC = Text, 0x19 = WaitDialog, 0x1000004B = gmContractsUI), so a class
// id out of the decomp is a type; an id out of a layout dump is an id.
// Searching only one of them silently finds the wrong element, because
// the two share a number space.
static bool FindElement(ElementInfo e, uint wanted, out string path)
{
if (e.Id == wanted || (uint)e.Type == wanted)
{
string how = e.Id == wanted ? "id" : "TYPE";
path = $"0x{e.Id:X8} (match on {how}; type 0x{e.Type:X}, "
+ $"{e.Width}x{e.Height} at {e.X},{e.Y})";
return true;
}
foreach (ElementInfo child in e.Children)
{
if (FindElement(child, wanted, out path))
{
path = $"0x{e.Id:X8} > {path}";
return true;
}
}
path = string.Empty;
return false;
}
}
ElementInfo? root = ids.Length > 1
? LayoutImporter.ImportInfos(adapter, ids[0], ids[1])
: LayoutImporter.ImportInfos(adapter, ids[0]);