boolean selection
This commit is contained in:
@@ -2158,6 +2158,8 @@ lenum.getblock = Fetch a building and type at coordinates.\nUnit must be in rang
|
|||||||
lenum.within = Check if unit is near a position.
|
lenum.within = Check if unit is near a position.
|
||||||
lenum.boost = Start/stop boosting.
|
lenum.boost = Start/stop boosting.
|
||||||
|
|
||||||
|
lbool.wave-natural.false = Will not increment the wave counter.
|
||||||
|
|
||||||
#Don't translate these yet!
|
#Don't translate these yet!
|
||||||
onset.commandmode = Hold [accent]shift[] to enter [accent]command mode[].\n[accent]Left-click and drag[] to select units.\n[accent]Right-click[] to order selected units to move or attack.
|
onset.commandmode = Hold [accent]shift[] to enter [accent]command mode[].\n[accent]Left-click and drag[] to select units.\n[accent]Right-click[] to order selected units to move or attack.
|
||||||
onset.commandmode.mobile = Press the [accent]command button[] to enter [accent]command mode[].\nHold down a finger, then [accent]drag[] to select units.\n[accent]Tap[] to order selected units to move or attack.
|
onset.commandmode.mobile = Press the [accent]command button[] to enter [accent]command mode[].\nHold down a finger, then [accent]drag[] to select units.\n[accent]Tap[] to order selected units to move or attack.
|
||||||
|
|||||||
@@ -260,10 +260,11 @@ public class LExecutor{
|
|||||||
public static class UnitLocateI implements LInstruction{
|
public static class UnitLocateI implements LInstruction{
|
||||||
public LLocate locate = LLocate.building;
|
public LLocate locate = LLocate.building;
|
||||||
public BlockFlag flag = BlockFlag.core;
|
public BlockFlag flag = BlockFlag.core;
|
||||||
public int enemy, ore;
|
public int ore;
|
||||||
|
public boolean enemy;
|
||||||
public int outX, outY, outFound, outBuild;
|
public int outX, outY, outFound, outBuild;
|
||||||
|
|
||||||
public UnitLocateI(LLocate locate, BlockFlag flag, int enemy, int ore, int outX, int outY, int outFound, int outBuild){
|
public UnitLocateI(LLocate locate, BlockFlag flag, boolean enemy, int ore, int outX, int outY, int outFound, int outBuild){
|
||||||
this.locate = locate;
|
this.locate = locate;
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
this.enemy = enemy;
|
this.enemy = enemy;
|
||||||
@@ -298,7 +299,7 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case building -> {
|
case building -> {
|
||||||
Building b = Geometry.findClosest(unit.x, unit.y, exec.bool(enemy) ? indexer.getEnemy(unit.team, flag) : indexer.getFlagged(unit.team, flag));
|
Building b = Geometry.findClosest(unit.x, unit.y, enemy ? indexer.getEnemy(unit.team, flag) : indexer.getFlagged(unit.team, flag));
|
||||||
res = b == null ? null : b.tile;
|
res = b == null ? null : b.tile;
|
||||||
build = true;
|
build = true;
|
||||||
}
|
}
|
||||||
@@ -1530,9 +1531,10 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class ExplosionI implements LInstruction{
|
public static class ExplosionI implements LInstruction{
|
||||||
public int team, x, y, radius, damage, air, ground, pierce;
|
public int team, x, y, radius, damage;
|
||||||
|
public boolean air, ground, pierce;
|
||||||
|
|
||||||
public ExplosionI(int team, int x, int y, int radius, int damage, int air, int ground, int pierce){
|
public ExplosionI(int team, int x, int y, int radius, int damage, boolean air, boolean ground, boolean pierce){
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -1552,7 +1554,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
Team t = exec.team(team);
|
Team t = exec.team(team);
|
||||||
//note that there is a radius cap
|
//note that there is a radius cap
|
||||||
Call.logicExplosion(t, World.unconv(exec.numf(x)), World.unconv(exec.numf(y)), World.unconv(Math.min(exec.numf(radius), 100)), exec.numf(damage), exec.bool(air), exec.bool(ground), exec.bool(pierce));
|
Call.logicExplosion(t, World.unconv(exec.numf(x)), World.unconv(exec.numf(y)), World.unconv(Math.min(exec.numf(radius), 100)), exec.numf(damage), air, ground, pierce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1611,9 +1613,10 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SetFlagI implements LInstruction{
|
public static class SetFlagI implements LInstruction{
|
||||||
public int flag, value;
|
public int flag;
|
||||||
|
public boolean value;
|
||||||
|
|
||||||
public SetFlagI(int flag, int value){
|
public SetFlagI(int flag, boolean value){
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
@@ -1624,7 +1627,7 @@ public class LExecutor{
|
|||||||
@Override
|
@Override
|
||||||
public void run(LExecutor exec){
|
public void run(LExecutor exec){
|
||||||
if(exec.obj(flag) instanceof String str){
|
if(exec.obj(flag) instanceof String str){
|
||||||
if(!exec.bool(value)){
|
if(!value){
|
||||||
state.rules.objectiveFlags.remove(str);
|
state.rules.objectiveFlags.remove(str);
|
||||||
}else{
|
}else{
|
||||||
state.rules.objectiveFlags.add(str);
|
state.rules.objectiveFlags.add(str);
|
||||||
@@ -1634,13 +1637,13 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SpawnWaveI implements LInstruction{
|
public static class SpawnWaveI implements LInstruction{
|
||||||
public int natural;
|
public boolean natural;
|
||||||
public int x, y;
|
public int x, y;
|
||||||
|
|
||||||
public SpawnWaveI(){
|
public SpawnWaveI(){
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpawnWaveI(int natural, int x, int y){
|
public SpawnWaveI(boolean natural, int x, int y){
|
||||||
this.natural = natural;
|
this.natural = natural;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -1650,7 +1653,7 @@ public class LExecutor{
|
|||||||
public void run(LExecutor exec){
|
public void run(LExecutor exec){
|
||||||
if(net.client()) return;
|
if(net.client()) return;
|
||||||
|
|
||||||
if(exec.bool(natural)){
|
if(natural){
|
||||||
logic.skipWave(); //TODO: Does this sync?
|
logic.skipWave(); //TODO: Does this sync?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,23 @@ public abstract class LStatement{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void boolSelect(Button b, String name, boolean current, Boolc getter){
|
||||||
|
showSelectTable(b, (t, hide) -> {
|
||||||
|
ButtonGroup<Button> group = new ButtonGroup<>();
|
||||||
|
int i = 0;
|
||||||
|
t.defaults().size(60f, 38f);
|
||||||
|
|
||||||
|
for(boolean bool : Mathf.booleans){
|
||||||
|
t.button(String.valueOf(bool), Styles.logicTogglet, () -> {
|
||||||
|
getter.get(bool);
|
||||||
|
hide.run();
|
||||||
|
}).self(c -> {
|
||||||
|
tooltip(c, "lbool." + name + "." + bool);
|
||||||
|
}).checked(current == bool).group(group);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected <T> void showSelect(Button b, T[] values, T current, Cons<T> getter, int cols, Cons<Cell> sizer){
|
protected <T> void showSelect(Button b, T[] values, T current, Cons<T> getter, int cols, Cons<Cell> sizer){
|
||||||
showSelectTable(b, (t, hide) -> {
|
showSelectTable(b, (t, hide) -> {
|
||||||
ButtonGroup<Button> group = new ButtonGroup<>();
|
ButtonGroup<Button> group = new ButtonGroup<>();
|
||||||
|
|||||||
@@ -969,7 +969,8 @@ public class LStatements{
|
|||||||
public static class UnitLocateStatement extends LStatement{
|
public static class UnitLocateStatement extends LStatement{
|
||||||
public LLocate locate = LLocate.building;
|
public LLocate locate = LLocate.building;
|
||||||
public BlockFlag flag = BlockFlag.core;
|
public BlockFlag flag = BlockFlag.core;
|
||||||
public String enemy = "true", ore = "@copper";
|
public String ore = "@copper";
|
||||||
|
public boolean enemy = true;
|
||||||
public String outX = "outx", outY = "outy", outFound = "found", outBuild = "building";
|
public String outX = "outx", outY = "outy", outFound = "found", outBuild = "building";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1000,9 +1001,13 @@ public class LStatements{
|
|||||||
}, Styles.logict, () -> {}).size(110, 40).color(table.color).left().padLeft(2);
|
}, Styles.logict, () -> {}).size(110, 40).color(table.color).left().padLeft(2);
|
||||||
row(table);
|
row(table);
|
||||||
|
|
||||||
table.add(" enemy ").left().self(this::param);
|
table.add(" enemy ");
|
||||||
|
table.button(b -> {
|
||||||
fields(table, enemy, str -> enemy = str);
|
b.label(() -> String.valueOf(enemy)).growX().wrap().labelAlign(Align.center);
|
||||||
|
b.clicked(() -> boolSelect(b, "loc-enemy", enemy, o -> {
|
||||||
|
enemy = o;
|
||||||
|
}));
|
||||||
|
}, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color);
|
||||||
|
|
||||||
table.row();
|
table.row();
|
||||||
}
|
}
|
||||||
@@ -1065,7 +1070,7 @@ public class LStatements{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LInstruction build(LAssembler builder){
|
public LInstruction build(LAssembler builder){
|
||||||
return new UnitLocateI(locate, flag, builder.var(enemy), builder.var(ore), builder.var(outX), builder.var(outY), builder.var(outFound), builder.var(outBuild));
|
return new UnitLocateI(locate, flag, enemy, builder.var(ore), builder.var(outX), builder.var(outY), builder.var(outFound), builder.var(outBuild));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1291,21 +1296,33 @@ public class LStatements{
|
|||||||
|
|
||||||
@RegisterStatement("spawnwave")
|
@RegisterStatement("spawnwave")
|
||||||
public static class SpawnWaveStatement extends LStatement{
|
public static class SpawnWaveStatement extends LStatement{
|
||||||
public String natural = "false";
|
public boolean natural = false;
|
||||||
public String x = "10", y = "10";
|
public String x = "10", y = "10";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table){
|
public void build(Table table){
|
||||||
table.add("natural ");
|
rebuild(table);
|
||||||
fields(table, natural, str -> {
|
}
|
||||||
natural = str;
|
|
||||||
});
|
|
||||||
|
|
||||||
table.add("x ").visible(() -> natural.equals("false"));
|
public void rebuild(Table table){
|
||||||
fields(table, x, str -> x = str).visible(() -> natural.equals("false"));
|
table.clearChildren();
|
||||||
|
|
||||||
table.add(" y ").visible(() -> natural.equals("false"));
|
table.add("natural").padLeft(10);
|
||||||
fields(table, y, str -> y = str).visible(() -> natural.equals("false"));
|
table.button(b -> {
|
||||||
|
b.label(() -> String.valueOf(natural)).growX().wrap().labelAlign(Align.center);
|
||||||
|
b.clicked(() -> boolSelect(b, "wave-natural", natural, o -> {
|
||||||
|
natural = o;
|
||||||
|
rebuild(table);
|
||||||
|
}));
|
||||||
|
}, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color);
|
||||||
|
|
||||||
|
|
||||||
|
if(natural) return;
|
||||||
|
table.add(" x ");
|
||||||
|
fields(table, x, str -> x = str);
|
||||||
|
|
||||||
|
table.add(" y ");
|
||||||
|
fields(table, y, str -> y = str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1315,7 +1332,7 @@ public class LStatements{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LInstruction build(LAssembler builder){
|
public LInstruction build(LAssembler builder){
|
||||||
return new SpawnWaveI(builder.var(natural), builder.var(x), builder.var(y));
|
return new SpawnWaveI(natural, builder.var(x), builder.var(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1493,7 +1510,8 @@ public class LStatements{
|
|||||||
|
|
||||||
@RegisterStatement("explosion")
|
@RegisterStatement("explosion")
|
||||||
public static class ExplosionStatement extends LStatement{
|
public static class ExplosionStatement extends LStatement{
|
||||||
public String team = "@crux", x = "0", y = "0", radius = "5", damage = "50", air = "true", ground = "true", pierce = "false";
|
public String team = "@crux", x = "0", y = "0", radius = "5", damage = "50";
|
||||||
|
public boolean air = true, ground = true, pierce = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table){
|
public void build(Table table){
|
||||||
@@ -1504,10 +1522,28 @@ public class LStatements{
|
|||||||
fields(table, "radius", radius, str -> radius = str);
|
fields(table, "radius", radius, str -> radius = str);
|
||||||
table.row();
|
table.row();
|
||||||
fields(table, "damage", damage, str -> damage = str);
|
fields(table, "damage", damage, str -> damage = str);
|
||||||
fields(table, "air", air, str -> air = str);
|
table.add("air");;
|
||||||
|
table.button(b -> {
|
||||||
|
b.label(() -> String.valueOf(air)).growX().wrap().labelAlign(Align.center);
|
||||||
|
b.clicked(() -> boolSelect(b, "exp-air", air, o -> {
|
||||||
|
air = o;
|
||||||
|
}));
|
||||||
|
}, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color);
|
||||||
row(table);
|
row(table);
|
||||||
fields(table, "ground", ground, str -> ground = str);
|
table.add("ground");
|
||||||
fields(table, "pierce", pierce, str -> pierce = str);
|
table.button(b -> {
|
||||||
|
b.label(() -> String.valueOf(ground)).growX().wrap().labelAlign(Align.center);
|
||||||
|
b.clicked(() -> boolSelect(b, "exp-ground", ground, o -> {
|
||||||
|
ground = o;
|
||||||
|
}));
|
||||||
|
}, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color);
|
||||||
|
table.add("pierce");
|
||||||
|
table.button(b -> {
|
||||||
|
b.label(() -> String.valueOf(pierce)).growX().wrap().labelAlign(Align.center);
|
||||||
|
b.clicked(() -> boolSelect(b, "exp-pierce", pierce, o -> {
|
||||||
|
pierce = o;
|
||||||
|
}));
|
||||||
|
}, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1517,7 +1553,7 @@ public class LStatements{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LInstruction build(LAssembler b){
|
public LInstruction build(LAssembler b){
|
||||||
return new ExplosionI(b.var(team), b.var(x), b.var(y), b.var(radius), b.var(damage), b.var(air), b.var(ground), b.var(pierce));
|
return new ExplosionI(b.var(team), b.var(x), b.var(y), b.var(radius), b.var(damage), air, ground, pierce);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1642,7 +1678,8 @@ public class LStatements{
|
|||||||
|
|
||||||
@RegisterStatement("setflag")
|
@RegisterStatement("setflag")
|
||||||
public static class SetFlagStatement extends LStatement{
|
public static class SetFlagStatement extends LStatement{
|
||||||
public String flag = "\"flag\"", value = "true";
|
public String flag = "\"flag\"";
|
||||||
|
public boolean value = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table){
|
public void build(Table table){
|
||||||
@@ -1650,7 +1687,12 @@ public class LStatements{
|
|||||||
|
|
||||||
table.add(" = ");
|
table.add(" = ");
|
||||||
|
|
||||||
fields(table, value, str -> value = str);
|
table.button(b -> {
|
||||||
|
b.label(() -> String.valueOf(value)).growX().wrap().labelAlign(Align.center);
|
||||||
|
b.clicked(() -> boolSelect(b, "flag-value", value, o -> {
|
||||||
|
value = o;
|
||||||
|
}));
|
||||||
|
}, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1660,7 +1702,7 @@ public class LStatements{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LInstruction build(LAssembler builder){
|
public LInstruction build(LAssembler builder){
|
||||||
return new SetFlagI(builder.var(flag), builder.var(value));
|
return new SetFlagI(builder.var(flag), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user