LStatement categories + improved UI (#7046)

* LStatement categories + improved UI

Co-authored-by: code-explorer786 <68312688+code-explorer786@users.noreply.github.com>

* annihilate LStatement#color

Co-authored-by: code-explorer786 <68312688+code-explorer786@users.noreply.github.com>
This commit is contained in:
Goobrr
2022-06-19 21:57:49 +07:00
committed by GitHub
parent a30f6325d4
commit 625f7e9936
7 changed files with 247 additions and 158 deletions

View File

@@ -6,6 +6,7 @@ import arc.graphics.*;
import arc.scene.actions.*;
import arc.scene.ui.*;
import arc.scene.ui.TextButton.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.core.GameState.*;
import mindustry.ctype.*;
@@ -154,28 +155,50 @@ public class LogicDialog extends BaseDialog{
buttons.button("@add", Icon.add, () -> {
BaseDialog dialog = new BaseDialog("@add");
dialog.cont.pane(t -> {
t.background(Tex.button);
int i = 0;
for(Prov<LStatement> prov : LogicIO.allStatements){
LStatement example = prov.get();
if(example instanceof InvalidStatement || example.hidden() || (example.privileged() && !privileged) || (example.nonPrivileged() && privileged)) continue;
dialog.cont.table(table -> {
table.background(Tex.button);
table.pane(t -> {
for(Prov<LStatement> prov : LogicIO.allStatements){
LStatement example = prov.get();
if(example instanceof InvalidStatement || example.hidden() || (example.privileged() && !privileged) || (example.nonPrivileged() && privileged)) continue;
TextButtonStyle style = new TextButtonStyle(Styles.flatt);
style.fontColor = example.color();
style.font = Fonts.outline;
LCategory category = example.category();
Table cat = t.find(category.name);
if(cat == null){
t.table(s -> {
if(category.icon != null){
s.image(category.icon, Pal.darkishGray).left().size(15f).padRight(10f);
}
s.add(category.localized()).color(Pal.darkishGray).left().tooltip(category.description());
s.image(Tex.whiteui, Pal.darkishGray).left().height(5f).growX().padLeft(10f);
}).growX().pad(5f).padTop(10f);
t.button(example.name(), style, () -> {
canvas.add(prov.get());
dialog.hide();
}).size(130f, 50f).self(c -> tooltip(c, "lst." + example.name()));
if(++i % 3 == 0) t.row();
}
});
t.row();
cat = t.table(c -> {
c.top().left();
}).name(category.name).top().left().growX().fillY().get();
t.row();
}
TextButtonStyle style = new TextButtonStyle(Styles.flatt);
style.fontColor = category.color;
style.font = Fonts.outline;
cat.button(example.name(), style, () -> {
canvas.add(prov.get());
dialog.hide();
}).size(130f, 50f).self(c -> tooltip(c, "lst." + example.name())).top().left();
if(cat.getChildren().size % 3 == 0) cat.row();
}
}).grow();
}).fill().maxHeight(Core.graphics.getHeight() * 0.8f);
dialog.addCloseButton();
dialog.show();
}).disabled(t -> canvas.statements.getChildren().size >= LExecutor.maxInstructions);
add(canvas).grow().name("canvas");
row();