diff --git a/maps.json b/maps.json index d70d448..de456fa 100644 --- a/maps.json +++ b/maps.json @@ -292,8 +292,8 @@ "crop": null, "minZoom": 0, "place": { - "cx": 1089.07, - "cy": 1041.03, + "cx": 1090.96, + "cy": 1043.24, "w": 70.0, "h": 79.81 }, diff --git a/tools/export_base.py b/tools/export_base.py index 4ed37e0..d01b9da 100644 --- a/tools/export_base.py +++ b/tools/export_base.py @@ -67,7 +67,13 @@ _patch_stroke_effects() def apply_visibility(psd, keep: list[str], map_id: str) -> None: - """Hide every layer that is not on the path to, or inside, a kept layer.""" + """Keep selected layer trees without reviving hidden descendants. + + Selected layers and their ancestors must be visible so they can render, + but descendants retain the visibility saved in the PSD. Forcing every + descendant on can composite hidden backup/alternate art over the intended + map (Customs Dorms contains exactly such a hidden duplicate floor set). + """ kept = [tuple(p.split("/")) for p in keep] matched: set[tuple[str, ...]] = set() @@ -83,7 +89,11 @@ def apply_visibility(psd, keep: list[str], map_id: str) -> None: if not (inside or ancestor): layer.visible = False continue - layer.visible = True + # Ancestors (including an exact target) must be enabled. Once we + # are below a selected group, preserve each child's authored + # visibility instead of turning hidden alternates back on. + if ancestor: + layer.visible = True if layer.is_group(): walk(layer, path) diff --git a/web/app.js b/web/app.js index c9d2c0a..a2494d2 100644 --- a/web/app.js +++ b/web/app.js @@ -127,8 +127,11 @@ async function main() { maxBounds: extent.pad(0.05), maxBoundsViscosity: 0.75, attributionControl: false, + zoomControl: false, }); + L.control.zoom({ position: 'bottomright' }).addTo(map); + L.control.attribution({ prefix: false }) .addAttribution(world.attribution) .addTo(map); @@ -335,10 +338,12 @@ async function main() { const markerMaps = new Map(world.maps.map((m) => [m.id, m])); const markerDefaults = { color: '#5d6876', size: 18, symbol: '•', displayText: false, - defaultVisible: true, labelMinZoom: 6, extractLabelMinZoom: 2, + defaultVisible: true, visibleMinZoom: 2.5, labelMinZoom: 6, extractLabelMinZoom: 2, gridSize: 2048, viewportPadding: 0.15, ...(markerConfig.defaults ?? {}), }; + const markerVisibleMinZoom = Number(markerDefaults.visibleMinZoom) || 2.5; + const markerZoomVisible = () => map.getZoom() >= markerVisibleMinZoom; const extractCategories = new Set([ 'extract-pmc', 'extract-scav', 'extract-neutral', 'extract-hidden', 'transit', ]); @@ -580,6 +585,16 @@ async function main() { if (getComputedStyle(label).display === 'none') continue; const record = markerRecords.get(id); if (!record) continue; + if (record.category === 'location') { + const bounds = label.getBoundingClientRect(); + addOccupied(paddedRect( + bounds.left - containerBounds.left, + bounds.top - containerBounds.top, + bounds.width, + bounds.height, + )); + continue; + } const settings = categoryConfig(record.category); const size = safeSize(settings.size); const point = map.latLngToContainerPoint(leafletMarker.getLatLng()); @@ -708,7 +723,7 @@ async function main() { const refreshMarkers = () => { markerRefreshFrame = null; try { - if (!markersVisible) return; + if (!markersVisible || !markerZoomVisible()) return; const bounds = map.getBounds().pad(Number(markerDefaults.viewportPadding) || 0.15); const x0 = Math.floor(bounds.getWest() / gridSize); const x1 = Math.floor(bounds.getEast() / gridSize); @@ -782,15 +797,18 @@ async function main() { const markerButton = document.getElementById('toggle-markers'); const renderMarkerVisibility = () => { - if (markersVisible && !map.hasLayer(markerLayer)) markerLayer.addTo(map); - if (!markersVisible && map.hasLayer(markerLayer)) { + const shouldRender = markersVisible && markerZoomVisible(); + if (shouldRender && !map.hasLayer(markerLayer)) markerLayer.addTo(map); + if (!shouldRender && map.hasLayer(markerLayer)) { map.removeLayer(markerLayer); renderedMarkers.clear(); markerLayer.clearLayers(); } markerButton.setAttribute('aria-pressed', String(markersVisible)); markerButton.textContent = `Markers (${markerRecords.size})`; - if (markersVisible) scheduleMarkerRefresh(); + markerButton.title = markersVisible && !shouldRender + ? `Markers appear at zoom ${markerVisibleMinZoom} and closer.` : ''; + if (shouldRender) scheduleMarkerRefresh(); }; markerButton.addEventListener('click', () => { markersVisible = !markersVisible; @@ -845,6 +863,7 @@ async function main() { map.getZoom() >= (Number(markerDefaults.extractLabelMinZoom) || 2), ); map.getContainer().classList.toggle('marker-overview', map.getZoom() < 2.5); + renderMarkerVisibility(); }; map.on('zoom', updateMarkerDensity); map.on('moveend zoomend resize', scheduleMarkerRefresh); @@ -858,6 +877,7 @@ async function main() { // --- picker ----------------------------------------------------------- const list = document.getElementById('maplist'); + const overviewButton = document.getElementById('overview-map'); const editButton = document.getElementById('edit-placement'); const trimButton = document.getElementById('edit-trim'); const editorPanel = document.getElementById('placement-editor'); @@ -1235,6 +1255,7 @@ async function main() { trimButton.disabled = !!m.base; markerEditButton.disabled = !!m.base; buttons.forEach((b) => { b.dataset.selected = String(b.dataset.id === m.id); }); + overviewButton.dataset.selected = String(!!m.base); if (!m.base && mode === 'placement') openEditor(m); if (!m.base && mode === 'trim') openTrimEditor(m); if (!m.base && mode === 'markers') openMarkerEditor(m); @@ -1247,10 +1268,9 @@ async function main() { ]); const orderedIds = new Set(orderedDetail.map((m) => m.id)); orderedDetail.push(...detail.filter((m) => !orderedIds.has(m.id))); - const targets = [base, ...orderedDetail]; - const buttons = targets.map((m) => { + const buttons = orderedDetail.map((m) => { const b = document.createElement('button'); - b.textContent = m.base ? 'Overview' : m.name; + b.textContent = m.name; b.dataset.id = m.id; b.dataset.subMap = String(!!m.parent); b.addEventListener('click', () => { @@ -1264,6 +1284,12 @@ async function main() { return b; }); + overviewButton.addEventListener('click', () => { + selectTarget(base); + focus(base.id); + map.flyToBounds(familyViewRect(base), { padding: [24, 24], duration: 0.7 }); + }); + editButton.setAttribute('aria-pressed', 'false'); trimButton.setAttribute('aria-pressed', 'false'); markerEditButton.setAttribute('aria-pressed', 'false'); @@ -1578,11 +1604,12 @@ async function main() { const syncUI = () => { const c = map.getCenter(); // Smallest non-base map containing the centre wins -- Dorms beats Customs. - const hit = world.maps + const hit = markerZoomVisible() ? world.maps .filter((m) => !m.base && viewContains(m, c) && map.getZoom() >= m.minZoom) - .sort((a, b) => a.size[0] * a.size[1] - b.size[0] * b.size[1])[0]; + .sort((a, b) => a.size[0] * a.size[1] - b.size[0] * b.size[1])[0] : null; buttons.forEach((b) => b.setAttribute( - 'aria-current', String(hit ? hit.id === b.dataset.id : b.dataset.id === base.id))); + 'aria-current', String(!!hit && hit.id === b.dataset.id))); + overviewButton.setAttribute('aria-current', String(!hit)); focus(editor.active ? editor.selectedId : (trimEditor.active ? trimEditor.selectedId : (markerEditing.active ? markerEditing.selectedMapId : hit?.id))); diff --git a/web/data/marker-config.json b/web/data/marker-config.json index 64e5088..8806a33 100644 --- a/web/data/marker-config.json +++ b/web/data/marker-config.json @@ -7,6 +7,7 @@ "symbol": "•", "displayText": false, "defaultVisible": true, + "visibleMinZoom": 2.5, "labelMinZoom": 6, "extractLabelMinZoom": 2, "gridSize": 2048, diff --git a/web/index.html b/web/index.html index 26077aa..e95f38c 100644 --- a/web/index.html +++ b/web/index.html @@ -11,10 +11,11 @@
-