diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 95d88a6dac..36603d9fc5 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -525,6 +525,7 @@ details = Details... edit = Edit variables = Vars logic.clear.confirm = Are you sure you want to clear all code from this processor? +logic.restart = Restart logic.globals = Built-in Variables editor.name = Name: diff --git a/core/src/mindustry/logic/LogicDialog.java b/core/src/mindustry/logic/LogicDialog.java index 10e0d74ed3..047e54c99c 100644 --- a/core/src/mindustry/logic/LogicDialog.java +++ b/core/src/mindustry/logic/LogicDialog.java @@ -31,7 +31,7 @@ public class LogicDialog extends BaseDialog{ boolean privileged; @Nullable LExecutor executor; GlobalVarsDialog globalsDialog = new GlobalVarsDialog(); - boolean wasRows, wasPortrait; + boolean wasRows, wasPortrait, forceRestart; public LogicDialog(){ super("logic"); @@ -142,7 +142,14 @@ public class LogicDialog extends BaseDialog{ }catch(Throwable e){ ui.showException(e); } - }).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null); + }).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null).row(); + + t.button("@logic.restart", Icon.refresh, style, () -> { + forceRestart = true; + dialog.hide(); + hide(); + }).marginLeft(12f); + }); }); @@ -336,6 +343,7 @@ public class LogicDialog extends BaseDialog{ public void show(String code, LExecutor executor, boolean privileged, Cons modified){ this.executor = executor; this.privileged = privileged; + this.forceRestart = false; canvas.statements.clearChildren(); canvas.rebuild(); canvas.privileged = privileged; @@ -346,7 +354,7 @@ public class LogicDialog extends BaseDialog{ canvas.load(""); } this.consumer = result -> { - if(!result.equals(code)){ + if(forceRestart || !result.equals(code)){ modified.get(result); } };