Skip to content

Commit

Permalink
feat: implement train restart on manual announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Mar 17, 2024
1 parent 98f18c2 commit 3e76dba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/announcement-data/systems/stations/AmeyPhil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4196,8 +4196,11 @@ export default class AmeyPhil extends StationAnnouncementSystem {
const restartAsTrainAfterIndex = callingPoints.findIndex(p => p.continuesAsTrainAfterHere)

const upToRrb = callingPoints.slice(0, rrbAfterIndex + 1)
const rrbCalls = callingPoints.slice(rrbAfterIndex + 1, restartAsTrainAfterIndex === -1 ? Number.MAX_SAFE_INTEGER : restartAsTrainAfterIndex)
const restartedTrainCalls = restartAsTrainAfterIndex === -1 ? [] : callingPoints.slice(restartAsTrainAfterIndex)
const rrbCalls = callingPoints.slice(
rrbAfterIndex + 1,
restartAsTrainAfterIndex === -1 ? Number.MAX_SAFE_INTEGER : restartAsTrainAfterIndex + 1,
)
const restartedTrainCalls = restartAsTrainAfterIndex === -1 ? [] : callingPoints.slice(restartAsTrainAfterIndex + 1)

if (upToRrb.length >= 1) {
files.push({ id: 'm.calling at', opts: { delayStart: this.callingPointsOptions.beforeCallingAtDelay } })
Expand Down
20 changes: 20 additions & 0 deletions src/components/CallingAtSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,26 @@ function CallingAtSelector({
},
)}

{enableRrbContinuations &&
createOptionField(
{
default: false,
name: 'RRB ends; train restarts',
type: 'boolean',
// This can only happen once
disabled:
!value.some((s, _i) => s.continuesAsRrbAfterHere && i > _i) ||
value.some(s => s.continuesAsTrainAfterHere && s.randomId !== stop.randomId),
},
{
value: stop.continuesAsTrainAfterHere || false,
key: 'continuesAsTrainAfterHere',
onChange(v) {
onChange(value.map(s => (s.randomId === stop.randomId ? { ...s, continuesAsTrainAfterHere: v } : s)))
},
},
)}

{enableSplits && (
<>
{createOptionField(
Expand Down

0 comments on commit 3e76dba

Please sign in to comment.