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
@@ -34,6 +34,7 @@ export const LEGACY_SHARE_STATE_KEYS = Object.freeze([
|
||||
'bloomVersion',
|
||||
'sharpenIntensity',
|
||||
'hudVariant',
|
||||
'hudSonar',
|
||||
'hudVisible',
|
||||
'detectionMode',
|
||||
'detectionDensity',
|
||||
|
||||
@@ -146,6 +146,23 @@ test('links from earlier long-form versions keep their historical meaning', () =
|
||||
assert.equal(off.layerState.options.flights.models3d, false);
|
||||
});
|
||||
|
||||
test('Sonar beside the Minimal layout survives the compact form; older links do not name it', () => {
|
||||
const { parsed, state } = assertLegacyRoundTrip(
|
||||
'v=2&lat=10&lon=20&hud=minimal&hs=1',
|
||||
);
|
||||
assert.equal(parsed.hudSonar, true);
|
||||
assert.equal(state.hudVariant, 'minimal');
|
||||
assert.equal(state.hudSonar, true);
|
||||
// Links made before `hs`: Minimal carries no Sonar, Cyber carries it in
|
||||
// its own code.
|
||||
for (const hud of ['minimal', 'cyber']) {
|
||||
const old = assertLegacyRoundTrip(`v=2&lat=10&lon=20&hud=${hud}`);
|
||||
assert.equal(old.parsed.hudSonar, false);
|
||||
assert.equal(old.state.hudVariant, hud);
|
||||
assert.equal(old.state.hudSonar, false);
|
||||
}
|
||||
});
|
||||
|
||||
test('a tracking selection becomes a thing view and back', () => {
|
||||
const flights = assertLegacyRoundTrip('v=2&lat=1&lon=2&l=f&lo=f.t.a1b2c3');
|
||||
assert.deepEqual(flights.state.view.entity, {
|
||||
@@ -232,6 +249,7 @@ function generatedLegacyHash(random) {
|
||||
bloomVersion: pick(random, [1, 2]),
|
||||
sharpenIntensity: int(0, 100),
|
||||
hudVariant: pick(random, HUD_LAYOUTS),
|
||||
hudSonar: random() < 0.5,
|
||||
hudVisible: random() < 0.5,
|
||||
detectionMode: pick(random, ['OFF', 'SPARSE', 'BALANCED', 'DENSE']),
|
||||
detectionDensity: density,
|
||||
|
||||
@@ -255,6 +255,9 @@ export const SHARE_VIEW_FLAGS = freezeAll([
|
||||
{ bit: 2, key: 'hudVisible', default: BY_STYLE },
|
||||
{ bit: 3, key: 'celestialRing', default: BY_STYLE },
|
||||
{ bit: 4, key: 'scopeEnabled', default: true },
|
||||
// Sonar on beside a HUD layout whose code cannot say so (Minimal). Tactical
|
||||
// with Sonar stays the `cyber` layout code alone.
|
||||
{ bit: 5, key: 'hudSonar', default: false },
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
@@ -348,6 +348,7 @@ test('every registered field round-trips at once', () => {
|
||||
bloomVersion: 1,
|
||||
sharpenIntensity: 65,
|
||||
hudVariant: 'operator',
|
||||
hudSonar: true,
|
||||
hudVisible: false,
|
||||
detectionMode: 'SPARSE',
|
||||
detectionDensity: 100,
|
||||
@@ -449,6 +450,28 @@ test('links made with a retired HUD layout still decode to its name', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('Sonar beside the Minimal layout is flag bit 5; links made before it keep their meaning', () => {
|
||||
const minimal = { ...createDefaultShareViewState(), hudVariant: 'minimal' };
|
||||
const plain = encodeShareView(minimal);
|
||||
// Off is the default, so a view without Sonar costs nothing for it.
|
||||
assert.equal(encodeShareView({ ...minimal, hudSonar: false }), plain);
|
||||
const withSonar = assertRoundTrip({ ...minimal, hudSonar: true });
|
||||
assert.notEqual(withSonar, plain);
|
||||
const decoded = decodeOk(withSonar).state;
|
||||
assert.equal(decoded.hudVariant, 'minimal');
|
||||
assert.equal(decoded.hudSonar, true);
|
||||
assert.equal(decodeOk(plain).state.hudSonar, false);
|
||||
// Tactical with Sonar is still the Cyber code alone.
|
||||
const cyber = { ...createDefaultShareViewState(), hudVariant: 'cyber' };
|
||||
assert.equal(decodeOk(encodeShareView(cyber)).state.hudSonar, false);
|
||||
// A link made before the bit (thermal, Cyber, Scope off) decodes as it did:
|
||||
// Cyber without the bit, which the app opens as Tactical with Sonar on.
|
||||
const before = decodeOk('ARD-7j4YuxMguBcoUEgQcAOAAQPIASPQAWGa').state;
|
||||
assert.equal(before.hudVariant, 'cyber');
|
||||
assert.equal(before.hudSonar, false);
|
||||
assert.equal(encodeShareView(before), 'ARD-7j4YuxMguBcoUEgQcAOAAQPIASPQAWGa');
|
||||
});
|
||||
|
||||
test('defaults travel as frozen meanings that match today’s app defaults', () => {
|
||||
const defaults = createDefaultShareViewState();
|
||||
// When an app default moves, these tests should be updated to document the
|
||||
@@ -535,6 +558,7 @@ test('the field registry is well formed and permanent', () => {
|
||||
[2, 'hudVisible', BY_STYLE],
|
||||
[3, 'celestialRing', BY_STYLE],
|
||||
[4, 'scopeEnabled', true],
|
||||
[5, 'hudSonar', false],
|
||||
],
|
||||
);
|
||||
// The style-applied defaults are frozen meanings too. If the app's style
|
||||
@@ -921,7 +945,7 @@ test('unknown fields inside a thing view, codes and bits are skipped too', () =>
|
||||
thing.textField(20, 'cockpit'); // a future thing field
|
||||
const writer = new WireWriter();
|
||||
writer.bytes.push(1);
|
||||
writer.sintField(2, 100000).uintField(9, 0b100001); // flag bit 5 unknown
|
||||
writer.sintField(2, 100000).uintField(9, 0b1000001); // flag bit 6 unknown
|
||||
writer.bytesField(
|
||||
10,
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
|
||||
@@ -944,7 +968,7 @@ test('unknown fields inside a thing view, codes and bits are skipped too', () =>
|
||||
result.unknownFields.map((u) => [u.scope, u.field ?? u.code]),
|
||||
[
|
||||
['enum:style', 99],
|
||||
['flags', 32],
|
||||
['flags', 64],
|
||||
['layer', 160],
|
||||
['panel', 12],
|
||||
['thing', 20],
|
||||
|
||||
Reference in new issue
Block a user