|
1 | 1 | import { button, checkbox, CheckboxParams, colourPicker, compute, dropdown, dropdownSpinner, DropdownSpinnerParams, FlexiblePosition, groupbox, horizontal, label, SpinnerParams, toggle, twoway, vertical, viewport, WidgetCreator, window } from "openrct2-flexui"; |
2 | 2 | import { isDevelopment, pluginVersion } from "../environment"; |
| 3 | +import { RideType } from "../objects/rideType"; |
3 | 4 | import { RideVehicleVariant, VehicleVisibility } from "../objects/rideVehicleVariant"; |
4 | 5 | import { invoke, refreshRide } from "../services/events"; |
5 | 6 | import { getDistanceFromProgress } from "../services/spacingEditor"; |
6 | 7 | import { applyToTargets, CopyFilter, getTargets, getVehicleSettings } from "../services/vehicleCopier"; |
7 | 8 | import { changeSpacing, changeTrackProgress, setMass, setPositionX, setPositionY, setPositionZ, setPoweredAcceleration, setPoweredMaximumSpeed, setPrimaryColour, setReversed, setRideType, setSeatCount, setSecondaryColour, setSpin, setTertiaryColour, setVariant } from "../services/vehicleEditor"; |
8 | 9 | import { VehicleSpan } from "../services/vehicleSpan"; |
9 | 10 | import { isValidGameVersion } from "../services/versionChecker"; |
| 11 | +import * as Log from "../utilities/logger"; |
10 | 12 | import { floor } from "../utilities/math"; |
11 | 13 | import { VehicleViewModel } from "../viewmodels/vehicleViewModel"; |
12 | 14 | import { model as rideModel, rideWindow } from "./rideWindow"; |
@@ -281,7 +283,7 @@ const mainWindow = window({ |
281 | 283 | text: "Visuals", |
282 | 284 | content: [ |
283 | 285 | dropdown({ // vehicle type editor |
284 | | - items: compute(model._rideTypes, c => c.map(t => t._object().name)), |
| 286 | + items: compute(model._rideTypes, getUniqueRideTypeNames), |
285 | 287 | tooltip: "All ride types currently available in the park", |
286 | 288 | disabledMessage: "No ride types available", |
287 | 289 | disabled: compute(model._isEditDisabled, model._type, (noEdit, type) => (noEdit || !type)), |
@@ -530,3 +532,36 @@ function positionSpinner(params: LabelledSpinnerParams & FlexiblePosition): Widg |
530 | 532 | params._noDisabledMessage = true; |
531 | 533 | return labelSpinner(params); |
532 | 534 | } |
| 535 | + |
| 536 | +/** |
| 537 | + * Hack: make ride type names unique so they don't get mixed up. |
| 538 | + */ |
| 539 | +function getUniqueRideTypeNames(rideTypes: RideType[]): string[] |
| 540 | +{ |
| 541 | + const length = rideTypes.length; |
| 542 | + const array = Array<string>(length); |
| 543 | + let streak: string | undefined; |
| 544 | + let last: string | undefined; |
| 545 | + let current: string | undefined; |
| 546 | + let idx = 0; |
| 547 | + |
| 548 | + for (; idx < length; idx++) |
| 549 | + { |
| 550 | + current = rideTypes[idx]._object().name; |
| 551 | + |
| 552 | + if (current === streak) |
| 553 | + { |
| 554 | + last += " "; // Add invisible space to add difference. |
| 555 | + } |
| 556 | + else |
| 557 | + { |
| 558 | + streak = last = current; |
| 559 | + } |
| 560 | + |
| 561 | + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
| 562 | + array[idx] = last!; |
| 563 | + } |
| 564 | + |
| 565 | + Log.debug("getUniqueRideTypeNames():", array); |
| 566 | + return array; |
| 567 | +} |
0 commit comments