mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Carry Sonar with the Minimal HUD layout in links and scene shots
A link or scene shot made in Minimal with Sonar on played back with Sonar off, and turned off the viewer's own. Tactical with Sonar keeps the `cyber` layout code, which older readers understand; Minimal with Sonar now carries an explicit mark beside its layout: flag bit 5 (`hudSonar`, default off) of a compact link, `hs=1` in the long form, and `hud.sonar: true` in a scene shot. A restore turns Sonar on when the state names Cyber or carries the mark, so a state made before it restores exactly as it did. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
c69a421678
commit
40e2998466
14 files changed
+266
-28
No files matched your search
@@ -158,6 +158,37 @@ test('share-link serialization emits the current celestial state', () => {
|
||||
assert.equal(new URLSearchParams(window.location.hash.slice(1)).get('cr'), '1');
|
||||
});
|
||||
|
||||
test('Sonar beside the HUD layout rides as hs only when on, and through the compact link', async () => {
|
||||
// Links made before `hs` name no Sonar.
|
||||
assert.equal(makeManager('#v=2&lat=10&lon=20&hud=minimal').parseInitialHash().hudSonar, false);
|
||||
assert.equal(makeManager('#v=2&lat=10&lon=20&hud=minimal&hs=1').parseInitialHash().hudSonar, true);
|
||||
|
||||
const manager = makeManager();
|
||||
manager.onToggleChange(false, false, { hudVariant: 'minimal', hudSonar: false });
|
||||
assert.equal(manager._buildHashParams().has('hs'), false, 'off writes nothing');
|
||||
assert.equal(sharedState(manager.buildLink()).hudSonar, false);
|
||||
manager.onToggleChange(false, false, { hudVariant: 'minimal', hudSonar: true });
|
||||
assert.equal(manager._buildHashParams().get('hs'), '1');
|
||||
const shared = sharedState(manager.buildLink());
|
||||
assert.equal(shared.hudVariant, 'minimal');
|
||||
assert.equal(shared.hudSonar, true);
|
||||
// Tactical with Sonar is written as the Cyber layout code alone.
|
||||
manager.onToggleChange(false, false, { hudVariant: 'cyber', hudSonar: false });
|
||||
assert.equal(manager._buildHashParams().get('hud'), 'cyber');
|
||||
assert.equal(manager._buildHashParams().has('hs'), false);
|
||||
assert.equal(sharedState(manager.buildLink()).hudVariant, 'cyber');
|
||||
clearTimeout(manager._debounceTimer);
|
||||
|
||||
// The restore hands it to the visual settings beside the layout.
|
||||
const opened = makeManager('#v=2&lat=40&lon=-74&hud=minimal&hs=1');
|
||||
let restored = null;
|
||||
opened._onRestore = (state) => { restored = state; };
|
||||
opened._isNavigationCurrent = () => false;
|
||||
await opened.applyState(opened.parseInitialHash(), { navigationToken: 1 });
|
||||
assert.equal(restored.hudVariant, 'minimal');
|
||||
assert.equal(restored.hudSonar, true);
|
||||
});
|
||||
|
||||
test('generated links are v2 and include deterministic layers, options, style params, and panels', () => {
|
||||
const manager = makeManager();
|
||||
const layers = createDefaultLayerState();
|
||||
|
||||
Reference in new issue
Block a user