Added on-hover switches info

+TrackHoverInfoPopup now displays switch ID and model if the hovered track is part of a switch
*Fixed typo: renamed the "Switches names" layer to "Switch names"
This commit is contained in:
izawartka 2025-07-11 01:42:17 +02:00
parent dfe90bfd2d
commit 745d31e44a
3 changed files with 14 additions and 3 deletions

View File

@ -20,12 +20,23 @@ export default function TrackHoverInfoPopup(props) {
<InfoPopupItem value={slopeArr} label="Slope" options={slopeOptions} />
<InfoPopupItem value={track['electrificationStatus']} label="Electrification" options={{translationConstKey: 'electrification'}} />
<InfoPopupItem value={track['type']} label="Type" options={{translationConstKey: 'type'}} />
<InfoPopupSwitchItems track={track} />
</tbody>
</table>
</div>
);
}
function InfoPopupSwitchItems(props) {
const { track } = props;
if (!track.switch) return null;
return <>
<InfoPopupItem value={track.switch.id_switch} label="Switch ID" />
<InfoPopupItem value={track.switch.bare_model} label="Switch model" />
</>
}
function processItemValue(value, options) {
const { translationConstKey, join, subOptions, suffix } = options || {};
@ -37,7 +48,7 @@ function processItemValue(value, options) {
return TrackHoverInfoConsts[translationConstKey]?.[value] || value;
}
if (!value) {
if (value === undefined || value === null || value === '') {
return "N/A";
}

View File

@ -70,12 +70,11 @@ const Constants = {
},
{
id: 'switches-names',
name: 'Switches names',
name: 'Switch names',
default: false,
},
{
id: 'isolations-ids',
name: 'Isolations IDs',
name: 'Isolations',
default: false,
},

View File

@ -7,6 +7,7 @@ import Constants from "../helpers/constants.js";
export default class Switch extends SceneryObject {
model;
bare_model;
data;
id_isolation;
id_switch;