Implemented new display/icon system for power lasers/batteries
|
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 617 B |
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 229 B |
BIN
core/assets-raw/sprites/blocks/tech/batterylarge-base.png
Normal file
|
After Width: | Height: | Size: 635 B |
|
Before Width: | Height: | Size: 662 B After Width: | Height: | Size: 221 B |
BIN
core/assets-raw/sprites/blocks/tech/laser-base.png
Normal file
|
After Width: | Height: | Size: 177 B |
|
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 241 B |
|
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 263 B |
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 234 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Mar 10 20:25:11 EST 2018
|
#Sat Mar 10 23:26:21 EST 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=439
|
androidBuildCode=441
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.fragments;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Colors;
|
import com.badlogic.gdx.graphics.Colors;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
@@ -114,7 +115,17 @@ public class BlocksFragment implements Fragment{
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (Recipe r : recipes) {
|
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(){
|
image.addListener(new ClickListener(){
|
||||||
@Override
|
@Override
|
||||||
@@ -152,14 +163,13 @@ public class BlocksFragment implements Fragment{
|
|||||||
});
|
});
|
||||||
|
|
||||||
table.add(image).size(size + 8);
|
table.add(image).size(size + 8);
|
||||||
image.getImageCell().size(size);
|
|
||||||
|
|
||||||
image.update(() -> {
|
image.update(() -> {
|
||||||
boolean canPlace = !control.tutorial().active() || control.tutorial().canPlace();
|
boolean canPlace = !control.tutorial().active() || control.tutorial().canPlace();
|
||||||
boolean has = (state.inventory.hasItems(r.requirements)) && canPlace;
|
boolean has = (state.inventory.hasItems(r.requirements)) && canPlace;
|
||||||
image.setChecked(input.recipe == r);
|
image.setChecked(input.recipe == r);
|
||||||
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
|
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)
|
if (i % rows == rows - 1)
|
||||||
@@ -248,8 +258,14 @@ public class BlocksFragment implements Fragment{
|
|||||||
desctable.add(header).left();
|
desctable.add(header).left();
|
||||||
|
|
||||||
desctable.row();
|
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);
|
Label nameLabel = new Label(recipe.result.formalName);
|
||||||
nameLabel.setWrap(true);
|
nameLabel.setWrap(true);
|
||||||
header.add(nameLabel).padLeft(2).width(120f);
|
header.add(nameLabel).padLeft(2).width(120f);
|
||||||
|
|||||||
@@ -177,16 +177,20 @@ public class Block extends BaseBlock {
|
|||||||
Effects.sound(explosionSound, x, y);
|
Effects.sound(explosionSound, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextureRegion getIcon(){
|
public TextureRegion[] getIcon(boolean compact){
|
||||||
if(Draw.hasRegion(name + "-icon")){
|
if(Draw.hasRegion(name + "-icon")){
|
||||||
return Draw.region(name + "-icon");
|
return new TextureRegion[]{Draw.region(name + "-icon")};
|
||||||
}else{
|
}else{
|
||||||
TextureRegion region = new TextureRegion(Draw.region(name));
|
return new TextureRegion[]{compact ? iconRegion(name) : Draw.region(name)};
|
||||||
region.setRegionWidth(8);
|
|
||||||
region.setRegionHeight(8);
|
|
||||||
return region;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected TextureRegion iconRegion(String name){
|
||||||
|
TextureRegion region = new TextureRegion(Draw.region(name));
|
||||||
|
region.setRegionWidth(8);
|
||||||
|
region.setRegionHeight(8);
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
public TileEntity getEntity(){
|
public TileEntity getEntity(){
|
||||||
return new TileEntity();
|
return new TileEntity();
|
||||||
|
|||||||
@@ -56,8 +56,11 @@ public abstract class BaseBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void tryMoveLiquid(Tile tile, Tile next){
|
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,
|
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));
|
Math.min(tile.entity.liquid.amount/liquidFlowFactor * Math.max(Timers.delta(), 1f), tile.entity.liquid.amount));
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class DistributionBlocks{
|
|||||||
laserDirections = 1;
|
laserDirections = 1;
|
||||||
size = 3;
|
size = 3;
|
||||||
powerCapacity = 2000f;
|
powerCapacity = 2000f;
|
||||||
|
base = "batterylarge-base";
|
||||||
}},
|
}},
|
||||||
teleporter = new Teleporter("teleporter"){{
|
teleporter = new Teleporter("teleporter"){{
|
||||||
}},
|
}},
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class LiquidRouter extends LiquidBlock{
|
|||||||
rotate = false;
|
rotate = false;
|
||||||
solid = true;
|
solid = true;
|
||||||
liquidFlowFactor = 2f;
|
liquidFlowFactor = 2f;
|
||||||
|
hasInventory = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.generation.Generator;
|
import io.anuke.mindustry.world.blocks.types.generation.Generator;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
|
||||||
public class PowerLaser extends Generator{
|
public class PowerLaser extends Generator{
|
||||||
public Color color = Color.valueOf("e54135");
|
public Color color = Color.valueOf("e54135");
|
||||||
|
public String base = null;
|
||||||
|
|
||||||
public PowerLaser(String name) {
|
public PowerLaser(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@@ -18,8 +20,16 @@ public class PowerLaser extends Generator{
|
|||||||
hasInventory = false;
|
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
|
@Override
|
||||||
public void draw(Tile tile) {
|
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);
|
Draw.rect(name(), tile.drawx(), tile.drawy(), tile.getRotation() * 90 - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||