Skip to content

Commit

Permalink
Merge branch 'feat/tfw-calling-at' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Oct 21, 2023
2 parents 5066154 + 2615c28 commit 4393e75
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<void> {
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<void> {
const { thisStationCode, terminatesAtCode } = options

Expand Down Expand Up @@ -467,6 +493,24 @@ export default class TfWTrainFx extends TrainAnnouncementSystem {
})

readonly customAnnouncementTabs: Record<string, CustomAnnouncementTab> = {
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,
Expand Down
1 change: 1 addition & 0 deletions src/components/CallingAtSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function CallingAtSelector({ onChange, value, availableStations, additionalOptio
onClick={() => {
onChange(value.filter(s => s.randomId !== stop.randomId))
}}
style={{ marginLeft: 'auto' }}
>
<svg viewBox="0 0 24 24">
<path
Expand Down
4 changes: 4 additions & 0 deletions src/data/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ const changelog: IChangelogVersion[] = [
'[TfL Northern Line] Fix next station Goodge Street not working',
],
},
{
date: '2023-10-20',
fixes: ['[TfW - TrainFX] Add start of journey announcement'],
},
]

export default changelog

0 comments on commit 4393e75

Please sign in to comment.