Fixed crude turret icons
|
After Width: | Height: | Size: 173 B |
|
After Width: | Height: | Size: 682 B |
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 191 B |
|
Before Width: | Height: | Size: 400 B After Width: | Height: | Size: 400 B |
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 127 KiB |
@@ -157,7 +157,7 @@ public class TurretBlocks extends BlockList implements ContentList {
|
||||
size = 3;
|
||||
}};
|
||||
|
||||
spectre = new ItemTurret("eraser") {{
|
||||
spectre = new ItemTurret("spectre") {{
|
||||
ammoTypes = new AmmoType[]{AmmoTypes.bulletTungsten, AmmoTypes.bulletLead, AmmoTypes.bulletCarbide, AmmoTypes.bulletThermite, AmmoTypes.bulletThorium, AmmoTypes.bulletSilicon};
|
||||
reload = 25f;
|
||||
restitution = 0.03f;
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.Turret;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.StatCategory;
|
||||
@@ -364,7 +365,13 @@ public class BlocksFragment implements Fragment{
|
||||
ScrollPane pane = new ScrollPane(table, "clear");
|
||||
|
||||
table.table(title -> {
|
||||
title.addImage(Draw.region("block-icon-" + block.name)).size(8 * 6);
|
||||
int size = 8*6;
|
||||
|
||||
if(block instanceof Turret){
|
||||
size = (8 * block.size + 2) * (7 - block.size*2);
|
||||
}
|
||||
|
||||
title.addImage(Draw.region("block-icon-" + block.name)).size(size);
|
||||
title.add("[accent]" + block.formalName).padLeft(5);
|
||||
});
|
||||
|
||||
|
||||
@@ -374,10 +374,7 @@ public class Block extends BaseBlock implements UnlockableContent{
|
||||
/**Returns a list of icon regions that have been cropped to 8x8*/
|
||||
public TextureRegion[] getCompactIcon(){
|
||||
if(compactIcon == null) {
|
||||
compactIcon = new TextureRegion[getIcon().length];
|
||||
for (int i = 0; i < compactIcon.length; i++) {
|
||||
compactIcon[i] = iconRegion(getIcon()[i]);
|
||||
}
|
||||
compactIcon = new TextureRegion[]{iconRegion(Draw.region("block-icon-" + name))};
|
||||
}
|
||||
return compactIcon;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class LiquidTurret extends Turret {
|
||||
public void setStats() {
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.inputItems, new LiquidFilterValue(item -> liquidAmmoMap.containsKey(item)));
|
||||
stats.add(BlockStat.inputLiquid, new LiquidFilterValue(item -> liquidAmmoMap.containsKey(item)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,15 +56,20 @@ public abstract class Turret extends Block{
|
||||
protected float rotatespeed = 5f; //in degrees per tick
|
||||
protected float shootCone = 8f;
|
||||
protected float shootShake = 0f;
|
||||
|
||||
protected Translator tr = new Translator();
|
||||
protected Translator tr2 = new Translator();
|
||||
protected String base = null; //name of the region to draw under turret, usually null
|
||||
|
||||
protected TextureRegion baseRegion;
|
||||
protected TextureRegion heatRegion;
|
||||
protected TextureRegion baseTopRegion;
|
||||
|
||||
protected BiConsumer<Tile, TurretEntity> drawer = (tile, entity) -> Draw.rect(name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
protected BiConsumer<Tile, TurretEntity> heatDrawer = (tile, entity) ->{
|
||||
Graphics.setAdditiveBlending();
|
||||
Draw.color(heatColor);
|
||||
Draw.alpha(entity.heat);
|
||||
Draw.rect(name + "-heat", tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
Draw.rect(heatRegion, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
Graphics.setNormalBlending();
|
||||
};
|
||||
|
||||
@@ -82,6 +87,15 @@ public abstract class Turret extends Block{
|
||||
viewRange = range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
baseRegion = Draw.region("block-" + size);
|
||||
baseTopRegion = Draw.region("block-" +size + "-top");
|
||||
heatRegion = Draw.region(name + "-heat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
@@ -98,16 +112,10 @@ public abstract class Turret extends Block{
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
if(base == null) {
|
||||
Draw.rect("block-" + size, tile.drawx(), tile.drawy());
|
||||
if(Draw.hasRegion("block-" + size + "-top")) {
|
||||
Draw.color(tile.getTeam().color, Color.WHITE, 0.45f);
|
||||
Draw.rect("block-" + size + "-top", tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
}
|
||||
}else{
|
||||
Draw.rect(base, tile.drawx(), tile.drawy());
|
||||
}
|
||||
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color(tile.getTeam().color, Color.WHITE, 0.45f);
|
||||
Draw.rect(baseTopRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,11 +136,11 @@ public abstract class Turret extends Block{
|
||||
@Override
|
||||
public TextureRegion[] getBlockIcon(){
|
||||
if(blockIcon == null){
|
||||
blockIcon = Draw.hasRegion(name) ? new TextureRegion[]{Draw.region("block-" + size), Draw.region(name)} : new TextureRegion[0];
|
||||
blockIcon = new TextureRegion[]{Draw.region("block-icon-" + name)};
|
||||
}
|
||||
return blockIcon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
Draw.color(tile.getTeam().color);
|
||||
|
||||
@@ -8,6 +8,8 @@ import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.mindustry.type.Upgrade;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.Turret;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
|
||||
public class Generators {
|
||||
|
||||
@@ -21,20 +23,56 @@ public class Generators {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(regions[0] == null){
|
||||
context.err("Error in block \"{0}\": null region!", block.name);
|
||||
}
|
||||
if(block instanceof Turret){
|
||||
Color color = Color.ROYAL;
|
||||
|
||||
Image image = context.get(regions[0]);
|
||||
|
||||
for(TextureRegion region : regions){
|
||||
if(region == null){
|
||||
context.err("Error in block \"{0}\": null region!", block.name);
|
||||
Image image = context.get(block.name);
|
||||
if(image.width() != block.size*8 + 2){
|
||||
Image resized = context.create(block.size*8 + 2, block.size*8 + 2);
|
||||
resized.draw(image, (resized.width() - image.width())/2, (resized.height() - image.height())/2);
|
||||
image = resized;
|
||||
}
|
||||
image.draw(region);
|
||||
}
|
||||
|
||||
image.save("block-icon-" + block.name);
|
||||
Image read = context.create(image.width(), image.height());
|
||||
read.draw(image);
|
||||
|
||||
for (int x = 0; x < image.width(); x++) {
|
||||
for (int y = 0; y < image.height(); y++) {
|
||||
if(read.isEmpty(x, y) &&
|
||||
(!read.isEmpty(x, y + 1) || !read.isEmpty(x, y - 1) || !read.isEmpty(x + 1, y) || !read.isEmpty(x - 1, y))){
|
||||
image.draw(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image base = context.get("block-" + block.size);
|
||||
Image top = context.get("block-" + block.size + "-top");
|
||||
|
||||
for (int x = 0; x < base.width(); x++) {
|
||||
for (int y = 0; y < base.height(); y++) {
|
||||
Color result = top.getColor(x, y);
|
||||
if(result.a > 0.01f){
|
||||
Hue.mix(result, color, 0.45f, result);
|
||||
base.draw(x, y, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image padded = context.create(base.width() + 2, base.height() + 2);
|
||||
padded.draw(base, 1, 1);
|
||||
padded.draw(image, 0, 0);
|
||||
|
||||
padded.save("block-icon-" + block.name);
|
||||
}else {
|
||||
|
||||
Image image = context.get(regions[0]);
|
||||
|
||||
for (TextureRegion region : regions) {
|
||||
image.draw(region);
|
||||
}
|
||||
|
||||
image.save("block-icon-" + block.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
@@ -20,12 +21,16 @@ public class Image {
|
||||
private Color color = new Color();
|
||||
|
||||
public Image(BufferedImage atlas, TextureRegion region){
|
||||
this.atlas = atlas;
|
||||
|
||||
this.image = new BufferedImage(region.getRegionWidth(), region.getRegionHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
this.graphics = image.createGraphics();
|
||||
this(atlas, region.getRegionWidth(), region.getRegionHeight());
|
||||
|
||||
draw(region);
|
||||
}
|
||||
|
||||
public Image(BufferedImage atlas, int width, int height){
|
||||
this.atlas = atlas;
|
||||
|
||||
this.image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
this.graphics = image.createGraphics();
|
||||
|
||||
toDispose.add(this);
|
||||
}
|
||||
@@ -38,6 +43,14 @@ public class Image {
|
||||
return image.getHeight();
|
||||
}
|
||||
|
||||
public boolean isEmpty(int x, int y){
|
||||
if(!Mathf.inBounds(x, y, width(), height())){
|
||||
return true;
|
||||
}
|
||||
Color color = getColor(x, y);
|
||||
return color.a <= 0.001f;
|
||||
}
|
||||
|
||||
public Color getColor(int x, int y){
|
||||
int i = image.getRGB(x, y);
|
||||
Color.argb8888ToColor(color, i);
|
||||
@@ -56,7 +69,12 @@ public class Image {
|
||||
|
||||
/**Draws an image at the top left corner.*/
|
||||
public void draw(Image image){
|
||||
graphics.drawImage(image.image, 0, 0, null);
|
||||
draw(image, 0, 0);
|
||||
}
|
||||
|
||||
/**Draws an image at the coordinates specified.*/
|
||||
public void draw(Image image, int x, int y){
|
||||
graphics.drawImage(image.image, x, y, null);
|
||||
}
|
||||
|
||||
public void draw(TextureRegion region, boolean flipx, boolean flipy){
|
||||
|
||||
@@ -93,6 +93,10 @@ public class ImageContext {
|
||||
Log.info("&ly[Generator]&lc Time to generate &lm{0}&lc: &lg{1}&lcms", name, Timers.elapsed());
|
||||
}
|
||||
|
||||
public Image create(int width, int height){
|
||||
return new Image(image, width, height);
|
||||
}
|
||||
|
||||
public Image get(String name){
|
||||
return get(Core.atlas.getRegion(name));
|
||||
}
|
||||
|
||||