minor improvements

This commit is contained in:
Stephan Richter
2021-04-01 22:05:37 +02:00
parent f7c895620a
commit 744fb3eb32
4 changed files with 13 additions and 5 deletions

View File

@@ -888,7 +888,14 @@ public class Route extends BaseClass {
return true;
}
public boolean start() {
public boolean start() {
if (isNull(context) || context.invalidated()) {
LOG.debug("Invalid context: {}",context);
return false;
}
Train train = context.train();
if (train.direction() != startDirection) train.turn();
if (isSet(startDelay)) sleep(startDelay.random());
return startNow();
}

View File

@@ -141,6 +141,7 @@ public class Train extends BaseClass implements Comparable<Train> {
case ACTION_QUIT:
return train.properties(train.quitAutopilot());
case ACTION_REVERSE:
train.quitAutopilot();
return train.reverse().properties();
case ACTION_SLOWER10:
return train.slower(Train.defaultSpeedStep);
@@ -748,12 +749,11 @@ public class Train extends BaseClass implements Comparable<Train> {
button(t("reverse"), Map.of(ACTION,ACTION_REVERSE)).title(t("Turns the train, as if it went through a loop.")).addTo(directionLi).addTo(propList);
Tag dest = new Tag("li").content(t("Destination")+COL);
if (isNull(destination)) {
button(t("Select from plan"),Map.of(ACTION,ACTION_MOVE,ASSIGN,DESTINATION)).addTo(dest);
} else {
if (isSet(destination)) {
link("span",destination,Map.of(REALM,REALM_PLAN,ID,destination.id().toString(),ACTION,ACTION_CLICK)).addTo(dest);
new Button(t("Drop"),Map.of(REALM,REALM_TRAIN,ID,id,ACTION,ACTION_MOVE,DESTINATION,"")).addTo(dest);
}
button(t("Select from plan"),Map.of(ACTION,ACTION_MOVE,ASSIGN,DESTINATION)).addTo(dest);
dest.addTo(propList);
if (isSet(route)) route.link("li", route).addTo(propList);