mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Replace the semantic keys with the English source text, so code reads as the
UI does and English needs no catalog: t('Save keys'), tn(count, one, other)
for plurals, msg() for text stored in data, and bare data-i18n* markup that
translates the element's own English. Other languages are one flat JSON each.
- Simplify src/i18n: drop namespaces, the configurable locale pair
(GEV_DEFAULT_LOCALE / GEV_SECONDARY_LOCALE) and its build defines. Locale
comes from ?lang=, the stored choice, then browser languages.
- Add scripts/i18n.mjs (npm run i18n): extracts every message from t/tn/msg
and markup, and fails on missing, unused, placeholder-mismatched or
wrongly-shaped plural entries. npm test runs it via catalog.test.mjs.
- Add Russian (src/i18n/locales/ru.json, 833 messages), started from the
community catalog in #312 and reviewed against the current English.
- Fix data-i18n placed on parents that would wipe their children (cockpit
LEVEL and local weather cells, first-run EXPLORE MANUALLY tile), and a
doubled degree sign in the TRACK ACQUIRED signal.
- Rewrite docs/TRANSLATORS.md for the new workflow; drop sections the earlier
merge resurrected in docs/CURRENT-STATE.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
158 lines
5.4 KiB
JavaScript
158 lines
5.4 KiB
JavaScript
import { t } from '../i18n/index.js';
|
|
|
|
export function _initCctvPanel() {
|
|
if (!this._cctvPanel) return;
|
|
|
|
this.listen(this._cctvEnableBtn, 'click', async () => {
|
|
this._actionGeneration++;
|
|
await this.actions.toggleEnabled();
|
|
});
|
|
|
|
this.listen(this._cctvNearestBtn, 'click', async () => {
|
|
const generation = ++this._actionGeneration;
|
|
const activeId = this._cctvState?.activeCameraId;
|
|
if (!(await this.actions.toggleEnabled(true))) return;
|
|
if (
|
|
this.destroyed ||
|
|
generation !== this._actionGeneration ||
|
|
!this.actions.isEnabled() ||
|
|
(activeId && activeId !== this._cctvState?.activeCameraId)
|
|
)
|
|
return;
|
|
this.actions.runExplicitFocus(
|
|
() => this.cctv.focusNearest({ focus: false }),
|
|
(cameraId) => this.cctv.focusCamera(cameraId, 1.8),
|
|
);
|
|
});
|
|
|
|
this.listen(this._cctvPrevBtn, 'click', async () => {
|
|
const generation = ++this._actionGeneration;
|
|
const activeId = this._cctvState?.activeCameraId;
|
|
if (!(await this.actions.toggleEnabled(true))) return;
|
|
if (
|
|
this.destroyed ||
|
|
generation !== this._actionGeneration ||
|
|
!this.actions.isEnabled() ||
|
|
(activeId && activeId !== this._cctvState?.activeCameraId)
|
|
)
|
|
return;
|
|
this.actions.runExplicitFocus(
|
|
() => this.cctv.cycleCamera(-1),
|
|
(cameraId) => this.cctv.focusCamera(cameraId, 1.4),
|
|
);
|
|
});
|
|
|
|
this.listen(this._cctvNextBtn, 'click', async () => {
|
|
const generation = ++this._actionGeneration;
|
|
const activeId = this._cctvState?.activeCameraId;
|
|
if (!(await this.actions.toggleEnabled(true))) return;
|
|
if (
|
|
this.destroyed ||
|
|
generation !== this._actionGeneration ||
|
|
!this.actions.isEnabled() ||
|
|
(activeId && activeId !== this._cctvState?.activeCameraId)
|
|
)
|
|
return;
|
|
this.actions.runExplicitFocus(
|
|
() => this.cctv.cycleCamera(1),
|
|
(cameraId) => this.cctv.focusCamera(cameraId, 1.4),
|
|
);
|
|
});
|
|
|
|
this.listen(this._cctvSelect, 'change', async () => {
|
|
const generation = ++this._actionGeneration;
|
|
const activeId = this._cctvState?.activeCameraId;
|
|
const cameraId = this._cctvSelect.value;
|
|
if (!cameraId) return;
|
|
if (!(await this.actions.toggleEnabled(true))) return;
|
|
if (
|
|
this.destroyed ||
|
|
generation !== this._actionGeneration ||
|
|
!this.actions.isEnabled() ||
|
|
(activeId && activeId !== this._cctvState?.activeCameraId)
|
|
)
|
|
return;
|
|
// Picking a camera from the dropdown flies to it. The catalog spans
|
|
// three metros, so a bare selection used to leave the view in the old
|
|
// city with a camera active thousands of km away.
|
|
this.actions.runExplicitFocus(
|
|
() => (this.cctv.selectCamera(cameraId) ? cameraId : null),
|
|
(selectedId) => this.cctv.focusCamera(selectedId, 2.2),
|
|
);
|
|
this.actions.setParams({ selectedCameraId: cameraId }, { origin: 'user' });
|
|
});
|
|
|
|
this.listen(this._cctvFocusBtn, 'click', async () => {
|
|
const generation = ++this._actionGeneration;
|
|
const activeId = this._cctvState?.activeCameraId;
|
|
const selected = this._cctvState?.activeCameraId || this._cctvSelect?.value;
|
|
if (!selected) return;
|
|
if (!(await this.actions.toggleEnabled(true))) return;
|
|
if (
|
|
this.destroyed ||
|
|
generation !== this._actionGeneration ||
|
|
!this.actions.isEnabled() ||
|
|
(activeId && activeId !== this._cctvState?.activeCameraId)
|
|
)
|
|
return;
|
|
this.actions.runExplicitFocus(
|
|
() => selected,
|
|
(cameraId) => this.cctv.focusCamera(cameraId, 1.9),
|
|
);
|
|
this.actions.setParams({ selectedCameraId: selected }, { origin: 'user' });
|
|
});
|
|
|
|
this.listen(this._cctvCoverageBtn, 'click', () => {
|
|
const current =
|
|
this._cctvState?.coverageMode ||
|
|
(this._cctvState?.showCoverage ? 'on' : 'off');
|
|
const next =
|
|
current === 'off' ? 'on' : current === 'on' ? 'viewshed' : 'off';
|
|
this.actions.setParams({ coverageMode: next }, { origin: 'user' });
|
|
});
|
|
|
|
this.listen(this._cctvAutoHopBtn, 'click', () => {
|
|
const current = !!this._cctvState?.autoHop;
|
|
this.actions.setParams({ autoHop: !current }, { origin: 'user' });
|
|
});
|
|
|
|
this.listen(this._cctvProjectionBtn, 'click', () => {
|
|
const current = this._cctvState?.showProjection !== false;
|
|
this.actions.setParams({ showProjection: !current }, { origin: 'user' });
|
|
});
|
|
|
|
this.listen(this._cctvAdjustBtn, 'click', () => {
|
|
const current = !!this._cctvState?.calibrationMode;
|
|
this.actions.setParams({ calibrationMode: !current }, { origin: 'user' });
|
|
});
|
|
|
|
// Click-to-edit pose readout: each chip swaps to a number input; Enter or
|
|
// blur commits (converted to a calibration offset against basePose),
|
|
// Escape cancels. Delegated so re-renders never re-bind.
|
|
this.listen(this._cctvCalReadout, 'click', (event) => {
|
|
const chip = event.target.closest?.('.cctv-cal-value');
|
|
if (!chip || chip.disabled || chip.querySelector('input')) return;
|
|
this._beginCctvCalValueEdit(chip);
|
|
});
|
|
|
|
this.listen(this._cctvCalibSaveBtn, 'click', () => {
|
|
const cameraId = this._activeCctvCameraId();
|
|
if (!cameraId || !this.actions.setParams) return;
|
|
this.actions.setParams(
|
|
{
|
|
selectedCameraId: cameraId,
|
|
calibration: { cameraId, save: true },
|
|
},
|
|
{ origin: 'user' },
|
|
);
|
|
this.actions.showToast(t('CCTV calibration saved'));
|
|
});
|
|
|
|
this.listen(this._cctvCalibResetBtn, 'click', () => {
|
|
this._resetCctvCalibration();
|
|
});
|
|
|
|
this._renderCctvState(null);
|
|
this.actions.syncViewport();
|
|
}
|