Tweaked sector dialog / Item icons fixed / Bugfixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.type.Item.Icon;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.arc.scene.ui.Image;
|
||||
@@ -18,7 +19,7 @@ public class ItemImage extends Stack{
|
||||
}
|
||||
|
||||
public ItemImage(ItemStack stack){
|
||||
add(new Image(stack.item.region));
|
||||
add(new Image(stack.item.icon(Icon.large)));
|
||||
|
||||
if(stack.amount != 0){
|
||||
Table t = new Table().left().bottom();
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.anuke.arc.collection.ObjectIntMap;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Item.Icon;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
@@ -30,7 +31,7 @@ public class ItemsDisplay extends Table{
|
||||
for(Item item : content.items()){
|
||||
if(item.type == ItemType.material && data.isUnlocked(item)){
|
||||
t.label(() -> format.format(items.get(item, 0))).left();
|
||||
t.addImage(item.region).size(8*3).padLeft(4).padRight(4);
|
||||
t.addImage(item.icon(Icon.medium)).size(8*3).padLeft(4).padRight(4);
|
||||
t.add(item.localizedName()).color(Color.LIGHT_GRAY).left();
|
||||
t.row();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.scene.Group;
|
||||
@@ -17,19 +16,17 @@ import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.io.SaveIO.SaveException;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
import io.anuke.mindustry.ui.ItemsDisplay;
|
||||
import io.anuke.mindustry.ui.TreeLayout;
|
||||
import io.anuke.mindustry.ui.TreeLayout.TreeNode;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class DeployDialog extends FloatingDialog{
|
||||
private final float nodeSize = Unit.dp.scl(250f);
|
||||
private final float nodeSize = Unit.dp.scl(210f);
|
||||
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
|
||||
private ZoneInfoDialog info = new ZoneInfoDialog();
|
||||
|
||||
public DeployDialog(){
|
||||
super("");
|
||||
@@ -37,7 +34,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
ZoneNode root = new ZoneNode(Zones.groundZero, null);
|
||||
|
||||
TreeLayout layout = new TreeLayout();
|
||||
layout.gapBetweenLevels = layout.gapBetweenNodes = Unit.dp.scl(40f);
|
||||
layout.gapBetweenLevels = layout.gapBetweenNodes = Unit.dp.scl(50f);
|
||||
layout.layout(root);
|
||||
|
||||
addCloseButton();
|
||||
@@ -49,7 +46,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
public void setup(){
|
||||
cont.clear();
|
||||
titleTable.remove();
|
||||
marginTop(0f);
|
||||
margin(0f).marginBottom(8);
|
||||
|
||||
cont.stack(control.saves.getZoneSlot() == null ? new View() : new Table(){{
|
||||
SaveSlot slot = control.saves.getZoneSlot();
|
||||
@@ -109,53 +106,23 @@ public class DeployDialog extends FloatingDialog{
|
||||
drawDefaultBackground(x, y);
|
||||
}
|
||||
|
||||
boolean canUnlock(Zone zone){
|
||||
if(data.isUnlocked(zone)){
|
||||
return true;
|
||||
}
|
||||
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
if(!data.isCompleted(other)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for(Block other : zone.blockRequirements){
|
||||
if(!data.isUnlocked(other)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return data.hasItems(zone.itemRequirements);
|
||||
}
|
||||
|
||||
void buildButton(Zone zone, TextButton button){
|
||||
button.setDisabled(() -> !canUnlock(zone) || !data.hasItems(zone.deployCost));
|
||||
button.clicked(() -> {
|
||||
if(!data.isUnlocked(zone)){
|
||||
data.removeItems(zone.itemRequirements);
|
||||
data.unlockContent(zone);
|
||||
setup();
|
||||
}else{
|
||||
data.removeItems(zone.deployCost);
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
}
|
||||
});
|
||||
button.setDisabled(() -> hidden(zone));
|
||||
button.clicked(() -> info.show(zone));
|
||||
|
||||
if(zone.unlocked()){
|
||||
button.table(title -> {
|
||||
title.addImage("icon-zone").padRight(3);
|
||||
title.add(zone.localizedName());
|
||||
});
|
||||
button.row();
|
||||
//button.table(title -> {
|
||||
button.addImage("icon-zone").padRight(3);
|
||||
button.labelWrap(zone.localizedName()).width(140).growX();
|
||||
//});
|
||||
|
||||
if(data.getWaveScore(zone) > 0){
|
||||
button.add(Core.bundle.format("bestwave", data.getWaveScore(zone)));
|
||||
}
|
||||
|
||||
button.row();
|
||||
//if(data.getWaveScore(zone) > 0){
|
||||
// button.add(Core.bundle.format("bestwave", data.getWaveScore(zone)));
|
||||
//}
|
||||
|
||||
/*
|
||||
button.add("$launch").color(Color.LIGHT_GRAY).pad(4);
|
||||
button.row();
|
||||
button.table(req -> {
|
||||
@@ -163,8 +130,13 @@ public class DeployDialog extends FloatingDialog{
|
||||
req.addImage(stack.item.region).size(8 * 3);
|
||||
req.add(stack.amount + "").left();
|
||||
}
|
||||
}).pad(3).growX();
|
||||
}).pad(3).growX();*/
|
||||
}else{
|
||||
button.addImage("icon-zone-locked");
|
||||
button.row();
|
||||
button.add("$locked");
|
||||
|
||||
/*else{
|
||||
button.addImage("icon-zone-locked");
|
||||
button.row();
|
||||
button.add("$locked").padBottom(6);
|
||||
@@ -220,6 +192,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
}
|
||||
}).growX();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +204,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
{
|
||||
for(ZoneNode node : nodes){
|
||||
TextButton button = new TextButton("", "node");
|
||||
button.setSize(nodeSize);
|
||||
button.setSize(node.width, node.height);
|
||||
button.update(() -> {
|
||||
button.setPosition(node.x + panX + width/2f, node.y + panY + height/2f, Align.center);
|
||||
});
|
||||
@@ -270,6 +243,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
this.zone = zone;
|
||||
this.parent = parent;
|
||||
this.width = this.height = nodeSize;
|
||||
this.height /= 2f;
|
||||
nodes.add(this);
|
||||
|
||||
arr.selectFrom(content.zones(), other -> Structs.contains(other.zoneRequirements, zone));
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.anuke.arc.Core;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Item.Icon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -60,7 +61,7 @@ public class GameOverDialog extends FloatingDialog{
|
||||
if(state.stats.itemsDelivered.get(item, 0) > 0){
|
||||
cont.table(items -> {
|
||||
items.add(" [LIGHT_GRAY]" + state.stats.itemsDelivered.get(item, 0));
|
||||
items.addImage(item.region).size(8 *3).pad(4);
|
||||
items.addImage(item.icon(Icon.medium)).size(8 *3).pad(4);
|
||||
}).left();
|
||||
cont.row();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
@@ -16,8 +15,6 @@ import io.anuke.arc.scene.ui.ImageButton;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.mindustry.content.TechTree;
|
||||
import io.anuke.mindustry.content.TechTree.TechNode;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
@@ -25,7 +22,6 @@ import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.ui.ItemsDisplay;
|
||||
import io.anuke.mindustry.ui.TreeLayout;
|
||||
import io.anuke.mindustry.ui.TreeLayout.TreeNode;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@@ -45,23 +41,9 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
layout.layout(root);
|
||||
|
||||
titleTable.remove();
|
||||
margin(0f);
|
||||
margin(0f).marginBottom(8);
|
||||
cont.stack(new View(), items = new ItemsDisplay()).grow();
|
||||
|
||||
{ //debug code; TODO remove
|
||||
ObjectSet<Block> used = new ObjectSet<Block>().select(t -> true);
|
||||
for(TechTreeNode node : nodes){
|
||||
used.add(node.node.block);
|
||||
}
|
||||
Array<Block> recipes = content.blocks().select(r -> r.isVisible() && !used.contains(r));
|
||||
recipes.sort(Structs.comparing(r -> r.buildCost));
|
||||
|
||||
if(recipes.size > 0){
|
||||
Log.info("Missing recipe tree items! ");
|
||||
recipes.forEach(r -> Log.info("> {0}", r));
|
||||
}
|
||||
}
|
||||
|
||||
shown(() -> checkNodes(root));
|
||||
hidden(ui.deploy::setup);
|
||||
addCloseButton();
|
||||
|
||||
142
core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java
Normal file
142
core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java
Normal file
@@ -0,0 +1,142 @@
|
||||
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.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ZoneInfoDialog extends FloatingDialog{
|
||||
|
||||
public ZoneInfoDialog(){
|
||||
super("");
|
||||
|
||||
titleTable.remove();
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(Zone zone){
|
||||
setup(zone);
|
||||
show();
|
||||
}
|
||||
|
||||
private void setup(Zone zone){
|
||||
cont.clear();
|
||||
|
||||
cont.table(cont -> {
|
||||
if(zone.locked()){
|
||||
cont.addImage("icon-zone-locked");
|
||||
cont.row();
|
||||
cont.add("$locked").padBottom(6);
|
||||
cont.row();
|
||||
|
||||
cont.table(req -> {
|
||||
req.defaults().left();
|
||||
|
||||
if(zone.zoneRequirements.length > 0){
|
||||
req.table(r -> {
|
||||
r.add("$complete").colspan(2).left();
|
||||
r.row();
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
r.addImage("icon-zone").padRight(4);
|
||||
r.add(other.localizedName()).color(Color.LIGHT_GRAY);
|
||||
r.addImage(data.isCompleted(other) ? "icon-check-2" : "icon-cancel-2")
|
||||
.color(data.isCompleted(other) ? Color.LIGHT_GRAY : Color.SCARLET).padLeft(3);
|
||||
r.row();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
req.row();
|
||||
|
||||
if(zone.blockRequirements.length > 0){
|
||||
req.table(r -> {
|
||||
r.add("$research.list").colspan(2).left();
|
||||
r.row();
|
||||
for(Block block : zone.blockRequirements){
|
||||
r.addImage(block.icon(Icon.small)).size(8 * 3).padRight(4);
|
||||
r.add(block.formalName).color(Color.LIGHT_GRAY);
|
||||
r.addImage(data.isUnlocked(block) ? "icon-check-2" : "icon-cancel-2")
|
||||
.color(data.isUnlocked(block) ? Color.LIGHT_GRAY : Color.SCARLET).padLeft(3);
|
||||
r.row();
|
||||
}
|
||||
|
||||
}).padTop(10);
|
||||
}
|
||||
}).growX();
|
||||
|
||||
}else{
|
||||
cont.add(zone.localizedName()).color(Pal.accent).growX().center();
|
||||
cont.row();
|
||||
cont.addImage("white").color(Pal.accent).height(3).pad(6).growX();
|
||||
cont.row();
|
||||
cont.table(res -> {
|
||||
res.add("$zone.resources").padRight(6);
|
||||
if(zone.resources.length > 0){
|
||||
for(Item item : zone.resources){
|
||||
res.addImage(item.icon(Item.Icon.medium)).size(8 * 3);
|
||||
}
|
||||
}else{
|
||||
res.add("$none");
|
||||
}
|
||||
});
|
||||
|
||||
if(data.getWaveScore(zone) > 0){
|
||||
cont.row();
|
||||
cont.add(Core.bundle.format("bestwave", data.getWaveScore(zone)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cont.row();
|
||||
|
||||
Button button = cont.addButton(zone.locked() ? "$uncover" : "$launch", () -> {
|
||||
if(!data.isUnlocked(zone)){
|
||||
data.removeItems(zone.itemRequirements);
|
||||
data.unlockContent(zone);
|
||||
ui.deploy.setup();
|
||||
setup(zone);
|
||||
}else{
|
||||
ui.deploy.hide();
|
||||
data.removeItems(zone.deployCost);
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
}
|
||||
}).size(300f, 70f).padTop(5).disabled(b -> zone.locked() ? !canUnlock(zone) : !data.hasItems(zone.deployCost)).get();
|
||||
|
||||
button.row();
|
||||
button.table(r -> {
|
||||
ItemStack[] stacks = zone.unlocked() ? zone.deployCost : zone.itemRequirements;
|
||||
for(ItemStack stack : stacks){
|
||||
r.addImage(stack.item.icon(Item.Icon.medium)).size(8*3).padRight(1);
|
||||
r.add(stack.amount + "").color(Color.LIGHT_GRAY).padRight(5);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean canUnlock(Zone zone){
|
||||
if(data.isUnlocked(zone)){
|
||||
return true;
|
||||
}
|
||||
|
||||
for(Zone other : zone.zoneRequirements){
|
||||
if(!data.isCompleted(other)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for(Block other : zone.blockRequirements){
|
||||
if(!data.isUnlocked(other)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return data.hasItems(zone.itemRequirements);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Item.Icon;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
@@ -135,7 +136,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
HandCursorListener l = new HandCursorListener();
|
||||
l.setEnabled(canPick);
|
||||
|
||||
ItemImage image = new ItemImage(item.region, () -> {
|
||||
ItemImage image = new ItemImage(item.icon(Icon.large), () -> {
|
||||
if(tile == null || tile.entity == null){
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.type.Category;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
@@ -209,7 +210,7 @@ public class PlacementFragment extends Fragment{
|
||||
for(ItemStack stack : lastDisplay.buildRequirements){
|
||||
req.table(line -> {
|
||||
line.left();
|
||||
line.addImage(stack.item.region).size(8 * 2);
|
||||
line.addImage(stack.item.icon(Item.Icon.small)).size(8 * 2);
|
||||
line.add(stack.item.localizedName()).color(Color.LIGHT_GRAY).padLeft(2).left();
|
||||
line.labelWrap(() -> {
|
||||
TileEntity core = players[0].getClosestCore();
|
||||
|
||||
Reference in New Issue
Block a user