working on contact and signal functions
This commit is contained in:
@@ -1,5 +1,39 @@
|
||||
package de.srsoftware.web4rail.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
|
||||
public abstract class Contact extends Tile{
|
||||
|
||||
private boolean active = false;
|
||||
|
||||
|
||||
private void activate() throws IOException {
|
||||
active = true;
|
||||
stream();
|
||||
new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
sleep(200);
|
||||
active=false;
|
||||
stream();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object click() throws IOException {
|
||||
activate();
|
||||
return super.click();
|
||||
}
|
||||
|
||||
public void stream() throws IOException {
|
||||
Tag tag = super.tag(null);
|
||||
if (active) tag.clazz(tag.get("class")+" active");
|
||||
plan.stream("place "+tag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import de.srsoftware.web4rail.Plan.Direction;
|
||||
|
||||
public abstract class Signal extends Tile{
|
||||
|
||||
private static final String STOP = "stop";
|
||||
public static final String STOP = "stop";
|
||||
private String state = STOP;
|
||||
|
||||
public Signal() {
|
||||
|
||||
@@ -5,8 +5,12 @@ 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);
|
||||
if (lockedBy != null) {
|
||||
plan.stream(t("{} is locked by {}!",this,lockedBy));
|
||||
} else {
|
||||
state = (state == State.STRAIGHT) ? State.LEFT : State.STRAIGHT;
|
||||
plan.stream("place "+tag(null));
|
||||
}
|
||||
return propMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,12 @@ import java.io.IOException;
|
||||
public class TurnoutR extends Turnout {
|
||||
@Override
|
||||
public Object click() throws IOException {
|
||||
state = (state == State.STRAIGHT) ? State.RIGHT : State.STRAIGHT;
|
||||
return tag(null);
|
||||
if (lockedBy != null) {
|
||||
plan.stream(t("{} is locked by {}!",this,lockedBy));
|
||||
} else {
|
||||
state = (state == State.STRAIGHT) ? State.RIGHT : State.STRAIGHT;
|
||||
plan.stream("place "+tag(null));
|
||||
}
|
||||
return propMenu();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user