Display jump statement destination
This commit is contained in:
@@ -217,6 +217,7 @@ public class LCanvas extends Table{
|
|||||||
|
|
||||||
e.setSize(width, e.getPrefHeight());
|
e.setSize(width, e.getPrefHeight());
|
||||||
e.setPosition(0, height - cy, Align.topLeft);
|
e.setPosition(0, height - cy, Align.topLeft);
|
||||||
|
((StatementElem)e).updateAddress(i);
|
||||||
|
|
||||||
cy += e.getPrefHeight() + space;
|
cy += e.getPrefHeight() + space;
|
||||||
seq.add(e);
|
seq.add(e);
|
||||||
@@ -316,6 +317,8 @@ public class LCanvas extends Table{
|
|||||||
|
|
||||||
public class StatementElem extends Table{
|
public class StatementElem extends Table{
|
||||||
public LStatement st;
|
public LStatement st;
|
||||||
|
public int index;
|
||||||
|
Label addressLabel;
|
||||||
|
|
||||||
public StatementElem(LStatement st){
|
public StatementElem(LStatement st){
|
||||||
this.st = st;
|
this.st = st;
|
||||||
@@ -333,9 +336,11 @@ public class LCanvas extends Table{
|
|||||||
t.margin(6f);
|
t.margin(6f);
|
||||||
t.touchable = Touchable.enabled;
|
t.touchable = Touchable.enabled;
|
||||||
|
|
||||||
t.add(st.name()).style(Styles.outlineLabel).color(color).padRight(8);
|
t.add(st.name()).style(Styles.outlineLabel).name("statement-name").color(color).padRight(8);
|
||||||
t.add().growX();
|
t.add().growX();
|
||||||
|
|
||||||
|
addressLabel = t.add(index + "").style(Styles.outlineLabel).color(color).padRight(8).get();
|
||||||
|
|
||||||
t.button(Icon.copy, Styles.logici, () -> {
|
t.button(Icon.copy, Styles.logici, () -> {
|
||||||
}).size(24f).padRight(6).get().tapped(this::copy);
|
}).size(24f).padRight(6).get().tapped(this::copy);
|
||||||
|
|
||||||
@@ -395,6 +400,11 @@ public class LCanvas extends Table{
|
|||||||
marginBottom(7);
|
marginBottom(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateAddress(int index){
|
||||||
|
this.index = index;
|
||||||
|
addressLabel.setText(index + "");
|
||||||
|
}
|
||||||
|
|
||||||
public void copy(){
|
public void copy(){
|
||||||
st.saveUI();
|
st.saveUI();
|
||||||
LStatement copy = st.copy();
|
LStatement copy = st.copy();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.logic;
|
package mindustry.logic;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
@@ -758,6 +759,20 @@ public class LStatements{
|
|||||||
|
|
||||||
table.add().growX();
|
table.add().growX();
|
||||||
table.add(new JumpButton(() -> dest, s -> dest = s)).size(30).right().padLeft(-8);
|
table.add(new JumpButton(() -> dest, s -> dest = s)).size(30).right().padLeft(-8);
|
||||||
|
|
||||||
|
String name = name();
|
||||||
|
|
||||||
|
//hack way of finding the title label...
|
||||||
|
Core.app.post(() -> {
|
||||||
|
//must be delayed because parent is added later
|
||||||
|
if(table.parent != null){
|
||||||
|
Label title = table.parent.find("statement-name");
|
||||||
|
if(title != null){
|
||||||
|
title.update(() -> title.setText((dest != null ? name + " -> " + dest.index : name)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rebuild(Table table){
|
void rebuild(Table table){
|
||||||
|
|||||||
Reference in New Issue
Block a user