Restore engine-specific Cinematic sharpness across live switches

This commit is contained in:
German Khokhlov committed 2026-11-02 13:19:21 +04:00
1 parent b8f4d097c4
commit f71c76c306
4 files changed
+69 -20

No files matched your search

+19
View File
@@ -402,6 +402,25 @@ test('a shared vessel is selected once the vessel feed has it', async (t) => {
assert.match(page.notices.at(-1), /^366999712 isn't reporting now/);
});
test('the live preset follows the engine while a copied link keeps its rendered sharpness', (t) => {
const { location } = installPage(t, 'https://gev.example/?engine=navara');
const manager = new ShareLinkManager(viewerEngine(fakeViewer()));
t.after(() => manager.destroy());
manager.onToggleChange(false, true, {
sharpenIntensity: 80,
sharpenFollowsEngine: true,
});
manager.flush();
assert.equal(new URLSearchParams(location.hash.slice(1)).get('siAuto'), '1');
const code = parseSharePath(new URL(manager.buildLink()).pathname).code;
assert.equal(decodeShareView(code).state.sharpenIntensity, 80);
manager.onToggleChange(false, true, { sharpenIntensity: 80 });
manager.flush();
const params = new URLSearchParams(location.hash.slice(1));
assert.equal(params.has('siAuto'), false);
assert.equal(params.get('si'), '80');
});
test('the share button links to /share/<code>, following the followed entity', (t) => {
installPage(t, 'https://gev.example/?lang=ru#v=2&lat=1&lon=2');
const manager = new ShareLinkManager(viewerEngine(fakeViewer()));
+12 -18
View File
@@ -1,5 +1,6 @@
import { clampScopeFeatherPct } from '../scopeMaskPolicy.js';
import {
ENGINE_SHARPEN_DEFAULT,
STYLE_STATUS_LABELS,
presetSharpenIntensity,
} from './visualPresets.js';
@@ -104,8 +105,7 @@ export class VisualSettings {
const intensity = decodeBloomIntensity(bloomIntensity, bloomVersion);
this._setBloomIntensity(intensity, { syncShare: false });
}
if (typeof sharpenIntensity === 'number')
this._setSharpenIntensity(sharpenIntensity, { syncShare: false });
this._setSharpenIntensity(sharpenIntensity, { syncShare: false });
if (typeof bloom === 'boolean') this._setBloomEnabled(bloom);
if (typeof sharpen === 'boolean') this._setSharpenEnabled(sharpen);
if (hudVariant) this._setHudVariant(hudVariant);
@@ -210,6 +210,7 @@ export class VisualSettings {
});
// The sharpen amount as a whole percentage. VisualEffects keeps the
// fraction it applies, and drops writes once it is stopped.
this._sharpenFollowsEngine = true;
this._sharpenPct = presetSharpenIntensity(
GLOBAL_POST_DEFAULTS.sharpen.intensity,
this._engineKind,
@@ -588,8 +589,10 @@ export class VisualSettings {
/** Set the sharpen amount, a percentage clamped to 0-100, and apply it. */
_setSharpenIntensity(pct, { syncShare = true } = {}) {
if (!Number.isFinite(pct)) return;
this._sharpenPct = Math.max(0, Math.min(100, Math.round(pct)));
const value = presetSharpenIntensity(pct, this._engineKind);
if (!Number.isFinite(value)) return;
this._sharpenFollowsEngine = pct === ENGINE_SHARPEN_DEFAULT;
this._sharpenPct = Math.max(0, Math.min(100, Math.round(value)));
this._applySharpenIntensity(this._sharpenPct / 100);
this._publishDisplay();
if (syncShare) this._syncShareState();
@@ -798,12 +801,7 @@ export class VisualSettings {
}
const sharpenInput = preset.sharpen || {};
const presetSharpen = presetSharpenIntensity(
sharpenInput.intensity,
this._engineKind,
);
if (typeof presetSharpen === 'number')
this._setSharpenIntensity(presetSharpen, { syncShare: false });
this._setSharpenIntensity(sharpenInput.intensity, { syncShare: false });
if (typeof sharpenInput.enabled === 'boolean') {
this._setSharpenEnabled(sharpenInput.enabled);
}
@@ -845,14 +843,9 @@ export class VisualSettings {
this._setBloomEnabled(defaults.bloom.enabled);
}
const defaultSharpen = presetSharpenIntensity(
defaults.sharpen?.intensity,
this._engineKind,
);
if (typeof defaultSharpen === 'number')
this._setSharpenIntensity(defaultSharpen, {
syncShare: false,
});
this._setSharpenIntensity(defaults.sharpen?.intensity, {
syncShare: false,
});
if (typeof defaults.sharpen?.enabled === 'boolean') {
this._setSharpenEnabled(defaults.sharpen.enabled);
}
@@ -912,6 +905,7 @@ export class VisualSettings {
bloomIntensity: this._getBloomIntensity(),
bloomVersion: BLOOM_SCALE_VERSION,
sharpenIntensity: this._sharpenPct,
sharpenFollowsEngine: this._sharpenFollowsEngine,
hudVariant: this.hud.getVariant(),
hudVisible: this.hud.visible,
detectionMode: detection.mode,