Skip to content

Commit

Permalink
fix: build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Jul 7, 2024
1 parent 891a6da commit 283083e
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 43 deletions.
3 changes: 3 additions & 0 deletions src/announcement-data/AnnouncementSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export interface CustomAnnouncementTab<OptionIds extends string> {
| 'defaultState'
>
| ICustomButtonPaneProps
/**
* Merged with any personal preset to allow migration if new features are added.
*/
defaultState: Record<OptionIds, any>
}

Expand Down
15 changes: 15 additions & 0 deletions src/announcement-data/systems/rolling-stock/BombardierXstar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,12 @@ export default class BombardierXstar extends TrainAnnouncementSystem {
approachingStation: {
name: 'Approaching station',
component: CustomAnnouncementPane,
defaultState: {
stationCode: this.RealAvailableStationNames[0],
mindTheGap: true,
keepBelongings: false,
cannotUseOyster: false,
},
props: {
playHandler: this.playApproachingStationAnnouncement.bind(this),
options: {
Expand Down Expand Up @@ -485,6 +491,11 @@ export default class BombardierXstar extends TrainAnnouncementSystem {
stoppedAtStation: {
name: 'Stopped at station',
component: CustomAnnouncementPane,
defaultState: {
thisStationCode: this.RealAvailableStationNames[0],
terminatesAtCode: this.RealAvailableStationNames[0],
callingAtCodes: [],
},
props: {
playHandler: this.playStoppedAtStationAnnouncement.bind(this),
presets: announcementPresets.stopped,
Expand Down Expand Up @@ -516,6 +527,10 @@ export default class BombardierXstar extends TrainAnnouncementSystem {
departingStation: {
name: 'Departing station',
component: CustomAnnouncementPane,
defaultState: {
terminatesAtCode: this.RealAvailableStationNames[0],
nextStationCode: this.RealAvailableStationNames[0],
},
props: {
playHandler: this.playDepartingStationAnnouncement.bind(this),
options: {
Expand Down
13 changes: 13 additions & 0 deletions src/announcement-data/systems/rolling-stock/LNERAzuma.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ export default class LnerAzuma extends TrainAnnouncementSystem {
stoppedAtStation: {
name: 'Stopped at station',
component: CustomAnnouncementPane,
defaultState: {
thisStationCode: this.ALL_STATIONS[0],
terminatesAtCode: this.ALL_STATIONS[0],
callingAtCodes: [],
},
props: {
presets: announcementPresets.stopped,
playHandler: this.playStoppedAtStationAnnouncement.bind(this),
Expand Down Expand Up @@ -422,6 +427,10 @@ export default class LnerAzuma extends TrainAnnouncementSystem {
departingStation: {
name: 'Route start & departing station',
component: CustomAnnouncementPane,
defaultState: {
terminatesAtCode: this.ALL_STATIONS[0],
callingAtCodes: [],
},
props: {
presets: announcementPresets.departingStation,
playHandler: this.playDepartingStationAnnouncement.bind(this),
Expand All @@ -447,6 +456,10 @@ export default class LnerAzuma extends TrainAnnouncementSystem {
aproachingStation: {
name: 'Approaching station',
component: CustomAnnouncementPane,
defaultState: {
nextStationCode: this.ALL_STATIONS[0],
terminates: false,
},
props: {
playHandler: this.playApproachingStationAnnouncement.bind(this),
options: {
Expand Down
26 changes: 22 additions & 4 deletions src/announcement-data/systems/rolling-stock/TLClass700.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,15 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem {
return arr
}

readonly customAnnouncementTabs: Record<string, CustomAnnouncementTab> = {
readonly customAnnouncementTabs: Record<string, CustomAnnouncementTab<string>> = {
initialDeparture: {
name: 'Initial departure',
component: CustomAnnouncementPane,
defaultState: {
terminatesAtCode: this.allAvailableStationsAndTestStations[0].value,
callingAtCodes: [],
isSoutheastern: false,
},
props: {
playHandler: this.playInitialDepartureAnnouncement.bind(this),
options: {
Expand All @@ -830,10 +835,17 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem {
},
},
},
},
} as CustomAnnouncementTab<keyof IInitialDepartureAnnouncementOptions>,
approachingStation: {
name: 'Approaching station',
component: CustomAnnouncementPane,
defaultState: {
stationCode: this.allAvailableStationsAndTestStations[0].value,
isAto: false,
terminatesHere: false,
takeCareAsYouLeave: false,
changeFor: [],
},
props: {
playHandler: this.playApproachingStationAnnouncement.bind(this),
options: {
Expand Down Expand Up @@ -890,10 +902,16 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem {
},
},
},
},
} as CustomAnnouncementTab<keyof IApproachingStationAnnouncementOptions>,
stoppedAtStation: {
name: 'Stopped at station',
component: CustomAnnouncementPane,
defaultState: {
thisStationCode: this.allAvailableStationsAndTestStations[0].value,
terminatesAtCode: this.allAvailableStationsAndTestStations[0].value,
callingAtCodes: [],
mindTheGap: false,
},
props: {
presets: announcementPresets.stopped,
playHandler: this.playStoppedAtStationAnnouncement.bind(this),
Expand Down Expand Up @@ -927,7 +945,7 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem {
},
},
},
},
} as CustomAnnouncementTab<keyof IStoppedAtStationAnnouncementOptions>,
announcementButtons: {
name: 'Announcement buttons',
component: CustomButtonPane,
Expand Down
36 changes: 23 additions & 13 deletions src/announcement-data/systems/rolling-stock/TfLElizabeth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ function createNormalStation(
name: stn.name,
crs: crsCode,
audioName: {
b: AllStationFiles.b.includes(crsCode) ? `stations.b.${crsCode}` : null,
m: AllStationFiles.em.includes(crsCode) ? `stations.m.${crsCode}` : null,
e: AllStationFiles.em.includes(crsCode) ? `stations.e.${crsCode}` : null,
b: AllStationFiles.b.includes(crsCode) ? `stations.b.${crsCode}` : undefined,
m: AllStationFiles.em.includes(crsCode) ? `stations.m.${crsCode}` : undefined,
e: AllStationFiles.em.includes(crsCode) ? `stations.e.${crsCode}` : undefined,
},
changeFor,
exitFor,
Expand Down Expand Up @@ -1173,25 +1173,25 @@ export default class TfLElizabethLine extends AnnouncementSystem {
return
}

files.push(thisStation.audioName.e)
files.push(thisStation.audioName.e!!)

if (thisStation.crs === destinationStation.crs) {
files.push({ id: 'conjoiners.this train terminates here all change please', opts: { delayStart: 1000 } })
} else {
files.push({ id: 'conjoiners.this is the train to', opts: { delayStart: 1000 } })

if (viaStation) {
files.push(destinationStation.audioName.m, 'conjoiners.via', viaStation.audioName.e)
files.push(destinationStation.audioName.m!!, 'conjoiners.via', viaStation.audioName.e!!)
} else {
files.push(destinationStation.audioName.e)
files.push(destinationStation.audioName.e!!)
}

files.push({ id: 'conjoiners.next station', opts: { delayStart: 1000 } })

if (nextStation.crs === destinationStation.crs) {
files.push(nextStation.audioName.m, 'conjoiners.where this train terminates')
files.push(nextStation.audioName.m!!, 'conjoiners.where this train terminates')
} else {
files.push(nextStation.audioName.e)
files.push(nextStation.audioName.e!!)
}
}

Expand All @@ -1204,16 +1204,16 @@ export default class TfLElizabethLine extends AnnouncementSystem {
const nextStation = AllStations.find(stn => stn.crs === options.nextStationCrs)

if (!nextStation) {
alert(`Invalid station.\n\n${nextStation?.crs}`)
alert(`Invalid station.\n\n${options.nextStationCrs}`)
return
}

files.push({ id: 'conjoiners.next station', opts: { delayStart: 1000 } })

if (options.terminating) {
files.push(nextStation.audioName.m, 'conjoiners.where this train terminates')
files.push(nextStation.audioName.m!!, 'conjoiners.where this train terminates')
} else {
files.push(nextStation.audioName.e)
files.push(nextStation.audioName.e!!)
}

if (nextStation.changeFor.length) {
Expand All @@ -1237,6 +1237,12 @@ export default class TfLElizabethLine extends AnnouncementSystem {
thisStation: {
name: 'Stopped at station',
component: CustomAnnouncementPane,
defaultState: {
thisStationCrs: AllStationFiles.em[0],
destinationCrs: AllStationFiles.em[0],
viaCrs: 'none',
nextStationCrs: AllStationFiles.em[0],
},
props: {
playHandler: this.playAtStationAnnouncement.bind(this),
presets: announcementPresets.thisStation,
Expand Down Expand Up @@ -1270,10 +1276,14 @@ export default class TfLElizabethLine extends AnnouncementSystem {
},
},
},
},
} as CustomAnnouncementTab<keyof IAtStationAnnouncementOptions>,
approachingStation: {
name: 'Approaching station',
component: CustomAnnouncementPane,
defaultState: {
nextStationCrs: AllStationFiles.em[0],
terminating: false,
},
props: {
playHandler: this.playApproachingStationAnnouncement.bind(this),
presets: announcementPresets.approachingStation,
Expand All @@ -1291,7 +1301,7 @@ export default class TfLElizabethLine extends AnnouncementSystem {
},
},
},
},
} as CustomAnnouncementTab<keyof IApproachingStationAnnouncementOptions>,

// announcementButtons: {
// name: 'Announcement buttons',
Expand Down
42 changes: 27 additions & 15 deletions src/announcement-data/systems/rolling-stock/TfLJubileeLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export default class TfLJubileeLine extends AnnouncementSystem {

const stationData = StationData.find(s => s.name === options.stationName)

if (stationData.fullMessages) {
if (stationData?.fullMessages) {
files.push(...stationData.approachingFiles)

return await this.playAudioFiles(files, download)
Expand All @@ -271,9 +271,9 @@ export default class TfLJubileeLine extends AnnouncementSystem {
const stnFiles: AudioItem[] = []

if (elizAffectedStations.includes(options.stationName) && options.usePostEliz) {
stnFiles.push(...stationData.postEliz.approachingFiles)
stnFiles.push(...(stationData?.postEliz?.approachingFiles ?? []))
} else {
stnFiles.push(...stationData.approachingFiles)
stnFiles.push(...(stationData?.approachingFiles ?? []))
}

stnFiles[0] = { id: stnFiles[0] as string, opts: { delayStart: 250 } }
Expand All @@ -291,7 +291,7 @@ export default class TfLJubileeLine extends AnnouncementSystem {

const stationData = StationData.find(s => s.name === options.stationName)

if (stationData.fullMessages) {
if (stationData?.fullMessages) {
files.push(...stationData.standingFiles)

return await this.playAudioFiles(files, download)
Expand All @@ -302,9 +302,9 @@ export default class TfLJubileeLine extends AnnouncementSystem {
const stnFiles: AudioItem[] = []

if (elizAffectedStations.includes(options.stationName) && options.usePostEliz) {
stnFiles.push(...stationData.postEliz.standingFiles)
stnFiles.push(...(stationData?.postEliz?.standingFiles ?? []))
} else {
stnFiles.push(...stationData.standingFiles)
stnFiles.push(...(stationData?.standingFiles ?? []))
}

stnFiles[0] = { id: stnFiles[0] as string, opts: { delayStart: 250 } }
Expand All @@ -318,6 +318,9 @@ export default class TfLJubileeLine extends AnnouncementSystem {
destinationInfo: {
name: 'Destination info',
component: CustomAnnouncementPane,
defaultState: {
terminatingStationName: StationData.filter(s => s.canTerminate)[0].name,
},
props: {
playHandler: this.playDestinationInfoAnnouncement.bind(this),
presets: announcementPresets.destinationInfo,
Expand All @@ -330,10 +333,15 @@ export default class TfLJubileeLine extends AnnouncementSystem {
},
},
},
},
} as CustomAnnouncementTab<keyof IDestinationInfoAnnouncementOptions>,
nextStation: {
name: 'Next station',
component: CustomAnnouncementPane,
defaultState: {
stationName: StationData[0].name,
doorDirection: 'right',
usePostEliz: true,
},
props: {
playHandler: this.playNextStationAnnouncement.bind(this),
options: {
Expand All @@ -351,26 +359,30 @@ export default class TfLJubileeLine extends AnnouncementSystem {
{ title: 'Right', value: 'right' },
],
type: 'select',
onlyShowWhen: ({ stationName }: { stationName: string }) => {
onlyShowWhen: ({ stationName }) => {
const stationData = StationData.find(s => s.name === stationName)

return !stationData.fullMessages
return !stationData?.fullMessages
},
},
usePostEliz: {
name: 'Use Elizabeth line version',
default: true,
type: 'boolean',
onlyShowWhen: ({ stationName }: { stationName: string }) => {
return elizAffectedStations.includes(stationName)
onlyShowWhen: ({ stationName }) => {
return elizAffectedStations.includes(stationName as string)
},
},
},
},
},
} as CustomAnnouncementTab<keyof INextStationAnnouncementOptions>,
thisStation: {
name: 'Stopped at station',
component: CustomAnnouncementPane,
defaultState: {
stationName: StationData[0].name,
usePostEliz: true,
},
props: {
playHandler: this.playAtStationAnnouncement.bind(this),
options: {
Expand All @@ -384,13 +396,13 @@ export default class TfLJubileeLine extends AnnouncementSystem {
name: 'Use Elizabeth line version',
default: true,
type: 'boolean',
onlyShowWhen: ({ stationName }: { stationName: string }) => {
return elizAffectedStations.includes(stationName)
onlyShowWhen: ({ stationName }) => {
return elizAffectedStations.includes(stationName as string)
},
},
},
},
},
} as CustomAnnouncementTab<keyof IAtStationAnnouncementOptions>,
announcementButtons: {
name: 'Announcement buttons',
component: CustomButtonPane,
Expand Down
Loading

0 comments on commit 283083e

Please sign in to comment.