feat(ui): Map/House panel — slices 2+3, panel shell + Map tab

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>
This commit is contained in:
Erik 2026-08-17 02:04:19 +02:00
parent 04841b6807
commit 6b0fa4ff0d
15 changed files with 5865 additions and 3 deletions

View file

@ -257,7 +257,8 @@ public sealed class InteractionRetainedUiCompositionTests
ClientTime: static () => 0d,
Log: static _ => { },
GpuDevice: null!,
GpuFrameSource: null!);
GpuFrameSource: null!,
CurrentCalendar: static () => default);
}
public InteractionRetainedUiDependencies Dependencies { get; }

View file

@ -272,6 +272,15 @@ public static class FixtureLoader
public static ElementInfo LoadSocialPanelHostInfos()
=> LoadInfos("social_panel_2100006E_1000018F.json");
/// <summary>The two-tab Map/House panel host slot <c>0x1000018C</c> —
/// Batch C (overnight hover/UI round). This is what
/// <see cref="MapHousePanelController.Bind"/> actually mounts.</summary>
public static ImportedLayout LoadMapHouseHost()
=> LayoutImporter.Build(LoadMapHouseHostInfos(), _ => (0u, 0, 0), null);
public static ElementInfo LoadMapHouseHostInfos()
=> LoadInfos("map_house_2100006E_1000018C.json");
/// <summary>Configure Keyboard screen LayoutDesc <c>0x21000009</c> (standalone
/// import — its own separate full-screen window, NOT nested under the Options
/// panel's <c>0x2100006E</c> host — Campaign OP slice OP8).</summary>

View file

@ -0,0 +1,171 @@
using System.Linq;
using AcDream.App.UI;
using AcDream.App.UI.Layout;
using AcDream.Core.Net.Messages;
using AcDream.Core.World;
namespace AcDream.App.Tests.UI.Layout;
/// <summary>
/// Controller-level tests for <see cref="MapHousePanelController"/> against
/// the committed <c>map_house_2100006E_1000018C.json</c> fixture (Batch C,
/// overnight hover/UI round) — the SAME <c>LayoutImporter.ImportInfos(dats,
/// 0x2100006Eu, 0x1000018Cu)</c> catalog import
/// <see cref="RetailUiRuntime.MountMapHousePanel"/> performs against real
/// DATs. No DAT access, no live runtime — dat-free per the established
/// <see cref="FixtureLoader"/> pattern.
/// </summary>
public sealed class MapHousePanelControllerTests
{
/// <summary>Serves BOTH the town-hotspot template (any (layoutId,
/// elementId) pair not the player/house icon ids) and the two icons
/// <see cref="MapPageController.Bind"/> re-resolves standalone
/// (<c>m_pMap</c>'s own button-swallowed children) — a real
/// <see cref="RowTemplateResolver"/> would set <c>DatElementId</c> the
/// same way <see cref="LayoutImporter.Build"/> does, so tests that need
/// to find these icons back by id after the fact need it too.</summary>
private static UiElement? FakeHotspotTemplate(uint layoutId, uint elementId)
=> new UiText { Width = 10f, Height = 10f, DatElementId = elementId };
private static MapHousePanelController.Callbacks MakeCallbacks(
List<string>? calls = null,
Func<DerethDateTime.Calendar>? currentCalendar = null,
Func<uint>? playerCellId = null,
Func<CreateObject.ServerPosition?>? housePosition = null,
Func<IReadOnlyList<string>>? houseLines = null)
{
calls ??= new List<string>();
return new MapHousePanelController.Callbacks(
Toggle: () => calls.Add("toggle"),
Map: new MapPageController.Bindings(
CurrentCalendar: currentCalendar ?? (static () => default),
PlayerCellId: playerCellId ?? (static () => 0u),
HousePosition: housePosition ?? (static () => null),
TemplateResolver: FakeHotspotTemplate),
House: new HousePageController.Bindings(
Lines: houseLines ?? (static () => Array.Empty<string>()),
OnShown: () => calls.Add("house-shown")));
}
[Fact]
public void Bind_RootBuildsAsUiTabPanel()
{
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
MapHousePanelController? controller =
MapHousePanelController.Bind(rootInfo, layout, MakeCallbacks());
Assert.NotNull(controller);
Assert.IsType<UiTabPanel>(controller!.Root);
}
/// <summary>Pins the authored tab table exactly as read from the live
/// DATs (<c>MapHousePanelSlotProbeTests</c>): two entries, Map is the
/// sole default.</summary>
[Fact]
public void TabTable_MatchesLiveDatPairing_MapIsDefault()
{
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
var tabs = Assert.IsType<UiTabPanel>(layout.Root);
Assert.Equal(2, tabs.Tabs.Count);
Assert.Contains(tabs.Tabs, e =>
e.ButtonElementId == 0x100001F3u && e.PageElementId == 0x100001F6u && e.IsDefault);
Assert.Contains(tabs.Tabs, e =>
e.ButtonElementId == 0x100001F4u && e.PageElementId == 0x100001F7u && !e.IsDefault);
Assert.Single(tabs.Tabs, e => e.IsDefault);
}
[Fact]
public void Bind_Succeeds_AndActivateTabs_SelectsMapByDefault()
{
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
MapHousePanelController? controller =
MapHousePanelController.Bind(rootInfo, layout, MakeCallbacks());
Assert.NotNull(controller);
controller!.ActivateTabs();
Assert.Empty(controller.TabPanel.UnresolvedEntries);
Assert.False(controller.IsShowingHouse);
}
[Fact]
public void SwitchToHouse_FiresOnShown_OnlyWhenPanelIsVisible()
{
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
var calls = new List<string>();
MapHousePanelController? controller =
MapHousePanelController.Bind(rootInfo, layout, MakeCallbacks(calls));
Assert.NotNull(controller);
controller!.ActivateTabs();
// Not visible yet: switching tabs must not fire OnShown.
controller.TabPanel.SwitchTo(0x100001F7u);
Assert.DoesNotContain("house-shown", calls);
controller.OnShown();
Assert.Contains("house-shown", calls);
}
[Fact]
public void CloseButton_InvokesToggle()
{
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
var calls = new List<string>();
MapHousePanelController? controller =
MapHousePanelController.Bind(rootInfo, layout, MakeCallbacks(calls));
Assert.NotNull(controller);
UiElement? close = layout.FindElement(0x100001F5u);
Assert.IsType<UiButton>(close);
((UiButton)close!).OnClick?.Invoke();
Assert.Contains("toggle", calls);
}
[Fact]
public void Bind_BuildsAll53TownHotspots_UnderTheMapWidget()
{
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
MapHousePanelController? controller =
MapHousePanelController.Bind(rootInfo, layout, MakeCallbacks());
Assert.NotNull(controller);
UiElement? map = UiElement.FindDescendant(controller!.Root, MapPageController.MapWidgetId);
Assert.NotNull(map);
// m_pMap's own children are the player/house icons (re-resolved
// standalone — see MapPageController.Bind's doc on why m_pMap being
// a Button swallows its authored nested children) PLUS the 53 town
// hotspots.
var townMarkers = map!.Children
.Where(c => c.DatElementId != MapPageController.PlayerIconId
&& c.DatElementId != MapPageController.HouseIconId)
.ToList();
Assert.Equal(55, map.Children.Count);
Assert.Equal(53, townMarkers.Count);
Assert.All(townMarkers, c => Assert.Contains(
MapLocations.All, loc => loc.Width == c.Width && loc.Height == c.Height));
Assert.All(townMarkers, c => Assert.True(c.AuthoredTooltipEnabled));
Assert.Contains(townMarkers, c => c.AuthoredTooltipText == "Holtburg");
}
[Fact]
public void Bind_HouseListBoxStartsEmpty_MatchingRetailPostInit()
{
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
MapHousePanelController? controller =
MapHousePanelController.Bind(rootInfo, layout, MakeCallbacks());
Assert.NotNull(controller);
UiElement? box = UiElement.FindDescendant(controller!.Root, HousePageController.TextBoxId);
var listBox = Assert.IsType<UiTemplateListBox>(box);
Assert.Equal(0, listBox.ContentHeight);
}
}

View file

@ -0,0 +1,191 @@
using AcDream.App.UI;
using AcDream.App.UI.Layout;
using AcDream.Core.Net.Messages;
using AcDream.Core.Physics;
using AcDream.Core.Ui;
using AcDream.Core.World;
namespace AcDream.App.Tests.UI.Layout;
/// <summary>
/// Unit coverage for <see cref="MapPageController"/>'s pure math: the
/// calendar formatter (<c>"Date: %s\nTime: %s"</c>,
/// <c>gmMapUI::Update @0x004a1eb0</c>) and the 53-town static table
/// (verbatim port of <c>s_rgLocations</c>). Marker-placement math itself is
/// <see cref="RadarCoordinates"/>/<see cref="LandDefs.GidToLcoord"/> — both
/// already unit-tested elsewhere; this file only proves the wiring
/// reproduces their output through the real fixture (no re-derivation).
/// </summary>
public sealed class MapPageControllerTests
{
// ── Calendar formatter ───────────────────────────────────────────────
[Fact]
public void FormatDateTime_OrdinaryHour_NoAndHalfSuffix()
{
var calendar = new DerethDateTime.Calendar(
119, DerethDateTime.MonthName.Frostfell, 27, DerethDateTime.HourName.Dawnsong);
string text = MapPageController.FormatDateTime(calendar);
Assert.Equal("Date: Frostfell 27, 119 P.Y.\nTime: Dawnsong", text);
}
[Fact]
public void FormatDateTime_AndHalfHour_RewritesSuffixWithHyphens()
{
var calendar = new DerethDateTime.Calendar(
10, DerethDateTime.MonthName.Morningthaw, 1, DerethDateTime.HourName.MorntideAndHalf);
string text = MapPageController.FormatDateTime(calendar);
Assert.Equal("Date: Morningthaw 1, 10 P.Y.\nTime: Morntide-and-Half", text);
}
[Theory]
[InlineData(DerethDateTime.HourName.Darktide, "Darktide")]
[InlineData(DerethDateTime.HourName.DarktideAndHalf, "Darktide-and-Half")]
[InlineData(DerethDateTime.HourName.Gloaming, "Gloaming")]
[InlineData(DerethDateTime.HourName.GloamingAndHalf, "Gloaming-and-Half")]
[InlineData(DerethDateTime.HourName.WarmtideAndHalf, "Warmtide-and-Half")]
public void FormatDateTime_EveryHourName_MatchesExpectedDisplayText(
DerethDateTime.HourName hour, string expectedHourText)
{
var calendar = new DerethDateTime.Calendar(
10, DerethDateTime.MonthName.Morningthaw, 1, hour);
string text = MapPageController.FormatDateTime(calendar);
Assert.EndsWith($"Time: {expectedHourText}", text);
}
// ── Town table ────────────────────────────────────────────────────────
[Fact]
public void MapLocations_Has53Entries()
{
Assert.Equal(53, MapLocations.All.Length);
}
[Fact]
public void MapLocations_AllNamesAreUnique()
{
var names = new HashSet<string>(StringComparer.Ordinal);
foreach (MapLocation loc in MapLocations.All)
Assert.True(names.Add(loc.Name), $"duplicate town name: {loc.Name}");
}
[Fact]
public void MapLocations_Holtburg_MatchesDecompiledByteValues()
{
// s_rgLocations[0x13] (pc:977379): X=0xa4 Y=0x4d W=9 H=8.
MapLocation holtburg = Assert.Single(MapLocations.All, l => l.Name == "Holtburg");
Assert.Equal(0xa4, holtburg.X);
Assert.Equal(0x4d, holtburg.Y);
Assert.Equal(9, holtburg.Width);
Assert.Equal(8, holtburg.Height);
}
[Fact]
public void MapLocations_EveryRectIsWithinTheMapWidgetsAuthoredExtent()
{
// m_pMap's own authored size (MapHousePanelSlotProbeTests: markerArea
// (6,8)-(247,258) — the widest observed extent). Town rects are
// independent of the marker-area rect but should still land inside
// a sane 0..300 canvas — a coarse sanity check that the verbatim
// port didn't transpose a digit.
foreach (MapLocation loc in MapLocations.All)
{
Assert.InRange(loc.X, 0, 260);
Assert.InRange(loc.Y, 0, 260);
Assert.InRange(loc.Width, 1, 20);
Assert.InRange(loc.Height, 1, 20);
}
}
// ── Marker placement wiring (real fixture, no re-derivation) ────────────
[Fact]
public void Bind_PlayerMarker_OutdoorCell_ReproducesRadarCoordinatesPlacement()
{
// Arwic's landblock cell id (0x11CE0001 — an arbitrary real outdoor
// cell, picked only because RadarCoordinates.TryFromCell already
// proves gid-to-lcoord conformance elsewhere; this test proves the
// WIRING, not the formula).
const uint cellId = 0x11CE0001u;
Assert.True(RadarCoordinates.TryFromCell(cellId, out RadarCoordinates expected));
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
var callbacks = new MapHousePanelController.Callbacks(
Toggle: () => { },
Map: new MapPageController.Bindings(
CurrentCalendar: static () => default,
PlayerCellId: () => cellId,
HousePosition: static () => (CreateObject.ServerPosition?)null,
TemplateResolver: (_, e) => new UiText { Width = 10f, Height = 10f, DatElementId = e }),
House: new HousePageController.Bindings(Lines: static () => Array.Empty<string>()));
MapHousePanelController? controller = MapHousePanelController.Bind(rootInfo, layout, callbacks);
Assert.NotNull(controller);
UiElement? playerIcon = UiElement.FindDescendant(controller!.Root, MapPageController.PlayerIconId);
Assert.NotNull(playerIcon);
Assert.True(playerIcon!.Visible);
// markerArea from the live fixture (MapHousePanelSlotProbeTests):
// (6,8)-(247,258) -> m_x0=6, m_y0=8.
const int markerX0 = 6, markerY0 = 8;
Assert.Equal(markerX0 + (float)expected.X - playerIcon.Width / 2f, playerIcon.Left, precision: 3);
Assert.Equal(markerY0 + (float)expected.Y - playerIcon.Height / 2f, playerIcon.Top, precision: 3);
}
[Fact]
public void Bind_PlayerMarker_IndoorCell_HidesIconAndClearsCoordinateText()
{
// Envcell low word (>= 0x100) fails RadarCoordinates.TryFromCell —
// the indoor branch (gmMapUI::Update's else: SetVisible(0)).
const uint indoorCellId = 0x0012_0100u;
Assert.False(RadarCoordinates.TryFromCell(indoorCellId, out _));
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
var callbacks = new MapHousePanelController.Callbacks(
Toggle: () => { },
Map: new MapPageController.Bindings(
CurrentCalendar: static () => default,
PlayerCellId: () => indoorCellId,
HousePosition: static () => (CreateObject.ServerPosition?)null,
TemplateResolver: (_, e) => new UiText { Width = 10f, Height = 10f, DatElementId = e }),
House: new HousePageController.Bindings(Lines: static () => Array.Empty<string>()));
MapHousePanelController? controller = MapHousePanelController.Bind(rootInfo, layout, callbacks);
Assert.NotNull(controller);
UiElement? playerIcon = UiElement.FindDescendant(controller!.Root, MapPageController.PlayerIconId);
Assert.NotNull(playerIcon);
Assert.False(playerIcon!.Visible);
}
[Fact]
public void Bind_HouseMarker_NullPosition_StaysHidden()
{
ElementInfo rootInfo = FixtureLoader.LoadMapHouseHostInfos();
ImportedLayout layout = FixtureLoader.LoadMapHouseHost();
var callbacks = new MapHousePanelController.Callbacks(
Toggle: () => { },
Map: new MapPageController.Bindings(
CurrentCalendar: static () => default,
PlayerCellId: static () => 0u,
HousePosition: static () => (CreateObject.ServerPosition?)null,
TemplateResolver: (_, e) => new UiText { Width = 10f, Height = 10f, DatElementId = e }),
House: new HousePageController.Bindings(Lines: static () => Array.Empty<string>()));
MapHousePanelController? controller = MapHousePanelController.Bind(rootInfo, layout, callbacks);
Assert.NotNull(controller);
UiElement? houseIcon = UiElement.FindDescendant(controller!.Root, MapPageController.HouseIconId);
Assert.NotNull(houseIcon);
Assert.False(houseIcon!.Visible);
}
}

View file

@ -153,6 +153,11 @@ public sealed class RetailLayoutFixtureGenerator
// lane-A unknowns U3/U4/U6/U7/U10.
(SocialPanelController.HostLayoutId, SocialPanelController.SlotElementId,
"social_panel_2100006E_1000018F.json"),
// Batch C (overnight hover/UI round, 2026-08-17): the two-tab
// Map/House panel — recon doc
// docs/research/2026-08-17-map-house-recon.md.
(MapHousePanelController.HostLayoutId, MapHousePanelController.SlotElementId,
"map_house_2100006E_1000018C.json"),
})
{
ElementInfo? panelPart = LayoutImporter.ImportInfos(dats, layoutId, rootId);

File diff suppressed because it is too large Load diff