Skip to content

Commit 196768d

Browse files
Adding ability to see a car's vehicle's soundRange variable value
1 parent a8833b7 commit 196768d

File tree

7 files changed

+79
-10
lines changed

7 files changed

+79
-10
lines changed

.DS_Store

6 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"watch": "nodemon --watch ./src --ext js,ts",
1111
"build": "npm run lint && rollup --config rollup.config.prod.js",
1212
"build:dev": "rollup --config rollup.config.dev.js",
13-
"lint": "eslint ./src --ext .js --ext .ts",
13+
"lint": "eslint ./src --fix --ext .js --ext .ts",
1414
"test": "nyc ava"
1515
},
1616
"repository": {

src/.DS_Store

6 KB
Binary file not shown.

src/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/**
55
* Returns the current version of the plugin.
66
*/
7-
export const pluginVersion = "1.1";
7+
export const pluginVersion = "1.1 by Basssiiie - soundRange fork";
88

99

1010
/**

src/registerPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import main from "./main";
77
registerPlugin({
88
name: "RideVehicleEditor",
99
version: Environment.pluginVersion,
10-
authors: ["Basssiiie"],
10+
authors: ["Basssiiie", "reticulatingsplines"],
1111
type: "local",
1212
licence: "MIT",
1313
main,

src/services/editor.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface VehicleSettings
2222
mass: number;
2323
poweredAcceleration?: number;
2424
poweredMaxSpeed?: number;
25+
soundRange: number;
2526
}
2627

2728

@@ -40,6 +41,7 @@ export default class VehicleEditor
4041
readonly isPowered = new Observable<boolean>();
4142
readonly poweredAcceleration = new Observable<number>();
4243
readonly poweredMaxSpeed = new Observable<number>();
44+
readonly soundRange = new Observable<number>();
4345

4446

4547
/**
@@ -203,6 +205,27 @@ export default class VehicleEditor
203205
}
204206
}
205207

208+
/**
209+
* Sets the sound_range variable for this vehicle.
210+
* @param soundRange this is a value assigned to vehicles to determine what sounds they play when traveling (e.g. screams)
211+
*/
212+
setSoundrange(soundRange: number): void
213+
{ const currentCar = this.getSelectedCar();
214+
if (currentCar)
215+
{
216+
const vehicleObject = this.getVehicleObject(this.variant);
217+
if (vehicleObject.soundRange == 6)
218+
{
219+
vehicleObject.soundRange = 255;
220+
this.soundRange.set(vehicleObject.soundRange);
221+
}
222+
else
223+
{
224+
vehicleObject.soundRange = soundRange;
225+
this.soundRange.set(soundRange);
226+
}
227+
}
228+
}
206229

207230
/**
208231
* Scroll the main viewport to the currently selected vehicle.
@@ -234,6 +257,7 @@ export default class VehicleEditor
234257
variant: this.variant.get(),
235258
seats: this.seats.get(),
236259
mass: this.mass.get(),
260+
soundRange: this.soundRange.get(),
237261
};
238262

239263
if (vehicle.isPowered())
@@ -324,16 +348,20 @@ export default class VehicleEditor
324348
* Internal function that applies all vehicle settings to the specified car.
325349
*/
326350
private applySettingsToCar(car: Car, settings: VehicleSettings, updateObservables: boolean): void
351+
327352
{
353+
const vehicleObj = this.getVehicleObject(settings.variant);
328354
car.vehicleObject = settings.variant;
329355
car.numSeats = settings.seats;
330356
car.mass = settings.mass;
357+
vehicleObj.soundRange = settings.soundRange;
331358

332359
if (updateObservables)
333360
{
334361
this.variant.set(settings.variant);
335362
this.seats.set(settings.seats);
336363
this.mass.set(settings.mass);
364+
this.soundRange.set(settings.soundRange);
337365
}
338366

339367
const rideTypes = this.rideTypeList.get();
@@ -399,6 +427,7 @@ export default class VehicleEditor
399427
this.trackProgress.set(car.trackProgress);
400428
this.seats.set(car.numSeats);
401429
this.mass.set(car.mass);
430+
this.soundRange.set(this.getVehicleObject(car.vehicleObject).soundRange);
402431

403432
const definition = RideVehicle.getDefinition(car);
404433
const isPowered = RideVehicle.isPowered(definition);
@@ -433,17 +462,20 @@ export default class VehicleEditor
433462
const vehicleObj = this.getVehicleObject(variant);
434463

435464
const seats = (vehicleObj.numSeats & 0x7F); // VEHICLE_SEAT_NUM_MASK
465+
const soundRange = (vehicleObj.soundRange);
436466
const powAcceleration = vehicleObj.poweredAcceleration;
437467
const powMaxSpeed = vehicleObj.poweredMaxSpeed;
438468
const mass = (vehicleObj.carMass + (car.mass - oldMass));
439469
car.vehicleObject = variant;
440470
car.numSeats = seats;
441471
car.mass = mass;
472+
vehicleObj.soundRange = soundRange;
442473
car.poweredAcceleration = powAcceleration;
443474
car.poweredMaxSpeed = powMaxSpeed;
444475
this.variant.set(variant);
445476
this.seats.set(seats);
446477
this.mass.set(mass);
478+
this.soundRange.set(soundRange);
447479
this.isPowered.set(RideVehicle.isPowered(vehicleObj));
448480
this.poweredAcceleration.set(powAcceleration);
449481
this.poweredMaxSpeed.set(powMaxSpeed);

src/ui/editorWindow.ts

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import DropdownButtonControl from "./dropdownButton";
1717
const windowId = "ride-vehicle-editor";
1818
const windowStart = 18;
1919
const windowWidth = 375;
20-
const windowHeight = 248;
20+
const windowHeight = 285;
2121
const widgetLineHeight = 14;
2222
const groupboxMargin = 5;
2323
const groupboxItemMargin = (groupboxMargin + 5);
@@ -55,6 +55,7 @@ export default class VehicleEditorWindow
5555
readonly powAccelerationSpinner: SpinnerControl;
5656
readonly powMaxSpeedSpinner: SpinnerControl;
5757
readonly massSpinner: SpinnerControl;
58+
readonly soundRangeList: DropdownControl;
5859

5960
readonly locateButton: ButtonControl;
6061
readonly pickerButton: ButtonControl;
@@ -284,6 +285,29 @@ export default class VehicleEditorWindow
284285
});
285286
editor.mass.subscribe(v => this.massSpinner.set(v));
286287

288+
// soundRange ID of the selected vehicle.
289+
this.soundRangeList = new DropdownControl({
290+
name: "rve-soundRange-list",
291+
tooltip: "Pick from available soundRange IDs.",
292+
disabledMessage: "No soundRange IDs available.",
293+
items: ["ID 0 - Screams 1 and 8", "ID 1 - Screams 1-7", "ID 2 - Screams 1 and 6", "ID 3 - Whistle", "ID 4 - Bell", "ID 255 - No Sound"],
294+
disableSingleItem: false,
295+
x: groupboxMargin + viewportSize + 5 + (controlsSize * controlLabelPart),
296+
y: (editorStartY + 1 + controlHeight * 5),
297+
width: (controlsSize * (1 - controlLabelPart)),
298+
height: widgetLineHeight,
299+
onSelect: (v): void => editor.setSoundrange(v),
300+
});
301+
editor.soundRange.subscribe(v =>
302+
{
303+
if (v == 255)
304+
{
305+
v = 6;
306+
}
307+
this.soundRangeList.set(v);
308+
}
309+
);
310+
287311
// Powered acceleration of the selected vehicle.
288312
this.powAccelerationSpinner = new SpinnerControl({
289313
name: "rve-powered-acceleration-spinner",
@@ -293,7 +317,7 @@ export default class VehicleEditorWindow
293317
minimum: 0,
294318
maximum: 256,
295319
x: (groupboxMargin + viewportSize + 5) + (controlsSize * controlLabelPart),
296-
y: (editorStartY + 1 + controlHeight * 5),
320+
y: (editorStartY + 1 + controlHeight * 6),
297321
width: (controlsSize * (1 - controlLabelPart)),
298322
height: widgetLineHeight,
299323
onChange: (v): void => editor.setPoweredAcceleration(v)
@@ -309,7 +333,7 @@ export default class VehicleEditorWindow
309333
minimum: 0,
310334
maximum: 256,
311335
x: (groupboxMargin + viewportSize + 5) + (controlsSize * controlLabelPart),
312-
y: (editorStartY + 1 + controlHeight * 6),
336+
y: (editorStartY + 1 + controlHeight * 7),
313337
width: (controlsSize * (1 - controlLabelPart)),
314338
height: widgetLineHeight,
315339
onChange: (v): void => editor.setPoweredMaximumSpeed(v)
@@ -390,7 +414,7 @@ export default class VehicleEditorWindow
390414
{ text: "Apply this to all trains", onClick: (): void => this.applyToAllTrains() }
391415
],
392416
x: (groupboxMargin + viewportSize + 5),
393-
y: (editorStartY + controlHeight * 7) + 2,
417+
y: (editorStartY + controlHeight * 8) + 2,
394418
width: 211,
395419
height: (widgetLineHeight + 1),
396420
});
@@ -401,7 +425,7 @@ export default class VehicleEditorWindow
401425
tooltip: "Multiplies all spinner controls by the specified amount",
402426
items: ["x1", "x10", "x100"],
403427
x: (windowWidth - (groupboxMargin + 45)),
404-
y: (editorStartY + controlHeight * 7) + 2,
428+
y: (editorStartY + controlHeight * 8) + 2,
405429
width: 45,
406430
height: widgetLineHeight,
407431
onSelect: (i): void => this.updateMultiplier(i)
@@ -503,12 +527,24 @@ export default class VehicleEditorWindow
503527
},
504528
this.massSpinner.createWidget(),
505529

530+
// soundRange
531+
<LabelWidget>{
532+
tooltip: this.soundRangeList.params.tooltip,
533+
type: "label",
534+
x: (groupboxMargin + viewportSize + 5),
535+
y: (editorStartY + controlHeight * 5) + 2,
536+
width: (controlsSize * controlLabelPart),
537+
height: widgetLineHeight,
538+
text: "soundRange:"
539+
},
540+
this.soundRangeList.createWidget(),
541+
506542
// Powered acceleration
507543
<LabelWidget>{
508544
tooltip: this.powAccelerationSpinner.params.tooltip,
509545
type: "label",
510546
x: (groupboxMargin + viewportSize + 5),
511-
y: (editorStartY + controlHeight * 5) + 2,
547+
y: (editorStartY + controlHeight * 6) + 2,
512548
width: (controlsSize * controlLabelPart),
513549
height: widgetLineHeight,
514550
text: "Acceleration:"
@@ -520,7 +556,7 @@ export default class VehicleEditorWindow
520556
tooltip: this.powMaxSpeedSpinner.params.tooltip,
521557
type: "label",
522558
x: (groupboxMargin + viewportSize + 5),
523-
y: (editorStartY + controlHeight * 6) + 2,
559+
y: (editorStartY + controlHeight * 7) + 2,
524560
width: (controlsSize * controlLabelPart),
525561
height: widgetLineHeight,
526562
text: "Max. speed:"
@@ -649,6 +685,7 @@ export default class VehicleEditorWindow
649685
this.trackProgressSpinner.active(toggle);
650686
this.seatCountSpinner.active(toggle);
651687
this.massSpinner.active(toggle);
688+
this.soundRangeList.active(toggle);
652689

653690
// Buttons
654691
this.applyToOthersButton.active(toggle);

0 commit comments

Comments
 (0)