Improvements to the Schematics UI (#8605)
* schematics UI improvements * better edit tags UI * visual tweaks * cleanup inline obsession cleanup again... another little bit of cleanup a little bit of cleanup minor cleanup
This commit is contained in:
@@ -803,7 +803,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}
|
||||
|
||||
if(i == 0){
|
||||
blockSelection.add("@none.found").color(Color.lightGray).padLeft(54f).padTop(10f);
|
||||
blockSelection.add("@none.found").padLeft(54f).padTop(10f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package mindustry.editor;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
@@ -11,65 +13,60 @@ import mindustry.ui.dialogs.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapLoadDialog extends BaseDialog{
|
||||
private Map selected = null;
|
||||
private @Nullable Map selected = null;
|
||||
|
||||
public MapLoadDialog(Cons<Map> loader){
|
||||
super("@editor.loadmap");
|
||||
|
||||
shown(this::rebuild);
|
||||
hidden(() -> selected = null);
|
||||
onResize(this::rebuild);
|
||||
|
||||
TextButton button = new TextButton("@load");
|
||||
button.setDisabled(() -> selected == null);
|
||||
button.clicked(() -> {
|
||||
buttons.defaults().size(210f, 64f);
|
||||
buttons.button("@cancel", Icon.cancel, this::hide);
|
||||
buttons.button("@load", Icon.ok, () -> {
|
||||
if(selected != null){
|
||||
loader.get(selected);
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
buttons.defaults().size(200f, 50f);
|
||||
buttons.button("@cancel", this::hide);
|
||||
buttons.add(button);
|
||||
}).disabled(b -> selected == null);
|
||||
addCloseListener();
|
||||
makeButtonOverlay();
|
||||
}
|
||||
|
||||
public void rebuild(){
|
||||
cont.clear();
|
||||
if(maps.all().size > 0){
|
||||
selected = maps.all().first();
|
||||
}
|
||||
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
|
||||
int maxcol = 3;
|
||||
ButtonGroup<Button> group = new ButtonGroup<>();
|
||||
|
||||
int i = 0;
|
||||
int cols = Math.max((int)(Core.graphics.getWidth() / Scl.scl(250f)), 1);
|
||||
|
||||
Table table = new Table();
|
||||
table.defaults().size(200f, 90f).pad(4f);
|
||||
table.defaults().size(250f, 90f).pad(4f);
|
||||
table.margin(10f);
|
||||
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
pane.setFadeScrollBars(false);
|
||||
pane.setScrollingDisabledX(true);
|
||||
|
||||
for(Map map : maps.all()){
|
||||
table.button(b -> {
|
||||
b.add(new BorderImage(map.safeTexture(), 2f).setScaling(Scaling.fit)).padLeft(5f).size(16 * 4f);
|
||||
b.add(map.name()).wrap().grow().labelAlign(Align.center).padLeft(5f);
|
||||
}, Styles.squareTogglet, () -> selected = map).group(group).checked(b -> selected == map);
|
||||
|
||||
TextButton button = new TextButton(map.name(), Styles.flatTogglet);
|
||||
button.add(new BorderImage(map.safeTexture(), 2f).setScaling(Scaling.fit)).padLeft(5f).size(16 * 4f);
|
||||
button.getCells().reverse();
|
||||
button.clicked(() -> selected = map);
|
||||
button.getLabelCell().grow().left().padLeft(5f);
|
||||
group.add(button);
|
||||
table.add(button);
|
||||
if(++i % maxcol == 0) table.row();
|
||||
if(++i % cols == 0) table.row();
|
||||
}
|
||||
|
||||
group.uncheckAll();
|
||||
|
||||
if(maps.all().isEmpty()){
|
||||
table.add("@maps.none").center();
|
||||
}else{
|
||||
cont.add("@editor.selectmap");
|
||||
}
|
||||
|
||||
cont.row();
|
||||
cont.add(pane).growX();
|
||||
cont.add(pane);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
|
||||
private Table table;
|
||||
private int search = -1;
|
||||
private UnitType lastType = UnitTypes.dagger;
|
||||
private @Nullable UnitType filterType;
|
||||
private Sort sort = Sort.begin;
|
||||
private boolean reverseSort = false;
|
||||
@@ -160,7 +159,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
start = Math.max(search - (displayed / 2) - (displayed % 2), 0);
|
||||
buildGroups();
|
||||
}).growX().maxTextLength(8).get().setMessageText("@waves.search");
|
||||
s.button(Icon.units, Styles.emptyi, () -> showUnits(type -> filterType = type, true)).size(46f).tooltip("@waves.filter.unit")
|
||||
s.button(Icon.units, Styles.emptyi, () -> showUnits(type -> filterType = type, true)).size(46f).tooltip("@waves.filter")
|
||||
.update(b -> b.getStyle().imageUp = filterType != null ? new TextureRegionDrawable(filterType.uiIcon) : Icon.filter);
|
||||
}).growX().pad(6f).row();
|
||||
|
||||
@@ -168,10 +167,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
|
||||
main.table(t -> {
|
||||
t.button("@add", () -> {
|
||||
SpawnGroup newGroup = new SpawnGroup(lastType);
|
||||
groups.add(newGroup);
|
||||
expandedGroup = newGroup;
|
||||
showUnits(type -> newGroup.type = lastType = type, false);
|
||||
showUnits(type -> groups.add(expandedGroup = new SpawnGroup(type)), false);
|
||||
buildGroups();
|
||||
}).growX().height(70f);
|
||||
|
||||
@@ -233,9 +229,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
b.label(() -> (group.begin + 1) + "").color(Color.lightGray).minWidth(45f).labelAlign(Align.left).left();
|
||||
|
||||
b.button(Icon.copySmall, Styles.emptyi, () -> {
|
||||
SpawnGroup copy = group.copy();
|
||||
expandedGroup = copy;
|
||||
groups.insert(groups.indexOf(group) + 1, copy);
|
||||
groups.insert(groups.indexOf(group) + 1, expandedGroup = group.copy());
|
||||
buildGroups();
|
||||
}).pad(-6).size(46f).tooltip("@editor.copy");
|
||||
|
||||
@@ -244,7 +238,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
Icon.logicSmall,
|
||||
Styles.emptyi, () -> showEffects(group)).pad(-6).size(46f).scaling(Scaling.fit).tooltip(group.effect != null ? group.effect.localizedName : "@none");
|
||||
|
||||
b.button(Icon.unitsSmall, Styles.emptyi, () -> showUnits(type -> group.type = lastType = type, false)).pad(-6).size(46f).tooltip("@stat.unittype");
|
||||
b.button(Icon.unitsSmall, Styles.emptyi, () -> showUnits(type -> group.type = type, false)).pad(-6).size(46f).tooltip("@stat.unittype");
|
||||
b.button(Icon.cancel, Styles.emptyi, () -> {
|
||||
groups.remove(group);
|
||||
if(expandedGroup == group) expandedGroup = null;
|
||||
@@ -253,9 +247,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
buildGroups();
|
||||
}).pad(-6).size(46f).padRight(-12f).tooltip("@waves.remove");
|
||||
b.clicked(KeyCode.mouseMiddle, () -> {
|
||||
SpawnGroup copy = group.copy();
|
||||
groups.insert(groups.indexOf(group) + 1, copy);
|
||||
expandedGroup = copy;
|
||||
groups.insert(groups.indexOf(group) + 1, expandedGroup = group.copy());
|
||||
buildGroups();
|
||||
});
|
||||
}, () -> {
|
||||
@@ -415,8 +407,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
}
|
||||
|
||||
void showUnits(Cons<UnitType> cons, boolean reset){
|
||||
BaseDialog dialog = new BaseDialog("");
|
||||
dialog.setFillParent(true);
|
||||
BaseDialog dialog = new BaseDialog(reset ? "@waves.filter" : "");
|
||||
dialog.cont.pane(p -> {
|
||||
p.defaults().pad(2).fillX();
|
||||
if(reset){
|
||||
@@ -444,40 +435,39 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
}).margin(12f);
|
||||
if(++i % 3 == 0) p.row();
|
||||
}
|
||||
}).growX().scrollX(false);
|
||||
}).scrollX(false);
|
||||
dialog.addCloseButton();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
void showEffects(SpawnGroup group){
|
||||
BaseDialog dialog = new BaseDialog("");
|
||||
dialog.setFillParent(true);
|
||||
dialog.cont.pane(p -> {
|
||||
int i = 0;
|
||||
p.defaults().pad(2).fillX();
|
||||
p.button(t -> {
|
||||
t.left();
|
||||
t.image(Icon.none).size(8 * 4).scaling(Scaling.fit).padRight(2f);
|
||||
t.add("@settings.resetKey");
|
||||
}, () -> {
|
||||
group.effect = null;
|
||||
dialog.hide();
|
||||
buildGroups();
|
||||
}).margin(12f);
|
||||
int i = 1;
|
||||
for(StatusEffect effect : content.statusEffects()){
|
||||
if(effect != StatusEffects.none && (effect.isHidden() || effect.reactive)) continue;
|
||||
|
||||
if(effect.isHidden() || effect.reactive) continue;
|
||||
p.button(t -> {
|
||||
t.left();
|
||||
if(effect.uiIcon != null && effect != StatusEffects.none){
|
||||
t.image(effect.uiIcon).size(8 * 4).scaling(Scaling.fit).padRight(2f);
|
||||
}else{
|
||||
t.image(Icon.none).size(8 * 4).scaling(Scaling.fit).padRight(2f);
|
||||
}
|
||||
|
||||
if(effect != StatusEffects.none){
|
||||
t.add(effect.localizedName);
|
||||
}else{
|
||||
t.add("@settings.resetKey");
|
||||
}
|
||||
t.image(effect.uiIcon).size(8 * 4).scaling(Scaling.fit).padRight(2f);
|
||||
t.add(effect.localizedName);
|
||||
}, () -> {
|
||||
group.effect = effect != StatusEffects.none ? effect : null;
|
||||
group.effect = effect;
|
||||
dialog.hide();
|
||||
buildGroups();
|
||||
}).pad(2).margin(12f).fillX();
|
||||
}).margin(12f);
|
||||
if(++i % 3 == 0) p.row();
|
||||
}
|
||||
}).growX().scrollX(false);
|
||||
}).scrollX(false);
|
||||
dialog.addCloseButton();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user