From bc85ef83f62ff5fefbb97543dcb3e02a5d55d1aa Mon Sep 17 00:00:00 2001 From: Arturo Manzoli Date: Wed, 2 Oct 2024 17:15:13 -0300 Subject: [PATCH] Main vehicle: Alert when Cockpit is minimized while vehicle is still armed Signed-off-by: Arturo Manzoli --- src/stores/alert.ts | 5 +++++ src/stores/controller.ts | 8 ++++++++ src/views/ConfigurationAlertsView.vue | 26 ++++++++++++++++++++------ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/stores/alert.ts b/src/stores/alert.ts index 6c821d715..29f3e2259 100644 --- a/src/stores/alert.ts +++ b/src/stores/alert.ts @@ -1,7 +1,9 @@ +import { ipcRenderer } from 'electron' import { defineStore } from 'pinia' import { computed, reactive, watch } from 'vue' import { useBlueOsStorage } from '@/composables/settingsSyncer' +import { isElectron } from '@/libs/utils' import { Alert, AlertLevel } from '../types/alert' @@ -138,6 +140,9 @@ export const useAlertStore = defineStore('alert', () => { watch(alerts, () => { const lastAlert = alerts.slice(-1)[0] const alertLevelEnabled = enabledAlertLevels.value.find((enabledAlert) => enabledAlert.level === lastAlert.level) + if (lastAlert.level === AlertLevel.Critical && alertLevelEnabled !== undefined && alertLevelEnabled.enabled) { + speak(lastAlert.message) + } if ( !enableVoiceAlerts.value || ((alertLevelEnabled === undefined || !alertLevelEnabled.enabled) && !lastAlert.message.startsWith('#')) diff --git a/src/stores/controller.ts b/src/stores/controller.ts index 70f53c037..c2994b47a 100644 --- a/src/stores/controller.ts +++ b/src/stores/controller.ts @@ -28,6 +28,7 @@ import { } from '@/types/joystick' import { useAlertStore } from './alert' +import { useMainVehicleStore } from './mainVehicle' export type controllerUpdateCallback = ( state: JoystickState, @@ -42,6 +43,8 @@ const cockpitStdMappingsKey = 'cockpit-standard-mappings-v2' export const useControllerStore = defineStore('controller', () => { const alertStore = useAlertStore() + const vehicleStore = useMainVehicleStore() + const joysticks = ref>(new Map()) const updateCallbacks = ref([]) const protocolMappings = useBlueOsStorage(protocolMappingsKey, cockpitStandardToProtocols) @@ -162,6 +165,11 @@ export const useControllerStore = defineStore('controller', () => { if (value === 'hidden') { console.warn('Window/tab hidden. Disabling joystick forwarding.') + if (vehicleStore.isArmed) { + const criticalMessage = + 'Critical: Cockpit minimized while vehicle is armed. Joystick inputs will not work. Ensure vehicle safety.' + alertStore.pushAlert(new Alert(AlertLevel.Critical, criticalMessage)) + } enableForwarding.value = false } else { console.info('Window/tab visible. Enabling joystick forwarding.') diff --git a/src/views/ConfigurationAlertsView.vue b/src/views/ConfigurationAlertsView.vue index cc6a6dcaf..0e0632471 100644 --- a/src/views/ConfigurationAlertsView.vue +++ b/src/views/ConfigurationAlertsView.vue @@ -6,12 +6,24 @@ class="flex flex-col justify-around align-start ml-5 max-h-[85vh] overflow-y-auto" :class="interfaceStore.isOnSmallScreen ? 'max-w-[70vw]' : 'max-w-[40vw]'" > - +
+ + +