From 58d9c476c932d3a611c5d9d225f09846638ee4b6 Mon Sep 17 00:00:00 2001
From: Pyro Nicampt <81565698+PyroNicampt@users.noreply.github.com>
Date: Wed, 2 Jul 2025 21:58:10 -0500
Subject: [PATCH] Add derail state & speed to map
Add legend toggle for non-player trains.
v0.6.2 > v0.6.3
---
index.html | 2 +-
index.js | 10 +++++++---
js/mapdata.js | 7 +++++--
legend.js | 15 ++++++++++++++-
4 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/index.html b/index.html
index 7453f78..80714f2 100644
--- a/index.html
+++ b/index.html
@@ -27,7 +27,7 @@
- Map v0.6.4 alpha
+ Map v0.6.5 alpha
Updated for Game Build 99.5
diff --git a/index.js b/index.js
index ea31fde..990f135 100644
--- a/index.js
+++ b/index.js
@@ -527,6 +527,7 @@ function redrawDynamics(){
break;
case 'car':
if(!(MapData.layers.dynamic && MapData.layers.cars)) break;
+ if(!MapData.layers.otherCars && !marker.isPlayer) break;
let scale = MapData.view.pixelRatio * MapData.view.scale;
let limitScaleRatio = (MapData.view.pixelRatio * Math.max(MapData.view.scale, 3)) / scale;
let width = marker.width * scale;
@@ -544,14 +545,17 @@ function redrawDynamics(){
dynctx.moveTo(0.5 * width, 0);
dynctx.arc(0.5 * width, 0.5 * length, 15, -0.5*Math.PI, 1.5*Math.PI);
dynctx.resetTransform();
- dynctx.strokeStyle = '#fff';
+ dynctx.strokeStyle = marker.derailed ? '#f83' : '#fff';
dynctx.lineWidth = 0.75 * scale * limitScaleRatio;
dynctx.miterLimit = 1.5;
dynctx.stroke();
- dynctx.fillStyle = marker.isLoco ? '#e79830aa' : '#559bd4aa';
+ if(marker.derailed)
+ dynctx.fillStyle = marker.isLoco ? '#db4f18aa' : '#9e54d3aa';
+ else
+ dynctx.fillStyle = marker.isLoco ? '#e79830aa' : '#559bd4aa';
dynctx.fill();
- dynctx.strokeStyle = '#000';
+ dynctx.strokeStyle = marker.derailed ? '#410' : '#000';
dynctx.lineWidth = 0.3 * scale * limitScaleRatio;
dynctx.stroke();
if(!marker.tooltipHitzone){
diff --git a/js/mapdata.js b/js/mapdata.js
index 1e577bc..a00ae3d 100644
--- a/js/mapdata.js
+++ b/js/mapdata.js
@@ -734,12 +734,15 @@ export function connectPlayerLocation(address, status){
y: car.y,
z: car.z
},
- length: car.length,
+ length: car.length - 0.5,
width: 2.0,
rotation: car.rotation,
guid: car.carGuid,
isLoco: car.isLoco,
- tooltip: `${car.id}
Type: ${car.name}\nLength: ${car.length.toFixed(1)}m`,
+ tooltip: `${car.id}
Type: ${car.name}\nLength: ${car.length.toFixed(1)}m${car.speed >= 0.1 ? `\nSpeed: ${(car.speed * 3.6).toFixed(1)} km/h` : '' }${car.derailed ? '\nDerailed!' : ''}`,
+ derailed: car.derailed,
+ isPlayer: car.isPlayer,
+ isActive: car.isActive,
});
}
dynamicMarkers.push(playerMarker);
diff --git a/legend.js b/legend.js
index 2419fd2..bd83411 100644
--- a/legend.js
+++ b/legend.js
@@ -259,7 +259,7 @@ let settingEntries = [
}
},
{
- label: 'Cars',
+ label: 'Train Cars',
id: 'toggle_cars',
saveState: true,
state: true,
@@ -267,6 +267,19 @@ let settingEntries = [
MapData.layers.cars = state;
MapData.view.dynDirty = true;
},
+ children:[
+ {
+ label: 'Non-Player Trains',
+ tooltip: 'Other trains with active locomotives',
+ id: 'toggle_otherCars',
+ saveState: true,
+ state: true,
+ func: state =>{
+ MapData.layers.otherCars = state;
+ MapData.view.dynDirty = true;
+ },
+ }
+ ]
},
]
},