diff --git a/pom.xml b/pom.xml index fade0d1..962d7f8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 de.srsoftware web4rail - 1.5.28 + 1.5.29 Web4Rail jar Java Model Railway Control diff --git a/resources/css/style.css b/resources/css/style.css index b8fdcea..dc8d141 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -99,6 +99,11 @@ svg.preview rect{ fill:cyan; } +polygon.direction { + fill: rgba(0,0,0,0.4) !important; + stroke: none; +} + svg rect.sig_a, svg rect.sig_b{ fill: inherit; diff --git a/resources/translations/Application.de.translation b/resources/translations/Application.de.translation index 175026d..00f9589 100644 --- a/resources/translations/Application.de.translation +++ b/resources/translations/Application.de.translation @@ -196,6 +196,7 @@ Found {} routes. : {} Routen gefunden. free : frei machen FreeStartBlock : Start-Block freigeben Free tiles behind train : Kacheln hinter dem Zug freigeben +{} from {} : {} von {} Fullscreen : Vollbild Function : Funktion Function {} : Funktion {} diff --git a/src/main/java/de/srsoftware/web4rail/Destination.java b/src/main/java/de/srsoftware/web4rail/Destination.java index 23e563c..421f788 100644 --- a/src/main/java/de/srsoftware/web4rail/Destination.java +++ b/src/main/java/de/srsoftware/web4rail/Destination.java @@ -3,7 +3,9 @@ package de.srsoftware.web4rail; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import de.srsoftware.web4rail.BaseClass.Id; import de.srsoftware.web4rail.Plan.Direction; +import de.srsoftware.web4rail.moving.Train; import de.srsoftware.web4rail.tiles.Block; public class Destination { @@ -12,7 +14,12 @@ public class Destination { private Direction enterDirection; public Block block; + private boolean shunting = false; + + private boolean turn = false; + public Destination(Block block, Direction enterFrom) { + if (block == null) throw new NullPointerException(); this.block = block; this.enterDirection = enterFrom; } @@ -34,10 +41,90 @@ public class Destination { return block.id().toString(); }; + public static String dropFirstFrom(String tag) { + if (BaseClass.isNull(tag)) return null; + + String[] parts = tag.split(Train.DESTINATION_PREFIX,3); + if (parts.length<3) return null; + + return Train.DESTINATION_PREFIX+parts[2]; + } + + private Destination enterFrom(Direction enterFrom) { + this.enterDirection = enterFrom; + return this; + } + + + public static Destination from(String tag) { + if (BaseClass.isNull(tag)) return null; + + LOG.debug("→ processing \"{}\"...",tag); + String[] parts = tag.split(Train.DESTINATION_PREFIX,3); + if (parts.length<2) return null; + + String firstTag = parts[1]; + LOG.debug("processing first tag: {}",firstTag); + if (firstTag.length()<1) return null; + int pos = firstTag.indexOf(Train.FLAG_SEPARATOR); + String blockId = pos<0 ? firstTag : firstTag.substring(0,pos); + + Block block = Block.get(new Id(blockId)); + if (block == null) return null; + + Destination destination = new Destination(block); + if (pos>0) { + String modifiers = firstTag.substring(pos+1); + for (int i=0; i { } public void addTag(String tag) { - tags.add(tag); + if (isSet(tag)) { + tags.add(tag); + LOG.debug("added tag \"{}\" to {}",tag,this); + } } private Object addCar(Params params) { @@ -366,28 +369,11 @@ public class Train extends BaseClass implements Comparable { } public Destination destination(){ - //LOG.debug("{}.destination()",this); if (isNull(destination)) { - String destTag = destinationTag(); - LOG.debug("→ processing \"{}\"...",destTag); - if (isSet(destTag)) { - destTag = destTag.split(DESTINATION_PREFIX)[1]; - LOG.debug("....processing \"{}\"…",destTag); - for (int i=destTag.length()-1; i>0; i--) { - switch (destTag.charAt(i)) { - case FLAG_SEPARATOR: - destTag = destTag.substring(0,i); - i=0; - break; - case SHUNTING_FLAG: - LOG.debug("....enabled shunting option"); - shunting = true; - break; - } - } - destination = new Destination(BaseClass.get(new Id(destTag))); - } - }// else LOG.debug("→ heading towards {}",destination); + destination = Destination.from(destinationTag()); + LOG.debug("{}.destination() → {}",this,destination); + if (isSet(destination)) shunting |= destination.shunting(); + } return destination; } @@ -471,37 +457,13 @@ public class Train extends BaseClass implements Comparable { if (resetDest){ destination = null; - String destTag = destinationTag(); - if (isSet(destTag)) { - LOG.debug("destination list: {}",destTag); - String[] parts = destTag.split(Train.DESTINATION_PREFIX); - for (int i=0; i0; i--) { - switch (destId.charAt(i)) { - case Train.FLAG_SEPARATOR: - destId = destId.substring(0,i); - i=0; - break; - case Train.TURN_FLAG: - turn = true; - LOG.debug("Turn flag is set!"); - break; - } - } - if (destId.equals(endBlock.id().toString())) { - if (turn) turn(); - - // update destination tag: remove and add altered tag: - removeTag(destTag); - destTag = destTag.substring(parts[1].length()+1); - if (destTag.isEmpty()) { // no further destinations - destTag = null; - } else addTag(destTag); - } + String destTag = destinationTag(); + Destination destinationFromTag = Destination.from(destTag); + if (endedRoute.endsAt(destinationFromTag)) { + if (destinationFromTag.turn()) turn(); + removeTag(destTag); + destTag = Destination.dropFirstFrom(destTag); + addTag(destTag); } if (isNull(destTag)) { @@ -879,6 +841,7 @@ public class Train extends BaseClass implements Comparable { } public Iterator removeTag(String tag) { + LOG.debug("Removing tag \"{}\" from {}",tag,this); tags.remove(tag); return tags().iterator(); } @@ -1106,6 +1069,7 @@ public class Train extends BaseClass implements Comparable { public SortedSet tags() { TreeSet list = new TreeSet(tags); for (Car car:cars) list.addAll(car.tags()); + LOG.debug("{}.tags() → {}",this,list); return list; } diff --git a/src/main/java/de/srsoftware/web4rail/tiles/Block.java b/src/main/java/de/srsoftware/web4rail/tiles/Block.java index 6582fea..7bf0644 100644 --- a/src/main/java/de/srsoftware/web4rail/tiles/Block.java +++ b/src/main/java/de/srsoftware/web4rail/tiles/Block.java @@ -487,6 +487,11 @@ public abstract class Block extends StretchableTile{ @Override public String title() { StringBuilder sb = new StringBuilder(name); + sb.append(" @ ("); + sb.append(x); + sb.append(", "); + sb.append(y); + sb.append(")"); Train occupyingTrain = occupyingTrain(); if (isSet(occupyingTrain)) sb.append(title(occupyingTrain)); if (isSet(parkedTrains)) for (Train parked : parkedTrains.trains) sb.append(title(parked));