diff --git a/src/services/spacingEditor.ts b/src/services/spacingEditor.ts index 7ab26ef..149954b 100644 --- a/src/services/spacingEditor.ts +++ b/src/services/spacingEditor.ts @@ -44,7 +44,7 @@ export function getDistanceFromProgress(car: Car, trackProgress: number): number ? new ForwardIterator(trackProgress, currentProgress) : new BackwardIterator(abs(trackProgress), currentProgress); - let trackPosition = currentTrackLocation as CoordsXYZD; + let trackPosition: CoordsXYZD = currentTrackLocation; let trackDistances = getTrackDistances(iteratorSegment, subposition, trackPosition.direction); subpositionIterator._setInitialDistanceFromCarRemainingDistance(car.remainingDistance); diff --git a/src/services/vehicleEditor.ts b/src/services/vehicleEditor.ts index 390d138..8309fcd 100644 --- a/src/services/vehicleEditor.ts +++ b/src/services/vehicleEditor.ts @@ -232,6 +232,7 @@ function updateVehicleSetting(args: UpdateVehicleSettingArgs): void case massKey: case poweredAccelerationKey: case poweredMaxSpeedKey: + case spinKey: { callback = (car): void => { @@ -249,14 +250,6 @@ function updateVehicleSetting(args: UpdateVehicleSettingArgs): void }; break; } - case spinKey: - { - callback = (car): void => - { - car.spin += value; - }; - break; - } case trackProgressKey: { callback = (car): void => diff --git a/src/ui/mainWindow.ts b/src/ui/mainWindow.ts index 11cdf0e..5e2e0d0 100644 --- a/src/ui/mainWindow.ts +++ b/src/ui/mainWindow.ts @@ -376,15 +376,15 @@ export const mainWindow = window({ format: model._formatPosition, onChange: (_, incr) => model._modifyVehicle(setPositionZ, incr) }), - positionSpinner({ + labelSpinner({ _label: { text: "Seat spin:" }, minimum: 0, maximum: 255, - disabled: model._isPositionDisabled, + disabled: model._isEditDisabled, step: model._multiplier, value: model._spin, - format: model._formatPosition, - onChange: (_, incr) => model._modifyVehicle(setSpin, incr) + wrapMode: "clampThenWrap", + onChange: value => model._modifyVehicle(setSpin, value) }) ] }), diff --git a/tests/services/spacingEditor.tests.ts b/tests/services/spacingEditor.tests.ts index b172768..7f185c8 100644 --- a/tests/services/spacingEditor.tests.ts +++ b/tests/services/spacingEditor.tests.ts @@ -20,6 +20,11 @@ class TrackPiece { return new TrackPiece({ x, y, z, direction }, this.type, this.subpositions); } + + toLocation(): CarTrackLocation + { + return { ...this.position, trackType: this.type }; + } } const flatTrackPiece = new TrackPiece({ x: 0, y: 0, z: 0, direction: 0 }, 1, @@ -462,8 +467,8 @@ test("Two flat tracks: get spacing to next track piece by 1", t => const pieces = [ flatTrackPiece.copyTo(32, 64), flatTrackPiece.copyTo(32, 32) ]; const mapMock = setupTrackIterator(pieces); const train = createTrain(mapMock, [ - { trackProgress: 0, trackLocation: {...pieces[1].position, trackType: pieces[1].type} }, // front car - { trackProgress: 31, trackLocation: {...pieces[0].position, trackType: pieces[0].type} } // back car + { trackProgress: 0, trackLocation: pieces[1].toLocation() }, // front car + { trackProgress: 31, trackLocation: pieces[0].toLocation() } // back car ]); const car = train._at(1)._car(); @@ -478,8 +483,8 @@ test("Two flat tracks: get spacing to next track piece by 10", t => const pieces = [ flatTrackPiece.copyTo(32, 64), flatTrackPiece.copyTo(32, 32) ]; const mapMock = setupTrackIterator(pieces); const train = createTrain(mapMock, [ - { trackProgress: 3, trackLocation: {...pieces[1].position, trackType: pieces[1].type} }, // front car - { trackProgress: 25, trackLocation: {...pieces[0].position, trackType: pieces[0].type} } // back car + { trackProgress: 3, trackLocation: pieces[1].toLocation() }, // front car + { trackProgress: 25, trackLocation: pieces[0].toLocation() } // back car ]); const car = train._at(1)._car(); @@ -494,8 +499,8 @@ test("Three flat tracks: get spacing to next track piece by 50", t => const pieces = [ flatTrackPiece.copyTo(32, 96), flatTrackPiece.copyTo(32, 64), flatTrackPiece.copyTo(32, 32) ]; const mapMock = setupTrackIterator(pieces); const train = createTrain(mapMock, [ - { trackProgress: 5, trackLocation: {...pieces[2].position, trackType: pieces[2].type} }, // front car - { trackProgress: 19, trackLocation: {...pieces[0].position, trackType: pieces[0].type} } // back car + { trackProgress: 5, trackLocation: pieces[2].toLocation() }, // front car + { trackProgress: 19, trackLocation: pieces[0].toLocation() } // back car ]); const car = train._at(1)._car();