mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge branch 'main' into samehkhamis/omnibar-reading-fixes
This commit is contained in:
180 files changed
+11996
-1158
No files matched your search
@@ -219,7 +219,6 @@ export class StyleManager extends ShellFacade {
|
||||
pinia: applicationPinia(),
|
||||
pickWorld: services.pickWorldFromScreen,
|
||||
regionalBrief: services.fetchRegionalBrief,
|
||||
overlayHit: services.hitTestWorldOverlay,
|
||||
});
|
||||
this.mapStackController = mapStackController;
|
||||
this.placeSearch = placeSearch;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
import { inputFor } from '../input/dispatcher.js';
|
||||
import { isUnderOtherCard } from '../data/pickRegistry.js';
|
||||
import { findQuery } from '../render/rendererOf.js';
|
||||
import { clampOrbitalLook, easeLook } from '../cockpitLook.js';
|
||||
import { ORBITAL_EARTH_RADIUS_M } from '../cockpitOrbital.js';
|
||||
@@ -286,7 +287,12 @@ export function routeSceneClick() {
|
||||
// A viewer with no input (headless tools, partial stubs) has no clicks.
|
||||
return () => {};
|
||||
}
|
||||
return input.onClick((event) => this.onOrbitalClick(event?.position));
|
||||
return input.onClick((event) => {
|
||||
// Another layer's card or label painted on top takes the click: the site
|
||||
// under it does not focus, and the click does not end a held focus.
|
||||
if (isUnderOtherCard(event)) return;
|
||||
this.onOrbitalClick(event?.position);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,7 @@ import CockpitView from './views/CockpitView.vue';
|
||||
import ContextView from './views/ContextView.vue';
|
||||
import IntelHudView from './views/IntelHudView.vue';
|
||||
import { claimPointer, releasePointer } from '../data/inputOwnership.js';
|
||||
import { setClickCardHitTest } from '../data/pickRegistry.js';
|
||||
import { ORBITAL_FOCUS_EASE_TAU_MS } from '../cockpitOrbitalFocus.js';
|
||||
import { ORBITAL_HOP_MS } from '../cockpitOrbitalSatellites.js';
|
||||
|
||||
@@ -648,6 +649,23 @@ test('a click a tool owns is left alone', async (t) => {
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id, 'kept while drawing');
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: a site under another
|
||||
// layer's card does not focus, and a click there does not end a held focus.
|
||||
test('another layer\'s card over the orbital view keeps the click', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
t.after(() => setClickCardHitTest(null));
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(scene.cockpit.orbital.focus ?? null, null, 'covered: no focus');
|
||||
top = null;
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
scene.click(EMPTY_GROUND);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id, 'covered: kept');
|
||||
});
|
||||
|
||||
test('a double-click on a site focuses it and keeps the orbital view', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, viewer, handler } = scene;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @module ui/creditLineHeight
|
||||
* @description Keeps `--credit-line-height` on the page's root at the
|
||||
* height of the attribution line at the bottom of the screen, so what sits
|
||||
* above it (the HUD's bottom corners) clears it when it wraps onto more
|
||||
* lines. The line is the application's own (`#gev-credits`) or the one a
|
||||
* renderer draws inside `#cesium-credits`.
|
||||
*/
|
||||
|
||||
const LINES = ['#gev-credits', '#cesium-credits .cesium-widget-credits'];
|
||||
|
||||
/**
|
||||
* Follow the attribution line's height in `--credit-line-height`.
|
||||
* @param {Document} [doc]
|
||||
* @returns {() => void} Stops following it and clears the property.
|
||||
*/
|
||||
export function trackCreditLineHeight(doc = globalThis.document) {
|
||||
const Observer = doc?.defaultView?.ResizeObserver;
|
||||
if (!doc?.documentElement || typeof Observer !== 'function') return () => {};
|
||||
const root = doc.documentElement;
|
||||
const lines = LINES.map((selector) => doc.querySelector(selector)).filter(
|
||||
Boolean,
|
||||
);
|
||||
if (!lines.length) return () => {};
|
||||
const update = () => {
|
||||
const height = Math.max(
|
||||
0,
|
||||
...lines.map((line) => line.getBoundingClientRect().height),
|
||||
);
|
||||
if (height > 0)
|
||||
root.style.setProperty('--credit-line-height', `${Math.ceil(height)}px`);
|
||||
else root.style.removeProperty('--credit-line-height');
|
||||
};
|
||||
const observer = new Observer(update);
|
||||
for (const line of lines) observer.observe(line);
|
||||
update();
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
root.style.removeProperty('--credit-line-height');
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { trackCreditLineHeight } from './creditLineHeight.js';
|
||||
|
||||
/** A ResizeObserver the test drives, with each line's height set by hand. */
|
||||
function fakeResizing() {
|
||||
const observers = [];
|
||||
const window = document.defaultView;
|
||||
const original = window.ResizeObserver;
|
||||
window.ResizeObserver = class {
|
||||
constructor(callback) {
|
||||
this.callback = callback;
|
||||
this.targets = new Set();
|
||||
observers.push(this);
|
||||
}
|
||||
observe(target) {
|
||||
this.targets.add(target);
|
||||
}
|
||||
disconnect() {
|
||||
this.targets.clear();
|
||||
}
|
||||
};
|
||||
return {
|
||||
resize(element, height) {
|
||||
element.getBoundingClientRect = () => ({ height });
|
||||
for (const observer of observers)
|
||||
if (observer.targets.has(element)) observer.callback([]);
|
||||
},
|
||||
restore() {
|
||||
window.ResizeObserver = original;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test("the credit line's height follows it as it wraps, for either renderer's line", () => {
|
||||
const resizing = fakeResizing();
|
||||
try {
|
||||
for (const markup of [
|
||||
'<div id="gev-credits"></div>',
|
||||
'<div id="cesium-credits"><div class="cesium-widget-credits"></div></div>',
|
||||
]) {
|
||||
document.body.innerHTML = markup;
|
||||
const line = document.querySelector(
|
||||
'#gev-credits, #cesium-credits .cesium-widget-credits',
|
||||
);
|
||||
line.getBoundingClientRect = () => ({ height: 28 });
|
||||
const stop = trackCreditLineHeight(document);
|
||||
const root = document.documentElement.style;
|
||||
assert.equal(root.getPropertyValue('--credit-line-height'), '28px');
|
||||
resizing.resize(line, 66.4);
|
||||
assert.equal(root.getPropertyValue('--credit-line-height'), '67px');
|
||||
// Hidden, it holds no room.
|
||||
resizing.resize(line, 0);
|
||||
assert.equal(root.getPropertyValue('--credit-line-height'), '');
|
||||
resizing.resize(line, 28);
|
||||
stop();
|
||||
assert.equal(root.getPropertyValue('--credit-line-height'), '');
|
||||
}
|
||||
} finally {
|
||||
resizing.restore();
|
||||
document.body.replaceChildren();
|
||||
}
|
||||
});
|
||||
|
||||
test('without a credit line nothing is followed', () => {
|
||||
const resizing = fakeResizing();
|
||||
try {
|
||||
document.body.replaceChildren();
|
||||
const stop = trackCreditLineHeight(document);
|
||||
assert.equal(
|
||||
document.documentElement.style.getPropertyValue('--credit-line-height'),
|
||||
'',
|
||||
);
|
||||
stop();
|
||||
} finally {
|
||||
resizing.restore();
|
||||
}
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import { resolvePickedContext } from '../data/pickedContext.js';
|
||||
import { clickCard } from '../data/pickRegistry.js';
|
||||
import { followedOf, onFollowChanged } from '../data/followed.js';
|
||||
import { fromDegreesInto } from '../geo/ellipsoid.js';
|
||||
import { inputFor } from '../input/dispatcher.js';
|
||||
@@ -45,8 +46,6 @@ const FOLLOWABLE = new Set(['flights', 'military', 'satellites']);
|
||||
* to the point under the camera without it.
|
||||
* @param {(lat: number, lon: number) => Promise<object>} [options.regionalBrief]
|
||||
* The app's regional brief service, for the weather and news Context shows.
|
||||
* @param {(x: number, y: number) => object|null} [options.overlayHit]
|
||||
* The overlay card under a screen point, if any (a vessel's, a fire's).
|
||||
* @returns {() => void} disconnects
|
||||
*/
|
||||
export function installEntityContext({
|
||||
@@ -55,7 +54,6 @@ export function installEntityContext({
|
||||
pinia,
|
||||
pickWorld,
|
||||
regionalBrief,
|
||||
overlayHit,
|
||||
}) {
|
||||
const store = useEntityCardStore(pinia);
|
||||
const omnibar = useOmnibarStore(pinia);
|
||||
@@ -318,6 +316,10 @@ export function installEntityContext({
|
||||
// Cockpit has its own picks, and Context is hidden while it runs. A
|
||||
// camera drag never selects, even if it ends over something.
|
||||
if (inCockpit() || !isTrackingSelectionGesture(event.gesture)) return;
|
||||
// A card or label painted on top is its layer's click, read once per
|
||||
// click so every layer agrees: Context names nothing under it and keeps
|
||||
// its own card as it is.
|
||||
if (clickCard(event)) return;
|
||||
const identity = resolvePickedContext(event.hit, {
|
||||
dataManager: getDataManager(),
|
||||
});
|
||||
@@ -331,14 +333,8 @@ export function installEntityContext({
|
||||
// A click on open ground, sea or sky lets go of what was selected. A
|
||||
// click on something else Context cannot describe (a label, a trail)
|
||||
// leaves the card as it is.
|
||||
// Only a clean click lets go, as the layers' own clicks do; a card
|
||||
// painted on the overlay (a vessel's, a fire's) is not open map.
|
||||
if (
|
||||
event.surface &&
|
||||
isTrackingClickGesture(event.gesture) &&
|
||||
!overlayHit?.(event.screenPosition?.x, event.screenPosition?.y)
|
||||
)
|
||||
store.clear();
|
||||
// Only a clean click lets go, as the layers' own clicks do.
|
||||
if (event.surface && isTrackingClickGesture(event.gesture)) store.clear();
|
||||
});
|
||||
|
||||
// Layers that select through the context store (GeoJSON sites, fires,
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createPinia } from 'pinia';
|
||||
import { installEntityContext } from './entityContextBridge.js';
|
||||
import { useEntityCardStore } from './stores/entityCard.js';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import {
|
||||
registerPickOwner,
|
||||
setClickCardHitTest,
|
||||
unregisterPickOwner,
|
||||
} from '../data/pickRegistry.js';
|
||||
|
||||
// The card or label painted on top takes the click: Context names nothing
|
||||
// under it, exact or nearby, an acting owner's item or a passive one, and
|
||||
// keeps its own card. On open map it names what the click found.
|
||||
test('Context names nothing under a card painted on top, and keeps its card', (t) => {
|
||||
const previous = globalThis.matchMedia;
|
||||
globalThis.matchMedia = () => ({ matches: true });
|
||||
t.after(() => {
|
||||
if (previous) globalThis.matchMedia = previous;
|
||||
else delete globalThis.matchMedia;
|
||||
});
|
||||
const fire = { set: 'test-fires:1', id: 'fire:1' };
|
||||
const plane = { set: 'test-planes:1', id: 'plane:1' };
|
||||
const route = { set: 'test-route:1', id: 'route:line' };
|
||||
registerPickOwner('test-fires', (id) => id === fire.id);
|
||||
registerPickOwner('test-planes', (id) => id === plane.id);
|
||||
registerPickOwner('test-route', (id) => id.startsWith('route:'));
|
||||
let cardOnTop = false;
|
||||
// The card on top at a click, as the host answers the pick registry.
|
||||
setClickCardHitTest(() =>
|
||||
cardOnTop ? { sourceId: 'earthquake-card', entryId: 'q' } : null,
|
||||
);
|
||||
t.after(() => {
|
||||
setClickCardHitTest(null);
|
||||
unregisterPickOwner('test-fires');
|
||||
unregisterPickOwner('test-planes');
|
||||
unregisterPickOwner('test-route');
|
||||
});
|
||||
let exact = null;
|
||||
let near = null;
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick: () => (exact ? { id: exact } : null),
|
||||
drillPick: () => (near ? [{ id: near }] : []),
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
const pinia = createPinia();
|
||||
const disconnect = installEntityContext({
|
||||
viewer,
|
||||
getDataManager: () => ({
|
||||
isEnabled: () => true,
|
||||
layers: new Map(),
|
||||
getAll: () => [],
|
||||
}),
|
||||
pinia,
|
||||
});
|
||||
t.after(() => {
|
||||
disconnect();
|
||||
input.destroy();
|
||||
});
|
||||
const store = useEntityCardStore(pinia);
|
||||
const named = [];
|
||||
let clears = 0;
|
||||
store.select = (identity) => named.push(identity.id);
|
||||
store.clear = () => clears++;
|
||||
const tap = (hitExact, hitNear) => {
|
||||
exact = hitExact;
|
||||
near = hitNear;
|
||||
named.length = 0;
|
||||
input.click();
|
||||
return [...named];
|
||||
};
|
||||
assert.deepEqual(tap(null, fire), ['fire:1'], 'open map: a near fire');
|
||||
assert.deepEqual(tap(route, null), ['route:line'], 'open map: a route');
|
||||
cardOnTop = true;
|
||||
assert.deepEqual(tap(null, fire), [], 'under a card: a near fire');
|
||||
assert.deepEqual(tap(fire, fire), [], 'under a card: an exact fire');
|
||||
assert.deepEqual(tap(plane, plane), [], 'under a card: an aircraft');
|
||||
assert.deepEqual(tap(route, null), [], 'under a card: a route');
|
||||
const cleared = clears;
|
||||
tap(null, null);
|
||||
assert.equal(clears, cleared, 'a card over open map is not open map');
|
||||
});
|
||||
+131
-16
@@ -28,6 +28,13 @@ import { setCyberSonarControls } from './cyberSonarControls.js';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useDisplayStore } from './stores/display.js';
|
||||
import { VisualSettings } from './visualSettings.js';
|
||||
import { normalizeShot } from '../scenes/project.js';
|
||||
import {
|
||||
SCENE_DOCUMENT_VERSION,
|
||||
validateSceneDocument,
|
||||
} from '../director/document.js';
|
||||
import { decodeShareView, encodeShareView } from '../share/viewCodec.js';
|
||||
import { toLegacyShareState } from '../share/legacyShareState.js';
|
||||
import { STYLES } from './visualPresets.js';
|
||||
|
||||
const read = (relative) =>
|
||||
@@ -140,9 +147,10 @@ test('a share link, scene or saved view naming Cyber opens Tactical with Sonar o
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
});
|
||||
|
||||
test('links and scene shots record Tactical with Sonar as the Cyber code, and only that', (t) => {
|
||||
const { owner, root } = styleOwner(t, 'tactical');
|
||||
Object.assign(owner.services, {
|
||||
/** A styleOwner that can also read its share state and scene shot. */
|
||||
function sharingOwner(t, initialVariant) {
|
||||
const fixture = styleOwner(t, initialVariant);
|
||||
Object.assign(fixture.owner.services, {
|
||||
getDetectionTuning: () => ({ allocationStrategy: 'ELASTIC' }),
|
||||
getDetectionMode: () => 'OFF',
|
||||
isScopeMaskEnabled: () => true,
|
||||
@@ -150,18 +158,94 @@ test('links and scene shots record Tactical with Sonar as the Cyber code, and on
|
||||
getScopeMaskOpacity: () => 1,
|
||||
getScopeTerminusOverride: () => null,
|
||||
});
|
||||
owner.readCelestialRing = () => null;
|
||||
const shared = () => owner._readShareState().options.hudVariant;
|
||||
assert.equal(shared(), 'tactical');
|
||||
fixture.owner.readCelestialRing = () => null;
|
||||
return fixture;
|
||||
}
|
||||
|
||||
test('links and scene shots record Tactical with Sonar as the Cyber code, and only that', (t) => {
|
||||
const { owner, root } = sharingOwner(t, 'tactical');
|
||||
const shared = () => {
|
||||
const { hudVariant, hudSonar } = owner._readShareState().options;
|
||||
return [hudVariant, hudSonar];
|
||||
};
|
||||
const shot = () => owner.getVisualState().hud;
|
||||
assert.deepEqual(shared(), ['tactical', false]);
|
||||
assert.deepEqual(shot(), { visible: true, variant: 'tactical' });
|
||||
owner._setCyberSonarEnabled(true);
|
||||
assert.equal(shared(), 'cyber');
|
||||
// Minimal has no code that carries Sonar; it stays local.
|
||||
// Tactical with Sonar is the Cyber code alone, as older readers expect.
|
||||
assert.deepEqual(shared(), ['cyber', false]);
|
||||
assert.deepEqual(shot(), { visible: true, variant: 'cyber' });
|
||||
// Minimal has no such code, so Sonar is carried beside it.
|
||||
owner._setHudVariant('minimal');
|
||||
assert.equal(shared(), 'minimal');
|
||||
owner._setHudVariant('tactical');
|
||||
assert.equal(shared(), 'cyber');
|
||||
assert.deepEqual(shared(), ['minimal', true]);
|
||||
assert.deepEqual(shot(), { visible: true, variant: 'minimal', sonar: true });
|
||||
owner._setCyberSonarEnabled(false);
|
||||
assert.equal(shared(), 'tactical');
|
||||
assert.deepEqual(shared(), ['minimal', false]);
|
||||
assert.deepEqual(shot(), { visible: true, variant: 'minimal' });
|
||||
owner._setHudVariant('tactical');
|
||||
assert.deepEqual(shared(), ['tactical', false]);
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
});
|
||||
|
||||
test('Minimal with Sonar round-trips through a compact link and a scene shot', async (t) => {
|
||||
const { owner, hud, root } = sharingOwner(t, 'minimal');
|
||||
owner._setCyberSonarEnabled(true);
|
||||
const options = owner._readShareState().options;
|
||||
const shot = normalizeShot(
|
||||
JSON.parse(JSON.stringify({ visual: owner.getVisualState() })),
|
||||
);
|
||||
validateSceneDocument({
|
||||
version: SCENE_DOCUMENT_VERSION,
|
||||
scenes: [{ id: 'scene', title: 'Scene', shots: [shot] }],
|
||||
});
|
||||
const code = encodeShareView({
|
||||
hudVariant: options.hudVariant,
|
||||
hudSonar: options.hudSonar,
|
||||
});
|
||||
const link = decodeShareView(code, { nowMs: Date.now() }).state;
|
||||
|
||||
// The viewer is elsewhere: Tactical, Sonar off.
|
||||
owner._setHudVariant('tactical');
|
||||
owner._setCyberSonarEnabled(false);
|
||||
// The HUD fields of the parsed link (the fixture drives no detection).
|
||||
const { hudVariant, hudSonar } = toLegacyShareState(link);
|
||||
assert.deepEqual([hudVariant, hudSonar], ['minimal', true]);
|
||||
await owner.restoreShareState({ hudVariant, hudSonar });
|
||||
assert.equal(hud.getVariant(), 'minimal');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
|
||||
owner._setHudVariant('tactical');
|
||||
owner._setCyberSonarEnabled(false);
|
||||
// The saved shot's HUD, as the editor normalized and validated it.
|
||||
assert.deepEqual(shot.visual.hud, {
|
||||
visible: true,
|
||||
variant: 'minimal',
|
||||
sonar: true,
|
||||
});
|
||||
await owner.applyVisualState({ hud: shot.visual.hud });
|
||||
assert.equal(hud.getVariant(), 'minimal');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
});
|
||||
|
||||
test('a link or scene shot that does not mention Sonar restores as before', async (t) => {
|
||||
const { owner, hud, root } = sharingOwner(t, 'minimal');
|
||||
// Made before Sonar was carried: Minimal turns the viewer's Sonar off...
|
||||
setCyberSonarEnabled(true, root);
|
||||
await owner.restoreShareState({ hudVariant: 'minimal' });
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
setCyberSonarEnabled(true, root);
|
||||
await owner.applyVisualState({ hud: { variant: 'minimal' } });
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
// ...and Cyber still opens Tactical with Sonar on.
|
||||
await owner.restoreShareState({ hudVariant: 'cyber', hudSonar: false });
|
||||
assert.equal(hud.getVariant(), 'tactical');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
owner._setCyberSonarEnabled(false);
|
||||
await owner.applyVisualState({ hud: { variant: 'cyber' } });
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
// Sonar beside a layout counts only in a restore, not a layout choice.
|
||||
owner._setCyberSonarEnabled(false);
|
||||
owner._setHudVariant('minimal', { sonar: true });
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
});
|
||||
|
||||
@@ -458,8 +542,14 @@ test('the desktop bottom row: credits on the Power Up baseline, the dock lifted,
|
||||
const anchor = trays.match(
|
||||
/#cesium-credits \{\s*right: auto;\s*bottom: ([\d.]+)rem;\s*left: 1\.5rem;/,
|
||||
);
|
||||
// From 1200px, and in the Omnibar layout at every width: a long line
|
||||
// wraps rather than running under the corner row.
|
||||
const box = trayWide.match(
|
||||
/\n #cesium-credits \.cesium-widget-credits \{\s*width: max-content;\s*max-width: calc\(100vw - 1\.5rem - ([\d.]+)rem\);\s*white-space: normal;/,
|
||||
/\n\s*#cesium-credits \.cesium-widget-credits \{\s*width: max-content;\s*max-width: calc\(100vw - 1\.5rem - ([\d.]+)rem\);\s*white-space: normal;/,
|
||||
);
|
||||
assert.match(
|
||||
trays,
|
||||
/:has\(#command-dock > #gev-voice-control\)\s*\)\s*#cesium-credits\s*\.cesium-widget-credits \{\s*width: max-content;\s*max-width: calc\(100vw - 1\.5rem - 26rem\);/,
|
||||
);
|
||||
return anchor && box && [null, anchor[1], box[1]];
|
||||
})(),
|
||||
@@ -490,14 +580,22 @@ test('the desktop bottom row: credits on the Power Up baseline, the dock lifted,
|
||||
trayWide,
|
||||
/html\[dir='rtl'\]\s*body:not\(\.context-docked\):not\(\.ui-clean-view\):not\(\.recording-mode\)\s*:is\(#cesium-credits, #gev-credits\),\s*html\[dir='rtl'\]\s*body:not\(\.context-docked\):not\(\.ui-clean-view\):not\(\.recording-mode\):has\(\s*#intel-hud\[data-variant='minimal'\]\.active\s*\)\s*:is\(#cesium-credits, #gev-credits\) \{\s*right: 1\.5rem;\s*left: auto;/,
|
||||
);
|
||||
// Its box hangs from the anchor's right edge there, and in the Omnibar
|
||||
// layout at every width; never in clean view or recording, where the
|
||||
// anchor stays on the left.
|
||||
assert.match(
|
||||
trayWide,
|
||||
/#cesium-credits\s*\.cesium-widget-credits \{\s*right: 0;\s*left: auto;/,
|
||||
/body:not\(\.context-docked\):not\(\.ui-clean-view\):not\(\.recording-mode\)\s*#cesium-credits\s*\.cesium-widget-credits \{\s*right: 0;\s*left: auto;/,
|
||||
);
|
||||
// There the readout clears two lines of the row under it.
|
||||
assert.match(
|
||||
trays,
|
||||
/html\[dir='rtl'\]\s*body:not\(\.mobile-shell\)[^{]*:not\(\.recording-mode\):not\(\.context-docked\)[^{]*#cesium-credits\s*\.cesium-widget-credits \{\s*right: 0;\s*left: auto;/,
|
||||
);
|
||||
// There the readout clears the row under it, however many lines it wraps
|
||||
// onto (--credit-line-height).
|
||||
assert.match(
|
||||
read('./styles/omnibar-dock.css'),
|
||||
/html\[dir='rtl'\] \*\)\s*#intel-hud\[data-variant='tactical'\]\s*\.hud-bottom-right \{\s*bottom: calc\(3\.375rem \+ 1\.5rem\);/,
|
||||
/html\[dir='rtl'\] \*\):not\(\.context-docked\)\s*#intel-hud\[data-variant='tactical'\]\s*\.hud-bottom-right \{\s*bottom: max\(3\.375rem, var\(--omnibar-credits-clear\)\);/,
|
||||
);
|
||||
const locale = read('./styles/locale-picker.css');
|
||||
assert.match(locale, /#corner-actions \{[^}]*inset-inline-end: 0\.9rem;/);
|
||||
@@ -670,3 +768,20 @@ test('shared panel hooks affect only opted-in rail surfaces without overriding d
|
||||
/body:is\(\.ui-clean-view, \.recording-mode\)[^{]+\{[^}]*visibility: hidden !important;[^}]*pointer-events: none !important;/,
|
||||
);
|
||||
});
|
||||
|
||||
test('narrow Omnibar corners clear the World Timeline over the dock', () => {
|
||||
const css = read('./styles/omnibar-dock.css');
|
||||
const timeline = css.match(
|
||||
/#world-timeline \{\s*bottom: calc\(var\(--omnibar-dock-bottom\) \+ (\d+)px\);/,
|
||||
);
|
||||
const height = read('./styles/world-timeline.css').match(
|
||||
/#world-timeline \{[^}]*\n {2}height: (\d+)px;/,
|
||||
);
|
||||
const corners = css.match(
|
||||
/&:has\(#world-timeline\) \{\s*--omnibar-coordinates-bottom: max\(\s*calc\(var\(--omnibar-dock-bottom\) \+ (\d+)px \+ (\d+)px \+ (\d+)px\)/,
|
||||
);
|
||||
assert.ok(timeline && height && corners);
|
||||
assert.equal(Number(corners[1]), Number(timeline[1]));
|
||||
assert.equal(Number(corners[2]), Number(height[1]));
|
||||
assert.ok(Number(corners[3]) >= 6);
|
||||
});
|
||||
@@ -67,11 +67,26 @@ const RIGHT_STACK_OBSTACLE_SELECTOR = [
|
||||
'#gev-voice-control',
|
||||
'#world-timeline',
|
||||
].join(', ');
|
||||
/** True when a mutation adds or removes the Stories card (`#hPop`). */
|
||||
function movesStoriesCard(record) {
|
||||
/** The body class the welcome sets while BROWSE STORIES loads. */
|
||||
const OPENING_STORIES = 'first-run-opening-stories';
|
||||
/**
|
||||
* True when a mutation can show or hide the Stories card (`#hPop`): the card
|
||||
* itself coming or going, or the welcome that hides it (`#first-run-launcher`,
|
||||
* and the body class it sets while BROWSE STORIES loads) ending.
|
||||
*/
|
||||
export function movesStoriesCard(record) {
|
||||
if (record.type === 'attributes')
|
||||
return (
|
||||
(record.oldValue || '').split(/\s+/).includes(OPENING_STORIES) !==
|
||||
record.target.classList.contains(OPENING_STORIES)
|
||||
);
|
||||
for (const list of [record.addedNodes, record.removedNodes])
|
||||
for (const node of list)
|
||||
if (node.id === 'hPop' || node.querySelector?.('#hPop')) return true;
|
||||
if (
|
||||
['hPop', 'first-run-launcher'].includes(node.id) ||
|
||||
node.querySelector?.('#hPop, #first-run-launcher')
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -276,6 +291,18 @@ export class PanelLayoutController {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
const welcomeHost = document.querySelector('[data-gev-view="welcome"]');
|
||||
if (welcomeHost)
|
||||
this._storiesCardObserver.observe(welcomeHost, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
if (document.body)
|
||||
this._storiesCardObserver.observe(document.body, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
attributeOldValue: true,
|
||||
});
|
||||
this._storiesCardShownHandler = (event) => {
|
||||
if (event.target?.id === 'hPop') this._scheduleRightPanelLayout();
|
||||
};
|
||||
|
||||
@@ -878,3 +878,42 @@ test('left rail keeps collapsed panels shown beside Cockpit, still one open', ()
|
||||
assert.equal(f.stack.classList.contains('layout-exclusive'), false);
|
||||
assert.equal(f.first.getAttribute('aria-hidden'), undefined);
|
||||
});
|
||||
|
||||
test('the right rail is laid out again when the Stories card can appear or go', async () => {
|
||||
const { movesStoriesCard } = await import('./panelLayoutController.js');
|
||||
const node = (id, inner = null) => ({
|
||||
id,
|
||||
querySelector: (selector) =>
|
||||
inner && selector.split(', ').includes(`#${inner}`) ? {} : null,
|
||||
});
|
||||
const childList = (added = [], removed = []) => ({
|
||||
type: 'childList',
|
||||
addedNodes: added,
|
||||
removedNodes: removed,
|
||||
});
|
||||
const bodyClass = (oldValue, now) => ({
|
||||
type: 'attributes',
|
||||
oldValue,
|
||||
target: { classList: { contains: (name) => now.includes(name) } },
|
||||
});
|
||||
// The card itself, or a wrapper holding it, comes or goes.
|
||||
assert.equal(movesStoriesCard(childList([node('hPop')])), true);
|
||||
assert.equal(movesStoriesCard(childList([], [node('', 'hPop')])), true);
|
||||
// The welcome, which hides the card, is removed.
|
||||
assert.equal(
|
||||
movesStoriesCard(childList([], [node('first-run-launcher')])),
|
||||
true,
|
||||
);
|
||||
// Story playback's own changes do not lay the rail out.
|
||||
assert.equal(movesStoriesCard(childList([node('story-frame')])), false);
|
||||
// Only the welcome's loading class coming or going counts.
|
||||
assert.equal(
|
||||
movesStoriesCard(bodyClass('first-run-opening-stories', ['stories-mode'])),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
movesStoriesCard(bodyClass('', ['first-run-opening-stories'])),
|
||||
true,
|
||||
);
|
||||
assert.equal(movesStoriesCard(bodyClass('a', ['b'])), false);
|
||||
});
|
||||
@@ -8,7 +8,7 @@ import { markRaw, shallowRef } from 'vue';
|
||||
*/
|
||||
export const useFirstRunStore = defineStore('gev-first-run', () => {
|
||||
/**
|
||||
* `{removed, shown, visible, closing, state, busy, status, description,
|
||||
* `{removed, shown, visible, closing, state, busy, status,
|
||||
* environmentalTitle, environmentalSub, scrollable}`, or null until the
|
||||
* launcher is initialized (the card stays hidden).
|
||||
*/
|
||||
@@ -19,7 +19,7 @@ export const useFirstRunStore = defineStore('gev-first-run', () => {
|
||||
launcher.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/** `{choose(choice), dismiss(), suppress(wanted) → boolean}`, or null. */
|
||||
/** `{choose(choice), dismiss(), suppress(wanted) → boolean, refreshLayout()}`, or null. */
|
||||
const controls = shallowRef(null);
|
||||
|
||||
/** @param {?object} next The launcher's controls, or null to disconnect. */
|
||||
|
||||
@@ -528,9 +528,37 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
}
|
||||
}
|
||||
|
||||
/* Cesium draws the line in an absolutely placed box inside the empty
|
||||
#cesium-credits anchor, so the cap and the wrapping go on that box: from
|
||||
1200px, and in the Omnibar layout at every width, whose attribution row
|
||||
shares the bottom edge with the corner row (omnibar-dock.css). */
|
||||
body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
.ui-clean-view
|
||||
):not(.recording-mode):where(
|
||||
:has(#gev-omnibar):has(#command-dock > #gev-voice-control)
|
||||
)
|
||||
#cesium-credits
|
||||
.cesium-widget-credits {
|
||||
width: max-content;
|
||||
max-width: calc(100vw - 1.5rem - 26rem);
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
/* Right to left that layout puts the row at the bottom right at every
|
||||
width, so the box hangs from the anchor's right edge. */
|
||||
html[dir='rtl']
|
||||
body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
.ui-clean-view
|
||||
):not(.recording-mode):not(.context-docked):where(
|
||||
:has(#gev-omnibar):has(#command-dock > #gev-voice-control)
|
||||
)
|
||||
#cesium-credits
|
||||
.cesium-widget-credits {
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
/* Cesium draws the line in an absolutely placed box inside the empty
|
||||
#cesium-credits anchor, so the cap and the wrapping go on that box. */
|
||||
#cesium-credits .cesium-widget-credits {
|
||||
width: max-content;
|
||||
max-width: calc(100vw - 1.5rem - 26rem);
|
||||
|
||||
+1559
-95
File diff suppressed because it is too large.
Load diff
@@ -5,8 +5,13 @@ body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
:has(#gev-omnibar):has(#command-dock > #gev-voice-control)
|
||||
) {
|
||||
--omnibar-dock-width: clamp(400px, 32vw, 460px);
|
||||
--omnibar-dock-bottom: 74px;
|
||||
--omnibar-coordinates-bottom: 4.25rem;
|
||||
/* Clear of the attribution line under it, however many lines it wraps
|
||||
onto (--credit-line-height, src/ui/creditLineHeight.js). */
|
||||
--omnibar-credits-clear: calc(1rem + var(--credit-line-height, 28px) + 6px);
|
||||
/* The dock, and the World Timeline and narrow corners placed from it,
|
||||
rise over a line wrapped taller than its usual one or two lines. */
|
||||
--omnibar-dock-bottom: max(74px, calc(var(--omnibar-credits-clear) + 2px));
|
||||
--omnibar-coordinates-bottom: max(4.25rem, var(--omnibar-credits-clear));
|
||||
--world-timeline-lift: 0px;
|
||||
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
@@ -320,24 +325,61 @@ body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Align the plain credits with Power Up. */
|
||||
/* Align the plain credits with Power Up. The line wraps at every width
|
||||
rather than running under the corner row (Power Up and the language
|
||||
picker), whose side it stays clear of. */
|
||||
:is(#cesium-credits, #gev-credits),
|
||||
&:has(#intel-hud[data-variant='minimal'].active)
|
||||
:is(#cesium-credits, #gev-credits) {
|
||||
bottom: 1rem;
|
||||
}
|
||||
#gev-credits {
|
||||
width: max-content !important;
|
||||
max-width: calc(100vw - 1.5rem - 26rem);
|
||||
white-space: normal;
|
||||
}
|
||||
/* Right to left the corner row is at the bottom left, so the line takes
|
||||
the bottom right at every width. Expanded Context places it itself. */
|
||||
&:where(html[dir='rtl'] *):not(.context-docked) {
|
||||
:is(#cesium-credits, #gev-credits),
|
||||
&:has(#intel-hud[data-variant='minimal'].active)
|
||||
:is(#cesium-credits, #gev-credits) {
|
||||
right: 1.5rem;
|
||||
left: auto;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
/* 8px above the bottom-right corner row (Power Up and the language picker:
|
||||
32px tall, 14px up), as outside the Omnibar layout. */
|
||||
#intel-hud[data-variant='tactical'] .hud-bottom-right {
|
||||
bottom: 3.375rem;
|
||||
}
|
||||
/* Right to left the attribution row takes the bottom right: the readout
|
||||
clears two lines of it (rail-split.css). */
|
||||
@media (min-width: 1200px) {
|
||||
&:where(html[dir='rtl'] *)
|
||||
/* Right to left the attribution line is under the readout, which clears
|
||||
it however many lines it wraps onto. */
|
||||
&:where(html[dir='rtl'] *):not(.context-docked)
|
||||
#intel-hud[data-variant='tactical']
|
||||
.hud-bottom-right {
|
||||
bottom: max(3.375rem, var(--omnibar-credits-clear));
|
||||
}
|
||||
/* Narrower than the two corners and the dock between them, the corners
|
||||
rise above the dock. */
|
||||
@media (max-width: 1119px) {
|
||||
--omnibar-coordinates-bottom: max(
|
||||
calc(var(--omnibar-dock-bottom) + 56px + 10px),
|
||||
var(--omnibar-credits-clear)
|
||||
);
|
||||
/* And above the World Timeline (42px tall) over the dock. */
|
||||
&:has(#world-timeline) {
|
||||
--omnibar-coordinates-bottom: max(
|
||||
calc(var(--omnibar-dock-bottom) + 66px + 42px + 10px),
|
||||
var(--omnibar-credits-clear)
|
||||
);
|
||||
}
|
||||
#intel-hud[data-variant='tactical'] .hud-bottom-right,
|
||||
&:where(html[dir='rtl'] *):not(.context-docked)
|
||||
#intel-hud[data-variant='tactical']
|
||||
.hud-bottom-right {
|
||||
bottom: calc(3.375rem + 1.5rem);
|
||||
bottom: var(--omnibar-coordinates-bottom);
|
||||
}
|
||||
}
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
|
||||
@@ -125,16 +125,10 @@ html[dir='rtl'] #command-dock :is(#location-bar, #control-panel) .dock-pin-btn {
|
||||
}
|
||||
|
||||
/* The right rail sits on the left: its expand/collapse arrows point the
|
||||
other way, and the start window's "go" arrows point along the reading
|
||||
direction. */
|
||||
html[dir='rtl'] #right-context-rail .panel-collapse-btn,
|
||||
html[dir='rtl'] .first-run-arrow {
|
||||
other way. (The first-run card flips its own arrow in first-run.css.) */
|
||||
html[dir='rtl'] #right-context-rail .panel-collapse-btn {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
html[dir='rtl'] .first-run-choices button:hover .first-run-arrow,
|
||||
html[dir='rtl'] .first-run-choices button:focus-visible .first-run-arrow {
|
||||
transform: translateX(-2px) scaleX(-1);
|
||||
}
|
||||
|
||||
/* The cockpit is an aircraft panel, not page chrome: its windows keep their
|
||||
physical sides, so the data-layer stack goes back to the left edge instead
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
* @param {() => boolean} options.isActive Whether this surface may handle input now.
|
||||
* @param {() => void} options.onEscape Caller-owned dismissal action.
|
||||
* @param {() => HTMLElement} [options.fallbackFocus] Return target if the opener is gone.
|
||||
* @param {boolean} [options.claimOutsideFocus=true] Tab from a control outside
|
||||
* the surface moves into it. False leaves Tab to the page then, for a
|
||||
* surface that does not hold the keyboard (focus that has nowhere to be,
|
||||
* on the page body, still moves in).
|
||||
* @returns {{activate: Function, deactivate: Function, destroy: Function}}
|
||||
*/
|
||||
export function createSurfaceKeyboard({
|
||||
@@ -17,6 +21,7 @@ export function createSurfaceKeyboard({
|
||||
isActive,
|
||||
onEscape,
|
||||
fallbackFocus,
|
||||
claimOutsideFocus = true,
|
||||
}) {
|
||||
let active = false;
|
||||
let destroyed = false;
|
||||
@@ -54,6 +59,11 @@ export function createSurfaceKeyboard({
|
||||
// Allow native scrolling when cycling to an off-screen control in a short
|
||||
// surface. Initial focus and return focus use the caller's separate policy.
|
||||
if (!root.contains(focused)) {
|
||||
const lost =
|
||||
!focused ||
|
||||
focused === documentRef.body ||
|
||||
focused === documentRef.documentElement;
|
||||
if (!claimOutsideFocus && !lost) return;
|
||||
event.preventDefault();
|
||||
(event.shiftKey ? last : first).focus();
|
||||
} else if (event.shiftKey && focused === first) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createSurfaceKeyboard } from './surfaceKeyboard.js';
|
||||
|
||||
function fixture() {
|
||||
function fixture({ claimOutsideFocus } = {}) {
|
||||
const listeners = new Set();
|
||||
const documentRef = {
|
||||
activeElement: null,
|
||||
@@ -54,6 +54,7 @@ function fixture() {
|
||||
isActive: () => visible,
|
||||
onEscape: () => onEscape(),
|
||||
fallbackFocus: () => fallback,
|
||||
claimOutsideFocus,
|
||||
});
|
||||
opener.focus();
|
||||
const event = (key, extra = {}) => ({
|
||||
@@ -134,6 +135,23 @@ test('Tab enters from outside in either direction and wraps only at an edge', ()
|
||||
);
|
||||
});
|
||||
|
||||
test('a surface that does not claim outside focus leaves Tab to the page', () => {
|
||||
const f = fixture({ claimOutsideFocus: false });
|
||||
f.controller.activate();
|
||||
// From a control outside (the search bar), Tab follows the page.
|
||||
f.opener.focus();
|
||||
assert.equal(f.send('Tab').defaultPrevented, false);
|
||||
assert.equal(f.send('Tab', { shiftKey: true }).defaultPrevented, false);
|
||||
assert.equal(f.documentRef.activeElement, f.opener);
|
||||
// Focus with nowhere to be still moves in, and wraps inside as before.
|
||||
f.documentRef.activeElement = null;
|
||||
assert.equal(f.send('Tab').defaultPrevented, true);
|
||||
assert.equal(f.documentRef.activeElement, f.first);
|
||||
f.last.focus();
|
||||
f.send('Tab');
|
||||
assert.equal(f.documentRef.activeElement, f.first);
|
||||
});
|
||||
|
||||
test('Tab uses current controls and skips hidden/disabled nodes without changing native middle movement', () => {
|
||||
const f = fixture();
|
||||
f.controller.activate();
|
||||
|
||||
+272
-47
@@ -1,22 +1,142 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { msg, t } from '../../i18n/index.js';
|
||||
import {
|
||||
FIRST_RUN_TIP,
|
||||
environmentalLabel,
|
||||
} from '../../firstRunCopy.js';
|
||||
import { FIRST_RUN_LINKS, environmentalLabel } from '../../firstRunCopy.js';
|
||||
import { useFirstRunStore } from '../stores/firstRun.js';
|
||||
import { useStoriesStore } from '../stores/stories.js';
|
||||
|
||||
// The launcher initFirstRunExperience presents, and the controls it connects.
|
||||
const { launcher, controls } = storeToRefs(useFirstRunStore());
|
||||
// The card stays hidden until it is initialized; these show in the markup.
|
||||
const DESCRIPTION = msg(
|
||||
'It feels like a forbidden cockpit—then you realize the sources are public and the data is real.',
|
||||
);
|
||||
const ENVIRONMENTAL_SUB = msg(
|
||||
'Live earthquakes and active fires, from USGS and NASA',
|
||||
);
|
||||
|
||||
// Where the visitor starts: a tile selects it, ENTER GOD MODE runs it. A clean
|
||||
// globe unless they pick a mission.
|
||||
const start = ref('explore');
|
||||
const settling = ref(false);
|
||||
function selectStart(choice) {
|
||||
if (settling.value || launcher.value?.busy === 'true' || launcher.value?.closing) return;
|
||||
start.value = choice;
|
||||
}
|
||||
|
||||
// Three short steps instead of one dense card: mode, where to start, then the
|
||||
// three things worth knowing. Back and Next move between them; Skip closes.
|
||||
const STEPS = 3;
|
||||
const step = ref(1);
|
||||
const direction = ref('forward');
|
||||
function go(next, event) {
|
||||
if (event?.detail > 1) return;
|
||||
if (settling.value || launcher.value?.busy === 'true' || launcher.value?.closing) return;
|
||||
settling.value = true;
|
||||
direction.value = next > step.value ? 'forward' : 'back';
|
||||
step.value = Math.min(STEPS, Math.max(1, next));
|
||||
}
|
||||
// A press belongs to the step it began on: one begun while the steps were
|
||||
// changing (and released after) runs nothing. Keyboard clicks (detail 0)
|
||||
// have no press.
|
||||
let pressedOn = null;
|
||||
function onPrimaryDown() {
|
||||
pressedOn = settling.value ? null : step.value;
|
||||
}
|
||||
// A quick second click still moves to the next step, so the button never
|
||||
// looks dead; only the launch itself takes a single click, so a double click
|
||||
// that began on NEXT never confirms the start it lands on.
|
||||
function onPrimary(event) {
|
||||
if (settling.value) return;
|
||||
const pressed = pressedOn;
|
||||
pressedOn = null;
|
||||
if (event.detail >= 1 && pressed !== step.value) return;
|
||||
if (step.value < STEPS) go(step.value + 1);
|
||||
else if (event.detail <= 1) controls.value?.choose(start.value);
|
||||
}
|
||||
// GEV Stories opens in place: the card closes as Skip would, then Explore
|
||||
// takes the globe. The Stories announcement stays hidden while Stories loads,
|
||||
// so it does not flash up between the card closing and Explore opening; it is
|
||||
// still not marked seen. The card is left out where Stories is not offered.
|
||||
const stories = useStoriesStore();
|
||||
let openingStories = false;
|
||||
function openStories(event) {
|
||||
if (event?.detail > 1) return;
|
||||
if (settling.value || launcher.value?.busy === 'true' || launcher.value?.closing) return;
|
||||
if (!stories.available || !stories.controller) return;
|
||||
if (openingStories) return;
|
||||
const body = globalThis.document?.body;
|
||||
// Stories says at once whether it opens (it refuses while another mode
|
||||
// holds the globe): only then does the card close, so a refusal never
|
||||
// leaves nothing on screen.
|
||||
const opening = stories.controller.open();
|
||||
if (opening === false) return;
|
||||
openingStories = true;
|
||||
body?.classList.add('first-run-opening-stories');
|
||||
controls.value?.dismiss();
|
||||
Promise.resolve(opening)
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
openingStories = false;
|
||||
body?.classList.remove('first-run-opening-stories');
|
||||
});
|
||||
}
|
||||
function onPrimaryKeydown(event) {
|
||||
if (event.repeat) event.preventDefault();
|
||||
}
|
||||
function beforeStepEnter() {
|
||||
globalThis.document?.querySelector('#first-run-launcher .first-run-choices')
|
||||
?.scrollTo({ top: 0, behavior: 'instant' });
|
||||
}
|
||||
function afterStepEnter() {
|
||||
settling.value = false;
|
||||
controls.value?.refreshLayout();
|
||||
}
|
||||
// Keyboard users stay on the main action as the steps change.
|
||||
watch(step, async () => {
|
||||
await nextTick();
|
||||
if (!launcher.value?.visible || launcher.value?.closing) return;
|
||||
globalThis.document
|
||||
?.querySelector('#first-run-launcher [data-first-run-primary]')
|
||||
?.focus?.({ preventScroll: true });
|
||||
});
|
||||
const TITLES = [
|
||||
msg('Welcome to God\'s Eye View'),
|
||||
msg('Where do you want to start?'),
|
||||
msg('Three things to know'),
|
||||
];
|
||||
const LEADS = [
|
||||
msg('It feels like a forbidden cockpit—then you realize the sources are public and the data is real.'),
|
||||
msg('Pick one to begin with. You can change everything later.'),
|
||||
msg('That is all you need to get going.'),
|
||||
];
|
||||
|
||||
// A callout opens from the chip's start edge unless that would run past the
|
||||
// scrolling list, which clips it; then it opens from the end edge, and where
|
||||
// neither side has room it narrows (and wraps) to the roomier side.
|
||||
function alignCallout(event) {
|
||||
const chip = event.target?.closest?.('[data-callout]');
|
||||
const list = chip?.closest('.first-run-choices');
|
||||
if (!chip || !list) return;
|
||||
delete chip.dataset.calloutAlign;
|
||||
chip.style.removeProperty('--first-run-callout-max');
|
||||
const after = globalThis.getComputedStyle?.(chip, '::after');
|
||||
const width = parseFloat(after?.width);
|
||||
if (!Number.isFinite(width)) return;
|
||||
const box = chip.getBoundingClientRect();
|
||||
const bounds = list.getBoundingClientRect();
|
||||
const inset = parseFloat(after.insetInlineStart) || 0;
|
||||
const extra = ['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth']
|
||||
.reduce((sum, key) => sum + (parseFloat(after[key]) || 0), 0);
|
||||
const size = after.boxSizing === 'border-box' ? width : width + extra;
|
||||
const rtl = globalThis.getComputedStyle?.(chip).direction === 'rtl';
|
||||
const roomStart = rtl ? box.right - inset - bounds.left : bounds.right - box.left - inset;
|
||||
const roomEnd = rtl ? bounds.right - box.left - inset : box.right - inset - bounds.left;
|
||||
if (size <= roomStart) return;
|
||||
if (roomEnd > roomStart) chip.dataset.calloutAlign = 'end';
|
||||
if (size > Math.max(roomStart, roomEnd)) {
|
||||
chip.style.setProperty('--first-run-callout-max', `${Math.floor(Math.max(roomStart, roomEnd))}px`);
|
||||
}
|
||||
}
|
||||
|
||||
// A refused save puts the box back where the stored preference is.
|
||||
function onSuppress(event) {
|
||||
const box = event.currentTarget;
|
||||
@@ -25,62 +145,167 @@ function onSuppress(event) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Explicit mission choice on a fresh session. Live feeds are not auto-enabled
|
||||
<!-- Explicit first choice on a fresh session. Live feeds are not auto-enabled
|
||||
until the visitor asks; shared links skip this surface entirely. It returns
|
||||
every session until "Don't show this again" is ticked — see
|
||||
src/firstRunExperience.js for the full show policy. -->
|
||||
<!-- Tints the globe behind the card; click-through, so the card stays non-modal. -->
|
||||
<div v-if="!launcher?.removed && launcher?.shown" class="first-run-backdrop" :class="{ visible: launcher?.visible }" aria-hidden="true"></div>
|
||||
<aside v-if="!launcher?.removed" id="first-run-launcher" role="dialog" aria-labelledby="first-run-title" aria-describedby="first-run-description" :class="{ visible: launcher?.visible }" :hidden="!launcher?.shown" :aria-hidden="launcher?.closing ? 'true' : undefined" :aria-busy="launcher?.busy ?? undefined" :data-state="launcher?.state ?? undefined">
|
||||
<div class="first-run-scanline" aria-hidden="true"></div>
|
||||
<header class="first-run-header">
|
||||
<span class="first-run-kicker">{{ t('MISSION CONTROL · FIRST LAUNCH') }}</span>
|
||||
<ol role="img" class="first-run-dots" :aria-label="t('Step {step} of {total}', { step, total: STEPS })">
|
||||
<li v-for="n in STEPS" :key="n" :class="{ on: n === step, done: n < step }" aria-hidden="true"></li>
|
||||
</ol>
|
||||
<!-- A button, not just a hint: phones and tablets have no ESC key. It
|
||||
closes exactly as ESC does, for this session only. Touch screens
|
||||
see SKIP; a keyboard sees SKIP · ESC (first-run.css). -->
|
||||
<button type="button" class="first-run-dismiss" data-first-run-dismiss @click="controls?.dismiss()">
|
||||
<span class="first-run-dismiss-key">{{ t('SKIP · ESC') }}</span>
|
||||
<span class="first-run-dismiss-touch">{{ t('SKIP') }}</span>
|
||||
</button>
|
||||
</header>
|
||||
<h2 id="first-run-title">{{ t('Choose your first view') }}</h2>
|
||||
<!-- The card's one persuasive line, owner-authored and VERBATIM (2026-08-23)
|
||||
— including the unspaced em dash. The arc it has to carry: this looks
|
||||
like something you should not have access to → the sources are all
|
||||
public → the data is real. Tile subcopy stays purely functional. -->
|
||||
<p id="first-run-description">{{ launcher?.description ?? DESCRIPTION }}</p>
|
||||
<h2 id="first-run-title">{{ t(TITLES[step - 1]) }}</h2>
|
||||
<p class="first-run-step-announcement" role="status" aria-live="polite" aria-atomic="true">{{ t(TITLES[step - 1]) }}</p>
|
||||
<p id="first-run-description">{{ t(LEADS[step - 1]) }}</p>
|
||||
<div class="first-run-choices ui-scroll" :data-scrollable="launcher?.scrollable ?? undefined">
|
||||
<button type="button" data-first-run-choice="contacts" :aria-disabled="launcher?.busy ?? undefined" @click="controls?.choose('contacts')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">radar</span>
|
||||
<span><strong>{{ t('LIVE CONTACTS') }}</strong><small>{{ t('Aircraft, vessels and nearby intelligence') }}</small></span>
|
||||
<span class="material-symbols-outlined first-run-arrow" aria-hidden="true">arrow_forward</span>
|
||||
</button>
|
||||
<button type="button" data-first-run-choice="space-missions" :aria-disabled="launcher?.busy ?? undefined" @click="controls?.choose('space-missions')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">rocket_launch</span>
|
||||
<span><strong>{{ t('SPACE MISSIONS') }}</strong><small>{{ t('Launches, spacecraft and orbital context') }}</small></span>
|
||||
<span class="material-symbols-outlined first-run-arrow" aria-hidden="true">arrow_forward</span>
|
||||
</button>
|
||||
<button type="button" data-first-run-choice="environmental" :aria-disabled="launcher?.busy ?? undefined" @click="controls?.choose('environmental')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">local_fire_department</span>
|
||||
<!-- The title is ENVIRONMENTAL_LABEL_CHOICE's label once initialized. -->
|
||||
<!-- Subcopy names BOTH feeds this tile turns on, because the launcher
|
||||
optimizes for the fully configured experience (owner ruling,
|
||||
2026-08-23) — see the mission table in src/firstRunExperience.js. -->
|
||||
<span><strong data-first-run-environmental-title>{{ launcher?.environmentalTitle ?? environmentalLabel().title }}</strong><small>{{ launcher?.environmentalSub ?? ENVIRONMENTAL_SUB }}</small></span>
|
||||
<span class="material-symbols-outlined first-run-arrow" aria-hidden="true">arrow_forward</span>
|
||||
</button>
|
||||
<button type="button" class="first-run-explore" data-first-run-choice="explore" :aria-disabled="launcher?.busy ?? undefined" @click="controls?.choose('explore')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">public</span>
|
||||
<span><strong>{{ t('EXPLORE MANUALLY') }}</strong><small>{{ t('Begin with a clean globe') }}</small></span>
|
||||
<span class="material-symbols-outlined first-run-arrow" aria-hidden="true">arrow_forward</span>
|
||||
</button>
|
||||
<Transition :name="`first-run-step-${direction}`" mode="out-in" @before-enter="beforeStepEnter" @after-enter="afterStepEnter">
|
||||
<div v-if="step === 1" key="1" class="first-run-step">
|
||||
<section class="first-run-section" aria-labelledby="first-run-mode-heading">
|
||||
<h3 id="first-run-mode-heading" class="first-run-section-title">{{ t('Choose your mode') }}</h3>
|
||||
<div class="first-run-modes" role="list" aria-labelledby="first-run-mode-heading">
|
||||
<div class="first-run-mode" role="listitem" data-first-run-mode="god">
|
||||
<div class="first-run-preview first-run-preview--god" aria-hidden="true"><i><svg class="first-run-globe" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="1"><circle cx="32" cy="32" r="26" /><path d="M6 32h52M10 19h44M10 45h44" /><g class="first-run-meridians"><ellipse cx="32" cy="32" rx="26" ry="26" style="--m: 0" /><ellipse cx="32" cy="32" rx="26" ry="26" style="--m: 0.38" /><ellipse cx="32" cy="32" rx="26" ry="26" style="--m: 0.71" /><ellipse cx="32" cy="32" rx="26" ry="26" style="--m: 0.92" /></g></svg></i><svg class="first-run-callouts" viewBox="0 0 120 120" fill="none" stroke="currentColor" stroke-width="1"><path class="first-run-brackets" d="M8 18V8h10M102 8h10v10M112 102v10h-10M18 112H8v-10" /><circle class="first-run-orbit" cx="60" cy="60" r="34" /><g class="first-run-callout first-run-callout--a"><circle class="first-run-blip" cx="69" cy="50" r="1.6" /><circle class="first-run-ping" cx="69" cy="50" r="1.6" /><polyline class="first-run-leader" points="69,50 86,33 108,33" pathLength="1" /><path class="first-run-label" d="M88 29h18M88 37h11" /></g><g class="first-run-callout first-run-callout--b"><circle class="first-run-blip" cx="50" cy="71" r="1.6" /><circle class="first-run-ping" cx="50" cy="71" r="1.6" /><polyline class="first-run-leader" points="50,71 33,88 12,88" pathLength="1" /><path class="first-run-label" d="M14 84h18M14 92h11" /></g><g class="first-run-time"><line class="first-run-time-track" x1="26" y1="106" x2="94" y2="106" /><path class="first-run-time-ticks" d="M26 104v4 M34.5 105v2 M43 104v4 M51.5 105v2 M60 104v4 M68.5 105v2 M77 104v4 M85.5 105v2 M94 104v4" /><line class="first-run-time-played" x1="26" y1="106" x2="94" y2="106" /><g class="first-run-time-head"><line x1="26" y1="101" x2="26" y2="111" /><path d="M24 100h4l-2 2.5z" /></g></g></svg></div>
|
||||
<div class="first-run-mode-body">
|
||||
<p class="first-run-mode-title"><strong>{{ t('God') }}</strong> <span class="first-run-tag">{{ t('FUN') }}</span></p>
|
||||
<p class="first-run-mode-copy">{{ t('The spy-satellite keyhole: circular viewport, tactical HUD, cinematic camera. For exploring.') }}</p>
|
||||
<ul class="first-run-mode-points">
|
||||
<li>{{ t('Keyhole HUD') }}</li>
|
||||
<li>{{ t('Visual presets') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<span class="first-run-radio" aria-hidden="true"></span>
|
||||
</div>
|
||||
<div class="first-run-mode" role="listitem" data-first-run-mode="analyst">
|
||||
<div class="first-run-preview first-run-preview--analyst" aria-hidden="true"><i></i></div>
|
||||
<div class="first-run-mode-body">
|
||||
<p class="first-run-mode-title"><strong>{{ t('Analyst') }}</strong> <span class="first-run-tag first-run-tag--soon">{{ t('COMING SOON') }}</span></p>
|
||||
<p class="first-run-mode-copy">{{ t('A cleaner, readable view where every value shows its source. For research and reporting.') }}</p>
|
||||
</div>
|
||||
<span class="first-run-radio" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div v-else-if="step === 2" key="2" class="first-run-step">
|
||||
<section class="first-run-section" aria-labelledby="first-run-start-heading">
|
||||
<h3 id="first-run-start-heading" class="first-run-section-title">{{ t('Start with') }}</h3>
|
||||
<div class="first-run-missions first-run-missions--tiles" role="group" aria-labelledby="first-run-start-heading">
|
||||
<button type="button" data-first-run-start="space-missions" :aria-pressed="String(start === 'space-missions')" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('space-missions')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">rocket_launch</span>
|
||||
<span><strong>{{ t('SPACE MISSIONS') }}</strong><small>{{ t('Launches, spacecraft and orbital context') }}</small></span>
|
||||
</button>
|
||||
<button type="button" data-first-run-start="environmental" :aria-pressed="String(start === 'environmental')" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('environmental')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">local_fire_department</span>
|
||||
<!-- The title is ENVIRONMENTAL_LABEL_CHOICE's label once initialized. -->
|
||||
<!-- Subcopy names BOTH feeds this tile turns on, because the launcher
|
||||
optimizes for the fully configured experience (owner ruling,
|
||||
2026-08-23) — see the mission table in src/firstRunExperience.js. -->
|
||||
<span><strong data-first-run-environmental-title>{{ launcher?.environmentalTitle ?? environmentalLabel().title }}</strong><small>{{ launcher?.environmentalSub ?? t(ENVIRONMENTAL_SUB) }}</small></span>
|
||||
</button>
|
||||
<button type="button" data-first-run-start="explore" :aria-pressed="String(start === 'explore')" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="selectStart('explore')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">public</span>
|
||||
<span><strong>{{ t('EXPLORE MANUALLY') }}</strong><small>{{ t('Begin with a clean globe') }}</small></span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div v-else key="3" class="first-run-step">
|
||||
<ul class="first-run-tips">
|
||||
<li class="first-run-tip first-run-tip--search">
|
||||
<span class="first-run-tip-art" aria-hidden="true"><span class="material-symbols-outlined">search</span><i class="first-run-tip-caret"></i></span>
|
||||
<strong>{{ t('Search places') }}</strong>
|
||||
<small>{{ t('Type a place into the search bar.') }}</small>
|
||||
</li>
|
||||
<li class="first-run-tip first-run-tip--layers">
|
||||
<span class="first-run-tip-art" aria-hidden="true"><span class="material-symbols-outlined">layers</span><i class="first-run-tip-dot"></i></span>
|
||||
<strong>{{ t('Turn on layers') }}</strong>
|
||||
<small>{{ t('Turn layers on to see flights, ships, cameras, weather and more.') }}</small>
|
||||
</li>
|
||||
<li class="first-run-tip first-run-tip--context">
|
||||
<span class="first-run-tip-art" aria-hidden="true"><span class="material-symbols-outlined">my_location</span><i class="first-run-tip-ring"></i></span>
|
||||
<strong>{{ t('Click anything') }}</strong>
|
||||
<small>{{ t('Select a map item to see its details.') }}</small>
|
||||
</li>
|
||||
</ul>
|
||||
<section class="first-run-section" aria-labelledby="first-run-deeper-heading">
|
||||
<h3 id="first-run-deeper-heading" class="first-run-section-title">{{ t('Go deeper') }}</h3>
|
||||
<div v-if="stories.available" class="first-run-link-card first-run-stories">
|
||||
<div class="first-run-preview first-run-preview--stories" aria-hidden="true"><span class="material-symbols-outlined">movie</span></div>
|
||||
<div class="first-run-link-body">
|
||||
<p class="first-run-mode-title"><strong translate="no">GEV Stories</strong> <span class="first-run-tag">{{ t('NEW') }}</span></p>
|
||||
<p class="first-run-mode-copy">{{ t('Curated, interactive views of what is happening on Earth. Play one, take over the map whenever you like, then pick the story back up.') }}</p>
|
||||
</div>
|
||||
<button type="button" class="first-run-link-button" data-first-run-stories :aria-disabled="String(settling || launcher?.busy === 'true')" @click="openStories">{{ t('BROWSE STORIES') }}</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<section class="first-run-section" aria-labelledby="first-run-more-heading">
|
||||
<h3 id="first-run-more-heading" class="first-run-section-title">{{ t('More from Halfpixel') }}</h3>
|
||||
<div class="first-run-link-row first-run-link-row--chips" @pointerover="alignCallout" @focusin="alignCallout">
|
||||
<a class="first-run-link-card first-run-link-card--quiet" :href="FIRST_RUN_LINKS.youtube" :data-callout="t('Bilawal on YouTube')" target="_blank" rel="noopener noreferrer">
|
||||
<span class="first-run-link-badge" aria-hidden="true">▶</span>
|
||||
<span class="first-run-link-body"><strong translate="no">YouTube</strong></span>
|
||||
</a>
|
||||
<a class="first-run-link-card first-run-link-card--quiet" :href="FIRST_RUN_LINKS.x" :data-callout="t('Bilawal on {site}', { site: 'X' })" target="_blank" rel="noopener noreferrer">
|
||||
<span class="first-run-link-badge" aria-hidden="true">X</span>
|
||||
<span class="first-run-link-body"><strong translate="no">X</strong></span>
|
||||
</a>
|
||||
<a class="first-run-link-card first-run-link-card--quiet" :href="FIRST_RUN_LINKS.instagram" :data-callout="t('Bilawal on {site}', { site: 'Instagram' })" target="_blank" rel="noopener noreferrer">
|
||||
<span class="first-run-link-badge" aria-hidden="true">IG</span>
|
||||
<span class="first-run-link-body"><strong translate="no">Instagram</strong></span>
|
||||
</a>
|
||||
<a class="first-run-link-card first-run-link-card--quiet" :href="FIRST_RUN_LINKS.linkedin" :data-callout="t('Bilawal on {site}', { site: 'LinkedIn' })" target="_blank" rel="noopener noreferrer">
|
||||
<span class="first-run-link-badge" aria-hidden="true">in</span>
|
||||
<span class="first-run-link-body"><strong translate="no">LinkedIn</strong></span>
|
||||
</a>
|
||||
<a class="first-run-link-card first-run-link-card--quiet" :href="FIRST_RUN_LINKS.website" :data-callout="t('Bilawal\'s website')" target="_blank" rel="noopener noreferrer">
|
||||
<span class="first-run-link-badge" aria-hidden="true">B</span>
|
||||
<span class="first-run-link-body"><strong translate="no">bilawal.ai</strong></span>
|
||||
</a>
|
||||
<a class="first-run-link-card first-run-link-card--quiet" :href="FIRST_RUN_LINKS.halfpixel" :data-callout="t('The studio behind GEV')" target="_blank" rel="noopener noreferrer">
|
||||
<span class="first-run-link-badge" aria-hidden="true">HP</span>
|
||||
<span class="first-run-link-body"><strong translate="no">halfpixel.ai</strong></span>
|
||||
</a>
|
||||
<a class="first-run-link-card first-run-link-card--quiet" :href="FIRST_RUN_LINKS.source" target="_blank" rel="noopener noreferrer" :data-callout="t('Open source. Self-host, fork, add a layer.')">
|
||||
<span class="first-run-link-badge" aria-hidden="true"></></span>
|
||||
<span class="first-run-link-body"><strong translate="no">GitHub</strong></span>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
<div class="first-run-footer">
|
||||
<label class="first-run-suppress">
|
||||
<input type="checkbox" data-first-run-suppress @change="onSuppress" />
|
||||
<span>{{ t('Don\'t show this again') }}</span>
|
||||
</label>
|
||||
<!-- A button, not just a hint: phones and tablets have no ESC key. It
|
||||
closes exactly as ESC does, for this session only. Touch screens
|
||||
see DISMISS; a keyboard keeps the ESC hint (first-run.css). -->
|
||||
<button type="button" class="first-run-dismiss" data-first-run-dismiss @click="controls?.dismiss()">
|
||||
<span class="first-run-dismiss-key">{{ t('ESC to dismiss') }}</span>
|
||||
<span class="first-run-dismiss-touch">{{ t('DISMISS') }}</span>
|
||||
<!-- The status line: empty until a mission reports progress or an
|
||||
error. It sits in the footer row, so it never changes the card's
|
||||
height. -->
|
||||
<p class="first-run-note" data-first-run-status role="status" aria-live="polite">{{ launcher?.status ?? '' }}</p>
|
||||
<!-- The card's main action: God mode, starting where the selected tile
|
||||
says (a clean globe by default). -->
|
||||
<button v-if="step > 1" type="button" class="first-run-back" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="go(step - 1, $event)">{{ t('BACK') }}</button>
|
||||
<button type="button" class="first-run-enter" :data-first-run-choice="step === STEPS ? start : undefined" :data-first-run-next="step < STEPS ? '' : undefined" data-first-run-primary aria-describedby="first-run-title first-run-description" @pointerdown="onPrimaryDown" @keydown.enter="onPrimaryKeydown" :aria-disabled="String(settling || launcher?.busy === 'true')" @click="onPrimary">
|
||||
{{ step < STEPS ? t('NEXT') : t('ENTER GOD MODE') }} <span class="material-symbols-outlined" aria-hidden="true">arrow_forward</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Kept out of the footer row: it swaps to mission progress and errors, and
|
||||
a live region that also holds layout makes the row jump as it speaks. -->
|
||||
<p class="first-run-note" data-first-run-status role="status" aria-live="polite">{{ launcher?.status ?? FIRST_RUN_TIP }}</p>
|
||||
|
||||
</aside>
|
||||
</template>
|
||||
@@ -73,6 +73,7 @@ export class VisualSettings {
|
||||
bloomVersion,
|
||||
sharpenIntensity,
|
||||
hudVariant,
|
||||
hudSonar,
|
||||
hudVisible,
|
||||
detectionMode,
|
||||
detectionDensity,
|
||||
@@ -122,7 +123,8 @@ export class VisualSettings {
|
||||
this._setSharpenIntensity(sharpenIntensity, { syncShare: false });
|
||||
if (typeof bloom === 'boolean') this._setBloomEnabled(bloom);
|
||||
if (typeof sharpen === 'boolean') this._setSharpenEnabled(sharpen);
|
||||
if (hudVariant) this._setHudVariant(hudVariant, { restore: true });
|
||||
if (hudVariant)
|
||||
this._setHudVariant(hudVariant, { restore: true, sonar: hudSonar });
|
||||
if (typeof hudVisible === 'boolean') {
|
||||
this.hud.setMode(hudVisible ? 'on' : 'off');
|
||||
this._updateHudButtonState();
|
||||
@@ -719,15 +721,21 @@ export class VisualSettings {
|
||||
|
||||
/**
|
||||
* @param {string} variantName Layout, or the removed `cyber` layout.
|
||||
* @param {{restore?: boolean}} [options] A share link, scene or saved view
|
||||
* is authoritative for Sonar too: it is on only when the state names
|
||||
* Cyber. Other callers leave Sonar as the viewer set it.
|
||||
* @param {{restore?: boolean, sonar?: boolean}} [options] A share link,
|
||||
* scene or saved view is authoritative for Sonar too: it is on only when
|
||||
* the state names Cyber or says `sonar: true`, so a state that does not
|
||||
* mention Sonar turns it off unless it names Cyber. Other callers leave
|
||||
* Sonar as the viewer set it.
|
||||
*/
|
||||
_setHudVariant(variantName, { restore = false } = {}) {
|
||||
_setHudVariant(
|
||||
variantName,
|
||||
{ restore = false, sonar: sonarOn = false } = {},
|
||||
) {
|
||||
if (!variantName) return;
|
||||
// Cyber was removed; its sonar became a visual style. A state that names
|
||||
// Cyber opens in Tactical with Sonar on.
|
||||
const sonar = isLegacySonarHudLayout(variantName);
|
||||
const sonar =
|
||||
isLegacySonarHudLayout(variantName) || (restore && sonarOn === true);
|
||||
if (sonar || (restore && isCyberSonarEnabled()))
|
||||
this._setCyberSonarEnabled(sonar);
|
||||
this.hud.setVariant(variantName);
|
||||
@@ -761,8 +769,8 @@ export class VisualSettings {
|
||||
|
||||
/**
|
||||
* The HUD layout a share link or scene shot records. Tactical with Sonar on
|
||||
* is written as the retired Cyber code, which restores exactly that; Minimal
|
||||
* has no such code, so its Sonar stays local.
|
||||
* is written as the retired Cyber code, which restores exactly that and
|
||||
* which older readers understand too.
|
||||
*/
|
||||
_sharedHudVariant() {
|
||||
const variant = this.hud.getVariant();
|
||||
@@ -771,6 +779,17 @@ export class VisualSettings {
|
||||
: variant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a share link or scene shot records Sonar on beside its layout:
|
||||
* only when the layout code does not already say so (Minimal with Sonar),
|
||||
* so a state with Tactical and Sonar stays the Cyber code alone.
|
||||
*/
|
||||
_sharedHudSonar() {
|
||||
return (
|
||||
isCyberSonarEnabled() && !isLegacySonarHudLayout(this._sharedHudVariant())
|
||||
);
|
||||
}
|
||||
|
||||
_setCyberSonarSetting(name, value) {
|
||||
const settings = readCyberSonarSettings();
|
||||
if (!Object.hasOwn(settings, name)) return settings;
|
||||
@@ -919,6 +938,7 @@ export class VisualSettings {
|
||||
bloomVersion: BLOOM_SCALE_VERSION,
|
||||
sharpenIntensity: this._sharpenPct,
|
||||
hudVariant: this._sharedHudVariant(),
|
||||
hudSonar: this._sharedHudSonar(),
|
||||
hudVisible: this.hud.visible,
|
||||
detectionMode: detection.mode,
|
||||
detectionDensity: detection.densityPct,
|
||||
@@ -1237,6 +1257,9 @@ export class VisualSettings {
|
||||
hud: {
|
||||
visible: this.hud.visible,
|
||||
variant: this._sharedHudVariant(),
|
||||
// Written only when on beside a layout that cannot say it, so a shot
|
||||
// without Sonar or with Tactical and Sonar reads in older builds.
|
||||
...(this._sharedHudSonar() ? { sonar: true } : {}),
|
||||
},
|
||||
detection: {
|
||||
mode: getDetectionMode(),
|
||||
@@ -1284,7 +1307,10 @@ export class VisualSettings {
|
||||
|
||||
const hudState = state.hud || {};
|
||||
if (hudState.variant) {
|
||||
this._setHudVariant(hudState.variant, { restore: true });
|
||||
this._setHudVariant(hudState.variant, {
|
||||
restore: true,
|
||||
sonar: hudState.sonar,
|
||||
});
|
||||
}
|
||||
if (typeof hudState.visible === 'boolean') {
|
||||
this.hud.setMode(hudState.visible ? 'on' : 'off');
|
||||
|
||||
@@ -128,8 +128,10 @@ function fixture(
|
||||
now: () => NOW,
|
||||
overlayHost: {
|
||||
setEntries: (id, entries) => overlays.set(id, entries),
|
||||
hitTest: (_x, _y, { sourceId }) =>
|
||||
hit?.sourceId === sourceId ? hit : null,
|
||||
// As the host does: unfiltered, the topmost entry; filtered, only
|
||||
// an entry of that source.
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
hit && (!sourceId || hit.sourceId === sourceId) ? hit : null,
|
||||
},
|
||||
input: () => ({
|
||||
onClick(fn) {
|
||||
@@ -138,6 +140,8 @@ function fixture(
|
||||
},
|
||||
}),
|
||||
focus: { requestWorldFocus: (value) => flights.push(value) },
|
||||
// The card on top at a click, as the registry answers from the host.
|
||||
picking: { clickCard: () => hit },
|
||||
},
|
||||
parts: {
|
||||
rendering: { refreshSelection() {}, requestRender() {} },
|
||||
|
||||
Reference in new issue
Block a user