using System; namespace AcDream.App.UI.Layout; /// /// Mounts retail's two-tab Map/House panel — LayoutDesc 0x2100006E /// slot 0x1000018C, /// id 16. Batch C (overnight hover/UI round, 2026-08-17), built on /// the / /// recipe (Type-8 tab host, , /// per-page scoped controllers). /// /// /// Slot/panelId/button — resolved, not guessed. The FA campaign's own /// full 16-slot gmPanelUI::SetupChildren dump /// (docs/research/2026-08-11-fa-panel-structure.md:927-933) already /// named slot 0x1000018C as "gmMapUI+gmHouseUI pages", panel id 16 — /// this session's MapHousePanelSlotProbeTests re-confirmed it live. /// The toolbar button is 0x1000019A (own authored /// P0x10000029 = 16), one of three currently-ghosted panel buttons /// (see docs/research/2026-08-17-map-house-recon.md). /// /// /// /// Tab table — live-DAT-confirmed. /// button 0x100001F3 -> page 0x100001F6 (Map, DEFAULT), /// button 0x100001F4 -> page 0x100001F7 (House). The page roots are /// themselves typed 0x10000026 (gmMapUI) / 0x10000025 /// (gmHouseUI) in the DAT — has no special /// case for either id, so they build as generic containers (same as every /// other unmodeled retail UI class); and /// find their own signature children by /// id underneath. /// /// /// /// Close button: 0x100001F5 (Type 1, top-right at /// (276,0) 24x25) — same authored position/size as the Social /// panel's own close button, the established gmPanelUI sibling /// convention. /// /// public sealed class MapHousePanelController : IRetainedPanelController { public const uint HostLayoutId = 0x2100006Eu; public const uint SlotElementId = 0x1000018Cu; private const uint MapButtonId = 0x100001F3u; private const uint MapPageId = 0x100001F6u; private const uint HouseButtonId = 0x100001F4u; private const uint HousePageId = 0x100001F7u; private const uint CloseButtonId = 0x100001F5u; public sealed record Callbacks( Action Toggle, MapPageController.Bindings Map, HousePageController.Bindings House); private readonly UiTabPanel _tabPanel; private readonly MapPageController? _map; private readonly HousePageController? _house; private readonly Action _onActivePageChanged; private bool _visible; private bool _disposed; public UiElement Root => _tabPanel; public UiTabPanel TabPanel => _tabPanel; private MapHousePanelController( UiTabPanel tabPanel, MapPageController? map, HousePageController? house) { _tabPanel = tabPanel; _map = map; _house = house; // House's outbound query is a fire-when-shown convenience (see // HousePageController.Bindings.OnShown's own doc — not a ported // retail trigger, an acdream one), gated the same "window shown AND // my tab active" conjunction the social panel's Fellowship/ // Allegiance pages use for their own declarations. _onActivePageChanged = (_, _) => FireHouseShownIfActive(); _tabPanel.ActivePageChanged += _onActivePageChanged; } /// The pre-Build tree /// was built from — /// needs it to read m_pMap's own authored int/enum attrs, which /// only exist on , not the built /// tree. public static MapHousePanelController? Bind( ElementInfo rootInfo, ImportedLayout layout, Callbacks callbacks) { ArgumentNullException.ThrowIfNull(rootInfo); ArgumentNullException.ThrowIfNull(layout); ArgumentNullException.ThrowIfNull(callbacks); if (layout.Root is not UiTabPanel tabPanel) { Console.WriteLine( "[D.2b] MapHousePanelController.Bind: root did not build as UiTabPanel " + $"(actual type {layout.Root.GetType().Name}) — Map/House panel will not open."); return null; } if (layout.FindElement(CloseButtonId) is UiButton close) close.OnClick = callbacks.Toggle; else Console.WriteLine( $"[D.2b] MapHousePanelController: close button 0x{CloseButtonId:X8} not found."); UiElement? mapPage = UiElement.FindDescendant(tabPanel, MapPageId); UiElement? housePage = UiElement.FindDescendant(tabPanel, HousePageId); MapPageController? map = null; if (mapPage is not null) { ElementInfo? mapPageInfo = FindInfo(rootInfo, MapPageId); map = mapPageInfo is null ? null : MapPageController.Bind(mapPage, mapPageInfo, callbacks.Map); } HousePageController? house = housePage is null ? null : HousePageController.Bind(housePage, callbacks.House); if (mapPage is null) Console.WriteLine($"[D.2b] MapHousePanelController: Map page 0x{MapPageId:X8} not found."); if (housePage is null) Console.WriteLine($"[D.2b] MapHousePanelController: House page 0x{HousePageId:X8} not found."); return new MapHousePanelController(tabPanel, map, house); } public void ActivateTabs() => _tabPanel.ActivateTabBehavior(); public bool IsShowingHouse => _tabPanel.ActivePageElementId == HousePageId; public void OnShown() { _visible = true; FireHouseShownIfActive(); } public void OnHidden() => _visible = false; private void FireHouseShownIfActive() { if (_visible && IsShowingHouse) _house?.OnShown(); } /// Per-frame poll: Map's 5 s-gated refresh (cheap when not due) /// and House's revision-gated row rebuild. Both stay unconditional /// (unlike Friends/Squelch's DAT-locked rebuild) — Map's own cadence /// gate and House's list compare are both cheap even while hidden. public void Tick(double deltaSeconds) { if (_disposed) return; _map?.Tick(deltaSeconds); _house?.Tick(); } public void Dispose() { if (_disposed) return; _disposed = true; _tabPanel.ActivePageChanged -= _onActivePageChanged; } private static ElementInfo? FindInfo(ElementInfo info, uint id) { if (info.Id == id) return info; foreach (ElementInfo child in info.Children) { ElementInfo? found = FindInfo(child, id); if (found is not null) return found; } return null; } }