Mounts host 0x2100006E slot 0x1000018C (RetailPanelCatalog.MapHouse = 16) as a two-tab UiTabPanel (Map default, House second) through the OP3/FA3 recipe (LayoutImporter.Build -> Bind -> ActivateTabBehavior). Toolbar button 0x1000019A un-ghosts (added to both RetailPanelCatalog.Mounted and .Toolbar). Combined into one commit because MapHousePanelController.Bind depends on both MapPageController and HousePageController existing — splitting them would mean landing dead code first. Map tab (gmMapUI, MapPageController): - Calendar formatter matching gmMapUI::Update's "Date: %s\nTime: %s" shape, reusing WorldTimeService.CurrentCalendar (new Func<DerethDateTime.Calendar> dependency threaded through InteractionRetainedUiDependencies/GameWindow — a stable long-lived service, not routed through the deferred-binding machinery Radar's per-session state needs). MonthName enum values already match retail display text; HourName's "AndHalf" suffix is rewritten to "-and-Half". - Coordinate math + marker placement reuse RadarCoordinates/ LandDefs.GidToLcoord verbatim (both already byte-exact ports of CPlayerSystem::InqPlayerCoords/LandDefs::gid_to_lcoord) — no re-port. PlaceMarkerOnMap's centering math (m_x0 + x - w/2) ported from gmMapUI::PlaceMarkerOnMap @0x004a18b0. Indoor gating clears the coordinate text and hides the player marker, matching gmMapUI::Update's else branch. - 53-town s_rgLocations table ported verbatim into MapLocations.cs. Markers built once at bind time via the panel's own RowTemplateResolver against m_pMap's authored hotspot-template attrs (0x47/0x48), with literal-string tooltips through AuthoredTooltipText/Enabled (RetailTooltipPresenter) — closes divergence-register row TS-85's last item, gmMapUI::AddMapNote @0x004A1C51. - Structural finding: m_pMap (0x100001EC) is itself authored as a Type-1 BUTTON (the GM click-to-teleport hook at gmMapUI::ListenToElementMessage), and the player/house icons (0x100001ED/EE) are its own NESTED children, not siblings — UiButton.ConsumesDatChildren swallows them from the normally-built tree. Both are re-resolved standalone through the same template resolver the town hotspots use and reattached under m_pMap. House tab (gmHouseUI, HousePageController): mounts the ListBox (0x100001E6) with its authored row template, wired to an empty Lines() source by default — genuinely empty until Slice 4's wire lands, matching retail's own PostInit (no Update call, no static content). 21 new tests (7 MapHousePanelControllerTests, 14 MapPageControllerTests): tab table pairing, close button, town-hotspot count/tooltips, calendar formatter golden values (Frostfell 27/119 P.Y., every HourName incl. AndHalf), player/house marker placement and indoor-gating reproduced against the real fixture via already-tested RadarCoordinates (no re-derivation). Fixture map_house_2100006E_1000018C.json captured via the shared RetailLayoutFixtureGenerator (other 34 fixtures deliberately NOT regenerated — out of scope for this batch, would touch unrelated panels' schema drift). Full solution builds clean; App suite 5391/0 failed/71 skipped (non-live; one earlier flaky streaming failure unrelated to this change, confirmed pre-existing on the branch before these commits). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
180 lines
6.9 KiB
C#
180 lines
6.9 KiB
C#
using System;
|
|
|
|
namespace AcDream.App.UI.Layout;
|
|
|
|
/// <summary>
|
|
/// Mounts retail's two-tab Map/House panel — LayoutDesc <c>0x2100006E</c>
|
|
/// slot <c>0x1000018C</c>, <see cref="AcDream.App.UI.RetailPanelCatalog"/>
|
|
/// id <b>16</b>. Batch C (overnight hover/UI round, 2026-08-17), built on
|
|
/// the <see cref="SocialPanelController"/>/<see cref="OptionsPanelController"/>
|
|
/// recipe (Type-8 tab host, <see cref="UiTabPanel.ActivateTabBehavior"/>,
|
|
/// per-page scoped controllers).
|
|
///
|
|
/// <para>
|
|
/// <b>Slot/panelId/button — resolved, not guessed.</b> The FA campaign's own
|
|
/// full 16-slot <c>gmPanelUI::SetupChildren</c> dump
|
|
/// (<c>docs/research/2026-08-11-fa-panel-structure.md:927-933</c>) already
|
|
/// named slot <c>0x1000018C</c> as "gmMapUI+gmHouseUI pages", panel id 16 —
|
|
/// this session's <c>MapHousePanelSlotProbeTests</c> re-confirmed it live.
|
|
/// The toolbar button is <c>0x1000019A</c> (own authored
|
|
/// <c>P0x10000029 = 16</c>), one of three currently-ghosted panel buttons
|
|
/// (see <c>docs/research/2026-08-17-map-house-recon.md</c>).
|
|
/// </para>
|
|
///
|
|
/// <para>
|
|
/// <b>Tab table — live-DAT-confirmed.</b>
|
|
/// <c>button 0x100001F3 -> page 0x100001F6 (Map, DEFAULT)</c>,
|
|
/// <c>button 0x100001F4 -> page 0x100001F7 (House)</c>. The page roots are
|
|
/// themselves typed <c>0x10000026</c> (gmMapUI) / <c>0x10000025</c>
|
|
/// (gmHouseUI) in the DAT — <see cref="DatWidgetFactory"/> has no special
|
|
/// case for either id, so they build as generic containers (same as every
|
|
/// other unmodeled retail UI class); <see cref="MapPageController"/> and
|
|
/// <see cref="HousePageController"/> find their own signature children by
|
|
/// id underneath.
|
|
/// </para>
|
|
///
|
|
/// <para>
|
|
/// <b>Close button</b>: <c>0x100001F5</c> (Type 1, top-right at
|
|
/// <c>(276,0) 24x25</c>) — same authored position/size as the Social
|
|
/// panel's own close button, the established <c>gmPanelUI</c> sibling
|
|
/// convention.
|
|
/// </para>
|
|
/// </summary>
|
|
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<uint, uint> _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;
|
|
}
|
|
|
|
/// <param name="rootInfo">The pre-Build <see cref="ElementInfo"/> tree
|
|
/// <paramref name="layout"/> was built from — <see cref="MapPageController"/>
|
|
/// needs it to read <c>m_pMap</c>'s own authored int/enum attrs, which
|
|
/// only exist on <see cref="ElementInfo"/>, not the built
|
|
/// <see cref="UiElement"/> tree.</param>
|
|
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();
|
|
}
|
|
|
|
/// <summary>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.</summary>
|
|
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;
|
|
}
|
|
}
|