mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(overlays): let only the topmost painted card act on a click
Card handlers hit-tested only their own source, so a card buried under another layer's card still acted, and a click on a selected quake card over a vessel or fire card made both layers act. Vessels, FIRMS, wildlife, news, ghost maps and shipwrecks now read the unfiltered topmost painted entry: their own card acts only when it is on top, and a click on another layer's card is that layer's, so it neither acts here nor clears a selection. A top news or wildlife card still acts over another layer's scene item, so it never goes dead over a flight trail or a directions route; a registered marker under a foreign card is still its layer's to select.
This commit is contained in:
1 parent
5bc31ce08a
commit
836daf82b3
14 files changed
+310
-43
No files matched your search
@@ -1847,12 +1847,17 @@ test('vessel interaction wire: a vessel with an id and no MMSI is selected by cl
|
||||
* only publishes rects for `interactive` entries, so a stub returning a hit is
|
||||
* the same contract a painted, actionable card presents.
|
||||
*/
|
||||
function hostWithCardHit(entryId) {
|
||||
function hostWithCardHit(entryId, topHit) {
|
||||
return {
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: () => (entryId ? { sourceId: 'ais-live-vessels', entryId } : null),
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId && topHit
|
||||
? topHit
|
||||
: entryId
|
||||
? { sourceId: 'ais-live-vessels', entryId }
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1914,6 +1919,29 @@ test('vessel interaction wire: clicking the selected vessel card refocuses exact
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: a covered card yields while a real vessel pick still focuses', () => {
|
||||
for (const ownPick of [false, true]) {
|
||||
const harness = installWireHarness(ownPick ? { id: makeRecord().mmsi } : null);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`, {
|
||||
sourceId: 'earthquakes', entryId: 'quake:cover',
|
||||
}),
|
||||
);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, ownPick ? 1 : 0);
|
||||
assert.equal(aisLiveVesselsLayer.getSelectedInfo()?.mmsi, harness.record.mmsi);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: an unknown card id preserves selection and never flies', () => {
|
||||
const harness = installWireHarness({
|
||||
primitive: {},
|
||||
|
||||
@@ -58,6 +58,7 @@ function harness({
|
||||
fires = [makeFire()],
|
||||
picked = null,
|
||||
cardHit = null,
|
||||
topCard = null,
|
||||
cameraPosition = null,
|
||||
withDataSource = false,
|
||||
withGlobe = false,
|
||||
@@ -85,7 +86,12 @@ function harness({
|
||||
setEntries: (sourceId, entries) => published.push(...entries),
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: () => (cardHit ? { sourceId: 'firms', entryId: cardHit } : null),
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId && topCard
|
||||
? topCard
|
||||
: cardHit
|
||||
? { sourceId: 'firms', entryId: cardHit }
|
||||
: null,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -153,6 +159,9 @@ function harness({
|
||||
(record) => record.kind === 'icons' && !record.disposed,
|
||||
),
|
||||
click: () => input.click({ x: 400, y: 300 }),
|
||||
cover: (hit) => {
|
||||
topCard = hit;
|
||||
},
|
||||
cleanup() {
|
||||
Cesium.SceneTransforms.worldToWindowCoordinates = priorProjection;
|
||||
if (hadWindow) globalThis.window = priorWindow;
|
||||
@@ -308,7 +317,11 @@ test('far-side detections cannot consume the bounded ambient-card cohort', () =>
|
||||
|
||||
test('clicking a fire sprite selects it and requests the camera transfer', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({ fires: [fire], picked: glowPick('firms-7') });
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
picked: glowPick('firms-7'),
|
||||
topCard: { sourceId: 'earthquakes', entryId: 'quake:cover' },
|
||||
});
|
||||
try {
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
@@ -355,6 +368,34 @@ test('clicking a fire CARD behaves exactly like clicking its sprite', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('a covered fire card does not act, and keeps an existing selection', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
});
|
||||
try {
|
||||
// Covered by another layer's card from the start: nothing selects or flies.
|
||||
h.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 0);
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
// Uncovered, the card selects; covered again, the click is the other
|
||||
// layer's and leaves that selection alone.
|
||||
h.cover(null);
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
const selected = h.layer.getSelectedInfo();
|
||||
assert.ok(selected);
|
||||
h.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
assert.deepEqual(h.layer.getSelectedInfo(), selected);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// The voice model reads these labels as data (track_entity, get_entity_context,
|
||||
// pointer_context); the voice card translates them where it shows them.
|
||||
test('fire labels stay English data in a translated interface', () => {
|
||||
|
||||
Reference in new issue
Block a user