mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-22 05:47:44 +03:00
Fixed #4642 / Logic op reorganization
This commit is contained in:
parent
38843c25fb
commit
a99151441c
@ -41,9 +41,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||||||
boolean admin;
|
boolean admin;
|
||||||
@SyncLocal float mouseX, mouseY;
|
@SyncLocal float mouseX, mouseY;
|
||||||
String name = "noname";
|
String name = "noname";
|
||||||
String locale = "en";
|
|
||||||
Color color = new Color();
|
Color color = new Color();
|
||||||
|
|
||||||
|
//locale should not be synced.
|
||||||
|
transient String locale = "en";
|
||||||
transient float deathTimer;
|
transient float deathTimer;
|
||||||
transient String lastText = "";
|
transient String lastText = "";
|
||||||
transient float textFadeTime;
|
transient float textFadeTime;
|
||||||
|
@ -62,19 +62,18 @@ public class DesktopInput extends InputHandler{
|
|||||||
group.fill(t -> {
|
group.fill(t -> {
|
||||||
t.bottom();
|
t.bottom();
|
||||||
t.visible(() -> {
|
t.visible(() -> {
|
||||||
t.color.a = Mathf.lerpDelta(t.color.a, !isBuilding && !Core.settings.getBool("buildautopause") || player.unit().isBuilding() ? 1f : 0f, 0.15f);
|
t.color.a = Mathf.lerpDelta(t.color.a, player.unit().isBuilding() ? 1f : 0f, 0.15f);
|
||||||
|
|
||||||
return ui.hudfrag.shown && Core.settings.getBool("hints") && selectRequests.isEmpty() && t.color.a > 0.01f;
|
return ui.hudfrag.shown && Core.settings.getBool("hints") && selectRequests.isEmpty() && t.color.a > 0.01f;
|
||||||
});
|
});
|
||||||
t.touchable(() -> t.color.a < 0.1f ? Touchable.disabled : Touchable.childrenOnly);
|
t.touchable(() -> t.color.a < 0.1f ? Touchable.disabled : Touchable.childrenOnly);
|
||||||
t.table(Styles.black6, b -> {
|
t.table(Styles.black6, b -> {
|
||||||
b.defaults().left();
|
b.defaults().left();
|
||||||
b.label(() -> ((!isBuilding || !wasBuilding) && !Core.settings.getBool("buildautopause") && !player.unit().isBuilding() ?
|
b.label(() -> Core.bundle.format(!isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.toString())).style(Styles.outlineLabel);
|
||||||
Core.bundle.format("enablebuilding", Core.keybinds.get(Binding.pause_building).key.toString()) :
|
b.row();
|
||||||
Core.bundle.format(isBuilding ? "pausebuilding" : "resumebuilding", Core.keybinds.get(Binding.pause_building).key.toString()) +
|
b.label(() -> Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.toString())).style(Styles.outlineLabel);
|
||||||
"\n" + Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.toString()) +
|
b.row();
|
||||||
"\n" + Core.bundle.format("selectschematic", Core.keybinds.get(Binding.schematic_select).key.toString())
|
b.label(() -> Core.bundle.format("selectschematic", Core.keybinds.get(Binding.schematic_select).key.toString())).style(Styles.outlineLabel);
|
||||||
)).style(Styles.outlineLabel);
|
|
||||||
}).margin(10f);
|
}).margin(10f);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@ public class LAssembler{
|
|||||||
public static ObjectMap<String, Func<String[], LStatement>> customParsers = new ObjectMap<>();
|
public static ObjectMap<String, Func<String[], LStatement>> customParsers = new ObjectMap<>();
|
||||||
public static final int maxTokenLength = 36;
|
public static final int maxTokenLength = 36;
|
||||||
|
|
||||||
|
private static final StringMap opNameChanges = StringMap.of(
|
||||||
|
"atan2", "angle",
|
||||||
|
"dst", "len"
|
||||||
|
);
|
||||||
|
|
||||||
private int lastVar;
|
private int lastVar;
|
||||||
/** Maps names to variable IDs. */
|
/** Maps names to variable IDs. */
|
||||||
public ObjectMap<String, BVar> vars = new ObjectMap<>();
|
public ObjectMap<String, BVar> vars = new ObjectMap<>();
|
||||||
@ -127,6 +132,11 @@ public class LAssembler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fix up changed operaiton names
|
||||||
|
if(type.equals("op")){
|
||||||
|
arr[1] = opNameChanges.get(arr[1], arr[1]);
|
||||||
|
}
|
||||||
|
|
||||||
LStatement st = LogicIO.read(arr);
|
LStatement st = LogicIO.read(arr);
|
||||||
|
|
||||||
if(st != null){
|
if(st != null){
|
||||||
|
@ -114,7 +114,6 @@ public abstract class LStatement{
|
|||||||
t.actions(Actions.alpha(0), Actions.fadeIn(0.3f, Interp.fade));
|
t.actions(Actions.alpha(0), Actions.fadeIn(0.3f, Interp.fade));
|
||||||
|
|
||||||
t.top().pane(inner -> {
|
t.top().pane(inner -> {
|
||||||
inner.marginRight(24f);
|
|
||||||
inner.top();
|
inner.top();
|
||||||
hideCons.get(inner, hide);
|
hideCons.get(inner, hide);
|
||||||
}).top();
|
}).top();
|
||||||
|
@ -608,11 +608,20 @@ public class LStatements{
|
|||||||
}else{
|
}else{
|
||||||
row(table);
|
row(table);
|
||||||
|
|
||||||
field(table, a, str -> a = str);
|
//"function"-type operations have the name at the left and arguments on the right
|
||||||
|
if(op.func){
|
||||||
|
opButton(table);
|
||||||
|
|
||||||
opButton(table);
|
field(table, a, str -> a = str);
|
||||||
|
|
||||||
field(table, b, str -> b = str);
|
field(table, b, str -> b = str);
|
||||||
|
}else{
|
||||||
|
field(table, a, str -> a = str);
|
||||||
|
|
||||||
|
opButton(table);
|
||||||
|
|
||||||
|
field(table, b, str -> b = str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +632,7 @@ public class LStatements{
|
|||||||
op = o;
|
op = o;
|
||||||
rebuild(table);
|
rebuild(table);
|
||||||
}));
|
}));
|
||||||
}, Styles.logict, () -> {}).size(60f, 40f).pad(4f).color(table.color);
|
}, Styles.logict, () -> {}).size(65f, 40f).pad(4f).color(table.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,11 +28,11 @@ public enum LogicOp{
|
|||||||
xor("xor", (a, b) -> (long)a ^ (long)b),
|
xor("xor", (a, b) -> (long)a ^ (long)b),
|
||||||
not("flip", a -> ~(long)(a)),
|
not("flip", a -> ~(long)(a)),
|
||||||
|
|
||||||
max("max", Math::max),
|
max("max", true, Math::max),
|
||||||
min("min", Math::min),
|
min("min", true, Math::min),
|
||||||
atan2("atan2", (x, y) -> Mathf.atan2((float)x, (float)y) * Mathf.radDeg),
|
angle("angle", true, (x, y) -> Angles.angle((float)x, (float)y)),
|
||||||
dst("dst", (x, y) -> Mathf.dst((float)x, (float)y)),
|
len("len", true, (x, y) -> Mathf.dst((float)x, (float)y)),
|
||||||
noise("noise", LExecutor.noise::rawNoise2D),
|
noise("noise", true, LExecutor.noise::rawNoise2D),
|
||||||
abs("abs", a -> Math.abs(a)),
|
abs("abs", a -> Math.abs(a)),
|
||||||
log("log", Math::log),
|
log("log", Math::log),
|
||||||
log10("log10", Math::log10),
|
log10("log10", Math::log10),
|
||||||
@ -49,19 +49,29 @@ public enum LogicOp{
|
|||||||
public final OpObjLambda2 objFunction2;
|
public final OpObjLambda2 objFunction2;
|
||||||
public final OpLambda2 function2;
|
public final OpLambda2 function2;
|
||||||
public final OpLambda1 function1;
|
public final OpLambda1 function1;
|
||||||
public final boolean unary;
|
public final boolean unary, func;
|
||||||
public final String symbol;
|
public final String symbol;
|
||||||
|
|
||||||
LogicOp(String symbol, OpLambda2 function){
|
LogicOp(String symbol, OpLambda2 function){
|
||||||
this(symbol, function, null);
|
this(symbol, function, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogicOp(String symbol, boolean func, OpLambda2 function){
|
||||||
|
this.symbol = symbol;
|
||||||
|
this.function2 = function;
|
||||||
|
this.function1 = null;
|
||||||
|
this.unary = false;
|
||||||
|
this.objFunction2 = null;
|
||||||
|
this.func = func;
|
||||||
|
}
|
||||||
|
|
||||||
LogicOp(String symbol, OpLambda2 function, OpObjLambda2 objFunction){
|
LogicOp(String symbol, OpLambda2 function, OpObjLambda2 objFunction){
|
||||||
this.symbol = symbol;
|
this.symbol = symbol;
|
||||||
this.function2 = function;
|
this.function2 = function;
|
||||||
this.function1 = null;
|
this.function1 = null;
|
||||||
this.unary = false;
|
this.unary = false;
|
||||||
this.objFunction2 = objFunction;
|
this.objFunction2 = objFunction;
|
||||||
|
this.func = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicOp(String symbol, OpLambda1 function){
|
LogicOp(String symbol, OpLambda1 function){
|
||||||
@ -70,6 +80,7 @@ public enum LogicOp{
|
|||||||
this.function2 = null;
|
this.function2 = null;
|
||||||
this.unary = true;
|
this.unary = true;
|
||||||
this.objFunction2 = null;
|
this.objFunction2 = null;
|
||||||
|
this.func = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user