Map bugfixes / Sprite tweak / Zone loadout moved to dialog
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.scene.event.HandCursorListener;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.scene.ui.Button;
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.type.*;
|
||||
@@ -14,6 +13,7 @@ import io.anuke.mindustry.world.Block.Icon;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ZoneInfoDialog extends FloatingDialog{
|
||||
private ZoneLoadoutDialog loadout = new ZoneLoadoutDialog();
|
||||
|
||||
public ZoneInfoDialog(){
|
||||
super("");
|
||||
@@ -103,6 +103,8 @@ public class ZoneInfoDialog extends FloatingDialog{
|
||||
cont.row();
|
||||
cont.addImage("white").color(Pal.accent).height(3).pad(6).growX();
|
||||
cont.row();
|
||||
cont.addButton(zone.canConfigure() ? "$configure" : Core.bundle.format("configure.locked", zone.configureWave), () -> loadout.show(zone, rebuildItems)).fillX().pad(3).disabled(b -> !zone.canConfigure());
|
||||
cont.row();
|
||||
cont.table(res -> {
|
||||
res.add("$zone.resources").padRight(6);
|
||||
if(zone.resources.length > 0){
|
||||
@@ -118,75 +120,8 @@ public class ZoneInfoDialog extends FloatingDialog{
|
||||
cont.row();
|
||||
cont.add(Core.bundle.format("bestwave", zone.bestWave()));
|
||||
}
|
||||
|
||||
Table load = new Table();
|
||||
//thanks java, absolutely brilliant syntax here
|
||||
Runnable[] rebuildLoadout = {null};
|
||||
rebuildLoadout[0] = () -> {
|
||||
load.clear();
|
||||
float bsize = 40f;
|
||||
int step = 50;
|
||||
|
||||
load.left();
|
||||
for(ItemStack stack : zone.getStartingItems()){
|
||||
load.addButton("x", () -> {
|
||||
zone.getStartingItems().remove(stack);
|
||||
zone.updateLaunchCost();
|
||||
rebuildItems.run();
|
||||
rebuildLoadout[0].run();
|
||||
}).size(bsize).pad(2);
|
||||
|
||||
load.addButton("-", () -> {
|
||||
stack.amount = Math.max(stack.amount - step, 0);
|
||||
zone.updateLaunchCost();
|
||||
rebuildItems.run();
|
||||
}).size(bsize).pad(2);
|
||||
load.addButton("+", () -> {
|
||||
stack.amount = Math.min(stack.amount + step, zone.loadout.core().itemCapacity);
|
||||
zone.updateLaunchCost();
|
||||
rebuildItems.run();
|
||||
}).size(bsize).pad(2);
|
||||
|
||||
load.addImage(stack.item.icon(Item.Icon.medium)).size(8 * 3).padRight(4);
|
||||
load.label(() -> stack.amount + "").left();
|
||||
|
||||
load.row();
|
||||
}
|
||||
|
||||
load.addButton("$add", () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("");
|
||||
dialog.setFillParent(false);
|
||||
for(Item item : content.items().select(item -> data.getItem(item) > 0 && item.type == ItemType.material && zone.getStartingItems().find(stack -> stack.item == item) == null)){
|
||||
TextButton button = dialog.cont.addButton("", () -> {
|
||||
zone.getStartingItems().add(new ItemStack(item, 0));
|
||||
zone.updateLaunchCost();
|
||||
rebuildLoadout[0].run();
|
||||
dialog.hide();
|
||||
}).size(300f, 35f).pad(1).get();
|
||||
button.clearChildren();
|
||||
button.left();
|
||||
button.addImage(item.icon(Item.Icon.medium)).size(8 * 3).pad(4);
|
||||
button.add(item.localizedName);
|
||||
dialog.cont.row();
|
||||
}
|
||||
dialog.show();
|
||||
}).colspan(4).size(100f, bsize).left().disabled(b -> !content.items().contains(item -> data.getItem(item) > 0 && item.type == ItemType.material && !zone.getStartingItems().contains(stack -> stack.item == item)));
|
||||
};
|
||||
|
||||
rebuildLoadout[0].run();
|
||||
|
||||
cont.row();
|
||||
cont.table(zone.canConfigure() ? "button" : "button-disabled", t -> {
|
||||
t.left();
|
||||
t.add(!zone.canConfigure() ? Core.bundle.format("configure.locked", zone.configureWave) : "$configure").growX().wrap();
|
||||
if(zone.canConfigure()){
|
||||
t.row();
|
||||
t.pane(load).pad(2).growX().left();
|
||||
}
|
||||
}).width(300f).pad(4).left();
|
||||
}
|
||||
});
|
||||
|
||||
cont.row();
|
||||
|
||||
Button button = cont.addButton(zone.locked() ? "$uncover" : "$launch", () -> {
|
||||
@@ -200,7 +135,7 @@ public class ZoneInfoDialog extends FloatingDialog{
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
}
|
||||
}).minWidth(150f).margin(13f).padTop(5).disabled(b -> zone.locked() ? !canUnlock(zone) : !data.hasItems(zone.getLaunchCost())).get();
|
||||
}).minWidth(150f).margin(13f).padTop(5).disabled(b -> zone.locked() ? !canUnlock(zone) : !data.hasItems(zone.getLaunchCost())).uniformY().get();
|
||||
|
||||
button.row();
|
||||
button.add(iteminfo);
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.data;
|
||||
|
||||
public class ZoneLoadoutDialog extends FloatingDialog{
|
||||
private Zone zone;
|
||||
private Runnable hider;
|
||||
|
||||
public ZoneLoadoutDialog(){
|
||||
super("$configure");
|
||||
setFillParent(false);
|
||||
addCloseButton();
|
||||
shown(this::setup);
|
||||
hidden(() -> {
|
||||
if(hider != null){
|
||||
hider.run();
|
||||
}
|
||||
});
|
||||
buttons.row();
|
||||
buttons.addButton("$settings.reset", () -> {
|
||||
zone.resetStartingItems();
|
||||
zone.updateLaunchCost();
|
||||
setup();
|
||||
}).size(210f, 64f);
|
||||
}
|
||||
|
||||
public void show(Zone zone, Runnable hider){
|
||||
this.hider = hider;
|
||||
this.zone = zone;
|
||||
show();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
cont.clear();
|
||||
float bsize = 40f;
|
||||
int step = 50;
|
||||
|
||||
for(ItemStack stack : zone.getStartingItems()){
|
||||
cont.addButton("x", "clear-partial", () -> {
|
||||
zone.getStartingItems().remove(stack);
|
||||
zone.updateLaunchCost();
|
||||
setup();
|
||||
}).size(bsize);
|
||||
|
||||
cont.addButton("-", "clear-partial", () -> {
|
||||
stack.amount = Math.max(stack.amount - step, 0);
|
||||
zone.updateLaunchCost();
|
||||
}).size(bsize);
|
||||
cont.addButton("+", "clear-partial", () -> {
|
||||
stack.amount = Math.min(stack.amount + step, zone.loadout.core().itemCapacity);
|
||||
zone.updateLaunchCost();
|
||||
}).size(bsize);
|
||||
|
||||
cont.addImage(stack.item.icon(Item.Icon.medium)).size(8 * 3).padRight(4);
|
||||
cont.label(() -> stack.amount + "").left();
|
||||
|
||||
cont.row();
|
||||
}
|
||||
|
||||
cont.addButton("$add", () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("");
|
||||
dialog.setFillParent(false);
|
||||
for(Item item : content.items().select(item -> data.getItem(item) > 0 && item.type == ItemType.material && zone.getStartingItems().find(stack -> stack.item == item) == null)){
|
||||
TextButton button = dialog.cont.addButton("", "clear", () -> {
|
||||
zone.getStartingItems().add(new ItemStack(item, 0));
|
||||
zone.updateLaunchCost();
|
||||
setup();
|
||||
dialog.hide();
|
||||
}).size(300f, 36f).get();
|
||||
button.clearChildren();
|
||||
button.left();
|
||||
button.addImage(item.icon(Item.Icon.medium)).size(8 * 3).pad(4);
|
||||
button.add(item.localizedName);
|
||||
dialog.cont.row();
|
||||
}
|
||||
dialog.show();
|
||||
}).colspan(4).size(100f, bsize).left().disabled(b -> !content.items().contains(item -> data.getItem(item) > 0 && item.type == ItemType.material && !zone.getStartingItems().contains(stack -> stack.item == item)));
|
||||
pack();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user