mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-15 15:20:57 -08:00
Logic insert line button (from foo's client)
This commit is contained in:
parent
b34ceae965
commit
c3309bf3a9
2 changed files with 15 additions and 1 deletions
|
|
@ -131,6 +131,10 @@ public class LCanvas extends Table{
|
|||
statements.addChild(new StatementElem(statement));
|
||||
}
|
||||
|
||||
public void addAt(int at, LStatement statement){
|
||||
statements.addChildAt(at, new StatementElem(statement));
|
||||
}
|
||||
|
||||
public String save(){
|
||||
Seq<LStatement> st = statements.getChildren().<StatementElem>as().map(s -> s.st);
|
||||
st.each(LStatement::saveUI);
|
||||
|
|
@ -433,6 +437,10 @@ public class LCanvas extends Table{
|
|||
|
||||
addressLabel = t.add(index + "").style(Styles.outlineLabel).color(color).padRight(8).get();
|
||||
|
||||
//taken from foo's client
|
||||
t.button(Icon.add, Styles.logici, () -> Vars.ui.logic.showAddDialog(statements.insertPosition + 1))
|
||||
.disabled(b -> canvas.statements.getChildren().size >= LExecutor.maxInstructions).size(24f).padRight(6);
|
||||
|
||||
t.button(Icon.copy, Styles.logici, () -> {
|
||||
}).size(24f).padRight(6).get().tapped(this::copy);
|
||||
|
||||
|
|
@ -447,6 +455,8 @@ public class LCanvas extends Table{
|
|||
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
//don't start dragging when pressing the menu buttons
|
||||
if(event.targetActor instanceof Image) return false;
|
||||
|
||||
if(button == KeyCode.mouseMiddle){
|
||||
copy();
|
||||
|
|
|
|||
|
|
@ -254,6 +254,10 @@ public class LogicDialog extends BaseDialog{
|
|||
}
|
||||
|
||||
public void showAddDialog(){
|
||||
showAddDialog(-1);
|
||||
}
|
||||
|
||||
public void showAddDialog(int position){
|
||||
BaseDialog dialog = new BaseDialog("@add");
|
||||
dialog.cont.table(table -> {
|
||||
String[] searchText = {""};
|
||||
|
|
@ -326,7 +330,7 @@ public class LogicDialog extends BaseDialog{
|
|||
style.font = Fonts.outline;
|
||||
|
||||
cat.button(example.name(), style, () -> {
|
||||
canvas.add(prov.get());
|
||||
canvas.addAt(position == -1 ? canvas.statements.getChildren().size : position, prov.get());
|
||||
dialog.hide();
|
||||
}).size(130f, 50f).self(c -> tooltip(c, "lst." + example.name())).top().left();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue