mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Merge origin/main into space-missions-fixes
Main's single click rule (the card or label on top takes the click, read once per click through clickCard and isUnderOtherCard in src/data/pickRegistry.js) covers a click on a Space Missions label: a mission marker label is an interactive world-overlay entry, so the host's hit test names it as the card on top for every other layer. The per-layer label guards in CCTV, Drone Airspace, FIRMS, Ghost Maps, News, Perimeters, Shipwrecks, Vessels, Wildlife Sightings, ALPR, Local ADS-B and the cockpit orbital focus are dropped for main's versions. The mission-label tests are kept on main's API: fakeInputUnderLabel now also names the label as the card on top, and each test shows a click on the label never acts on the card, camera, vessel, fire, reader, aircraft or report under it, and leaves the selection as it is. A launches test checks that a mission label is interactive and is the card on top for every other layer. Docs, changelog and the dispatcher's `overlay` note describe the merged behaviour. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
commit
0e5c5e624c
146 files changed
+9734
-1157
No files matched your search
@@ -30,8 +30,23 @@ export function createSelection({
|
||||
// The bridge view owns the selection: a click on open water must not
|
||||
// deselect the vessel the camera is riding.
|
||||
if (state.cockpitSubjectId) return;
|
||||
// The card or label painted on top takes the click, read once per
|
||||
// click so every layer agrees: a card of ours acts whatever is drawn
|
||||
// under it; another layer's is that layer's click.
|
||||
const top = services.picking.clickCard?.(event) ?? null;
|
||||
if (top) {
|
||||
if (top.sourceId !== VESSEL_OVERLAY_SOURCE_ID) return;
|
||||
const id = String(top.entryId || '').startsWith('vessel:')
|
||||
? top.entryId.slice('vessel:'.length)
|
||||
: null;
|
||||
const carded = id ? state.records.byId.get(id) || null : null;
|
||||
// A stale card id is not empty terrain and must not clear a newer
|
||||
// selection. The next paint will evict its hit rectangle.
|
||||
if (carded) selectAndFocusVessel(carded);
|
||||
return;
|
||||
}
|
||||
const pickedId = event.id;
|
||||
let record = pickedId ? state.records.byId.get(pickedId) : null;
|
||||
const record = pickedId ? state.records.byId.get(pickedId) : null;
|
||||
// A vessel icon's pick is an item of the layer's icon set, whose id is
|
||||
// its row id: the record's id, or an unkeyed row's. Removing a row
|
||||
// removes its item, so an evicted vessel cannot be picked at all; a
|
||||
@@ -44,51 +59,19 @@ export function createSelection({
|
||||
|
||||
// An own-layer row without a live map key is a strict no-op (FB-1
|
||||
// residual). Trails carry no layer identity and hug their contacts, so any
|
||||
// `gev-trail:*` pick is also a no-op. Every other non-vessel pick — sibling
|
||||
// unowned scene picks dismiss the current vessel inspection.
|
||||
// `gev-trail:*` pick is also a no-op. A pick a sibling layer owns (an
|
||||
// aircraft, a route, a cyclone) is that layer's: preserve the current
|
||||
// vessel selection and do not compete with its camera command. Every
|
||||
// other non-vessel pick dismisses the current vessel inspection.
|
||||
if (ownRecordPick && (!pickedId || !record)) return;
|
||||
if (pickedId && !record && String(pickedId).startsWith('gev-trail:'))
|
||||
if (
|
||||
!record &&
|
||||
pickedId &&
|
||||
(String(pickedId).startsWith('gev-trail:') ||
|
||||
isOwnedByOtherLayer('ais-live-vessels', pickedId))
|
||||
)
|
||||
return;
|
||||
|
||||
// A sibling layer already owns this click. Preserve the current vessel
|
||||
// selection and do not compete with its camera command.
|
||||
const siblingOwned =
|
||||
pickedId && isOwnedByOtherLayer('ais-live-vessels', pickedId);
|
||||
// Cyclone geometry is ambient context behind painted cards. Its handler
|
||||
// yields to the same foreground AIS hit. Keep moving-contact precedence
|
||||
// unchanged: those handlers may issue their own camera command.
|
||||
const cycloneBackground =
|
||||
siblingOwned && !isOwnedByOtherLayer('weather-cyclones', pickedId);
|
||||
if (siblingOwned && !cycloneBackground) return;
|
||||
|
||||
// Cards are painted on a pointer-events:none canvas, so the scene pick is
|
||||
// usually terrain behind the card. Resolve against the host's current
|
||||
// actionable hit rectangles before treating the click as empty space.
|
||||
// A click a label painted over the cards took is not on a card.
|
||||
const cardHit =
|
||||
!record && !event.overlay
|
||||
? vesselState._vesselOverlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
{
|
||||
...(cycloneBackground
|
||||
? {}
|
||||
: { sourceId: VESSEL_OVERLAY_SOURCE_ID }),
|
||||
},
|
||||
)
|
||||
: null;
|
||||
if (cycloneBackground && cardHit?.sourceId !== VESSEL_OVERLAY_SOURCE_ID)
|
||||
return;
|
||||
if (!record && cardHit) {
|
||||
const id = String(cardHit.entryId || '').startsWith('vessel:')
|
||||
? cardHit.entryId.slice('vessel:'.length)
|
||||
: null;
|
||||
record = id ? state.records.byId.get(id) || null : null;
|
||||
// A stale card id is not empty terrain and must not clear a newer
|
||||
// selection. The next paint will evict its hit rectangle.
|
||||
if (!record) return;
|
||||
}
|
||||
|
||||
if (record) {
|
||||
// A valid sprite or card click always transfers the camera exactly once,
|
||||
// including a second click on the already-selected vessel.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { VESSEL_OVERLAY_SOURCE_ID } from '../../data/vesselLabels.js';
|
||||
import { clickCard } from '../../data/pickRegistry.js';
|
||||
import { fakeInputUnderLabel } from '../../input/testDoubles.mjs';
|
||||
import { createSelection } from './selection.js';
|
||||
|
||||
@@ -17,12 +18,18 @@ function recorder(calls) {
|
||||
);
|
||||
}
|
||||
|
||||
/** The vessel selection over a viewer whose clicks a label may take. */
|
||||
/** The vessel selection over a viewer whose clicks a Space Missions label
|
||||
* may take, with the vessel's card under every click. */
|
||||
function selectionHarness(t) {
|
||||
const viewer = { scene: { canvas: {}, pick: () => null } };
|
||||
const fake = fakeInputUnderLabel(viewer);
|
||||
t.after(() => fake.destroy());
|
||||
const vessel = { id: 'v1', name: 'NORTHERN STAR', lat: 0, lon: 0 };
|
||||
const fake = fakeInputUnderLabel(viewer, {
|
||||
beneath: () => ({
|
||||
sourceId: VESSEL_OVERLAY_SOURCE_ID,
|
||||
entryId: `vessel:${vessel.id}`,
|
||||
}),
|
||||
});
|
||||
t.after(() => fake.destroy());
|
||||
const focused = [];
|
||||
const calls = [];
|
||||
const state = {
|
||||
@@ -32,20 +39,11 @@ function selectionHarness(t) {
|
||||
selectedRecord: null,
|
||||
interactionKeyTarget: new EventTarget(),
|
||||
};
|
||||
const vesselState = {
|
||||
state,
|
||||
// The vessel's card lies under the click.
|
||||
_vesselOverlayHost: {
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
sourceId === VESSEL_OVERLAY_SOURCE_ID
|
||||
? { sourceId, entryId: `vessel:${vessel.id}` }
|
||||
: null,
|
||||
},
|
||||
};
|
||||
const vesselState = { state };
|
||||
const selection = createSelection({
|
||||
vesselState,
|
||||
services: {
|
||||
picking: { isOwnedByOtherLayer: () => false },
|
||||
picking: { isOwnedByOtherLayer: () => false, clickCard },
|
||||
worldFocus: { requestWorldFocus: (request) => focused.push(request.id) },
|
||||
context: recorder(calls),
|
||||
},
|
||||
@@ -68,7 +66,7 @@ function selectionHarness(t) {
|
||||
return { fake, state, vessel, focused };
|
||||
}
|
||||
|
||||
test("a click a label painted over a vessel's card takes never selects or focuses the vessel", (t) => {
|
||||
test("a click on a mission label over a vessel's card never selects or focuses the vessel", (t) => {
|
||||
const h = selectionHarness(t);
|
||||
h.fake.label.over = true;
|
||||
h.fake.click();
|
||||
@@ -76,14 +74,15 @@ test("a click a label painted over a vessel's card takes never selects or focuse
|
||||
assert.deepEqual(h.focused, [], 'the camera is not sent to the vessel');
|
||||
});
|
||||
|
||||
test('a click a label painted over the map takes lets go of the selected vessel', (t) => {
|
||||
test('a click on a mission label keeps the selected vessel', (t) => {
|
||||
const h = selectionHarness(t);
|
||||
// Off the label, a click on the card selects and focuses its vessel.
|
||||
h.fake.click();
|
||||
assert.equal(h.state.selectedRecord, h.vessel);
|
||||
assert.deepEqual(h.focused, ['v1']);
|
||||
// The label on top is its own click: the vessel stays selected.
|
||||
h.fake.label.over = true;
|
||||
h.fake.click();
|
||||
assert.equal(h.state.selectedRecord, null);
|
||||
assert.equal(h.state.selectedRecord, h.vessel);
|
||||
assert.deepEqual(h.focused, ['v1']);
|
||||
});
|
||||
Reference in new issue
Block a user