Signal signs rendering order and custom height
*Signal signs can now have custom height and will still be rendered with proper spacing *Order of signs rendered on signal's pole is now defined by the order in the DefinedSignalSigns dictionary
This commit is contained in:
parent
8f297df233
commit
b72dbe8f9a
@ -119,8 +119,8 @@ function getPolePoints(object, headOffsetX) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const signsCount = Object.keys(object.signal_elements.signs).length;
|
const signsHeight = Object.keys(object.signal_elements.signs).map(key => (DefinedSignalSigns[key]?.height || 1.0) + 0.2).reduce((a, b) => a + b, 0) || 0;
|
||||||
polePoints.signs = polePoints.bars + signsCount * 1.2;
|
polePoints.signs = polePoints.bars + signsHeight;
|
||||||
polePoints.end = isOverhead ? polePoints.signs : Math.max(polePoints.signs + 0.8, 2.2);
|
polePoints.end = isOverhead ? polePoints.signs : Math.max(polePoints.signs + 0.8, 2.2);
|
||||||
|
|
||||||
return polePoints;
|
return polePoints;
|
||||||
@ -271,13 +271,14 @@ function getSign(id, y) {
|
|||||||
function getSigns(object, polePoints, headOffsetY) {
|
function getSigns(object, polePoints, headOffsetY) {
|
||||||
if(!polePoints) return null;
|
if(!polePoints) return null;
|
||||||
const signs = [];
|
const signs = [];
|
||||||
let y = headOffsetY + polePoints.signs - 0.4;
|
let y = headOffsetY + polePoints.signs;
|
||||||
|
|
||||||
for(const [key, value] of Object.entries(object.signal_elements.signs)) {
|
for(const [key, def] of Object.entries(DefinedSignalSigns)) {
|
||||||
if(!value) continue;
|
if(!object.signal_elements.signs.hasOwnProperty(key) || !DefinedSignalSigns[key]) continue;
|
||||||
|
const height = (def.height || 1.0);
|
||||||
|
|
||||||
signs.push(getSign(key, y));
|
signs.push(getSign(key, y - height / 2 + 0.1));
|
||||||
y -= 1.2;
|
y -= height + 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return signs;
|
return signs;
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
|
/*
|
||||||
|
NOTE: Order of signs defined in this dictionary dictates the order of signs rendered on the signal pole
|
||||||
|
*/
|
||||||
|
|
||||||
const DefinedSignalSigns = {
|
const DefinedSignalSigns = {
|
||||||
"w1": {
|
"w1": {
|
||||||
"regex": /^(?:wsk_)?w1(?:\D)?.*$/,
|
"regex": /^(?:wsk_)?w1(?:\D)?.*$/,
|
||||||
"name": "W1",
|
"name": "W1",
|
||||||
"icon": "w1.svg",
|
"icon": "w1.svg",
|
||||||
|
"height": 1.28504,
|
||||||
},
|
},
|
||||||
"w18": {
|
"w18": {
|
||||||
"regex": /^(?:wsk_)?w18(?:\D)?.*$/,
|
"regex": /^(?:wsk_)?w18(?:\D)?.*$/,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user