Improved SignalBox labels
*Moved SignalBox labels into a separate component *SignalBoxEmpty labels now rotate towards the camera
This commit is contained in:
parent
634922986e
commit
58a51297c4
@ -1,15 +1,15 @@
|
||||
import { ReactSVG } from 'react-svg';
|
||||
import AlwaysUpText from '../text/AlwaysUpText';
|
||||
import SimpleLabelText from '../text/SimpleLabelText';
|
||||
|
||||
export default function SignalBoxRenderer(props) {
|
||||
const { object } = props;
|
||||
const [x, y] = object.pos.toSVGCoords();
|
||||
const text = object.getPrintableSignalBoxName();
|
||||
const rot = object.getFinalRotation();
|
||||
|
||||
return (
|
||||
<g className="signalbox" transform={`translate(${x}, ${y}) rotate(${rot})`}>
|
||||
<g className="signalbox-icon" transform={`translate(-4.725, -4.725)`}>
|
||||
<g className="signalbox" transform={`translate(${x}, ${y})`}>
|
||||
<g className="signalbox-icon" transform={`rotate(${rot}) translate(-4.725, -4.725)`}>
|
||||
<ReactSVG
|
||||
src={`${process.env.PUBLIC_URL}/assets/signalboxes/${object.def.icon}`}
|
||||
wrapper='svg'
|
||||
@ -20,16 +20,32 @@ export default function SignalBoxRenderer(props) {
|
||||
}}
|
||||
/>
|
||||
</g>
|
||||
<AlwaysUpText
|
||||
baseRot={rot - 90}
|
||||
additionalRot={180}
|
||||
offsetY={6}
|
||||
textProps={{
|
||||
textAnchor: 'middle'
|
||||
}}
|
||||
text={text}
|
||||
/>
|
||||
<SignalBoxText object={object} rot={rot} />
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function SignalBoxText(props) {
|
||||
const { object, rot } = props;
|
||||
const text = object.getPrintableSignalBoxName();
|
||||
|
||||
if (object.def?.empty) {
|
||||
return <SimpleLabelText
|
||||
text={text}
|
||||
textProps={{ y: 6 }}
|
||||
/>;
|
||||
}
|
||||
|
||||
return (
|
||||
<AlwaysUpText
|
||||
baseRot={rot - 90}
|
||||
additionalRot={180}
|
||||
additionalPreRot={rot}
|
||||
offsetY={6}
|
||||
textProps={{
|
||||
textAnchor: 'middle'
|
||||
}}
|
||||
text={text}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user