working on signals on routes
This commit is contained in:
@@ -58,7 +58,9 @@ public abstract class Block extends StretchableTile{
|
||||
public Tag tag(Map<String, Object> replacements) throws IOException {
|
||||
if (replacements == null) replacements = new HashMap<String, Object>();
|
||||
replacements.put("%text%",train == null ? name : train.name());
|
||||
return super.tag(replacements);
|
||||
Tag tag = super.tag(replacements);
|
||||
if (train != null) tag.clazz(tag.get("class")+" occupied");
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
package de.srsoftware.web4rail.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Plan.Direction;
|
||||
|
||||
public abstract class Signal extends Tile{
|
||||
|
||||
private static final String STOP = "stop";
|
||||
private String state = STOP;
|
||||
|
||||
public Signal() {
|
||||
super();
|
||||
@@ -10,4 +17,16 @@ public abstract class Signal extends Tile{
|
||||
}
|
||||
|
||||
public abstract boolean isAffectedFrom(Direction dir);
|
||||
|
||||
public void state(String state) throws IOException {
|
||||
this.state = state;
|
||||
plan.stream("place "+tag(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag tag(Map<String, Object> replacements) throws IOException {
|
||||
Tag tag = super.tag(replacements);
|
||||
tag.clazz(tag.get("class")+" "+state);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class Tile {
|
||||
protected HashSet<Shadow> shadows = new HashSet<>();
|
||||
private HashSet<Route> routes = new HashSet<>();
|
||||
protected Plan plan;
|
||||
private Train lockedBy;
|
||||
protected Train lockedBy;
|
||||
|
||||
protected static Logger LOG = LoggerFactory.getLogger(Tile.class);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
public class TurnoutL extends Turnout {
|
||||
@Override
|
||||
public Object click() throws IOException {
|
||||
if (lockedBy != null) return t("{} is locked by {}!",this,lockedBy);
|
||||
state = (state == State.STRAIGHT) ? State.LEFT : State.STRAIGHT;
|
||||
return tag(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user