feat(ui): authored state media animates, so the unseen-text indicator blinks
The blink is not code. It is data, and we were throwing it away. A retail UI state's media is a small program: images interleaved with timed pauses, branches, and a terminal hand-off to another state. Our importer kept the FIRST image per state and dropped the rest, so nothing authored could ever animate — the indicator was correct in every other respect and simply sat still. Measured from the installed dats (LayoutDump --media 0x1000048C), the chat unseen-text indicator's Normal state authors thirteen steps: two frames alternating every half second, three times, then `State 13` — Ghosted, whose authored 0x3B is Invisible. So retail's indicator is a three-second attention FLASH that hides itself, not a badge that stays lit until you scroll to the bottom. Nobody would guess that from the code, because there is no blink code anywhere; the behaviour lives entirely in the authored sequence. Our shipped version stayed lit, which is the one thing the data says it must not do. Sampling is a pure function of (steps, elapsed) rather than a playback object holding a cursor, so an element only has to remember WHEN its state began and the whole thing is testable without a clock, a GPU or a frame loop. One shared UiMediaClock is advanced once per frame by RetailUiRuntime; a UI element has no tick of its own. The controller change is the other half: it starts the flash on the rising edge ONLY. Re-setting Normal every frame would pin the sequence on frame zero and it would never blink at all — which is the failure mode the second new test exists to catch, and which no "is it visible?" assertion would notice. When the sequence reaches its terminal step the controller follows it down instead of re-lighting it. Two guesses are refused rather than made, and both are registered: a Pause's max duration (every sequence measured sets min == max, and what the range MEANS is not in the decomp) and a sub-1 branch probability (falls through, the direction where a malformed sequence stops rather than animates forever). A jump-cycle with no elapsed time is bounded so a bad sequence cannot spin inside a frame. Kept `Other` steps in the list rather than filtering them, so a jump's authored index still lands on the entry it names. Register: CT-3, CT-4. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f44f7641b1
commit
89db9a794c
10 changed files with 557 additions and 56 deletions
|
|
@ -49,49 +49,42 @@ Print(root, 0);
|
|||
int mediaAt = Array.IndexOf(args, "--media");
|
||||
if (mediaAt >= 0)
|
||||
{
|
||||
// The RAW media sequence per state, straight off the LayoutDesc. ElementInfo
|
||||
// keeps only the first image, so an animation is invisible above that level.
|
||||
// The RESOLVED media sequence per state — inheritance already applied by
|
||||
// ImportInfos, which is what the raw LayoutDesc walk could not do.
|
||||
uint wanted = mediaAt + 1 < args.Length
|
||||
? Convert.ToUInt32(args[mediaAt + 1], 16)
|
||||
: 0u;
|
||||
// Layouts are not necessarily in Portal — go through the adapter, the same
|
||||
// way LayoutImporter does.
|
||||
var ld = adapter.Get<DatReaderWriter.DBObjs.LayoutDesc>(ids[0]);
|
||||
if (ld is null)
|
||||
{
|
||||
Console.WriteLine($"layout 0x{ids[0]:X8} not found");
|
||||
return 2;
|
||||
}
|
||||
|
||||
foreach (var top in ld.Elements)
|
||||
Walk(top.Value);
|
||||
WalkMedia(root);
|
||||
return 0;
|
||||
|
||||
void Walk(DatReaderWriter.Types.ElementDesc d)
|
||||
void WalkMedia(ElementInfo e)
|
||||
{
|
||||
if (wanted == 0 || d.ElementId == wanted)
|
||||
if (wanted == 0 || e.Id == wanted)
|
||||
{
|
||||
Console.WriteLine($"element 0x{d.ElementId:X8}");
|
||||
if (d.States.Count == 0)
|
||||
Console.WriteLine($"element 0x{e.Id:X8}");
|
||||
foreach (var (stateId, st) in e.States.OrderBy(kv => kv.Key))
|
||||
{
|
||||
// Raw descriptors only carry what THIS element overrides; states
|
||||
// and their media usually come from the base element, and
|
||||
// LayoutDesc::InqFullDesc @0x0069A520 resolves that chain.
|
||||
// Following it here would mean reimplementing LayoutImporter's
|
||||
// Resolve, so say so rather than imply the element has none.
|
||||
if (st.MediaSteps.Count == 0) continue;
|
||||
Console.WriteLine(
|
||||
$" (no states of its own — inherited from base 0x{d.BaseElement:X8};"
|
||||
+ " raw media not resolved here)");
|
||||
}
|
||||
foreach (var st in d.States)
|
||||
{
|
||||
Console.WriteLine($" state {st.Key}: {st.Value.Media.Count} media");
|
||||
foreach (var m in st.Value.Media)
|
||||
Console.WriteLine($" {m.GetType().Name}");
|
||||
$" state {stateId}{(st.Name.Length != 0 ? $" ({st.Name})" : "")}"
|
||||
+ $": {st.MediaSteps.Count} steps");
|
||||
for (int i = 0; i < st.MediaSteps.Count; i++)
|
||||
{
|
||||
UiMediaStep m = st.MediaSteps[i];
|
||||
string detail = m.Kind switch
|
||||
{
|
||||
UiMediaStepKind.Image => $"file=0x{m.File:X8} draw={m.DrawMode}",
|
||||
UiMediaStepKind.Pause => $"min={m.MinDuration} max={m.MaxDuration}",
|
||||
UiMediaStepKind.Jump => $"to={m.JumpIndex} p={m.Probability}",
|
||||
UiMediaStepKind.State => $"state={m.JumpIndex} p={m.Probability}",
|
||||
_ => $"MediaType={(DatReaderWriter.Enums.MediaType)m.RawType}",
|
||||
};
|
||||
Console.WriteLine($" [{i,2}] {m.Kind,-6} {detail}");
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var child in d.Children)
|
||||
Walk(child.Value);
|
||||
foreach (ElementInfo child in e.Children)
|
||||
WalkMedia(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue