acdream/src/AcDream.App/UI/UiOptionToggleSlider.cs
Erik df9c7a35eb feat(ui): Campaign OP slice OP2 — tab control, template ListBox, UIOption widget mappings
Ships the two new widget primitives the retail Options panel needs plus the
four remaining UIOption_* factory mappings, so every tab page (OP3-OP6) has
somewhere to mount.

- ElementReader/ElementInfo gain three new dat-property readers, following
  the existing effective-state-resolution pattern (never a per-state
  first-wins scan, per the round-5 N1 lesson): the Type-8 tab table
  (property 0x2E -> TabTable), a ListBox's row-template list (property
  0x64 -> TemplateList), and scrollbar linkage (property 0x72 ->
  ScrollbarElementId). LayoutImporter gains one hook
  (IUiChildrenAttachedListener) so a widget can resolve cross-references
  its own dat properties name by id once its subtree actually exists.

- UiTabControl (Type 8): switches exactly one page-slot child visible,
  syncs each tab button's Open/Closed state via the existing
  RetailTabBinding helper, and honors the authored default tab on mount.

- UiTemplateListBox (Type 5 with an authored template list): wraps a
  UiScrollablePanel viewport (sealed, so composition not inheritance) and
  ports AddItemFromTemplateList(index) — the resolver seam a page
  controller wires with real DAT access via the SAME
  LayoutImporter.ImportInfos(dats, layoutId, elementId) overload
  RetailDialogFactory already uses for its catalog LayoutDesc.

- DatWidgetFactory maps the four remaining UIOption_* widgets, each
  verified against the regenerated options_2100002B.json fixture before
  writing any code: 0x10000037 (Slider) is structurally an ordinary
  horizontal UIElement_Scrollbar, so it reuses BuildScrollbar directly;
  0x10000038 (Menu) is structurally identical to the vendor category
  dropdown UiMenu already models, so it reuses `new UiMenu()` like the
  Type-6 case; 0x10000036 (CheckboxSlider) composes an existing
  UIOption_Checkbox child + UIOption_Slider child via the new
  UiOptionToggleSlider wrapper; 0x10000044 (CheckboxBitfield64) authors
  zero children in the dat (every row is added at runtime via retail's own
  AddChild(lowMask, highMask, label, tooltip) call shape), so it's a new
  UiCheckboxBitfield64 composing UiButton per row. No new drawing code
  anywhere in this set.

- Five new committed fixtures (options_2100002B/2100002A/21000028/
  2100005C/21000029) plus 25 new conformance tests pinning the tab table
  (4 entries, Gameplay default), all three template arrays, scrollbar
  linkage, every new widget-type mapping, and a UiTabControl behavioral
  test (switch -> exactly one page visible, click-through the tab
  button). The Character ListBox's authored 6-header/49-toggle shape
  (lane B section counts) is proven reachable end-to-end through
  AddItemFromTemplateList against the committed fixture.

- Regenerating fixtures also touched 27 PRE-EXISTING, unrelated fixtures
  (an Outline/OutlineColor field pair added by an earlier commit,
  bcc34ee3, that predates when those fixtures were last regenerated).
  Per the slice contract, that drift was NOT committed — reverted back to
  HEAD, only the five new Options-panel fixtures are new files here.

- Filed TS-72: UiCheckboxBitfield64's click-toggle bit math (AND/OR
  set/clear semantics) is a documented approximation — the decompiled
  excerpt this campaign pulled covers UIOption_CheckboxBitfield64::Apply's
  WRITE side, not its own click-handler's bit math. Flagged for OP5 (the
  Chat tab controller, the first consumer that reaches the wire) to
  verify against the real decomp before any live transaction depends on
  it; nothing user-reachable can observe this yet.

Full Release suite: 12,770 passed / 4 skipped / 0 failed (was 12,745/4/0
post-OP1 — 25 net new tests, zero regressions).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-11 00:06:43 +02:00

43 lines
2.1 KiB
C#

namespace AcDream.App.UI;
/// <summary>
/// Retail <c>UIOption_CheckboxSlider</c> (Type <c>0x10000036</c>) — a combined
/// toggle + slider option row (e.g. the Config tab's "Sound / Volume" pair: an
/// on/off LED plus a volume slider in one row). The dat class id lands on the
/// composite ROW'S OWN element (research doc §1.1: "row child element looked up —
/// the row root itself"), and the row authors NO media of its own; its content is
/// two NESTED option widgets — a <c>UIOption_Checkbox</c> child (dat id
/// <c>0x10000219</c> in every observed template) and a <c>UIOption_Slider</c> child
/// (<c>0x1000021C</c>) — verified against the regenerated <c>options_2100002B.json</c>
/// fixture's template elements <c>0x10000220</c>/<c>0x10000221</c>.
///
/// <para>
/// This widget does <b>not</b> consume its dat children: they build the ordinary
/// recursive way through <c>DatWidgetFactory</c>'s EXISTING checkbox (<c>0x10000035</c>
/// → <see cref="UiButton"/> via <c>BuildCheckbox</c>) and slider (<c>0x10000037</c> →
/// <see cref="UiScrollbar"/> via <c>BuildScrollbar</c>) mappings — no new drawing code,
/// per the campaign contract's "compose existing primitives" directive. Once the
/// subtree is attached (<see cref="IUiChildrenAttachedListener"/>), this widget just
/// grabs references to the two composed children for a page controller to bind
/// against directly instead of re-deriving them from child order/type.
/// </para>
/// </summary>
public sealed class UiOptionToggleSlider : UiElement, IUiChildrenAttachedListener
{
/// <summary>The composed checkbox (retail's LED half of the row).</summary>
public UiButton? Toggle { get; private set; }
/// <summary>The composed slider (retail's scalar half of the row).</summary>
public UiScrollbar? Slider { get; private set; }
public void OnChildrenAttached()
{
foreach (UiElement child in Children)
{
if (Toggle is null && child is UiButton button)
Toggle = button;
else if (Slider is null && child is UiScrollbar scrollbar)
Slider = scrollbar;
}
}
}