feat(D.2b): importer renders Type-12-with-sprites + carries DefaultState
Task G1: two gaps blocked chat window static sprite elements from rendering. Change 1 — DatWidgetFactory: only skip Type-12 elements that have no own state media (pure style prototypes). A Type-12 element that carries sprites (e.g. a chat Send button whose derived Type-0 element inherited Type 12 from its base prototype) now renders as a UiDatElement. Change 2 — ElementInfo: add DefaultStateName field (string, default ""). Change 3 — LayoutImporter.ToInfo: read ElementDesc.DefaultState.ToString() into DefaultStateName; normalize Undef/Undefined/0 sentinels to "". Change 4 — ElementReader.Merge: inherit DefaultStateName (derived wins if non-empty, else base). Change 5 — UiDatElement ctor: initialize ActiveState to DefaultStateName when set; else "Normal" when a Normal-state sprite is present (retail's implicit default for buttons/tabs); else "" (DirectState). This makes the Send button, max/min button, and numbered tabs render their default sprite without requiring explicit state assignment at runtime. Vitals neutrality: all vitals chrome/grip elements carry DirectState-only sprites with no "Normal" named state and DefaultStateName="" (Undef in dat), so their ActiveState stays "" and their existing conformance tests are unaffected. Vitals text labels (Type 0→12 via Merge, no StateMedia) are still skipped by the refined Type-12 guard (StateMedia.Count==0). Tests: 4 new tests (2 in DatWidgetFactoryTests, 3 in UiDatElementTests). All 386 pass; 387 total (1 pre-existing skip). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c2170ab18f
commit
6e6339b026
6 changed files with 126 additions and 19 deletions
|
|
@ -9,8 +9,10 @@ namespace AcDream.App.UI.Layout;
|
|||
/// <see cref="UiDatElement"/>.
|
||||
///
|
||||
/// <para>
|
||||
/// Type 12 (style prototype / BaseElement store) is never instantiated —
|
||||
/// <see cref="Create"/> returns null and the importer skips it.
|
||||
/// Type 12 elements that carry NO own state media (pure style prototypes /
|
||||
/// BaseElement stores) return null from <see cref="Create"/> and are skipped.
|
||||
/// Type 12 elements that DO carry own sprites (e.g. a chat element whose Type-0
|
||||
/// derived form inherited Type 12 from its base prototype) are rendered normally.
|
||||
/// See docs/research/2026-06-15-layoutdesc-format.md Correction 8.
|
||||
/// </para>
|
||||
///
|
||||
|
|
@ -42,14 +44,16 @@ public static class DatWidgetFactory
|
|||
/// Returns (0,0,0) when the texture is not yet uploaded.</param>
|
||||
/// <param name="datFont">Retail UI font for the meter's "cur/max" number overlay.
|
||||
/// May be null pre-load — the meter falls back to the debug bitmap font.</param>
|
||||
/// <returns>The widget, or <c>null</c> for a Type-12 style prototype (caller skips it).</returns>
|
||||
/// <returns>The widget, or <c>null</c> for a pure Type-12 style prototype with no own sprites (caller skips it).</returns>
|
||||
public static UiElement? Create(ElementInfo info,
|
||||
Func<uint, (uint, int, int)> resolve, UiDatFont? datFont)
|
||||
{
|
||||
// Type 12 = zero-size style prototype / BaseElement store referenced by
|
||||
// BaseLayoutId. These are property bags, never rendered. See format doc §8
|
||||
// ("style prototypes are Type 12 which must be skipped") and Correction 8.
|
||||
if (info.Type == 12) return null;
|
||||
// Type 12 = style prototype / BaseElement store referenced by BaseLayoutId.
|
||||
// PURE prototypes (no own state media) are property bags — never rendered; skip them.
|
||||
// A Type-12 element that carries its own state media (e.g. a chat Send button whose
|
||||
// Type-0 derived element inherited Type 12 from its base prototype) has sprites to
|
||||
// show and must render. See format doc §8 and the G1 task note.
|
||||
if (info.Type == 12 && info.StateMedia.Count == 0) return null;
|
||||
|
||||
UiElement e = info.Type switch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue