UI polish

This commit is contained in:
Anuken
2019-08-01 22:40:15 -04:00
parent 8b3995686f
commit 5acda423d8
24 changed files with 1005 additions and 926 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -216,7 +216,7 @@ editor.errorsave = Error saving file:\n[accent]{0}
editor.errorimage = That's an image, not a map. Don't go around changing extensions expecting it to work.\n\nIf you want to import a legacy map, use the 'import legacy map' button in the editor. editor.errorimage = That's an image, not a map. Don't go around changing extensions expecting it to work.\n\nIf you want to import a legacy map, use the 'import legacy map' button in the editor.
editor.errorlegacy = This map is too old, and uses a legacy map format that is no longer supported. editor.errorlegacy = This map is too old, and uses a legacy map format that is no longer supported.
editor.errorheader = This map file is either not valid or corrupt. editor.errorheader = This map file is either not valid or corrupt.
editor.errorname = Map has no name defined. editor.errorname = Map has no name defined. Are you trying to load a save file?
editor.update = Update editor.update = Update
editor.randomize = Randomize editor.randomize = Randomize
editor.apply = Apply editor.apply = Apply

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 KiB

After

Width:  |  Height:  |  Size: 464 KiB

View File

@ -54,6 +54,12 @@
down: button-down, down: button-down,
up: button up: button
}, },
square: {
over: button-square-over,
disabled: button-disabled,
down: button-square-down,
up: button-square
},
toggle: { toggle: {
checked: button-down, checked: button-down,
down: button-down, down: button-down,
@ -70,6 +76,15 @@
down: button-down, down: button-down,
up: button up: button
}, },
square: {
font: default,
fontColor: white,
disabledFontColor: gray,
over: button-square-over,
disabled: button-disabled,
down: button-square-down,
up: button-square
},
node: { node: {
disabled: button, disabled: button,
font: default, font: default,
@ -298,8 +313,8 @@
font: default, font: default,
fontColor: white fontColor: white
}, },
small: { outline: {
font: default, font: outline,
fontColor: white fontColor: white
} }
}, },

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -3,6 +3,7 @@ package io.anuke.mindustry.type;
import io.anuke.arc.*; import io.anuke.arc.*;
import io.anuke.arc.collection.*; import io.anuke.arc.collection.*;
import io.anuke.arc.function.*; import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
@ -27,6 +28,7 @@ public class Zone extends UnlockableContent{
public int configureWave = 15; public int configureWave = 15;
public int launchPeriod = 10; public int launchPeriod = 10;
public Loadout loadout = Loadouts.basicShard; public Loadout loadout = Loadouts.basicShard;
public Texture preview;
protected ItemStack[] baseLaunchCost = {}; protected ItemStack[] baseLaunchCost = {};
protected Array<ItemStack> startingItems = new Array<>(); protected Array<ItemStack> startingItems = new Array<>();
@ -152,6 +154,11 @@ public class Zone extends UnlockableContent{
} }
} }
@Override
public void load(){
preview = new Texture(Core.files.internal("zones/" + name + ".png"));
}
@Override @Override
public boolean alwaysUnlocked(){ public boolean alwaysUnlocked(){
return alwaysUnlocked; return alwaysUnlocked;

View File

@ -10,6 +10,7 @@ import io.anuke.arc.math.geom.*;
import io.anuke.arc.scene.*; import io.anuke.arc.scene.*;
import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.scene.utils.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*; import io.anuke.mindustry.content.*;
import io.anuke.mindustry.core.GameState.*; import io.anuke.mindustry.core.GameState.*;
@ -24,7 +25,7 @@ import io.anuke.mindustry.ui.TreeLayout.*;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
public class DeployDialog extends FloatingDialog{ public class DeployDialog extends FloatingDialog{
private final float nodeSize = Unit.dp.scl(210f); private final float nodeSize = Unit.dp.scl(230f);
private ObjectSet<ZoneNode> nodes = new ObjectSet<>(); private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
private ZoneInfoDialog info = new ZoneInfoDialog(); private ZoneInfoDialog info = new ZoneInfoDialog();
private Rectangle bounds = new Rectangle(); private Rectangle bounds = new Rectangle();
@ -35,7 +36,8 @@ public class DeployDialog extends FloatingDialog{
ZoneNode root = new ZoneNode(Zones.groundZero, null); ZoneNode root = new ZoneNode(Zones.groundZero, null);
TreeLayout layout = new TreeLayout(); TreeLayout layout = new TreeLayout();
layout.gapBetweenLevels = layout.gapBetweenNodes = Unit.dp.scl(50f); layout.gapBetweenLevels = layout.gapBetweenNodes = Unit.dp.scl(60f);
layout.gapBetweenNodes = Unit.dp.scl(120f);
layout.layout(root); layout.layout(root);
bounds.set(layout.getBounds()); bounds.set(layout.getBounds());
bounds.y += nodeSize*0.4f; bounds.y += nodeSize*0.4f;
@ -78,10 +80,18 @@ public class DeployDialog extends FloatingDialog{
}}.setScaling(Scaling.fit)); }}.setScaling(Scaling.fit));
if(control.saves.getZoneSlot() != null){ if(control.saves.getZoneSlot() != null){
float size = 230f;
stack.add(new Table(t -> { stack.add(new Table(t -> {
SaveSlot slot = control.saves.getZoneSlot(); SaveSlot slot = control.saves.getZoneSlot();
TextButton button = t.addButton(Core.bundle.format("resume", slot.getZone().localizedName()), () -> { Stack sub = new Stack();
if(control.saves.getZoneSlot().getZone() != null){
sub.add(new Table(f -> f.margin(4f).add(new Image(control.saves.getZoneSlot().getZone().preview).setScaling(Scaling.fit)).color(Color.DARK_GRAY).grow()));
}
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), "square", () -> {
hide(); hide();
ui.loadAnd(() -> { ui.loadAnd(() -> {
@ -95,7 +105,11 @@ public class DeployDialog extends FloatingDialog{
show(); show();
} }
}); });
}).size(230f).get(); });
sub.add(button);
t.add(sub).size(size);
String color = "[lightgray]"; String color = "[lightgray]";
@ -149,13 +163,12 @@ public class DeployDialog extends FloatingDialog{
drawDefaultBackground(x, y); drawDefaultBackground(x, y);
} }
void buildButton(Zone zone, TextButton button){ void buildButton(Zone zone, Button button){
button.setDisabled(() -> hidden(zone)); button.setDisabled(() -> hidden(zone));
button.clicked(() -> info.show(zone)); button.clicked(() -> info.show(zone));
if(zone.unlocked()){ if(zone.unlocked()){
button.addImage("icon-terrain").size(iconsize).padRight(3); button.labelWrap(zone.localizedName()).style("outline").width(140).growX().get().setAlignment(Align.center);
button.labelWrap(zone.localizedName()).width(140).growX();
}else{ }else{
button.addImage("icon-locked"); button.addImage("icon-locked");
button.row(); button.row();
@ -170,14 +183,26 @@ public class DeployDialog extends FloatingDialog{
{ {
for(ZoneNode node : nodes){ for(ZoneNode node : nodes){
TextButton button = new TextButton("", "node"); Stack stack = new Stack();
button.setSize(node.width, node.height); Tmp.v1.set(node.width, node.height);
button.update(() -> { if(node.zone.preview != null){
button.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center); Tmp.v1.set(Scaling.fit.apply(node.zone.preview.getWidth(), node.zone.preview.getHeight(), node.width, node.height));
}); }
button.clearChildren();
stack.setSize(Tmp.v1.x, Tmp.v1.y);
if(node.zone.unlocked() && node.zone.preview != null){
stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview)
.setScaling(Scaling.stretch)).color(Color.DARK_GRAY).grow()));
}else{
stack.add(new Table(t -> t.margin(4f).add(new Image("whiteui", Color.BLACK).setScaling(Scaling.stretch)).grow()));
}
stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center));
Button button = new Button("square");
buildButton(node.zone, button); buildButton(node.zone, button);
addChild(button); stack.add(button);
addChild(stack);
} }
dragged((x, y) -> { dragged((x, y) -> {
@ -206,7 +231,7 @@ public class DeployDialog extends FloatingDialog{
for(ZoneNode node : nodes){ for(ZoneNode node : nodes){
for(ZoneNode child : node.allChildren){ for(ZoneNode child : node.allChildren){
Lines.stroke(Unit.dp.scl(3f), node.zone.locked() || child.zone.locked() ? Pal.gray : Pal.accent); Lines.stroke(Unit.dp.scl(4f), node.zone.locked() || child.zone.locked() ? Pal.gray : Pal.gray);
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY); Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
} }
} }
@ -225,7 +250,7 @@ public class DeployDialog extends FloatingDialog{
this.zone = zone; this.zone = zone;
this.parent = parent; this.parent = parent;
this.width = this.height = nodeSize; this.width = this.height = nodeSize;
this.height /= 2f; //this.height /= 2f;
nodes.add(this); nodes.add(this);
arr.selectFrom(content.zones(), other -> other.zoneRequirements.length > 0 && other.zoneRequirements[0].zone == zone); arr.selectFrom(content.zones(), other -> other.zoneRequirements.length > 0 && other.zoneRequirements[0].zone == zone);

View File

@ -75,7 +75,15 @@ public class MapsDialog extends FloatingDialog{
map = world.maps.makeLegacyMap(file); map = world.maps.makeLegacyMap(file);
} }
String name = map.tags.get("name"); //when you attempt to import a save, it will have no name, so generate one
String name = map.tags.getOr("name", () -> {
String result = "unknown";
int number = 0;
while(world.maps.byName(result + number++) != null);
return result + number;
});
//this will never actually get called, but it remains just in case
if(name == null){ if(name == null){
ui.showError("$editor.errorname"); ui.showError("$editor.errorname");
return; return;

View File

@ -240,7 +240,7 @@ public class Block extends BlockStorage{
font.draw(text, dx, dy + layout.height + 1, Align.center); font.draw(text, dx, dy + layout.height + 1, Align.center);
dy -= 1f; dy -= 1f;
Lines.stroke(2f, Color.DARK_GRAY); Lines.stroke(2f, Color.DARK_GRAY);
Lines.line(dx - layout.width / 2f - 2f, dy, dx + layout.width / 2f + 2f, dy); Lines.line(dx - layout.width / 2f - 2f, dy, dx + layout.width / 2f + 1.5f, dy);
Lines.stroke(1f, color); Lines.stroke(1f, color);
Lines.line(dx - layout.width / 2f - 2f, dy, dx + layout.width / 2f + 1.5f, dy); Lines.line(dx - layout.width / 2f - 2f, dy, dx + layout.width / 2f + 1.5f, dy);