Logic unit control
This commit is contained in:
@@ -347,9 +347,9 @@ public class LStatements{
|
||||
//Q: why don't you just use arrays for this?
|
||||
//A: arrays aren't as easy to serialize so the code generator doesn't handle them
|
||||
int c = 0;
|
||||
for(int i = 0; i < type.parameters.length; i++){
|
||||
for(int i = 0; i < type.params.length; i++){
|
||||
|
||||
fields(table, type.parameters[i], i == 0 ? p1 : i == 1 ? p2 : i == 2 ? p3 : p4, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : i == 2 ? v -> p3 = v : v -> p4 = v);
|
||||
fields(table, type.params[i], i == 0 ? p1 : i == 1 ? p2 : i == 2 ? p3 : p4, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : i == 2 ? v -> p3 = v : v -> p4 = v);
|
||||
|
||||
if(++c % 2 == 0) row(table);
|
||||
}
|
||||
@@ -376,11 +376,13 @@ public class LStatements{
|
||||
public void build(Table table){
|
||||
table.defaults().left();
|
||||
|
||||
table.add(" from ");
|
||||
if(buildFrom()){
|
||||
table.add(" from ");
|
||||
|
||||
fields(table, radar, v -> radar = v);
|
||||
fields(table, radar, v -> radar = v);
|
||||
|
||||
row(table);
|
||||
row(table);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++){
|
||||
int fi = i;
|
||||
@@ -420,6 +422,10 @@ public class LStatements{
|
||||
fields(table, output, v -> output = v);
|
||||
}
|
||||
|
||||
public boolean buildFrom(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category(){
|
||||
return LCategory.blocks;
|
||||
@@ -694,4 +700,95 @@ public class LStatements{
|
||||
return LCategory.control;
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("ubind")
|
||||
public static class UnitBindStatement extends LStatement{
|
||||
public String type = "@mono";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
table.add(" type ");
|
||||
|
||||
field(table, type, str -> type = str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category(){
|
||||
return LCategory.units;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new UnitBindI(builder.var(type));
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("ucontrol")
|
||||
public static class UnitControlStatement extends LStatement{
|
||||
public LUnitControl type = LUnitControl.move;
|
||||
public String p1 = "0", p2 = "0", p3 = "0", p4 = "0";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
rebuild(table);
|
||||
}
|
||||
|
||||
void rebuild(Table table){
|
||||
table.clearChildren();
|
||||
|
||||
table.left();
|
||||
|
||||
table.add(" ");
|
||||
|
||||
table.button(b -> {
|
||||
b.label(() -> type.name());
|
||||
b.clicked(() -> showSelect(b, LUnitControl.all, type, t -> {
|
||||
type = t;
|
||||
rebuild(table);
|
||||
}, 2, cell -> cell.size(120, 50)));
|
||||
}, Styles.logict, () -> {}).size(120, 40).color(table.color).left().padLeft(2);
|
||||
|
||||
row(table);
|
||||
|
||||
//Q: why don't you just use arrays for this?
|
||||
//A: arrays aren't as easy to serialize so the code generator doesn't handle them
|
||||
int c = 0;
|
||||
for(int i = 0; i < type.params.length; i++){
|
||||
|
||||
fields(table, type.params[i], i == 0 ? p1 : i == 1 ? p2 : i == 2 ? p3 : p4, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : i == 2 ? v -> p3 = v : v -> p4 = v).width(110f);
|
||||
|
||||
if(++c % 2 == 0) row(table);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category(){
|
||||
return LCategory.units;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new UnitControlI(type, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4));
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("uradar")
|
||||
public static class UnitRadarStatement extends RadarStatement{
|
||||
|
||||
@Override
|
||||
public boolean buildFrom(){
|
||||
//do not build the "from" section
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category(){
|
||||
return LCategory.units;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new RadarI(target1, target2, target3, sort, LExecutor.varUnit, builder.var(sortOrder), builder.var(output));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user