Added health bars to block info / Fixed block info refresh bug
This commit is contained in:
BIN
core/assets-raw/sprites/ui/bar-top.9.png
Normal file
BIN
core/assets-raw/sprites/ui/bar-top.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 169 B |
BIN
core/assets-raw/sprites/ui/bar.9.png
Normal file
BIN
core/assets-raw/sprites/ui/bar.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 265 B |
@@ -148,6 +148,7 @@ save.wave = Wave {0}
|
|||||||
save.difficulty = Difficulty: {0}
|
save.difficulty = Difficulty: {0}
|
||||||
save.date = Last Saved: {0}
|
save.date = Last Saved: {0}
|
||||||
save.playtime = Playtime: {0}
|
save.playtime = Playtime: {0}
|
||||||
|
warning = Warning.
|
||||||
confirm = Confirm
|
confirm = Confirm
|
||||||
delete = Delete
|
delete = Delete
|
||||||
ok = OK
|
ok = OK
|
||||||
@@ -239,6 +240,8 @@ editor = Editor
|
|||||||
mapeditor = Map Editor
|
mapeditor = Map Editor
|
||||||
donate = Donate
|
donate = Donate
|
||||||
|
|
||||||
|
abandon = Abandon
|
||||||
|
abandon.text = This zone and all its resources will be lost to the enemy.
|
||||||
locked = Locked
|
locked = Locked
|
||||||
complete = [LIGHT_GRAY]Complete:
|
complete = [LIGHT_GRAY]Complete:
|
||||||
resume = Resume Zone:\n[LIGHT_GRAY]{0}
|
resume = Resume Zone:\n[LIGHT_GRAY]{0}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 988 KiB After Width: | Height: | Size: 989 KiB |
@@ -38,6 +38,7 @@ public class Palette{
|
|||||||
|
|
||||||
stoneGray = Color.valueOf("8f8f8f"),
|
stoneGray = Color.valueOf("8f8f8f"),
|
||||||
|
|
||||||
|
health = Color.valueOf("ff341c"),
|
||||||
heal = Color.valueOf("98ffa9"),
|
heal = Color.valueOf("98ffa9"),
|
||||||
bar = Color.SLATE,
|
bar = Color.SLATE,
|
||||||
accent = Color.valueOf("ffd37f"),
|
accent = Color.valueOf("ffd37f"),
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ public class MapGenerator extends Generator{
|
|||||||
|
|
||||||
for(int x = 0; x < data.width(); x++){
|
for(int x = 0; x < data.width(); x++){
|
||||||
for(int y = 0; y < data.height(); y++){
|
for(int y = 0; y < data.height(); y++){
|
||||||
if(Mathf.chance(0.05) && tiles[x][y].floor() == Blocks.stone && tiles[x][y].block() == Blocks.air){
|
|
||||||
tiles[x][y].setBlock(Blocks.rock);
|
|
||||||
}
|
|
||||||
|
|
||||||
final double scl = 10;
|
final double scl = 10;
|
||||||
final int mag = 3;
|
final int mag = 3;
|
||||||
int newX = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x, y) * mag + x), 0, data.width()-1);
|
int newX = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x, y) * mag + x), 0, data.width()-1);
|
||||||
@@ -84,7 +80,7 @@ public class MapGenerator extends Generator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(enemySpawns > enemies.size){
|
if(enemySpawns > enemies.size){
|
||||||
throw new IllegalArgumentException("Enemy spawn pool greater than map spawn #.");
|
throw new IllegalArgumentException("Enemy spawn pool greater than map spawn number.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(enemySpawns != -1){
|
if(enemySpawns != -1){
|
||||||
|
|||||||
82
core/src/io/anuke/mindustry/ui/Bar.java
Normal file
82
core/src/io/anuke/mindustry/ui/Bar.java
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.function.FloatProvider;
|
||||||
|
import io.anuke.arc.function.Supplier;
|
||||||
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.graphics.g2d.BitmapFont;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.g2d.GlyphLayout;
|
||||||
|
import io.anuke.arc.graphics.g2d.ScissorStack;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
|
import io.anuke.arc.scene.Element;
|
||||||
|
import io.anuke.arc.scene.style.Drawable;
|
||||||
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
|
|
||||||
|
public class Bar extends Element{
|
||||||
|
private static Rectangle scissor = new Rectangle();
|
||||||
|
|
||||||
|
private FloatProvider fraction;
|
||||||
|
private String name = "";
|
||||||
|
private float value, lastValue, blink;
|
||||||
|
private Color blinkColor = new Color();
|
||||||
|
|
||||||
|
public Bar(String name, Color color, FloatProvider fraction){
|
||||||
|
this.fraction = fraction;
|
||||||
|
this.name = Core.bundle.get(name);
|
||||||
|
this.blinkColor.set(color);
|
||||||
|
lastValue = value = fraction.get();
|
||||||
|
setColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bar(Supplier<String> name, Supplier<Color> color, FloatProvider fraction){
|
||||||
|
this.fraction = fraction;
|
||||||
|
update(() -> {
|
||||||
|
this.name = name.get();
|
||||||
|
setColor(color.get());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bar blink(Color color){
|
||||||
|
blinkColor.set(color);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
if(!Mathf.isEqual(lastValue, fraction.get())){
|
||||||
|
blink = 1f;
|
||||||
|
lastValue = fraction.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
blink = Mathf.lerpDelta(blink, 0f, 0.2f);
|
||||||
|
value = Mathf.lerpDelta(value, fraction.get(), 0.15f);
|
||||||
|
|
||||||
|
Draw.colorl(0.1f);
|
||||||
|
Draw.drawable("bar", x, y, width, height);
|
||||||
|
Draw.color(color, blinkColor, blink);
|
||||||
|
|
||||||
|
Drawable top = Core.scene.skin.getDrawable("bar-top");
|
||||||
|
float topWidth = width * value;
|
||||||
|
|
||||||
|
if(topWidth > Core.atlas.find("bar-top").getWidth()){
|
||||||
|
top.draw(x, y, topWidth, height);
|
||||||
|
}else{
|
||||||
|
if(ScissorStack.pushScissors(scissor.set(x, y, topWidth, height))){
|
||||||
|
top.draw(x, y, Core.atlas.find("bar-top").getWidth(), height);
|
||||||
|
ScissorStack.popScissors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
|
|
||||||
|
BitmapFont font = Core.scene.skin.getFont("default-font");
|
||||||
|
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||||
|
lay.setText(font, name);
|
||||||
|
|
||||||
|
font.draw(name, x + width/2f - lay.width/2f, y + height/2f + lay.height/2f + 1);
|
||||||
|
|
||||||
|
Pools.free(lay);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -154,7 +154,11 @@ public class DeployDialog extends FloatingDialog{
|
|||||||
}else{
|
}else{
|
||||||
SaveSlot slot = control.saves.getZoneSlot();
|
SaveSlot slot = control.saves.getZoneSlot();
|
||||||
|
|
||||||
|
TextButton b[] = {null};
|
||||||
|
|
||||||
TextButton button = addButton(Core.bundle.format("resume", slot.getZone().localizedName()), () -> {
|
TextButton button = addButton(Core.bundle.format("resume", slot.getZone().localizedName()), () -> {
|
||||||
|
if(b[0].childrenPressed()) return;
|
||||||
|
|
||||||
hide();
|
hide();
|
||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
try{
|
try{
|
||||||
@@ -168,6 +172,7 @@ public class DeployDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).size(200f).get();
|
}).size(200f).get();
|
||||||
|
b[0] = button;
|
||||||
|
|
||||||
String color = "[lightgray]";
|
String color = "[lightgray]";
|
||||||
|
|
||||||
@@ -177,6 +182,15 @@ public class DeployDialog extends FloatingDialog{
|
|||||||
button.row();
|
button.row();
|
||||||
button.label(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime()));
|
button.label(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime()));
|
||||||
button.row();
|
button.row();
|
||||||
|
button.add().grow();
|
||||||
|
button.row();
|
||||||
|
|
||||||
|
button.addButton("$abandon", () -> {
|
||||||
|
ui.showConfirm("$warning", "$abandon.text", () -> {
|
||||||
|
slot.delete();
|
||||||
|
setup();
|
||||||
|
});
|
||||||
|
}).growX().height(50f).pad(-12).padTop(10);
|
||||||
}
|
}
|
||||||
}})).grow();
|
}})).grow();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
Array<Block> returnArray = new Array<>();
|
Array<Block> returnArray = new Array<>();
|
||||||
Category currentCategory = Category.distribution;
|
Category currentCategory = Category.distribution;
|
||||||
Block hovered, lastDisplay;
|
Block hovered, lastDisplay;
|
||||||
|
Tile lastHover;
|
||||||
Tile hoverTile;
|
Tile hoverTile;
|
||||||
Table blockTable, toggler, topTable;
|
Table blockTable, toggler, topTable;
|
||||||
boolean shown = true;
|
boolean shown = true;
|
||||||
@@ -162,21 +163,25 @@ public class PlacementFragment extends Fragment{
|
|||||||
frame.table("button-edge-2", top -> {
|
frame.table("button-edge-2", top -> {
|
||||||
topTable = top;
|
topTable = top;
|
||||||
top.add(new Table()).growX().update(topTable -> {
|
top.add(new Table()).growX().update(topTable -> {
|
||||||
if((tileDisplayBlock() == null && lastDisplay == getSelected() && !lastGround) || (tileDisplayBlock() != null && lastDisplay == tileDisplayBlock() && lastGround))
|
//don't refresh unnecessarily
|
||||||
|
if((tileDisplayBlock() == null && lastDisplay == getSelected() && !lastGround)
|
||||||
|
|| (tileDisplayBlock() != null && lastHover == hoverTile && lastGround))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
topTable.clear();
|
topTable.clear();
|
||||||
topTable.top().left().margin(5);
|
topTable.top().left().margin(5);
|
||||||
|
|
||||||
|
lastHover = hoverTile;
|
||||||
lastDisplay = getSelected();
|
lastDisplay = getSelected();
|
||||||
lastGround = tileDisplayBlock() != null;
|
lastGround = tileDisplayBlock() != null;
|
||||||
|
|
||||||
if(lastDisplay != null){ //show selected recipe
|
if(lastDisplay != null){ //show selected recipe
|
||||||
|
lastGround = false;
|
||||||
|
|
||||||
topTable.table(header -> {
|
topTable.table(header -> {
|
||||||
header.left();
|
header.left();
|
||||||
header.add(new Image(lastDisplay.icon(Icon.medium))).size(8 * 4);
|
header.add(new Image(lastDisplay.icon(Icon.medium))).size(8 * 4);
|
||||||
header.labelWrap(() ->
|
header.labelWrap(() -> !data.isUnlocked(lastDisplay) ? Core.bundle.get("blocks.unknown") : lastDisplay.formalName)
|
||||||
!data.isUnlocked(lastDisplay) ? Core.bundle.get("blocks.unknown") : lastDisplay.formalName)
|
|
||||||
.left().width(190f).padLeft(5);
|
.left().width(190f).padLeft(5);
|
||||||
header.add().growX();
|
header.add().growX();
|
||||||
if(data.isUnlocked(lastDisplay)){
|
if(data.isUnlocked(lastDisplay)){
|
||||||
@@ -219,7 +224,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
topTable.table(t -> {
|
topTable.table(t -> {
|
||||||
t.left().defaults().left();
|
t.left().defaults().left();
|
||||||
lastDisplay.display(hoverTile, t);
|
lastDisplay.display(hoverTile, t);
|
||||||
}).left();
|
}).left().growX();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled);
|
}).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import io.anuke.mindustry.type.Category;
|
|||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
|
import io.anuke.mindustry.ui.Bar;
|
||||||
import io.anuke.mindustry.ui.ContentDisplay;
|
import io.anuke.mindustry.ui.ContentDisplay;
|
||||||
import io.anuke.mindustry.world.consumers.ConsumePower;
|
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
@@ -463,9 +464,28 @@ public class Block extends BlockStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void display(Tile tile, Table table){
|
public void display(Tile tile, Table table){
|
||||||
if(tile.entity != null){
|
TileEntity entity = tile.entity;
|
||||||
//TODO remove/replace
|
|
||||||
table.label(() -> "Health: [LIGHT_GRAY]" + (int)tile.entity.health + " / " + health);
|
if(entity != null){
|
||||||
|
table.table(bars -> {
|
||||||
|
bars.defaults().growX().height(18f).pad(4);
|
||||||
|
|
||||||
|
displayBars(tile, bars);
|
||||||
|
}).growX();
|
||||||
|
|
||||||
|
table.marginBottom(-5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayBars(Tile tile, Table bars){
|
||||||
|
TileEntity entity = tile.entity;
|
||||||
|
|
||||||
|
bars.add(new Bar("blocks.health", Palette.health, entity::healthf).blink(Color.WHITE));
|
||||||
|
bars.row();
|
||||||
|
|
||||||
|
if(entity.liquids != null){
|
||||||
|
bars.add(new Bar(() -> entity.liquids.current().localizedName(), () -> entity.liquids.current().color, () -> entity.liquids.total() / liquidCapacity)).growX();
|
||||||
|
bars.row();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user