mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Display > HUD > Sonar now turns the sonar sweep on over Tactical or Minimal. It is off by default, ON reveals its five sliders, and it keeps its guards: an OFF control, the sweep only while the HUD is visible and outside Cockpit, no animation under reduced motion, and repaint timers re-armed only after a drawn frame that still shows contacts. The Cyber layout, its shell skin and its Cockpit lanes are removed. Share links, scenes, saved views and set_hud that name Cyber open Tactical with Sonar on; links and scene shots record Tactical with Sonar under the same code, and a restored state that names another layout turns Sonar off. set_cyber_sonar keeps its name and works under any layout. A newer Sonar toggle or voice setting wins over a share-link restore that lands later. From 1200px wide the command dock and World Timeline sit 74px above the bottom edge, as in the Omnibar layout, leaving the bottom row to the map attribution (left) and the Power Up corner row (right). The attribution moves to the bottom right when the page runs right to left, where the corner row sits at the bottom left, and a long credit line wraps upward before reaching the corner row. The Tactical bottom-right readout sits 8px above Power Up and the coordinates start level with it. The World Timeline is narrowed to sit between the corners. Toasts keep clear of the raised dock and the chat and voice panel height budgets subtract its rise. Below 1200px the layout is unchanged. The left rail treats the centered World Timeline and voice control as obstacles only where they reach a laid-out panel. On top of the Omnibar: sonar.css replaces cyber.css after the Omnibar imports, the Omnibar's HUD guide step now says Layout picks Tactical or Minimal, and the Omnibar's Tactical bottom-right readout keeps the same 8px above Power Up. Co-authored-by: Sameh Khamis <[email protected]>
169 lines
5.5 KiB
JavaScript
169 lines
5.5 KiB
JavaScript
import { bindRadioControls } from './radioBindings.js';
|
|
import {
|
|
createRadioTunerState,
|
|
renderRadioState,
|
|
showRadioTuner,
|
|
} from './radioPresentation.js';
|
|
import { useRadioStore } from './stores/radio.js';
|
|
import { applicationPinia } from './vueRuntime.js';
|
|
import { onLocaleChange } from '../i18n/index.js';
|
|
|
|
/**
|
|
* Own Radio interaction, the tuner and the subscription; receive playback and
|
|
* application actions. The panel view renders the rest of the Radio panel
|
|
* from what this publishes (`gev-radio` store).
|
|
*/
|
|
export class RadioControls {
|
|
constructor({
|
|
elements,
|
|
radio,
|
|
actions,
|
|
canvas,
|
|
store = useRadioStore(applicationPinia()),
|
|
}) {
|
|
Object.assign(this, elements);
|
|
this.store = store;
|
|
this.radio = radio;
|
|
this.actions = actions;
|
|
this.canvas = canvas;
|
|
this.destroyed = false;
|
|
this.listeners = new AbortController();
|
|
this._radioUnsubscribe = null;
|
|
this._radioState = null;
|
|
this._radioView = null;
|
|
this._radioCategorySignature = '';
|
|
this._radioFilterOptions = null;
|
|
this._radioVolumeShown = null;
|
|
this._cockpitDisclosure = { display: false, radio: false };
|
|
this._radioTunerView = createRadioTunerState();
|
|
this._radioTunerStations = [];
|
|
this._radioTunerPool = [];
|
|
this._radioTunerDragging = false;
|
|
this._radioTunerDragStartSlot = 0;
|
|
this._radioTunerDragSnapshot = null;
|
|
this._radioTunerLastSlot = 0;
|
|
this._radioTunerDragDirection = 0;
|
|
this._radioTunerCoordinate = 0;
|
|
this._radioTunerPointerId = null;
|
|
this._radioTunerKeyboardKey = null;
|
|
this._radioTunerBandSignature = '';
|
|
this._radioTunerSelectedId = null;
|
|
this._radioTunerBandPinnedForNavigation = false;
|
|
this._refreshRadioTunerBand = null;
|
|
this._refreshRadioTunerText = null;
|
|
bindRadioControls.call(this);
|
|
// The panel carries translated text; present it again in a new locale,
|
|
// from a fresh layer state when there is one (its category labels are
|
|
// worded by the layer).
|
|
this._offLocale = onLocaleChange(() => {
|
|
const state = this.radio.getUIState?.() ?? this._radioState;
|
|
if (state) this._renderRadioState(state);
|
|
this._refreshRadioTunerText?.();
|
|
});
|
|
}
|
|
|
|
listen(target, type, handler, options = {}) {
|
|
target?.addEventListener(type, handler, {
|
|
...options,
|
|
signal: this.listeners.signal,
|
|
});
|
|
}
|
|
|
|
connect() {
|
|
this._radioUnsubscribe?.();
|
|
this._radioUnsubscribe = null;
|
|
if (this.destroyed) return;
|
|
this._radioUnsubscribe = this.radio.subscribe?.((state) =>
|
|
this._renderRadioState(state),
|
|
);
|
|
}
|
|
|
|
_renderRadioState(state) {
|
|
renderRadioState.call(this, state);
|
|
}
|
|
|
|
/**
|
|
* Reveal the newly enabled directory and transport inside Context without
|
|
* moving focus, the page, or the globe. Only the expanded Enable path calls
|
|
* this helper.
|
|
* @param {HTMLElement} trigger Initiating Radio Enable button.
|
|
* @returns {Promise<boolean>} Whether the internal scroller moved.
|
|
*/
|
|
async _revealRadioControlsAfterExplicitEnable(trigger) {
|
|
const contextPanel = document.getElementById('global-context-panel');
|
|
const scroller = contextPanel?.querySelector('.global-context-panel-inner');
|
|
const directory = this._radioPanel?.querySelector('.radio-directory-row');
|
|
const transport = this._radioPanel?.querySelector('.radio-transport');
|
|
if (
|
|
!contextPanel ||
|
|
contextPanel.classList.contains('collapsed') ||
|
|
!scroller ||
|
|
!directory ||
|
|
!transport ||
|
|
!this._radioState?.enabled
|
|
)
|
|
return false;
|
|
|
|
await new Promise((resolve) =>
|
|
requestAnimationFrame(() => requestAnimationFrame(resolve)),
|
|
);
|
|
if (this.destroyed || !this._radioState?.enabled || !trigger?.isConnected)
|
|
return false;
|
|
|
|
const viewport = scroller.getBoundingClientRect();
|
|
const directoryRect = directory.getBoundingClientRect();
|
|
const transportRect = transport.getBoundingClientRect();
|
|
const margin = 10;
|
|
const minimum =
|
|
scroller.scrollTop + transportRect.bottom - (viewport.bottom - margin);
|
|
const maximum =
|
|
scroller.scrollTop + directoryRect.top - (viewport.top + margin);
|
|
const desired =
|
|
minimum <= maximum
|
|
? Math.min(Math.max(scroller.scrollTop, minimum), maximum)
|
|
: minimum;
|
|
const next = Math.min(
|
|
Math.max(0, scroller.scrollHeight - scroller.clientHeight),
|
|
Math.max(0, desired),
|
|
);
|
|
if (Math.abs(next - scroller.scrollTop) < 1) return false;
|
|
const reducedMotion = window.matchMedia?.(
|
|
'(prefers-reduced-motion: reduce)',
|
|
)?.matches;
|
|
scroller.scrollTo({
|
|
top: next,
|
|
behavior: reducedMotion ? 'auto' : 'smooth',
|
|
});
|
|
return true;
|
|
}
|
|
|
|
destroy() {
|
|
if (this.destroyed) return;
|
|
this.destroyed = true;
|
|
this._offLocale();
|
|
this.listeners.abort();
|
|
if (this._storeToken) this.store.detach(this._storeToken);
|
|
this._radioUnsubscribe?.();
|
|
this._radioUnsubscribe = null;
|
|
const pointer = this._radioTunerPointerId;
|
|
this._radioTunerPointerId = null;
|
|
this._radioTunerDragging = false;
|
|
this._radioTunerKeyboardKey = null;
|
|
this._radioTunerDragSnapshot = null;
|
|
this._radioTunerPool = [];
|
|
this._radioTunerStations = [];
|
|
this._radioTunerBandPinnedForNavigation = false;
|
|
try {
|
|
if (pointer !== null)
|
|
this._radioTunerSlider?.releasePointerCapture(pointer);
|
|
} catch {
|
|
/* capture already released */
|
|
}
|
|
showRadioTuner.call(this, { dragging: false, static: false });
|
|
document
|
|
.getElementById('title-bar')
|
|
?.classList.remove('radio-broadcasting');
|
|
this.radio.endTuning();
|
|
}
|
|
}
|