Bugfixes
*Fixed route names not being rendered correctly on single track routes *Separated scenery layers rendering from SceneryRoot to SceneryLayer component *Fixed TrackObjects not always being correctly recognised as Signals *Fixed getPrintableSignalName not working with the old Signal syntax
This commit is contained in:
parent
b7f9d80045
commit
32a1d95ba2
28
src/components/map/SceneryLayer.js
Normal file
28
src/components/map/SceneryLayer.js
Normal file
@ -0,0 +1,28 @@
|
||||
import { useContext } from "react";
|
||||
import MainContext from "../../contexts/MainContext";
|
||||
import SettingsContext from "../../contexts/SettingsContext";
|
||||
|
||||
export default function SceneryLayer(props) {
|
||||
const { queueItem } = props;
|
||||
const { name, category, type, types, cond} = queueItem;
|
||||
const RendererComponent = queueItem.renderer;
|
||||
|
||||
const settings = useContext(SettingsContext);
|
||||
const { scenery } = useContext(MainContext);
|
||||
|
||||
if(!scenery) return;
|
||||
if(cond && !cond(settings)) return [null];
|
||||
const objects = scenery.objects[category] ?? null;
|
||||
if(!objects) return [null];
|
||||
|
||||
return (
|
||||
<g className={`scenery-layer-${name}`} key={name}>
|
||||
{Object.values(objects).map((object) => {
|
||||
if(type !== undefined && type !== object.type) return null;
|
||||
if(types !== undefined && !types.includes(object.type)) return null;
|
||||
|
||||
return <RendererComponent key={`${name}-${object.id}`} object={object} />;
|
||||
})}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
@ -1,38 +1,17 @@
|
||||
import { useContext, useMemo } from "react";
|
||||
import { useContext } from "react";
|
||||
import MainContext from "../../contexts/MainContext";
|
||||
import ObjectsRenderQueue from "./ObjectsRenderQueue";
|
||||
import SettingsContext from "../../contexts/SettingsContext";
|
||||
import SceneryLayer from "./SceneryLayer";
|
||||
|
||||
export default function SceneryRoot(props) {
|
||||
const { scenery } = useContext(MainContext);
|
||||
const settings = useContext(SettingsContext);
|
||||
|
||||
const content = useMemo(() => {
|
||||
if(!scenery) return null;
|
||||
|
||||
return ObjectsRenderQueue.map((queueItem) => {
|
||||
const { name, category, type, types, cond} = queueItem;
|
||||
const RendererComponent = queueItem.renderer;
|
||||
if(cond && !cond(settings)) return [null];
|
||||
|
||||
const objects = scenery.objects[category] ?? null;
|
||||
if(!objects) return [null];
|
||||
|
||||
return (
|
||||
<g className={`scenery-layer-${name}`} key={name}>
|
||||
{Object.values(objects).map((object) => {
|
||||
if((type !== undefined && type !== object.type) || (types !== undefined && !types.includes(object.type))) return null;
|
||||
|
||||
return <RendererComponent key={`${name}-${object.id}`} object={object} />;
|
||||
})}
|
||||
</g>
|
||||
);
|
||||
});
|
||||
}, [scenery, settings]);
|
||||
if (!scenery) return null;
|
||||
|
||||
return (
|
||||
<g className='scenery-root'>
|
||||
{content}
|
||||
{ ObjectsRenderQueue.map((queueItem) =>
|
||||
<SceneryLayer queueItem={queueItem} key={queueItem.name} />
|
||||
) }
|
||||
</g>
|
||||
)
|
||||
}
|
||||
@ -19,7 +19,7 @@ export default function RouteRenderer(props) {
|
||||
}, [object.rot]);
|
||||
|
||||
const upsideDownRot = upsideDown ? 90 : -90;
|
||||
const offY = object.track_count === 2 ? -22 : 20;
|
||||
const offY = object.track_count === 2 ? -22 : -20;
|
||||
const anchor = upsideDown ? "start" : "end";
|
||||
|
||||
return (
|
||||
|
||||
@ -18,6 +18,10 @@ export default class Signal extends TrackObject {
|
||||
}
|
||||
|
||||
getPrintableSignalName() {
|
||||
if (!this.signal_name) {
|
||||
return this.name
|
||||
}
|
||||
|
||||
// remove everything after the first '[' or '<' character (inclusive)
|
||||
const match = this.signal_name.match(/^[^[<]*/);
|
||||
if (match) {
|
||||
@ -34,7 +38,7 @@ export default class Signal extends TrackObject {
|
||||
*/
|
||||
static isSignal(text) {
|
||||
const values = text.split(";");
|
||||
if(values.length < 32) return false;
|
||||
if(values.length < 29) return false;
|
||||
|
||||
const prefabInfo = values[2].split(",");
|
||||
if(prefabInfo.length < 2) return false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user