Skip to content

Commit 37d61d5

Browse files
committed
Fix spin not applied/synchronised, fix filters not honored during synchronise
1 parent 7b92f89 commit 37d61d5

File tree

4 files changed

+66
-43
lines changed

4 files changed

+66
-43
lines changed

src/services/vehicleCopier.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ export const copyOptions = <const>[
4343
*/
4444
export const enum CopyFilter
4545
{
46-
Default = (0),
46+
Default = (0),
4747
TypeAndVariant = (1 << 0),
4848
Colours = (1 << 1),
4949
TrackProgress = (1 << 2),
5050
Spacing = (1 << 3),
51-
Seats = (1 << 4),
52-
Mass = (1 << 5),
53-
PoweredAcceleration = (1 << 6),
54-
PoweredMaxSpeed = (1 << 7),
51+
Position = (1 << 4),
52+
Seats = (1 << 5),
53+
Mass = (1 << 6),
54+
PoweredAcceleration = (1 << 7),
55+
PoweredMaxSpeed = (1 << 8),
56+
Spin = (1 << 9),
5557
All = -1
5658
}
5759

@@ -144,6 +146,10 @@ export function getVehicleSettings(source: RideVehicle, filters: CopyFilter): Ve
144146
const cols = car.colours;
145147
settings.colours = [ cols.body, cols.trim, cols.tertiary ];
146148
}
149+
if (filters & CopyFilter.Spin)
150+
{
151+
settings.spin = car.spin;
152+
}
147153
return settings;
148154
}
149155

@@ -170,6 +176,7 @@ export interface VehicleSettings
170176
poweredAcceleration?: number;
171177
poweredMaxSpeed?: number;
172178
colours?: number[];
179+
spin?: number;
173180
}
174181

175182

@@ -217,6 +224,7 @@ function applyVehicleSettings(car: Car, settings: VehicleSettings): void
217224
apply("mass", settings.mass);
218225
apply("poweredAcceleration", settings.poweredAcceleration);
219226
apply("poweredMaxSpeed", settings.poweredMaxSpeed);
227+
apply("spin", settings.spin);
220228

221229
const colours = settings.colours;
222230
if (colours)

src/ui/mainWindow.ts

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ model._selectedRide.subscribe(r =>
5353
const mainWindow = window({
5454
title,
5555
width: { value: 515, min: 515, max: 560 },
56-
height: 407,
56+
height: 415,
5757
spacing: 5,
5858
onOpen: () => model._open(),
5959
onClose: () =>
@@ -187,15 +187,21 @@ const mainWindow = window({
187187
}),
188188
checkbox({
189189
text: "Track progress",
190-
tooltip: "Copy the selected track progress to other vehicles.",
190+
tooltip: "Synchronize the selected track progress changes to other vehicles (apply not supported).",
191191
isChecked: compute(model._copyFilters, f => !!(f & CopyFilter.TrackProgress)),
192192
onChange: c => model._setFilter(CopyFilter.TrackProgress, c)
193193
}),
194194
checkbox({
195195
text: "Spacing",
196-
tooltip: "Copy the selected spacing to other vehicles.",
196+
tooltip: "Synchronize the selected spacing changes to other vehicles (apply not supported).",
197197
isChecked: compute(model._copyFilters, f => !!(f & CopyFilter.Spacing)),
198198
onChange: c => model._setFilter(CopyFilter.Spacing, c)
199+
}),
200+
checkbox({
201+
text: "Position",
202+
tooltip: "Synchronize the selected position changes to other vehicles (apply not supported).",
203+
isChecked: compute(model._copyFilters, f => !!(f & CopyFilter.Position)),
204+
onChange: c => model._setFilter(CopyFilter.Position, c)
199205
})
200206
]),
201207
vertical([
@@ -222,6 +228,12 @@ const mainWindow = window({
222228
tooltip: "Copy the selected maximum powered speed to other vehicles.",
223229
isChecked: compute(model._copyFilters, f => !!(f & CopyFilter.PoweredMaxSpeed)),
224230
onChange: c => model._setFilter(CopyFilter.PoweredMaxSpeed, c)
231+
}),
232+
checkbox({
233+
text: "Spin",
234+
tooltip: "Copy the selected spin to other vehicles.",
235+
isChecked: compute(model._copyFilters, f => !!(f & CopyFilter.Spin)),
236+
onChange: c => model._setFilter(CopyFilter.Spin, c)
225237
})
226238
])
227239
]),
@@ -285,15 +297,15 @@ const mainWindow = window({
285297
wrapMode: "wrap",
286298
disabled: compute(model._isEditDisabled, model._variants, (noEdit, variants) => (noEdit || variants.length < 2)),
287299
selectedIndex: model._variant,
288-
onChange: value => model._modifyVehicle(setVariant, value)
300+
onChange: value => model._modifyVehicle(setVariant, value, CopyFilter.TypeAndVariant)
289301
}),
290302
labelled<CheckboxParams>({
291303
_control: checkbox,
292304
_label: { text: "Reversed:", width: controlsLabelWidth },
293305
tooltip: "Look behind you!",
294306
disabled: model._isEditDisabled,
295307
isChecked: model._isReversed,
296-
onChange: value => model._modifyVehicle(setReversed, value)
308+
onChange: value => model._modifyVehicle(setReversed, value, CopyFilter.TypeAndVariant)
297309
}),
298310
horizontal([
299311
label({
@@ -306,19 +318,19 @@ const mainWindow = window({
306318
tooltip: "The primary (body) colour of the vehicle.",
307319
colour: model._primaryColour,
308320
disabled: model._isEditDisabled,
309-
onChange: value => model._modifyVehicle(setPrimaryColour, value)
321+
onChange: value => model._modifyVehicle(setPrimaryColour, value, CopyFilter.Colours)
310322
}),
311323
colourPicker({
312324
tooltip: "The secondary (trim) colour of the vehicle.",
313325
colour: model._secondaryColour,
314326
disabled: model._isEditDisabled,
315-
onChange: value => model._modifyVehicle(setSecondaryColour, value)
327+
onChange: value => model._modifyVehicle(setSecondaryColour, value, CopyFilter.Colours)
316328
}),
317329
colourPicker({
318330
tooltip: "The tertiary (detail) colour of the vehicle.",
319331
colour: model._tertiaryColour,
320332
disabled: model._isEditDisabled,
321-
onChange: value => model._modifyVehicle(setTertiaryColour, value)
333+
onChange: value => model._modifyVehicle(setTertiaryColour, value, CopyFilter.Colours)
322334
})
323335
])
324336
]
@@ -333,7 +345,7 @@ const mainWindow = window({
333345
disabled: model._isEditDisabled,
334346
step: model._multiplier,
335347
value: twoway(model._trackProgress),
336-
onChange: (_, incr) => applyTrackProgressChange(changeTrackProgress, incr)
348+
onChange: (_, incr) => applyTrackProgressChange(changeTrackProgress, incr, CopyFilter.TrackProgress)
337349
}),
338350
labelSpinner({
339351
_label: { text: "Spacing:" },
@@ -346,31 +358,31 @@ const mainWindow = window({
346358
const spacing = model._spacing.get();
347359
return (spacing === null) ? "Too far away" : spacing.toString();
348360
},
349-
onChange: (_, incr) => applyTrackProgressChange(changeSpacing, incr)
361+
onChange: (_, incr) => applyTrackProgressChange(changeSpacing, incr, CopyFilter.Spacing)
350362
}),
351363
positionSpinner({
352364
_label: { text: "X position:" },
353365
disabled: model._isPositionDisabled,
354366
step: model._multiplier,
355367
value: model._x,
356368
format: model._formatPosition,
357-
onChange: (_, incr) => model._modifyVehicle(setPositionX, incr)
369+
onChange: (_, incr) => model._modifyVehicle(setPositionX, incr, CopyFilter.Position)
358370
}),
359371
positionSpinner({
360372
_label: { text: "Y position:" },
361373
disabled: model._isPositionDisabled,
362374
step: model._multiplier,
363375
value: model._y,
364376
format: model._formatPosition,
365-
onChange: (_, incr) => model._modifyVehicle(setPositionY, incr)
377+
onChange: (_, incr) => model._modifyVehicle(setPositionY, incr, CopyFilter.Position)
366378
}),
367379
positionSpinner({
368380
_label: { text: "Z position:" },
369381
disabled: model._isPositionDisabled,
370382
step: model._multiplier,
371383
value: model._z,
372384
format: model._formatPosition,
373-
onChange: (_, incr) => model._modifyVehicle(setPositionZ, incr)
385+
onChange: (_, incr) => model._modifyVehicle(setPositionZ, incr, CopyFilter.Position)
374386
}),
375387
labelSpinner({
376388
_label: { text: "Spin angle:" },
@@ -379,7 +391,7 @@ const mainWindow = window({
379391
disabled: model._isSpinDisabled,
380392
step: model._multiplier,
381393
value: compute(model._spin, model._spinFrames, (spin, frames) => floor((spin * frames) / 256)),
382-
onChange: (_, incr) => model._modifyVehicle(setSpin, floor((incr * 256) / model._spinFrames.get()))
394+
onChange: (_, incr) => model._modifyVehicle(setSpin, floor((incr * 256) / model._spinFrames.get()), CopyFilter.Spin)
383395
})
384396
]
385397
}),
@@ -395,7 +407,7 @@ const mainWindow = window({
395407
disabled: model._isEditDisabled,
396408
step: model._multiplier,
397409
value: model._seats,
398-
onChange: value => model._modifyVehicle(setSeatCount, value)
410+
onChange: value => model._modifyVehicle(setSeatCount, value, CopyFilter.Seats)
399411
}),
400412
labelSpinner({
401413
_label: { text: "Mass:" },
@@ -405,7 +417,7 @@ const mainWindow = window({
405417
disabled: model._isEditDisabled,
406418
step: model._multiplier,
407419
value: model._mass,
408-
onChange: value => model._modifyVehicle(setMass, value)
420+
onChange: value => model._modifyVehicle(setMass, value, CopyFilter.Mass)
409421
}),
410422
labelSpinner({
411423
_label: { text: "Acceleration:" },
@@ -416,7 +428,7 @@ const mainWindow = window({
416428
disabled: model._isUnpowered,
417429
step: model._multiplier,
418430
value: model._poweredAcceleration,
419-
onChange: value => model._modifyVehicle(setPoweredAcceleration, value)
431+
onChange: value => model._modifyVehicle(setPoweredAcceleration, value, CopyFilter.PoweredAcceleration)
420432
}),
421433
labelSpinner({
422434
_label: { text: "Max. speed:" },
@@ -427,7 +439,7 @@ const mainWindow = window({
427439
disabled: model._isUnpowered,
428440
step: model._multiplier,
429441
value: model._poweredMaxSpeed,
430-
onChange: value => model._modifyVehicle(setPoweredMaximumSpeed, value)
442+
onChange: value => model._modifyVehicle(setPoweredMaximumSpeed, value, CopyFilter.PoweredMaxSpeed)
431443
})
432444
]
433445
}),
@@ -452,7 +464,7 @@ const mainWindow = window({
452464
function updateVehicleType(typeIdx: number): void
453465
{
454466
const type = model._rideTypes.get()[typeIdx];
455-
model._modifyVehicle(setRideType, type);
467+
model._modifyVehicle(setRideType, type, CopyFilter.TypeAndVariant);
456468
}
457469

458470
/**
@@ -473,13 +485,13 @@ function applySelectedSettingsToRide(): void
473485
/**
474486
* Apply the same amount of track progress to all selected vehicles based on the currently selected car.
475487
*/
476-
function applyTrackProgressChange(action: (vehicles: VehicleSpan[], value: number) => void, increment: number): void
488+
function applyTrackProgressChange(action: (vehicles: VehicleSpan[], value: number) => void, increment: number, filter: CopyFilter): void
477489
{
478490
const selectedVehicle = model._selectedVehicle.get();
479491
if (selectedVehicle)
480492
{
481493
const distance = getDistanceFromProgress(selectedVehicle[0]._car(), increment);
482-
model._modifyVehicle(action, distance);
494+
model._modifyVehicle(action, distance, filter);
483495
}
484496
}
485497

src/ui/utilityControls.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ export function multiplier(multiplierIndex: WritableStore<number>): WidgetCreato
88
{
99
const multiplierTip = "Multiplies all spinner controls by the specified amount";
1010

11-
return horizontal([
12-
label({
13-
text: "Multiplier:",
14-
tooltip: multiplierTip,
15-
width: 60,
16-
padding: { left: "1w" }
17-
}),
18-
dropdown({
19-
tooltip: multiplierTip,
20-
width: 45,
21-
padding: { right: 6 },
22-
items: ["x1", "x10", "x100"],
23-
selectedIndex: twoway(multiplierIndex)
24-
})
25-
]);
11+
return horizontal({
12+
padding: { top: -4, right: 1 },
13+
content: [
14+
label({
15+
text: "Multiplier:",
16+
tooltip: multiplierTip,
17+
width: 60,
18+
padding: { left: "1w" }
19+
}),
20+
dropdown({
21+
tooltip: multiplierTip,
22+
width: 45,
23+
items: ["x1", "x10", "x100"],
24+
selectedIndex: twoway(multiplierIndex)
25+
})
26+
]
27+
});
2628
}
2729

2830

src/viewmodels/vehicleViewModel.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class VehicleViewModel
285285
/**
286286
* Attempt to modify the vehicle with the specified action, if a vehicle is selected.
287287
*/
288-
_modifyVehicle<T>(action: (vehicles: VehicleSpan[], value: T) => void, value: T): void
288+
_modifyVehicle<T>(action: (vehicles: VehicleSpan[], value: T) => void, value: T, filter: CopyFilter): void
289289
{
290290
if (this._isRefreshing)
291291
{
@@ -295,7 +295,8 @@ export class VehicleViewModel
295295
const vehicle = this._selectedVehicle.get();
296296
if (vehicle)
297297
{
298-
if (this._synchronizeTargets.get())
298+
// Only apply if action matches filter.
299+
if (this._synchronizeTargets.get() && (!filter || ((this._copyFilters.get() || CopyFilter.All) & filter)))
299300
{
300301
action(this._copyTargets.get(), value);
301302
}

0 commit comments

Comments
 (0)