Refine map controls and fix Dorms export

This commit is contained in:
lucio committed 2026-08-08 23:09:55 -07:00
1 parent bbb4cadddd
commit 7c9e0ba5e1
6 files changed
+106 -24

No files matched your search

+2 -2
View File
@@ -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
},
+12 -2
View File
@@ -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)
+38 -11
View File
@@ -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)));
+1
View File
@@ -7,6 +7,7 @@
"symbol": "•",
"displayText": false,
"defaultVisible": true,
"visibleMinZoom": 2.5,
"labelMinZoom": 6,
"extractLabelMinZoom": 2,
"gridSize": 2048,
+9 -6
View File
@@ -11,10 +11,11 @@
<div id="map"></div>
<details id="panel" open>
<summary>Maps</summary>
<nav id="maplist"></nav>
<section id="placement-tools">
<div id="map-toolbar">
<details id="panel" open>
<summary>Maps</summary>
<nav id="maplist"></nav>
<section id="placement-tools">
<div class="layer-actions">
<button id="toggle-markers" type="button" aria-pressed="true">Markers</button>
<details id="marker-settings">
@@ -83,8 +84,10 @@
</div>
<output id="marker-edit-status" role="status"></output>
</div>
</section>
</details>
</section>
</details>
<button id="overview-map" type="button">Overview</button>
</div>
<div id="boot">Loading&hellip;</div>
+44 -3
View File
@@ -35,12 +35,19 @@ html, body {
/* --- map picker ------------------------------------------------------- */
#panel {
#map-toolbar {
position: absolute;
z-index: 1000;
top: calc(10px + env(safe-area-inset-top));
left: calc(10px + env(safe-area-inset-left));
max-width: min(260px, calc(100vw - 20px));
display: flex;
align-items: flex-start;
gap: 8px;
}
#panel {
position: relative;
max-width: min(260px, calc(100vw - 132px));
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
@@ -63,6 +70,23 @@ html, body {
#panel summary::after { content: " ▾"; }
#panel:not([open]) summary::after { content: " ▸"; }
#overview-map {
min-height: 42px;
padding: 0 14px;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--panel);
color: var(--muted);
font: 600 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
letter-spacing: .04em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(6px);
}
#overview-map:hover,
#overview-map:focus-visible { background: #2a303a; color: var(--text); }
#overview-map[aria-current="true"] { border-color: #57806a; color: var(--accent); }
#maplist {
display: flex;
flex-direction: column;
@@ -356,6 +380,23 @@ html, body {
}
.marker-extract .poi-label { font-size: 12px; font-weight: 750; }
/* Location names are fixed cartographic labels, not movable marker tags. */
.marker-location .poi-dot { display: none; }
.marker-location .poi-leader { display: none !important; }
.marker-location .poi-label {
left: 50%;
padding: 0;
border-radius: 0;
background: transparent;
color: #ddd9cd;
font: italic 650 12px/1.1 "Arial Narrow", "Roboto Condensed", "Segoe UI", sans-serif;
letter-spacing: .08em;
text-transform: uppercase;
text-shadow: 0 1px 2px #000, 0 0 5px #000e;
box-shadow: none;
transform: translate(-50%, -50%);
}
.poi-tooltip {
padding: 6px 8px;
border: 1px solid #5a6470;
@@ -415,6 +456,6 @@ html, body {
.leaflet-control-attribution a { color: var(--accent); }
@media (max-width: 640px) {
#panel { max-width: calc(100vw - 20px); }
#panel { max-width: calc(100vw - 132px); }
.leaflet-control-zoom { display: none; } /* pinch to zoom instead */
}