This commit is contained in:
Stephan Richter
2020-11-12 12:40:43 +01:00
parent d372b9333f
commit d12ddf66ad
4 changed files with 32 additions and 14 deletions

View File

@@ -245,6 +245,10 @@ public class Train extends BaseClass implements Comparable<Train> {
return train;
}
public Block currentBlock() {
return currentBlock;
}
public Block destination() {
return destination;
}
@@ -468,8 +472,13 @@ public class Train extends BaseClass implements Comparable<Train> {
if (isSet(currentBlock)) {
link("li",Map.of(REALM,REALM_PLAN,ID,currentBlock.id(),ACTION,ACTION_CLICK),t("Current location: {}",currentBlock)).addTo(propList);
Tag actions = new Tag("li").clazz().content(t("Actions:")+NBSP);
props.put(ACTION, ACTION_START);
new Button(t("start"),props).addTo(actions);
if (isSet(route)) {
props.put(ACTION, ACTION_STOP);
new Button(t("stop"),props).addTo(actions);
} else {
props.put(ACTION, ACTION_START);
new Button(t("start"),props).addTo(actions);
}
if (isNull(autopilot)) {
props.put(ACTION, ACTION_AUTO);
new Button(t("auto"),props).addTo(actions);
@@ -521,6 +530,10 @@ public class Train extends BaseClass implements Comparable<Train> {
} else return t("autopilot not active.");
}
public void removeFromTrace(Tile tile) {
trace.remove(tile);
}
private void reverseTrace() {
// TODO Auto-generated method stub
}
@@ -572,6 +585,10 @@ public class Train extends BaseClass implements Comparable<Train> {
this.speed = v;
}
public void setWaitTime(Range waitTime) {
if (autopilot != null) autopilot.waitTime = waitTime.random();
}
public void showTrace() {
int remainingLength = length();
if (remainingLength<1) remainingLength=1;
@@ -662,16 +679,8 @@ public class Train extends BaseClass implements Comparable<Train> {
return this;
}
public void removeFromTrace(Tile tile) {
trace.remove(tile);
}
public void setWaitTime(Range waitTime) {
if (autopilot != null) autopilot.waitTime = waitTime.random();
}
public Block currentBlock() {
return currentBlock;
public boolean usesAutopilot() {
return isSet(autopilot);
}
}

View File

@@ -223,6 +223,14 @@ public abstract class Tile extends BaseClass{
props.put(ACTION, ACTION_START);
window.children().insertElementAt(new Button(t("start"),props), 1);
}
if (train.usesAutopilot()) {
props.put(ACTION, ACTION_QUIT);
window.children().insertElementAt(new Button(t("quit autopilot"),props),2);
} else {
props.put(ACTION, ACTION_AUTO);
window.children().insertElementAt(new Button(t("auto"),props),2);
}
window.children().insertElementAt(train.link("span"), 1);
window.children().insertElementAt(new Tag("h4").content(t("Train:")), 1);
}