Better UI for certain dialogs
This commit is contained in:
@@ -675,7 +675,7 @@ public class Blocks implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
disassembler = new Separator("disassembler"){{
|
disassembler = new Separator("disassembler"){{
|
||||||
requirements(Category.crafting, ItemStack.with(Items.graphite, 150, Items.titanium, 100, Items.silicon, 150, Items.surgealloy, 70));
|
requirements(Category.crafting, ItemStack.with(Items.graphite, 140, Items.titanium, 100, Items.silicon, 150, Items.surgealloy, 70));
|
||||||
results = ItemStack.with(
|
results = ItemStack.with(
|
||||||
Items.sand, 4,
|
Items.sand, 4,
|
||||||
Items.graphite, 2,
|
Items.graphite, 2,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class CustomGameDialog extends BaseDialog{
|
|||||||
ScrollPane pane = new ScrollPane(maps);
|
ScrollPane pane = new ScrollPane(maps);
|
||||||
pane.setFadeScrollBars(false);
|
pane.setFadeScrollBars(false);
|
||||||
|
|
||||||
int maxwidth = Mathf.clamp((int)(Core.graphics.getWidth() / Scl.scl(200)), 1, 8);
|
int maxwidth = Math.max((int)(Core.graphics.getWidth() / Scl.scl(210)), 1);
|
||||||
float images = 146f;
|
float images = 146f;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -31,12 +31,11 @@ public class LoadDialog extends BaseDialog{
|
|||||||
super(title);
|
super(title);
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
shown(() -> {
|
shown(this::setup);
|
||||||
setup();
|
onResize(this::setup);
|
||||||
Time.runTask(2f, () -> Core.scene.setScrollFocus(pane));
|
|
||||||
});
|
|
||||||
|
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
addSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setup(){
|
protected void setup(){
|
||||||
@@ -47,16 +46,22 @@ public class LoadDialog extends BaseDialog{
|
|||||||
pane.setFadeScrollBars(false);
|
pane.setFadeScrollBars(false);
|
||||||
pane.setScrollingDisabled(true, false);
|
pane.setScrollingDisabled(true, false);
|
||||||
|
|
||||||
slots.marginRight(24);
|
slots.marginRight(24).marginLeft(20f);
|
||||||
|
|
||||||
Time.runTask(2f, () -> Core.scene.setScrollFocus(pane));
|
Time.runTask(2f, () -> Core.scene.setScrollFocus(pane));
|
||||||
|
|
||||||
Array<SaveSlot> array = control.saves.getSaveSlots();
|
Array<SaveSlot> array = control.saves.getSaveSlots();
|
||||||
array.sort((slot, other) -> -Long.compare(slot.getTimestamp(), other.getTimestamp()));
|
array.sort((slot, other) -> -Long.compare(slot.getTimestamp(), other.getTimestamp()));
|
||||||
|
|
||||||
|
int maxwidth = Math.max((int)(Core.graphics.getWidth() / Scl.scl(470)), 1);
|
||||||
|
int i = 0;
|
||||||
|
boolean any = false;
|
||||||
|
|
||||||
for(SaveSlot slot : array){
|
for(SaveSlot slot : array){
|
||||||
if(slot.isHidden()) continue;
|
if(slot.isHidden()) continue;
|
||||||
|
|
||||||
|
any = true;
|
||||||
|
|
||||||
TextButton button = new TextButton("", Styles.cleart);
|
TextButton button = new TextButton("", Styles.cleart);
|
||||||
button.getLabel().remove();
|
button.getLabel().remove();
|
||||||
button.clearChildren();
|
button.clearChildren();
|
||||||
@@ -97,8 +102,8 @@ public class LoadDialog extends BaseDialog{
|
|||||||
String color = "[lightgray]";
|
String color = "[lightgray]";
|
||||||
TextureRegion def = Core.atlas.find("nomap");
|
TextureRegion def = Core.atlas.find("nomap");
|
||||||
|
|
||||||
button.left().add(new BorderImage(def, 4f)).update(i -> {
|
button.left().add(new BorderImage(def, 4f)).update(im -> {
|
||||||
TextureRegionDrawable draw = (TextureRegionDrawable)i.getDrawable();
|
TextureRegionDrawable draw = (TextureRegionDrawable)im.getDrawable();
|
||||||
if(draw.getRegion().getTexture().isDisposed()){
|
if(draw.getRegion().getTexture().isDisposed()){
|
||||||
draw.setRegion(def);
|
draw.setRegion(def);
|
||||||
}
|
}
|
||||||
@@ -107,7 +112,7 @@ public class LoadDialog extends BaseDialog{
|
|||||||
if(draw.getRegion() == def && text != null){
|
if(draw.getRegion() == def && text != null){
|
||||||
draw.setRegion(new TextureRegion(text));
|
draw.setRegion(new TextureRegion(text));
|
||||||
}
|
}
|
||||||
i.setScaling(Scaling.fit);
|
im.setScaling(Scaling.fit);
|
||||||
}).left().size(160f).padRight(6);
|
}).left().size(160f).padRight(6);
|
||||||
|
|
||||||
button.table(meta -> {
|
button.table(meta -> {
|
||||||
@@ -128,27 +133,23 @@ public class LoadDialog extends BaseDialog{
|
|||||||
|
|
||||||
modifyButton(button, slot);
|
modifyButton(button, slot);
|
||||||
|
|
||||||
slots.add(button).uniformX().fillX().pad(4).padRight(-4).margin(10f).row();
|
slots.add(button).uniformX().fillX().pad(4).padRight(8f).margin(10f);
|
||||||
|
|
||||||
|
if(++i % maxwidth == 0){
|
||||||
|
slots.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!any){
|
||||||
|
slots.button("$save.none", () -> {}).disabled(true).fillX().margin(20f).minWidth(340f).height(80f).pad(4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
cont.add(pane);
|
cont.add(pane);
|
||||||
|
|
||||||
addSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSetup(){
|
public void addSetup(){
|
||||||
boolean valids = false;
|
|
||||||
for(SaveSlot slot : control.saves.getSaveSlots()) if(!slot.isHidden()) valids = true;
|
|
||||||
|
|
||||||
if(!valids){
|
buttons.button("$save.import", Icon.add, () -> {
|
||||||
slots.row();
|
|
||||||
slots.button("$save.none", () -> {
|
|
||||||
}).disabled(true).fillX().margin(20f).minWidth(340f).height(80f).pad(4f);
|
|
||||||
}
|
|
||||||
|
|
||||||
slots.row();
|
|
||||||
|
|
||||||
slots.button("$save.import", Icon.add, () -> {
|
|
||||||
platform.showFileChooser(true, saveExtension, file -> {
|
platform.showFileChooser(true, saveExtension, file -> {
|
||||||
if(SaveIO.isSaveValid(file)){
|
if(SaveIO.isSaveValid(file)){
|
||||||
try{
|
try{
|
||||||
@@ -162,7 +163,7 @@ public class LoadDialog extends BaseDialog{
|
|||||||
ui.showErrorMessage("$save.import.invalid");
|
ui.showErrorMessage("$save.import.invalid");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
}).fillX().margin(10f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runLoadSave(SaveSlot slot){
|
public void runLoadSave(SaveSlot slot){
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package mindustry.ui.dialogs;
|
|||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.input.*;
|
import arc.input.*;
|
||||||
import arc.math.*;
|
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -124,7 +123,7 @@ public class MapsDialog extends BaseDialog{
|
|||||||
ScrollPane pane = new ScrollPane(maps);
|
ScrollPane pane = new ScrollPane(maps);
|
||||||
pane.setFadeScrollBars(false);
|
pane.setFadeScrollBars(false);
|
||||||
|
|
||||||
int maxwidth = Mathf.clamp((int)(Core.graphics.getWidth() / Scl.scl(230)), 1, 8);
|
int maxwidth = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
||||||
float mapsize = 200f;
|
float mapsize = 200f;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -20,16 +20,17 @@ public class SaveDialog extends LoadDialog{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addSetup(){
|
public void addSetup(){
|
||||||
slots.row();
|
|
||||||
slots.button("$save.new", Icon.add, () ->
|
buttons.button("$save.new", Icon.add, () ->
|
||||||
ui.showTextInput("$save", "$save.newslot", 30, "", text -> {
|
ui.showTextInput("$save", "$save.newslot", 30, "", text -> {
|
||||||
ui.loadAnd("$saving", () -> {
|
ui.loadAnd("$saving", () -> {
|
||||||
control.saves.addSave(text);
|
control.saves.addSave(text);
|
||||||
Core.app.post(() -> Core.app.post(this::setup));
|
Core.app.post(() -> Core.app.post(this::setup));
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
).fillX().margin(10f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ public class SchematicsDialog extends BaseDialog{
|
|||||||
});
|
});
|
||||||
|
|
||||||
rebuildPane[0] = () -> {
|
rebuildPane[0] = () -> {
|
||||||
|
int maxwidth = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
||||||
|
|
||||||
t.clear();
|
t.clear();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
String regex = "[`~!@#$%^&*()-_=+[{]}|;:'\",<.>/?]";
|
String regex = "[`~!@#$%^&*()-_=+[{]}|;:'\",<.>/?]";
|
||||||
@@ -150,7 +152,7 @@ public class SchematicsDialog extends BaseDialog{
|
|||||||
|
|
||||||
sel[0].getStyle().up = Tex.pane;
|
sel[0].getStyle().up = Tex.pane;
|
||||||
|
|
||||||
if(++i % (mobile ? Core.graphics.isPortrait() ? 2 : 3 : 4) == 0){
|
if(++i % maxwidth == 0){
|
||||||
t.row();
|
t.row();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user