mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-09 04:44:01 +00:00
fix(vessels): hide the ridden ship's trail while its bridge is held
The sprite and card were hidden from the bridge but the selected-vessel trail was not: at sea it ran astern from under the eye, and on a raised river it lay buried under the water. It is now hidden while the bridge holds its ship, keeping its history, and shown again on release.
This commit is contained in:
1 parent
3ce3fce46f
commit
bbe33b48c7
2 files changed
+23
-1
No files matched your search
@@ -563,6 +563,9 @@ export function createQueries({
|
||||
const next = normalizeSelectionMmsi(mmsi);
|
||||
if (state.cockpitSubjectMmsi === next) return true;
|
||||
state.cockpitSubjectMmsi = next;
|
||||
// The ridden ship's trail runs from under the eye: hidden, its history
|
||||
// kept, while the bridge holds the ship it belongs to.
|
||||
state.trail?.setVisible?.(!next || next !== state.trailMmsi);
|
||||
components.rendering.updateVisibility(true);
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// src/layers/vessels/radarContacts.test.mjs — the vessels the Cockpit bridge
|
||||
// radar draws: within range, nearest first, without the ship it rides.
|
||||
// radar draws: within range, nearest first, without the ship it rides; and
|
||||
// the ridden ship's own trail, hidden while the bridge holds it.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createVesselLayer } from './index.js';
|
||||
@@ -128,6 +129,24 @@ test('ships with no MMSI each keep a key of their own', () => {
|
||||
assert.ok(ids.every((id) => id.startsWith('unkeyed:')));
|
||||
});
|
||||
|
||||
test("the ridden ship's trail is hidden while the bridge holds it", () => {
|
||||
const shown = [];
|
||||
const trail = {
|
||||
setPositions() {},
|
||||
clear() {},
|
||||
destroy() {},
|
||||
setVisible: (visible) => shown.push(visible),
|
||||
};
|
||||
const layer = layerWith([record('own', 0), record('other', 2)], {
|
||||
trail,
|
||||
trailMmsi: 'own',
|
||||
});
|
||||
layer.setCockpitSubject('own');
|
||||
assert.deepEqual(shown, [false]);
|
||||
layer.setCockpitSubject(null);
|
||||
assert.deepEqual(shown, [false, true]);
|
||||
});
|
||||
|
||||
test('a disabled layer has no radar contacts', () => {
|
||||
const layer = layerWith([record('1', 1)], { enabled: false });
|
||||
assert.deepEqual(layer.getRadarContacts(54.5, 10.2, 6 * 1852), []);
|
||||
|
||||
Reference in new issue
Block a user