mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Hold the shell's inputs between two engines instead of reaching released controllers
A visual choice made while no globe is attached (a style key, a Display control, a voice command) is queued and applied to the next engine's settings after it restored the address's view, so the person's choice wins; reads answer from the released settings. The globe reset and a location lookup started without a globe do nothing, and the map-source chips and camera buttons are unbound until the next globe binds them.
This commit is contained in:
1 parent
df73c5b21a
commit
40a81c58e6
7 files changed
+193
-5
No files matched your search
@@ -0,0 +1,68 @@
|
||||
// Between two globe engines the shell has no visual settings of its own:
|
||||
// the outgoing ones are released and the incoming ones are not built yet.
|
||||
// A choice the person makes meanwhile (a style key, a Display control, a
|
||||
// voice command) is kept and applied to the next engine's settings once
|
||||
// that engine has restored the address's view, so the person's choice wins.
|
||||
// Reads answer from the outgoing settings' last state.
|
||||
|
||||
/** The visual choices kept for the next engine, by method name. */
|
||||
export const PENDING_VISUAL_CHOICES = Object.freeze(
|
||||
new Set([
|
||||
'setStyle',
|
||||
'setBloom',
|
||||
'setSharpen',
|
||||
'setDetection',
|
||||
'setCelestialRingEnabled',
|
||||
'setStyleParameter',
|
||||
'applyVisualState',
|
||||
'applyCinematicPreset',
|
||||
'_setBloomEnabled',
|
||||
'_setBloomIntensity',
|
||||
'_setSharpenEnabled',
|
||||
'_setSharpenIntensity',
|
||||
'_setScope',
|
||||
'_setHudVariant',
|
||||
'_setDetectionDensity',
|
||||
'_setDetectionAllocation',
|
||||
'_setDetectionFade',
|
||||
'_setDetectionModeByLabel',
|
||||
'_setCyberSonarEnabled',
|
||||
'_setCyberSonarSetting',
|
||||
]),
|
||||
);
|
||||
|
||||
/**
|
||||
* Stand in for released visual settings: choices are queued (`queue`),
|
||||
* everything else reads the released settings.
|
||||
* @param {object} released The outgoing engine's VisualSettings.
|
||||
* @returns {{settings: object, queue: Array<[string, unknown[]]>}}
|
||||
*/
|
||||
export function pendingVisualSettings(released) {
|
||||
const queue = [];
|
||||
const settings = new Proxy(released, {
|
||||
get(target, name) {
|
||||
if (PENDING_VISUAL_CHOICES.has(name))
|
||||
return (...args) => {
|
||||
queue.push([name, args]);
|
||||
return { ok: true, pending: true };
|
||||
};
|
||||
const value = Reflect.get(target, name, target);
|
||||
return typeof value === 'function' ? value.bind(target) : value;
|
||||
},
|
||||
});
|
||||
return { settings, queue };
|
||||
}
|
||||
|
||||
/** Apply the queued choices, in order, to the next engine's settings. */
|
||||
export function applyPendingVisualChoices(settings, queue) {
|
||||
for (const [name, args] of queue.splice(0)) {
|
||||
try {
|
||||
settings[name]?.(...args);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`A visual choice made during the switch failed (${name}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user