Implemented new display/icon system for power lasers/batteries

This commit is contained in:
Anuken 2018-03-10 23:32:13 -05:00
parent 3ce7284fc5
commit 9d49c7d836
17 changed files with 392 additions and 343 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 B

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 662 B

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 B

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 234 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Sat Mar 10 20:25:11 EST 2018
#Sat Mar 10 23:26:21 EST 2018
version=release
androidBuildCode=439
androidBuildCode=441
name=Mindustry
code=3.4
build=custom build

View File

@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.core.GameState.State;
@ -114,7 +115,17 @@ public class BlocksFragment implements Fragment{
int i = 0;
for (Recipe r : recipes) {
ImageButton image = new ImageButton(r.result.getIcon(), "select");
ImageButton image = new ImageButton(new TextureRegion(), "select");
TextureRegion[] regions = r.result.getIcon(true);
Stack istack = new Stack();
for(TextureRegion region : regions){
istack.add(new Image(region));
}
image.getImageCell().setActor(istack).size(size);
image.addChild(istack);
image.getImage().remove();
image.addListener(new ClickListener(){
@Override
@ -152,14 +163,13 @@ public class BlocksFragment implements Fragment{
});
table.add(image).size(size + 8);
image.getImageCell().size(size);
image.update(() -> {
boolean canPlace = !control.tutorial().active() || control.tutorial().canPlace();
boolean has = (state.inventory.hasItems(r.requirements)) && canPlace;
image.setChecked(input.recipe == r);
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
image.getImage().setColor(has ? Color.WHITE : Hue.lightness(0.33f));
for(Element e : istack.getChildren()) e.setColor(has ? Color.WHITE : Hue.lightness(0.33f));
});
if (i % rows == rows - 1)
@ -248,8 +258,14 @@ public class BlocksFragment implements Fragment{
desctable.add(header).left();
desctable.row();
TextureRegion[] regions = recipe.result.getIcon(true);
Stack istack = new Stack();
for(TextureRegion region : regions) istack.add(new Image(region));
header.addImage(recipe.result.getIcon()).size(8*5).padTop(4);
header.add(istack).size(8*5).padTop(4);
Label nameLabel = new Label(recipe.result.formalName);
nameLabel.setWrap(true);
header.add(nameLabel).padLeft(2).width(120f);

View File

@ -177,16 +177,20 @@ public class Block extends BaseBlock {
Effects.sound(explosionSound, x, y);
}
public TextureRegion getIcon(){
public TextureRegion[] getIcon(boolean compact){
if(Draw.hasRegion(name + "-icon")){
return Draw.region(name + "-icon");
return new TextureRegion[]{Draw.region(name + "-icon")};
}else{
TextureRegion region = new TextureRegion(Draw.region(name));
region.setRegionWidth(8);
region.setRegionHeight(8);
return region;
return new TextureRegion[]{compact ? iconRegion(name) : Draw.region(name)};
}
}
protected TextureRegion iconRegion(String name){
TextureRegion region = new TextureRegion(Draw.region(name));
region.setRegionWidth(8);
region.setRegionHeight(8);
return region;
}
public TileEntity getEntity(){
return new TileEntity();

View File

@ -56,8 +56,11 @@ public abstract class BaseBlock {
}
public void tryMoveLiquid(Tile tile, Tile next){
if(next == null) return;
if(next != null && next.block().hasLiquids && tile.entity.liquid.amount > 0.01f){
next = next.target();
if(next.block().hasLiquids && tile.entity.liquid.amount > 0.01f){
float flow = Math.min(next.block().liquidCapacity - next.entity.liquid.amount - 0.001f,
Math.min(tile.entity.liquid.amount/liquidFlowFactor * Math.max(Timers.delta(), 1f), tile.entity.liquid.amount));

View File

@ -86,6 +86,7 @@ public class DistributionBlocks{
laserDirections = 1;
size = 3;
powerCapacity = 2000f;
base = "batterylarge-base";
}},
teleporter = new Teleporter("teleporter"){{
}},

View File

@ -12,6 +12,7 @@ public class LiquidRouter extends LiquidBlock{
rotate = false;
solid = true;
liquidFlowFactor = 2f;
hasInventory = false;
}
@Override

View File

@ -1,12 +1,14 @@
package io.anuke.mindustry.world.blocks.types.distribution;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.generation.Generator;
import io.anuke.ucore.graphics.Draw;
public class PowerLaser extends Generator{
public Color color = Color.valueOf("e54135");
public String base = null;
public PowerLaser(String name) {
super(name);
@ -18,8 +20,16 @@ public class PowerLaser extends Generator{
hasInventory = false;
}
@Override
public TextureRegion[] getIcon(boolean compact){
String bname = base == null ? "laser-base" : base;
return new TextureRegion[]{compact ? iconRegion(bname) : Draw.region(bname),
compact ? iconRegion(name) : Draw.region(name)};
}
@Override
public void draw(Tile tile) {
Draw.rect(base == null ? "laser-base" : base, tile.drawx(), tile.drawy());
Draw.rect(name(), tile.drawx(), tile.drawy(), tile.getRotation() * 90 - 90);
}