mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-06 01:06:28 +08:00
feat(flightlab): simplify takeoff flow and wait for TTS before auto-advance
This commit is contained in:
@@ -21,6 +21,7 @@ export function useFlightLabEngine(scenario: FlightLabScenario) {
|
||||
|
||||
// Callback for TTS when help message triggers
|
||||
let onHelpMessage: ((text: string) => void) | null = null
|
||||
let isAutoAdvanceBlocked: (() => boolean) | null = null
|
||||
|
||||
const phasesMap = computed(() => {
|
||||
const map = new Map<string, FlightLabPhase>()
|
||||
@@ -33,7 +34,7 @@ export function useFlightLabEngine(scenario: FlightLabScenario) {
|
||||
const currentPhase = computed(() => phasesMap.value.get(currentPhaseId.value) ?? null)
|
||||
|
||||
// Count only main phases (not comfort/info branches) for progress
|
||||
const mainPhaseIds = ['welcome', 'seatbelt_on', 'briefing', 'runway', 'engines_pre', 'engines_spool', 'takeoff_roll', 'rotation', 'gear_retract', 'climb', 'climb_high', 'leveloff', 'seatbelt_off', 'debrief', 'end']
|
||||
const mainPhaseIds = ['welcome', 'seatbelt_on', 'briefing', 'runway', 'engines_spool', 'takeoff_roll', 'rotation', 'gear_retract', 'climb', 'climb_high', 'leveloff', 'seatbelt_off', 'debrief', 'end']
|
||||
|
||||
const progress = computed(() => {
|
||||
const idx = mainPhaseIds.indexOf(currentPhaseId.value)
|
||||
@@ -105,6 +106,7 @@ export function useFlightLabEngine(scenario: FlightLabScenario) {
|
||||
conditionsMet.value = met
|
||||
|
||||
if (met && phase.simConditionNextPhase) {
|
||||
if (isAutoAdvanceBlocked?.()) return
|
||||
stopConditionMonitoring()
|
||||
goToPhase(phase.simConditionNextPhase)
|
||||
}
|
||||
@@ -164,6 +166,10 @@ export function useFlightLabEngine(scenario: FlightLabScenario) {
|
||||
onHelpMessage = fn
|
||||
}
|
||||
|
||||
function setAutoAdvanceBlocker(fn: () => boolean) {
|
||||
isAutoAdvanceBlocked = fn
|
||||
}
|
||||
|
||||
// --- Phase navigation ---
|
||||
|
||||
function selectOption(button: FlightLabButton) {
|
||||
@@ -260,6 +266,7 @@ export function useFlightLabEngine(scenario: FlightLabScenario) {
|
||||
dismissHelpMessage,
|
||||
evaluateConditions,
|
||||
setOnHelpMessage,
|
||||
setAutoAdvanceBlocker,
|
||||
cleanup,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user