make logic stuff public, cleanup

This commit is contained in:
DeltaNedas
2020-11-01 19:35:22 +00:00
parent a13f7f633e
commit cda6a6973d
5 changed files with 31 additions and 36 deletions

View File

@ -39,9 +39,7 @@ public enum LAccess{
enabled("to"), //"to" is standard for single parameter access
shoot("x", "y", "shoot"),
shootp(true, "unit", "shoot"),
configure(true, 30, "to")
;
configure(true, 30, "to");
public final String[] params;
public final boolean isObj;

View File

@ -17,9 +17,9 @@ public class LAssembler{
private int lastVar;
/** Maps names to variable IDs. */
ObjectMap<String, BVar> vars = new ObjectMap<>();
public ObjectMap<String, BVar> vars = new ObjectMap<>();
/** All instructions to be executed. */
LInstruction[] instructions;
public LInstruction[] instructions;
public LAssembler(){
//instruction counter

View File

@ -21,10 +21,10 @@ public class LCanvas extends Table{
//ew static variables
static LCanvas canvas;
DragLayout statements;
StatementElem dragging;
ScrollPane pane;
Group jumps;
public DragLayout statements;
public StatementElem dragging;
public ScrollPane pane;
public Group jumps;
float targetWidth;
public LCanvas(){
@ -69,18 +69,18 @@ public class LCanvas extends Table{
}
}
void add(LStatement statement){
public void add(LStatement statement){
statements.addChild(new StatementElem(statement));
}
String save(){
public String save(){
Seq<LStatement> st = statements.getChildren().<StatementElem>as().map(s -> s.st);
st.each(LStatement::saveUI);
return LAssembler.write(st);
}
void load(String asm){
public void load(String asm){
jumps.clear();
Seq<LStatement> statements = LAssembler.read(asm);
@ -239,7 +239,7 @@ public class LCanvas extends Table{
}
public class StatementElem extends Table{
LStatement st;
public LStatement st;
public StatementElem(LStatement st){
this.st = st;
@ -319,7 +319,7 @@ public class LCanvas extends Table{
marginBottom(7);
}
void copy(){
public void copy(){
LStatement copy = st.copy();
if(copy != null){
StatementElem s = new StatementElem(copy);
@ -345,15 +345,15 @@ public class LCanvas extends Table{
}
public static class JumpButton extends ImageButton{
Color hoverColor = Pal.place;
Color defaultColor = Color.white;
Prov<StatementElem> to;
boolean selecting;
float mx, my;
ClickListener listener;
StatementElem hovered;
public Color hoverColor = Pal.place;
public Color defaultColor = Color.white;
public Prov<StatementElem> to;
public boolean selecting;
public float mx, my;
public ClickListener listener;
public StatementElem hovered;
JumpCurve curve;
public JumpCurve curve;
public JumpButton(Prov<StatementElem> getter, Cons<StatementElem> setter){
super(Tex.logicNode, Styles.colori);
@ -421,7 +421,7 @@ public class LCanvas extends Table{
}
}
StatementElem hovered(){
public StatementElem hovered(){
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
if(e != null){
while(e != null && !(e instanceof StatementElem)){
@ -434,7 +434,7 @@ public class LCanvas extends Table{
}
public static class JumpCurve extends Element{
JumpButton button;
public JumpButton button;
public JumpCurve(JumpButton button){
this.button = button;
@ -483,7 +483,7 @@ public class LCanvas extends Table{
}
}
void drawCurve(float x, float y, float x2, float y2){
public void drawCurve(float x, float y, float x2, float y2){
Lines.stroke(4f, button.color);
Draw.alpha(parentAlpha);
@ -494,8 +494,7 @@ public class LCanvas extends Table{
x + dist, y,
x2 + dist, y2,
x2, y2,
Math.max(20, (int)(Mathf.dst(x, y, x2, y2) / 6))
);
Math.max(20, (int)(Mathf.dst(x, y, x2, y2) / 6)));
}
}
}

View File

@ -11,7 +11,7 @@ import mindustry.ui.dialogs.*;
import static mindustry.Vars.*;
public class LogicDialog extends BaseDialog{
LCanvas canvas;
public LCanvas canvas;
Cons<String> consumer = s -> {};
public LogicDialog(){
@ -25,7 +25,7 @@ public class LogicDialog extends BaseDialog{
addCloseListener();
buttons.defaults().size(160f, 64f);
buttons.button("@back", Icon.left, this::hide);
buttons.button("@back", Icon.left, this::hide).name("back");
buttons.button("@edit", Icon.edit, () -> {
BaseDialog dialog = new BaseDialog("@editor.export");
@ -53,7 +53,7 @@ public class LogicDialog extends BaseDialog{
dialog.addCloseButton();
dialog.show();
});
}).name("edit");
buttons.button("@add", Icon.add, () -> {
BaseDialog dialog = new BaseDialog("@add");
@ -79,11 +79,11 @@ public class LogicDialog extends BaseDialog{
dialog.show();
}).disabled(t -> canvas.statements.getChildren().size >= LExecutor.maxInstructions);
add(canvas).grow();
add(canvas).grow().name("canvas");
row();
add(buttons).growX();
add(buttons).growX().name("canvas");
hidden(() -> consumer.get(canvas.save()));

View File

@ -38,9 +38,7 @@ public enum LogicOp{
floor("floor", Math::floor),
ceil("ceil", Math::ceil),
sqrt("sqrt", Math::sqrt),
rand("rand", d -> Mathf.rand.nextDouble() * d),
;
rand("rand", d -> Mathf.rand.nextDouble() * d);
public static final LogicOp[] all = values();