Bugfixes / Requirement display
BIN
core/assets-raw/sprites/ui/icons/icon-power-requirement.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3 KiB |
|
|
@ -436,7 +436,7 @@ mode.freebuild.description = Limited resources and no timer for waves.
|
|||
mode.pvp.name = PvP
|
||||
mode.pvp.description = Fight against other players locally.
|
||||
mode.attack.name = Attack
|
||||
mode.attack.descrption = No waves, with the goal to destroy the enemy base.
|
||||
mode.attack.description = No waves, with the goal to destroy the enemy base.
|
||||
content.item.name = Items
|
||||
content.liquid.name = Liquids
|
||||
content.unit.name = Units
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
|
@ -883,7 +883,7 @@ public class Blocks implements ContentList{
|
|||
}};
|
||||
|
||||
impactReactor = new ImpactReactor("impact-reactor"){{
|
||||
requirements(Category.power, ItemStack.with(Items.lead, 800, Items.silicon, 600, Items.graphite, 600, Items.thorium, 200, Items.surgealloy, 400, Items.metaglass, 200));
|
||||
requirements(Category.power, ItemStack.with(Items.lead, 1000, Items.silicon, 600, Items.graphite, 600, Items.thorium, 200, Items.surgealloy, 400, Items.metaglass, 200));
|
||||
size = 4;
|
||||
health = 900;
|
||||
powerProduction = 70f;
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||
}
|
||||
|
||||
public int maxAccepted(Item item){
|
||||
return this.item.item != item ? 0 : getItemCapacity() - this.item.amount;
|
||||
return this.item.item != item && this.item.amount > 0 ? 0 : getItemCapacity() - this.item.amount;
|
||||
}
|
||||
|
||||
public void applyEffect(StatusEffect effect, float duration){
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ import io.anuke.arc.scene.ui.layout.Table;
|
|||
|
||||
public class ItemImage extends Stack{
|
||||
|
||||
public ItemImage(TextureRegion region, int amount){
|
||||
Table t = new Table().left().bottom();
|
||||
t.add(amount + "").name("item-label");
|
||||
|
||||
add(new Image(region));
|
||||
add(t);
|
||||
}
|
||||
|
||||
public ItemImage(TextureRegion region, Supplier<CharSequence> text){
|
||||
Table t = new Table().left().bottom();
|
||||
t.label(text).name("item-label");
|
||||
|
|
|
|||
36
core/src/io/anuke/mindustry/ui/ReqImage.java
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.arc.function.BooleanProvider;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.ui.Image;
|
||||
import io.anuke.arc.scene.ui.layout.Stack;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
|
||||
public class ReqImage extends Stack{
|
||||
|
||||
public ReqImage(Element image, BooleanProvider valid){
|
||||
add(image);
|
||||
add(new Element(){
|
||||
{
|
||||
visible(() -> !valid.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Lines.stroke(Unit.dp.scl(2f), Pal.removeBack);
|
||||
Lines.line(x, y - 2f + height, x + width, y - 2f);
|
||||
Draw.color(Pal.remove);
|
||||
Lines.line(x, y + height, x + width, y);
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ReqImage(TextureRegion region, BooleanProvider valid){
|
||||
this(new Image(region), valid);
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ import io.anuke.mindustry.graphics.Pal;
|
|||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.Bar;
|
||||
import io.anuke.mindustry.ui.ContentDisplay;
|
||||
import io.anuke.mindustry.world.consumers.Consume;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
|
|
@ -494,17 +495,27 @@ public class Block extends BlockStorage{
|
|||
|
||||
displayBars(tile, bars);
|
||||
}).growX();
|
||||
table.row();
|
||||
table.table(ctable -> {
|
||||
displayConsumption(tile, ctable);
|
||||
}).growX();
|
||||
|
||||
table.marginBottom(-5);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayConsumption(Tile tile, Table table){
|
||||
table.left();
|
||||
for(Consume cons : consumes.all()){
|
||||
cons.build(tile, table);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayBars(Tile tile, Table table){
|
||||
for(Function<TileEntity, Bar> bar : bars.list()){
|
||||
table.add(bar.get(tile.entity)).growX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public TextureRegion icon(Icon icon){
|
||||
|
|
|
|||
|
|
@ -93,9 +93,9 @@ public class PowerNode extends PowerBlock{
|
|||
super.setBars();
|
||||
bars.add("power", entity -> new Bar(() ->
|
||||
Core.bundle.format("blocks.powerbalance",
|
||||
(entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + Strings.toFixed(entity.power.graph.getPowerBalance()*60, 1)),
|
||||
entity.power.graph == null ? "+0" : ((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + Strings.toFixed(entity.power.graph.getPowerBalance()*60, 1))),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.power.graph.getPowerProduced() / entity.power.graph.getPowerNeeded())));
|
||||
() -> entity.power.graph == null ? 0 :Mathf.clamp(entity.power.graph.getPowerProduced() / entity.power.graph.getPowerNeeded())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package io.anuke.mindustry.world.consumers;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.arc.scene.ui.Tooltip;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
|
||||
/**An abstract class that defines a type of resource that a block can consume.*/
|
||||
public abstract class Consume{
|
||||
|
|
@ -38,7 +34,8 @@ public abstract class Consume{
|
|||
return update;
|
||||
}
|
||||
|
||||
public void build(Table table){
|
||||
public abstract void build(Tile tile, Table table);/*{
|
||||
|
||||
Table t = new Table("flat");
|
||||
t.margin(4);
|
||||
buildTooltip(t);
|
||||
|
|
@ -50,15 +47,13 @@ public abstract class Consume{
|
|||
out.addImage(getIcon()).size(10 * scale).color(Pal.accent);
|
||||
out.addImage("icon-missing").size(10 * scale).color(Pal.remove).padLeft(-10 * scale);
|
||||
}).size(10 * scale).get().addListener(new Tooltip<>(t));
|
||||
}
|
||||
}*/
|
||||
|
||||
/**Called when a consumption is triggered manually.*/
|
||||
public void trigger(Block block, TileEntity entity){
|
||||
|
||||
}
|
||||
|
||||
public abstract void buildTooltip(Table table);
|
||||
|
||||
public abstract String getIcon();
|
||||
|
||||
public abstract void update(Block block, TileEntity entity);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
package io.anuke.mindustry.world.consumers;
|
||||
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Item.Icon;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.ui.ReqImage;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
|
||||
public class ConsumeItem extends Consume{
|
||||
private final Item item;
|
||||
|
|
@ -37,8 +39,8 @@ public class ConsumeItem extends Consume{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip(Table table){
|
||||
table.add(new ItemImage(new ItemStack(item, amount))).size(8 * 4);
|
||||
public void build(Tile tile, Table table){
|
||||
table.add(new ReqImage(new ItemImage(item.icon(Icon.large), amount), () -> valid(tile.block(), tile.entity))).size(8*4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import io.anuke.mindustry.entities.type.TileEntity;
|
|||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Item.Icon;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.values.ItemFilterValue;
|
||||
|
|
@ -20,12 +21,8 @@ public class ConsumeItemFilter extends Consume{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip(Table table){
|
||||
Array<Item> list = new Array<>();
|
||||
|
||||
for(Item item : content.items()){
|
||||
if(filter.test(item)) list.add(item);
|
||||
}
|
||||
public void build(Tile tile, Table table){
|
||||
Array<Item> list = content.items().select(filter);
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Item item = list.get(i);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package io.anuke.mindustry.world.consumers;
|
||||
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Item.Icon;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.ui.ReqImage;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.values.ItemListValue;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
|
||||
public class ConsumeItems extends Consume{
|
||||
private ItemStack[] items;
|
||||
|
|
@ -21,9 +24,9 @@ public class ConsumeItems extends Consume{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip(Table table){
|
||||
public void build(Tile tile, Table table){
|
||||
for(ItemStack stack : items){
|
||||
table.add(new ItemImage(stack)).size(8 * 4).padRight(5);
|
||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Icon.large), stack.amount), () -> valid(tile.block(), tile.entity))).size(8*4).padRight(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package io.anuke.mindustry.world.consumers;
|
||||
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.ui.ReqImage;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
|
||||
public class ConsumeLiquid extends Consume{
|
||||
protected final float use;
|
||||
|
|
@ -26,8 +28,8 @@ public class ConsumeLiquid extends Consume{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip(Table table){
|
||||
table.addImage(liquid.getContentIcon()).size(8 * 3);
|
||||
public void build(Tile tile, Table table){
|
||||
table.add(new ReqImage(liquid.getContentIcon(), () -> valid(tile.block(), tile.entity))).size(8*4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
package io.anuke.mindustry.world.consumers;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.function.Predicate;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.ui.ReqImage;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.meta.values.LiquidFilterValue;
|
||||
import io.anuke.arc.function.Predicate;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
|
|
@ -29,16 +31,13 @@ public class ConsumeLiquidFilter extends Consume{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip(Table table){
|
||||
Array<Liquid> list = new Array<>();
|
||||
|
||||
for(Liquid item : content.liquids()){
|
||||
if(!item.isHidden() && filter.test(item)) list.add(item);
|
||||
}
|
||||
public void build(Tile tile, Table table){
|
||||
Array<Liquid> list = content.liquids().select(l -> !l.isHidden() && filter.test(l));
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Liquid item = list.get(i);
|
||||
table.addImage(item.getContentIcon()).size(8 * 3).padRight(2).padLeft(2).padTop(2).padBottom(2);
|
||||
Liquid liquid = list.get(i);
|
||||
|
||||
table.add(new ReqImage(liquid.getContentIcon(), () -> valid(tile.block(), tile.entity))).size(8*4).pad(2);
|
||||
if(i != list.size - 1){
|
||||
table.add("/");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import io.anuke.arc.math.Mathf;
|
|||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
|
|
@ -24,7 +25,8 @@ public class ConsumePower extends Consume{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildTooltip(Table table){
|
||||
public void build(Tile tile, Table table){
|
||||
//table.add(new ReqImage(new Image("icon-power-requirement"), () -> valid(tile.block(), tile.entity))).size(8*4).padRight(4);
|
||||
// No tooltip for power
|
||||
}
|
||||
|
||||
|
|
|
|||