diff --git a/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx b/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx index a76d380a4..c6b4943bd 100644 --- a/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx +++ b/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx @@ -5,6 +5,11 @@ import { getStationByCrs } from '@data/StationManipulators' import { AudioItem, CustomAnnouncementTab } from '../../AnnouncementSystem' import TrainAnnouncementSystem from '../../TrainAnnouncementSystem' import crsToStationItemMapper from '@helpers/crsToStationItemMapper' +import CallingAtSelector from '@components/CallingAtSelector' + +interface IStartOfJourneyAnnouncementOptions { + callingAtCodes: { crsCode: string; name: string; randomId: string }[] +} interface IStoppedAtStationAnnouncementOptions { thisStationCode: string @@ -28,6 +33,27 @@ export default class TfWTrainFx extends TrainAnnouncementSystem { readonly FILE_PREFIX = 'TfW/TrainFX' readonly SYSTEM_TYPE = 'train' + private async playStartOfJourneyAnnouncement(options: IStartOfJourneyAnnouncementOptions, download: boolean = false): Promise { + const { callingAtCodes } = options + + const files: AudioItem[] = [] + + files.push('conjoiners.welcome aboard', { + id: 'conjoiners.we will be calling at the following principal stations', + opts: { delayStart: 750 }, + }) + + files.push( + ...this.pluraliseAudio( + callingAtCodes.map(stn => stn.crsCode), + 0, + { andId: 'conjoiners.and', prefix: 'stations.high.', finalPrefix: 'stations.low.' }, + ), + ) + + await this.playAudioFiles(files, download) + } + private async playStoppedAtStationAnnouncement(options: IStoppedAtStationAnnouncementOptions, download: boolean = false): Promise { const { thisStationCode, terminatesAtCode } = options @@ -467,6 +493,24 @@ export default class TfWTrainFx extends TrainAnnouncementSystem { }) readonly customAnnouncementTabs: Record = { + startOfJourney: { + name: 'Start of journey', + component: CustomAnnouncementPane, + props: { + playHandler: this.playStartOfJourneyAnnouncement.bind(this), + options: { + callingAtCodes: { + name: '', + type: 'custom', + component: CallingAtSelector, + props: { + availableStations: this.AvailableStationNames.high, + }, + default: [], + }, + }, + }, + }, stoppedAtStation: { name: 'At station', component: CustomAnnouncementPane, diff --git a/src/components/CallingAtSelector.tsx b/src/components/CallingAtSelector.tsx index 96adae9fc..6ca9f275e 100644 --- a/src/components/CallingAtSelector.tsx +++ b/src/components/CallingAtSelector.tsx @@ -126,6 +126,7 @@ function CallingAtSelector({ onChange, value, availableStations, additionalOptio onClick={() => { onChange(value.filter(s => s.randomId !== stop.randomId)) }} + style={{ marginLeft: 'auto' }} >