improved cockpit: active functions now have colored buttons
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>1.3.29</version>
|
<version>1.3.30</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ button{
|
|||||||
margin: 2px;
|
margin: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.active{
|
||||||
|
background: green;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
#plan{
|
#plan{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ decouple : Abkuppeln
|
|||||||
decoupler : decoupler
|
decoupler : decoupler
|
||||||
Decoupler : Entkuppler
|
Decoupler : Entkuppler
|
||||||
DelayedAction : verzögerte Aktion
|
DelayedAction : verzögerte Aktion
|
||||||
|
Delay must not be less than zero! : Verzögerung darf nicht kleiner als null sein!
|
||||||
delete : entfernen
|
delete : entfernen
|
||||||
delete route : Route löschen
|
delete route : Route löschen
|
||||||
Destination : Ziel
|
Destination : Ziel
|
||||||
|
|||||||
@@ -89,16 +89,25 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
String realm = null;
|
String realm = null;
|
||||||
Train train = null;
|
Train train = null;
|
||||||
Locomotive loco = null;
|
Locomotive loco = null;
|
||||||
|
boolean fun1=false,fun2=false,fun3=false,fun4=false;
|
||||||
if (locoOrTrain instanceof Locomotive) {
|
if (locoOrTrain instanceof Locomotive) {
|
||||||
loco = (Locomotive) locoOrTrain;
|
loco = (Locomotive) locoOrTrain;
|
||||||
realm = REALM_LOCO;
|
realm = REALM_LOCO;
|
||||||
id = loco.id();
|
id = loco.id();
|
||||||
speed = loco.speed;
|
speed = loco.speed;
|
||||||
|
fun1 = loco.f1;
|
||||||
|
fun2 = loco.f2;
|
||||||
|
fun3 = loco.f3;
|
||||||
|
fun4 = loco.f4;
|
||||||
} else if (locoOrTrain instanceof Train) {
|
} else if (locoOrTrain instanceof Train) {
|
||||||
train = (Train)locoOrTrain;
|
train = (Train)locoOrTrain;
|
||||||
realm = REALM_TRAIN;
|
realm = REALM_TRAIN;
|
||||||
id = train.id();
|
id = train.id();
|
||||||
speed = train.speed;
|
speed = train.speed;
|
||||||
|
fun1 = train.getFunction(1);
|
||||||
|
fun2 = train.getFunction(2);
|
||||||
|
fun3 = train.getFunction(3);
|
||||||
|
fun4 = train.getFunction(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String,Object> params = new HashMap<String, Object>(Map.of(REALM,realm,ID,id));
|
HashMap<String,Object> params = new HashMap<String, Object>(Map.of(REALM,realm,ID,id));
|
||||||
@@ -109,10 +118,13 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
new Tag("span").content(t("Current velocity: {} {}",speed,speedUnit)).addTo(fieldset);
|
new Tag("span").content(t("Current velocity: {} {}",speed,speedUnit)).addTo(fieldset);
|
||||||
|
|
||||||
Tag par = new Tag("p");
|
Tag par = new Tag("p");
|
||||||
Map.of(t("Slower (10 {})",speedUnit),ACTION_SLOWER10,t("Faster (10 {})",speedUnit),ACTION_FASTER10).entrySet().forEach(e -> {
|
|
||||||
params.put(ACTION, e.getValue());
|
params.put(ACTION, ACTION_FASTER10);
|
||||||
new Button(t(e.getKey()),params).addTo(par);
|
new Button(t("Faster (10 {})",speedUnit),params).addTo(par);
|
||||||
});
|
|
||||||
|
params.put(ACTION, ACTION_SLOWER10);
|
||||||
|
new Button(t("Slower (10 {})",speedUnit),params).addTo(par);
|
||||||
|
|
||||||
par.addTo(fieldset);
|
par.addTo(fieldset);
|
||||||
|
|
||||||
Tag direction = new Tag("p");
|
Tag direction = new Tag("p");
|
||||||
@@ -143,10 +155,26 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
direction.addTo(fieldset);
|
direction.addTo(fieldset);
|
||||||
|
|
||||||
Tag functions = new Tag("p");
|
Tag functions = new Tag("p");
|
||||||
Map.of("F1",ACTION_TOGGLE_F1,"F2",ACTION_TOGGLE_F2,"F3",ACTION_TOGGLE_F3,"F4",ACTION_TOGGLE_F4).entrySet().stream().sorted((e1,e2)->(e1.getKey().compareTo(e2.getKey()))).forEach(e -> {
|
|
||||||
params.put(ACTION, e.getValue());
|
params.put(ACTION, ACTION_TOGGLE_F1);
|
||||||
new Button(t(e.getKey()),params).addTo(functions);
|
Button b1 = new Button(t("F1"),params);
|
||||||
});
|
if (fun1) b1.clazz("active");
|
||||||
|
b1.addTo(functions);
|
||||||
|
|
||||||
|
params.put(ACTION, ACTION_TOGGLE_F2);
|
||||||
|
Button b2 = new Button(t("F2"),params);
|
||||||
|
if (fun2) b2.clazz("active");
|
||||||
|
b2.addTo(functions);
|
||||||
|
|
||||||
|
params.put(ACTION, ACTION_TOGGLE_F3);
|
||||||
|
Button b3 = new Button(t("F3"),params);
|
||||||
|
if (fun3) b3.clazz("active");
|
||||||
|
b3.addTo(functions);
|
||||||
|
|
||||||
|
params.put(ACTION, ACTION_TOGGLE_F4);
|
||||||
|
Button b4 = new Button(t("F4"),params);
|
||||||
|
if (fun4) b4.clazz("active");
|
||||||
|
b4.addTo(functions);
|
||||||
functions.addTo(fieldset);
|
functions.addTo(fieldset);
|
||||||
|
|
||||||
return fieldset;
|
return fieldset;
|
||||||
|
|||||||
@@ -465,6 +465,21 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
return properties();
|
return properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getFunction(int num) {
|
||||||
|
switch (num) {
|
||||||
|
case 1:
|
||||||
|
return f1;
|
||||||
|
case 2:
|
||||||
|
return f2;
|
||||||
|
case 3:
|
||||||
|
return f3;
|
||||||
|
case 4:
|
||||||
|
return f4;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasLoco() {
|
private boolean hasLoco() {
|
||||||
for (Car c:cars) {
|
for (Car c:cars) {
|
||||||
if (c instanceof Locomotive) return true;
|
if (c instanceof Locomotive) return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user