fix(ui): OP2 rework — dormant UiDatElement subclasses, fixed Panel/CheckboxBitfield64 mechanism
OP2 (df9c7a35) was double-REJECTed: an unconditional Type-8/Type-5 factory
mapping silently re-classed 15 elements across 7 shipped panels (vendor
backdrop lost its fill, character/spellbook roots stopped passing clicks
through, combat gained a phantom import-time tab takeover, ten ListBoxes
gained a spurious hit-testable viewport) because the stale 27 pre-existing
fixtures never exercised the new fields — and the mechanism itself cited a
nonexistent "UIElement_TabControl" class, inverted UiCheckboxBitfield64's
checked-state predicate, and synthesized fake per-row geometry instead of
using the widget's own authored template.
Shape change: UiTabPanel (renamed from UiTabControl) and UiTemplateListBox
now derive from UiDatElement (unsealed) and stay DORMANT by default — an
imported Type-8/Type-5 element gets authored-media drawing, ClickThrough
generic-decoration default, and IUiDatStateful propagation identical to the
pre-OP2 UiDatElement fallback, with zero import-time side effects. The
factory's Type-8/Type-5 arms are unconditional again (no more guard whose
premise the blast-radius sweep proved false), because dormancy makes an
unactivated instance behaviorally indistinguishable from the old fallback.
UiTabPanel.ActivateTabBehavior() and UiTemplateListBox's lazy viewport
creation are the explicit, controller-driven opt-ins Campaign OP slice OP3+
will call; today nothing does, so the four pre-existing shipped Type-8
hosts (character/spellbook/vendor/combat) and ten pre-existing Type-5
ListBoxes keep their pre-OP2 behavior exactly. Filed AD-73 for this
dormant-vs-retail's-unconditional-activation adaptation.
Mechanism fixes (docs/research/2026-08-11-op2-review-mechanism.md):
- UiTabPanel cites UIElement_Panel (Type 8 is UIElement_Panel; no
UIElement_TabControl exists in the PDB), resolves buttons/pages via a
GetChildRecursive-equivalent descendant search (not direct-children-only),
performs no switch when no entry authors 0x32 (deleted the _tabs[0]
fallback), and surfaces unresolved tab-table entries via UnresolvedEntries
+ a diagnostic line instead of a silent no-op.
- ElementReader.ReadTabTable skips entries missing 0x30/0x31, matching
retail's SetupTabPageHash @0x0046C2E0 entry filter.
- UiCheckboxBitfield64 now builds every row from its OWN authored template
(property 0x64 -> {0x2100002B, 0x10000521}) via AddItemFromTemplateList,
deleting the synthesized ElementInfo + invented RowHeight=14 — matching
retail's CreateChildren @0x00485DF0, which is itself a UIElement_ListBox
call. IsSet is now retail's ANY-bit-set predicate (Refresh @0x004859C0),
not all-bits-set. TS-72 retired: the click-toggle bit math is now fully
decomp-confirmed (SetBitsOnOrOff via ListenToElementMessage @0x00485AE0).
Regenerated all 32 UI fixtures against real DAT (ACDREAM_REGENERATE_UI_FIXTURES=1)
and committed them — 27 pre-existing fixtures now carry Outline/OutlineColor/
TabTable/TemplateList/ScrollbarElementId; the 5 Options fixtures were already
current. Updated EffectsUiControllerTests' now-correct UiTemplateListBox
class-identity assertion. Added: 6 built-widget behavior pins for all five
pre-existing Type-8 elements + a representative Type-5 element the dormancy
model protects (OP2ReworkBlastRadiusConformanceTests.cs); 5 reader-level
tests driving ReadTabTable/ReadTemplateList/the 0x72 reader from raw
property bags (ElementReaderTests.cs); a multi-bit-mask UiCheckboxBitfield64
test proving the any-bit predicate (the prior single-bit test couldn't
distinguish it from all-bits); an activation-idempotency test and a
before-activation click-is-inert test for UiTabPanel.
Full Release suite: 12,868 passed / 4 skipped / 0 failed (baseline 12,853/4/0
post-OP1-fixes; +15 net new tests, zero regressions).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
8a05fda445
commit
b236a44279
40 changed files with 6249 additions and 1145 deletions
|
|
@ -93,21 +93,30 @@ public static class DatWidgetFactory
|
|||
or IndicatorBarController.VitaeClassId => BuildButton(
|
||||
info, resolve, elementFont, fontResolve, stringResolve),
|
||||
// gmUIElement_*Indicator custom button classes
|
||||
// UIElement_ListBox (Type 5) with an authored row-template list (dat
|
||||
// property 0x64) — the Options panel's Character/Chat/Config ListBoxes
|
||||
// (docs/research/2026-08-10-options-panel-structure.md §1.5). Gated on
|
||||
// info.TemplateList.Count > 0 so an ORDINARY Type-5 ListBox that authors
|
||||
// no template array (none currently reach this factory — vendor's category
|
||||
// dropdown is drawn procedurally by UiMenu.Scrollable, not imported as a
|
||||
// live Type-5 widget) keeps falling to the generic UiDatElement fallback
|
||||
// unchanged (OP2 acceptance: no behavior change to any existing widget).
|
||||
5 when info.TemplateList.Count > 0 => new UiTemplateListBox(
|
||||
info.TemplateList, info.ScrollbarElementId),
|
||||
// UIElement_ListBox (Type 5). OP2 rework (docs/research/2026-08-11-op2-
|
||||
// review-blast.md MUST-FIX 2): every pre-existing Type-5 element that
|
||||
// reaches this factory already authors a non-empty row-template array
|
||||
// (dat property 0x64) — the original "none currently reach this factory"
|
||||
// premise was false. UiTemplateListBox now derives from UiDatElement and
|
||||
// stays DORMANT (no viewport, no behavior change) until a controller calls
|
||||
// AddItemFromTemplateList, so mapping every Type-5 element unconditionally
|
||||
// is safe: an element with an empty TemplateList behaves EXACTLY like the
|
||||
// pre-OP2 UiDatElement fallback (media drawn, ClickThrough=true, state
|
||||
// propagation) because nothing ever activates it.
|
||||
5 => new UiTemplateListBox(info, resolve, info.TemplateList, info.ScrollbarElementId),
|
||||
6 => new UiMenu(), // UIElement_Menu (reg :120163)
|
||||
7 => BuildMeter(info, resolve, elementFont), // UIElement_Meter
|
||||
// UIElement_TabControl (Type 8) — the Options panel's tab strip (dat
|
||||
// property 0x2E; same research doc §1.3/§10.1).
|
||||
8 => new UiTabControl(info.TabTable),
|
||||
// UIElement_Panel (Type 8) — retail's tab-strip host (dat property 0x2E;
|
||||
// research doc §1.3/§10.1). OP2 rework (docs/research/2026-08-11-op2-
|
||||
// review-mechanism.md MUST-FIX 5): Type 8 is UIElement_Panel, NOT a class
|
||||
// called "UIElement_TabControl" (that name does not exist in the named-
|
||||
// retail PDB). UiTabPanel derives from UiDatElement and stays DORMANT (see
|
||||
// its class doc) until a controller calls ActivateTabBehavior(), so mapping
|
||||
// every Type-8 element unconditionally is safe for the same reason as the
|
||||
// Type-5 arm above — including the vendor backdrop 0x1000008D, which has NO
|
||||
// tab table and now keeps its authored DirectState fill via the UiDatElement
|
||||
// base instead of losing it to a bare UiElement with no OnDraw.
|
||||
8 => new UiTabPanel(info, resolve, info.TabTable),
|
||||
9 => BuildResizeGrip(info, resolve), // UIElement_Resizebar (reg 0x0046B920)
|
||||
0xD => new UiViewport(), // UIElement_Viewport — 3-D mini-scene blit leaf
|
||||
11 => BuildScrollbar(info, resolve), // UIElement_Scrollbar (reg :124137)
|
||||
|
|
@ -142,11 +151,15 @@ public static class DatWidgetFactory
|
|||
// ChatWindowController wires the channel menu.
|
||||
0x10000038u => new UiMenu(),
|
||||
// UIOption_CheckboxBitfield64 (Type 0x10000044): the Chat tab's per-window
|
||||
// text-filter block. Its authored template (0x10000520) carries no children
|
||||
// or media at all — every row is added at runtime via AddChild(lowMask,
|
||||
// highMask, label, tooltip), matching retail's own
|
||||
// gmChatOptionsUI::AddCheckboxBitfield64Option call pattern (research doc §5.2).
|
||||
0x10000044u => BuildCheckboxBitfield64(resolve, elementFont),
|
||||
// text-filter block. OP2 rework (docs/research/2026-08-11-op2-review-
|
||||
// mechanism.md MUST-FIX 4): the authored template (0x10000520) DOES author
|
||||
// content — its own row-template list (dat property 0x64 -> {0x2100002B,
|
||||
// 0x10000521}) — and retail CreateChildren @0x00485DF0 builds every row
|
||||
// through AddItemFromTemplateList(this, 0, nullptr), matching retail's own
|
||||
// gmChatOptionsUI::AddCheckboxBitfield64Option call pattern (research doc
|
||||
// §5.2). AddChild(lowMask, highMask, label, tooltip) resolves that SAME
|
||||
// template per row instead of synthesizing a fake ElementInfo.
|
||||
0x10000044u => new UiCheckboxBitfield64(info.TemplateList),
|
||||
_ => new UiDatElement(info, resolve), // generic fallback (incl. Type 3 chrome/containers)
|
||||
};
|
||||
|
||||
|
|
@ -800,21 +813,6 @@ public static class DatWidgetFactory
|
|||
return button;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a blank <see cref="UiCheckboxBitfield64"/> seeded with the sprite
|
||||
/// resolver and dat font a page controller's later
|
||||
/// <see cref="UiCheckboxBitfield64.AddChild(ulong, ulong, string, string?)"/>
|
||||
/// calls need — the template authors no rows, so there is nothing else to read
|
||||
/// from <c>ElementInfo</c> at import time.
|
||||
/// </summary>
|
||||
private static UiCheckboxBitfield64 BuildCheckboxBitfield64(
|
||||
Func<uint, (uint, int, int)> resolve, UiDatFont? elementFont)
|
||||
=> new()
|
||||
{
|
||||
SpriteResolve = resolve,
|
||||
LabelFont = elementFont,
|
||||
};
|
||||
|
||||
private static ElementInfo? FindStatefulFaceChild(ElementInfo info)
|
||||
=> FindStatefulFaceChildren(info).FirstOrDefault();
|
||||
|
||||
|
|
|
|||
|
|
@ -517,6 +517,13 @@ public static class ElementReader
|
|||
if (item.Kind != UiPropertyKind.Struct) continue;
|
||||
uint buttonId = ReadStructMemberId(item.StructValue, 0x30u);
|
||||
uint pageId = ReadStructMemberId(item.StructValue, 0x31u);
|
||||
// Retail UIElement_Panel::SetupTabPageHash @0x0046C2E0 skips an entry whose
|
||||
// InqProperty(0x30) (@0x0046C3E5) or InqProperty(0x31) (@0x0046C3FC) is
|
||||
// missing — a partial entry never enters m_TabPageHash. ReadStructMemberId
|
||||
// returns 0 for a missing/uncoercible member, and 0 is never a valid dat
|
||||
// element id, so treat it the same way: skip, don't admit a zero-id entry
|
||||
// that could still participate in SwitchTo and hide a page.
|
||||
if (buttonId == 0u || pageId == 0u) continue;
|
||||
bool isDefault = item.StructValue.TryGetValue(0x32u, out var flag)
|
||||
&& flag.Kind == UiPropertyKind.Bool
|
||||
&& flag.BoolValue;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ public static class LayoutImporter
|
|||
stateful.TrySetRetailState(stateful.ActiveRetailStateId);
|
||||
|
||||
// See IUiChildrenAttachedListener: a widget that must resolve OTHER children by
|
||||
// dat element id (e.g. UiTabControl's tab table) can only do so once its subtree
|
||||
// dat element id (e.g. UiTabPanel's tab table) can only do so once its subtree
|
||||
// is actually attached, which just happened above.
|
||||
if (w is IUiChildrenAttachedListener childrenAttached)
|
||||
childrenAttached.OnChildrenAttached();
|
||||
|
|
|
|||
|
|
@ -27,8 +27,20 @@ namespace AcDream.App.UI.Layout;
|
|||
/// <see cref="AcDream.App.Rendering.TextureCache.UploadRgba8"/> sets
|
||||
/// <c>GL_REPEAT</c> on both S and T, so vertical tiling is always active.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// <b>OP2 rework (2026-08-11):</b> unsealed so behavioral Type-8/Type-5 widgets
|
||||
/// (<see cref="UiTabPanel"/>, <see cref="UiTemplateListBox"/>) can subclass it and stay
|
||||
/// DORMANT by default — every element of those two dat Types that reaches
|
||||
/// <see cref="DatWidgetFactory"/> gets this exact media-draw / <c>ClickThrough</c> /
|
||||
/// <see cref="IUiDatStateful"/> behavior unless a controller explicitly opts a specific
|
||||
/// instance into its behavioral mechanism. This is what makes the unconditional Type-8/
|
||||
/// Type-5 factory mappings safe for the pre-existing shipped panels the OP2 REJECT
|
||||
/// findings named (`docs/research/2026-08-11-op2-review-blast.md`,
|
||||
/// `docs/research/2026-08-11-op2-review-mechanism.md`).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed class UiDatElement : UiElement, IUiDatStateful
|
||||
public class UiDatElement : UiElement, IUiDatStateful
|
||||
{
|
||||
// DrawModeType enum values from DatReaderWriter.Enums.
|
||||
// See docs/research/2026-06-15-layoutdesc-format.md §6.
|
||||
|
|
@ -39,13 +51,16 @@ public sealed class UiDatElement : UiElement, IUiDatStateful
|
|||
private const int DrawAlphablend = 3;
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
private readonly ElementInfo _info;
|
||||
/// <summary>Protected so subclasses (e.g. <see cref="UiTabPanel"/>,
|
||||
/// <see cref="UiTemplateListBox"/>) can read authored state/media for their own
|
||||
/// mechanism-specific fields without a second copy of the merged snapshot.</summary>
|
||||
protected readonly ElementInfo Info;
|
||||
private readonly Func<uint, (uint tex, int w, int h)> _resolve;
|
||||
|
||||
/// <summary>The dat element id from <see cref="ElementInfo.Id"/>. Exposed so controllers
|
||||
/// can identify which logical element a UiDatElement represents when walking subtrees
|
||||
/// (e.g. footer state groups that appear once per tab page but share the same dat id).</summary>
|
||||
public uint ElementId => _info.Id;
|
||||
public uint ElementId => Info.Id;
|
||||
|
||||
/// <summary>Which state name to render. <c>""</c> = the unnamed DirectState.
|
||||
/// Falls back to DirectState if the named state is absent.</summary>
|
||||
|
|
@ -57,7 +72,7 @@ public sealed class UiDatElement : UiElement, IUiDatStateful
|
|||
{
|
||||
if (string.IsNullOrEmpty(ActiveState))
|
||||
return UiStateInfo.DirectStateId;
|
||||
foreach (var (id, state) in _info.States)
|
||||
foreach (var (id, state) in Info.States)
|
||||
if (string.Equals(state.Name, ActiveState, StringComparison.Ordinal))
|
||||
return id;
|
||||
return UiButtonStateMachine.TryStateId(ActiveState, out uint standard)
|
||||
|
|
@ -73,12 +88,12 @@ public sealed class UiDatElement : UiElement, IUiDatStateful
|
|||
UiStateInfo? selectedState = null;
|
||||
if (stateId == UiStateInfo.DirectStateId)
|
||||
{
|
||||
if (!_info.States.TryGetValue(stateId, out selectedState)
|
||||
&& !_info.StateMedia.ContainsKey(""))
|
||||
if (!Info.States.TryGetValue(stateId, out selectedState)
|
||||
&& !Info.StateMedia.ContainsKey(""))
|
||||
return false;
|
||||
ActiveState = "";
|
||||
}
|
||||
else if (_info.States.TryGetValue(stateId, out selectedState))
|
||||
else if (Info.States.TryGetValue(stateId, out selectedState))
|
||||
{
|
||||
ActiveState = selectedState.Name;
|
||||
}
|
||||
|
|
@ -87,7 +102,7 @@ public sealed class UiDatElement : UiElement, IUiDatStateful
|
|||
string stateName = UiButtonStateMachine.StateName(stateId);
|
||||
if (string.IsNullOrEmpty(stateName))
|
||||
stateName = RetailUiStateIds.StateName(stateId);
|
||||
if (string.IsNullOrEmpty(stateName) || !_info.StateMedia.ContainsKey(stateName))
|
||||
if (string.IsNullOrEmpty(stateName) || !Info.StateMedia.ContainsKey(stateName))
|
||||
return false;
|
||||
ActiveState = stateName;
|
||||
}
|
||||
|
|
@ -106,7 +121,7 @@ public sealed class UiDatElement : UiElement, IUiDatStateful
|
|||
/// Returns (0,0,0) when the texture is not yet uploaded.</param>
|
||||
public UiDatElement(ElementInfo info, Func<uint, (uint tex, int w, int h)> resolve)
|
||||
{
|
||||
_info = info;
|
||||
Info = info;
|
||||
_resolve = resolve;
|
||||
ClickThrough = true; // generic decoration; behavioral widgets opt back in
|
||||
|
||||
|
|
@ -133,8 +148,8 @@ public sealed class UiDatElement : UiElement, IUiDatStateful
|
|||
/// </summary>
|
||||
// exposed for unit testing
|
||||
public (uint File, int DrawMode) ActiveMedia()
|
||||
=> _info.StateMedia.TryGetValue(ActiveState, out var m) ? m
|
||||
: _info.StateMedia.TryGetValue("", out var d) ? d
|
||||
=> Info.StateMedia.TryGetValue(ActiveState, out var m) ? m
|
||||
: Info.StateMedia.TryGetValue("", out var d) ? d
|
||||
: (0u, 0);
|
||||
|
||||
/// <summary>Optional click handler. Set by a controller for interactive dat
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue