UI refactoring, new save dialog

This commit is contained in:
Anuken
2017-12-22 18:10:34 -05:00
parent cbcdc96aaa
commit 60216b45f9
26 changed files with 144 additions and 77 deletions
@@ -51,7 +51,7 @@ public class FileChooser extends FloatingDialog{
private void setupWidgets(){
getCell(content()).maxWidth(Gdx.graphics.getWidth()/Unit.dp.scl(2f));
content().pad(-10);
content().margin(-10);
Table content = new Table();
@@ -139,7 +139,7 @@ public class FileChooser extends FloatingDialog{
content.add(icontable).expandX().fillX();
content.row();
//content.add(navigation).colspan(3).left().padBottom(10f).expandX().fillX().height(40f);
//content.add(navigation).colspan(3).left().marginBottom(10f).expandX().fillX().height(40f);
//content.row();
content.center().add(pane).width(Gdx.graphics.getWidth()/Unit.dp.scl(2)).colspan(3).grow();
@@ -117,7 +117,7 @@ public class LevelDialog extends FloatingDialog{
maps.add(stack).width(170).top().pad(4f);
maps.padRight(26);
maps.marginRight(26);
i ++;
}
@@ -42,12 +42,12 @@ public class LoadDialog extends FloatingDialog{
pane = new ScrollPane(slots);
pane.setFadeScrollBars(false);
slots.padRight(24);
slots.marginRight(24);
for(int i = 0; i < Vars.saveSlots; i++){
TextButton button = new TextButton("[accent]Slot " + (i + 1));
button.pad(12);
button.margin(12);
button.getLabelCell().top().left().growX();
button.row();
@@ -21,9 +21,7 @@ public class MindustryKeybindDialog extends KeybindDialog{
@Override
public void addCloseButton(){
buttons().addImageTextButton("Back", "icon-arrow-left", 30f, ()->{
hide();
}).size(230f, 64f);
buttons().addImageTextButton("Back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
keyDown(key->{
if(key == Keys.ESCAPE || key == Keys.BACK)
@@ -4,11 +4,23 @@ import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.utils.Align;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.SettingsDialog;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.ucore.UCore;
import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Mathf;
public class MindustrySettingsDialog extends SettingsDialog{
public SettingsTable graphics;
public SettingsTable game;
public SettingsTable sound;
private Table prefs;
private Table menu;
private boolean built = false;
public MindustrySettingsDialog(){
setFillParent(true);
@@ -16,24 +28,71 @@ public class MindustrySettingsDialog extends SettingsDialog{
getTitleTable().row();
getTitleTable().add(new Image("white"))
.growX().height(3f).pad(4f).get().setColor(Colors.get("accent"));
content().clearChildren();
content().remove();
buttons().remove();
ScrollPane pane = new ScrollPane(content(), "clear");
menu = new Table();
game = new SettingsTable();
graphics = new SettingsTable();
sound = new SettingsTable();
prefs = new Table();
prefs.top();
prefs.margin(14f);
menu.defaults().size(300f, 60f).pad(3f);
menu.addButton("Game", () -> visible(0));
menu.row();
menu.addButton("Graphics", () -> visible(1));
menu.row();
menu.addButton("Sound", () -> visible(2));
if(!Vars.android) {
menu.row();
menu.addButton("Controls", () -> Vars.ui.showControls());
}
prefs.clearChildren();
prefs.add(menu);
ScrollPane pane = new ScrollPane(prefs, "clear");
pane.setFadeScrollBars(false);
row();
add(pane).expand().fill();
add(pane).grow().top();
row();
add(buttons()).fillX();
hidden(this::back);
shown(() -> {
if(built) return;
built = true;
Mathf.each(table -> {
table.row();
table.addImageTextButton("Back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f);
}, game, graphics, sound);
});
}
private void back(){
prefs.clearChildren();
prefs.add(menu);
}
private void visible(int index){
prefs.clearChildren();
Table table = Mathf.select(index, game, graphics, sound);
prefs.add(table);
}
@Override
public void addCloseButton(){
buttons().addImageTextButton("Back", "icon-arrow-left", 30f, ()->{
hide();
}).size(230f, 64f);
buttons().addImageTextButton("Menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
keyDown(key->{
if(key == Keys.ESCAPE || key == Keys.BACK)
@@ -1,6 +1,5 @@
package io.anuke.mindustry.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import io.anuke.mindustry.Vars;
@@ -24,7 +23,7 @@ public class SaveDialog extends LoadDialog{
save(slot);
}){
{
content().pad(16);
content().margin(16);
for(Cell<?> cell : getButtonTable().getCells())
cell.size(110, 45).pad(4);
}
@@ -38,7 +38,7 @@ public class UpgradeDialog extends FloatingDialog{
});
Table weptab = new Table();
weptab.pad(20);
weptab.margin(20);
int i = 0;
for(Weapon weapon : Weapon.values()){
@@ -48,7 +48,7 @@ public class UpgradeDialog extends FloatingDialog{
button.add(img).size(8*5);
button.getCells().reverse();
button.row();
button.pad(14);
button.margin(14);
button.getLabelCell().left();
button.pack();
@@ -109,7 +109,7 @@ public class UpgradeDialog extends FloatingDialog{
if(control.hasWeapon(weapon)){
tiptable.add("[LIME]Purchased!").padTop(6).left();
}
tiptable.pad(14f);
tiptable.margin(14f);
};
run.listen();
@@ -76,7 +76,7 @@ public class BlocksFragment implements Fragment{
row();
}
table.pad(4);
table.margin(4);
table.top().left();
int i = 0;
@@ -124,8 +124,8 @@ public class BlocksFragment implements Fragment{
add(stack).colspan(Section.values().length);
margin(10f);
get().padLeft(0f);
get().padRight(0f);
get().marginLeft(0f);
get().marginRight(0f);
end();
}}.right().bottom().uniformX();
@@ -142,7 +142,7 @@ public class BlocksFragment implements Fragment{
desctable.defaults().left();
desctable.left();
desctable.pad(12);
desctable.margin(12);
Table header = new Table();
@@ -173,7 +173,7 @@ public class HudFragment implements Fragment{
.minWidth(140).left();
margin(12f);
get().padLeft(6);
get().marginLeft(6);
}}.left().end();
playButton(uheight);
@@ -45,7 +45,7 @@ public class MenuFragment implements Fragment{
if(!gwt){
add(new MenuButton("text-exit", group, Gdx.app::exit));
}
get().pad(16);
get().margin(16);
}}.end();
visible(()->GameState.is(State.menu));
@@ -57,7 +57,7 @@ public class WeaponFragment implements Fragment{
tiptable.row();
tiptable.row();
tiptable.add("[GRAY]" + description).left();
tiptable.pad(14f);
tiptable.margin(14f);
Tooltip tip = new Tooltip(tiptable);