From 9a55a688caf79dc4db7157b29e0225622e764888 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 15 Jun 2026 14:03:24 +0200 Subject: [PATCH] =?UTF-8?q?refactor(D.2b):=20LayoutImporter=20review=20fix?= =?UTF-8?q?es=20=E2=80=94=20root-fallback=20trace=20+=20cursor-discard=20n?= =?UTF-8?q?ote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- src/AcDream.App/UI/Layout/LayoutImporter.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/AcDream.App/UI/Layout/LayoutImporter.cs b/src/AcDream.App/UI/Layout/LayoutImporter.cs index ce3d1ce8..2b9c8411 100644 --- a/src/AcDream.App/UI/Layout/LayoutImporter.cs +++ b/src/AcDream.App/UI/Layout/LayoutImporter.cs @@ -86,8 +86,12 @@ public static class LayoutImporter var byId = new Dictionary(); // Root is never a Type-12 prototype in practice; fall back to a generic // container if the factory returns null for an exotic root type. - var root = BuildWidget(rootInfo, resolve, datFont, byId) - ?? new UiDatElement(rootInfo, resolve); + var root = BuildWidget(rootInfo, resolve, datFont, byId); + if (root is null) + { + Console.WriteLine($"[D.2b] LayoutImporter: root element 0x{rootInfo.Id:X8} (type {rootInfo.Type}) produced no widget — using empty container fallback."); + root = new UiDatElement(rootInfo, resolve); + } return new ImportedLayout(root, byId); } @@ -228,7 +232,8 @@ public static class LayoutImporter /// private static void ReadState(StateDesc sd, string name, ElementInfo info) { - // First MediaDescImage in this state's Media list wins (format doc §5). + // Only MediaDescImage is read for rendering; MediaDescCursor items (on grips/drag bars) + // are intentionally skipped — cursor behavior is Plan 2. foreach (var m in sd.Media) { if (m is MediaDescImage img && img.File != 0)