QoL: provide easy way to restart processor (#10743)

This commit is contained in:
Cardillan
2025-04-30 18:46:18 +02:00
committed by GitHub
parent b4068f2a74
commit 80047eb4db
2 changed files with 12 additions and 3 deletions

View File

@@ -525,6 +525,7 @@ details = Details...
edit = Edit edit = Edit
variables = Vars variables = Vars
logic.clear.confirm = Are you sure you want to clear all code from this processor? logic.clear.confirm = Are you sure you want to clear all code from this processor?
logic.restart = Restart
logic.globals = Built-in Variables logic.globals = Built-in Variables
editor.name = Name: editor.name = Name:

View File

@@ -31,7 +31,7 @@ public class LogicDialog extends BaseDialog{
boolean privileged; boolean privileged;
@Nullable LExecutor executor; @Nullable LExecutor executor;
GlobalVarsDialog globalsDialog = new GlobalVarsDialog(); GlobalVarsDialog globalsDialog = new GlobalVarsDialog();
boolean wasRows, wasPortrait; boolean wasRows, wasPortrait, forceRestart;
public LogicDialog(){ public LogicDialog(){
super("logic"); super("logic");
@@ -142,7 +142,14 @@ public class LogicDialog extends BaseDialog{
}catch(Throwable e){ }catch(Throwable e){
ui.showException(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<String> modified){ public void show(String code, LExecutor executor, boolean privileged, Cons<String> modified){
this.executor = executor; this.executor = executor;
this.privileged = privileged; this.privileged = privileged;
this.forceRestart = false;
canvas.statements.clearChildren(); canvas.statements.clearChildren();
canvas.rebuild(); canvas.rebuild();
canvas.privileged = privileged; canvas.privileged = privileged;
@@ -346,7 +354,7 @@ public class LogicDialog extends BaseDialog{
canvas.load(""); canvas.load("");
} }
this.consumer = result -> { this.consumer = result -> {
if(!result.equals(code)){ if(forceRestart || !result.equals(code)){
modified.get(result); modified.get(result);
} }
}; };