Status apply statement cleanup

This commit is contained in:
Anuken
2024-12-11 14:14:08 -05:00
parent e94fd845eb
commit 1dacb7989e

View File

@@ -1324,15 +1324,11 @@ public class LStatements{
@Override @Override
public void build(Table table){ public void build(Table table){
rebuild(table);
}
void rebuild(Table table){
table.clearChildren(); table.clearChildren();
table.button(clear ? "clear" : "apply", Styles.logict, () -> { table.button(clear ? "clear" : "apply", Styles.logict, () -> {
clear = !clear; clear = !clear;
rebuild(table); build(table);
}).size(80f, 40f).pad(4f).color(table.color); }).size(80f, 40f).pad(4f).color(table.color);
if(statusNames == null){ if(statusNames == null){
@@ -1343,11 +1339,10 @@ public class LStatements{
b.label(() -> effect).grow().wrap().labelAlign(Align.center).center(); b.label(() -> effect).grow().wrap().labelAlign(Align.center).center();
b.clicked(() -> showSelect(b, statusNames, effect, o -> { b.clicked(() -> showSelect(b, statusNames, effect, o -> {
effect = o; effect = o;
build(table);
}, 2, c -> c.size(120f, 38f))); }, 2, c -> c.size(120f, 38f)));
}, Styles.logict, () -> {}).size(120f, 40f).pad(4f).color(table.color); }, Styles.logict, () -> {}).size(120f, 40f).pad(4f).color(table.color);
//TODO effect select
table.add(clear ? " from " : " to "); table.add(clear ? " from " : " to ");
row(table); row(table);
@@ -2123,69 +2118,69 @@ public class LStatements{
return LCategory.world; return LCategory.world;
} }
} }
@RegisterStatement("playsound") @RegisterStatement("playsound")
public static class PlaySoundStatement extends LStatement{ public static class PlaySoundStatement extends LStatement{
public boolean positional; public boolean positional;
public String id = "@sfx-pew", volume = "1", pitch = "1", pan = "0", x = "@thisx", y = "@thisy", limit = "true"; public String id = "@sfx-pew", volume = "1", pitch = "1", pan = "0", x = "@thisx", y = "@thisy", limit = "true";
@Override @Override
public void build(Table table){ public void build(Table table){
rebuild(table); rebuild(table);
} }
void rebuild(Table table){ void rebuild(Table table){
table.clearChildren(); table.clearChildren();
table.button(positional ? "positional" : "global", Styles.logict, () -> { table.button(positional ? "positional" : "global", Styles.logict, () -> {
positional = !positional; positional = !positional;
rebuild(table); rebuild(table);
}).size(160f, 40f).pad(4f).color(table.color); }).size(160f, 40f).pad(4f).color(table.color);
row(table); row(table);
field(table, id, str -> id = str).padRight(0f).get(); field(table, id, str -> id = str).padRight(0f).get();
table.button(b -> { table.button(b -> {
b.image(Icon.pencilSmall); b.image(Icon.pencilSmall);
String soundName = id.startsWith("@sfx-") ? id.substring(5) : id; String soundName = id.startsWith("@sfx-") ? id.substring(5) : id;
b.clicked(() -> showSelect(b, GlobalVars.soundNames.toArray(String.class), soundName, t -> { b.clicked(() -> showSelect(b, GlobalVars.soundNames.toArray(String.class), soundName, t -> {
id = "@sfx-" + t; id = "@sfx-" + t;
rebuild(table); rebuild(table);
}, 2, cell -> cell.size(160, 50))); }, 2, cell -> cell.size(160, 50)));
}, Styles.logict, () -> {}).size(40).color(table.color).left().padLeft(-1); }, Styles.logict, () -> {}).size(40).color(table.color).left().padLeft(-1);
row(table); row(table);
fieldst(table, "volume", volume, str -> volume = str); fieldst(table, "volume", volume, str -> volume = str);
fieldst(table, "pitch", pitch, str -> pitch = str); fieldst(table, "pitch", pitch, str -> pitch = str);
table.row(); table.row();
if(positional){ if(positional){
fieldst(table, "x", x, str -> x = str); fieldst(table, "x", x, str -> x = str);
fieldst(table, "y", y, str -> y = str); fieldst(table, "y", y, str -> y = str);
}else{ }else{
fieldst(table, "pan", pan, str -> pan = str); fieldst(table, "pan", pan, str -> pan = str);
} }
table.row(); table.row();
fieldst(table, "limit", limit, str -> limit = str); fieldst(table, "limit", limit, str -> limit = str);
} }
@Override @Override
public boolean privileged(){ public boolean privileged(){
return true; return true;
} }
@Override @Override
public LInstruction build(LAssembler builder){ public LInstruction build(LAssembler builder){
return new PlaySoundI(positional, builder.var(id), builder.var(volume), builder.var(pitch), builder.var(pan), builder.var(x), builder.var(y), builder.var(limit)); return new PlaySoundI(positional, builder.var(id), builder.var(volume), builder.var(pitch), builder.var(pan), builder.var(x), builder.var(y), builder.var(limit));
} }
@Override @Override
public LCategory category(){ public LCategory category(){
return LCategory.world; return LCategory.world;