Icon generation improvements
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 766 B |
|
Before Width: | Height: | Size: 371 KiB After Width: | Height: | Size: 380 KiB |
|
Before Width: | Height: | Size: 611 KiB After Width: | Height: | Size: 632 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 258 KiB |
|
Before Width: | Height: | Size: 260 KiB After Width: | Height: | Size: 285 KiB |
|
Before Width: | Height: | Size: 870 KiB After Width: | Height: | Size: 905 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 271 KiB After Width: | Height: | Size: 252 KiB |
|
Before Width: | Height: | Size: 261 KiB After Width: | Height: | Size: 278 KiB |
|
Before Width: | Height: | Size: 916 KiB After Width: | Height: | Size: 955 KiB |
@@ -175,6 +175,7 @@ public class Mods implements Loadable{
|
||||
arr.each(c -> {
|
||||
if(c instanceof UnlockableContent && c.minfo.mod != null){
|
||||
UnlockableContent u = (UnlockableContent)c;
|
||||
u.load();
|
||||
u.createIcons(packer);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -443,13 +443,13 @@ public class Block extends UnlockableContent{
|
||||
return editorVariantRegions;
|
||||
}
|
||||
|
||||
protected TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name)};
|
||||
protected TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region};
|
||||
}
|
||||
|
||||
public TextureRegion[] getGeneratedIcons(){
|
||||
if(generatedIcons == null){
|
||||
generatedIcons = generateIcons();
|
||||
generatedIcons = icons();
|
||||
}
|
||||
return generatedIcons;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.defense;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
@@ -15,7 +14,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PointDefenseTurret extends Block{
|
||||
public final int timerTarget = timers++;
|
||||
@@ -48,8 +47,8 @@ public class PointDefenseTurret extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find("block-" + size), Core.atlas.find(name)};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
public class PointDefenseEntity extends TileEntity{
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Wall extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")};
|
||||
}
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find("block-" + size), Core.atlas.find(name)};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
@@ -72,8 +71,8 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-0-0")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{regions[0][0]};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
@@ -48,8 +47,8 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-base"), Core.atlas.find(name)};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PayloadConveyor extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextureRegion[] generateIcons(){
|
||||
protected TextureRegion[] icons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-icon")};
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public class Floor extends Block{
|
||||
|
||||
Color color = new Color();
|
||||
Color color2 = new Color();
|
||||
PixmapRegion image = Core.atlas.getPixmap((AtlasRegion)generateIcons()[0]);
|
||||
PixmapRegion image = Core.atlas.getPixmap((AtlasRegion)icons()[0]);
|
||||
PixmapRegion edge = Core.atlas.getPixmap("edge-stencil");
|
||||
Pixmap result = new Pixmap(edge.width, edge.height);
|
||||
|
||||
@@ -146,11 +146,6 @@ public class Floor extends Block{
|
||||
packer.add(PageType.environment, name + "-edge", result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBase(Tile tile){
|
||||
Mathf.random.setSeed(tile.pos());
|
||||
|
||||
@@ -26,8 +26,8 @@ public class Rock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return variants == 0 ? super.generateIcons() : new TextureRegion[]{Core.atlas.find(name + "1")};
|
||||
public TextureRegion[] icons(){
|
||||
return variants == 0 ? super.icons() : new TextureRegion[]{Core.atlas.find(name + "1")};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Conduit extends LiquidBlock implements Autotiler{
|
||||
public final int timerFlow = timers++;
|
||||
@@ -68,8 +68,8 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find("conduit-bottom"), Core.atlas.find(name + "-top-0")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{Core.atlas.find("conduit-bottom"), topRegions[0]};
|
||||
}
|
||||
|
||||
public class ConduitEntity extends LiquidBlockEntity{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.liquid;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -22,8 +21,8 @@ public class LiquidBlock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{bottomRegion, topRegion};
|
||||
}
|
||||
|
||||
public class LiquidBlockEntity extends TileEntity{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.liquid;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
@@ -25,8 +24,8 @@ public class LiquidJunction extends LiquidBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name)};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region};
|
||||
}
|
||||
|
||||
public class LiquidJunctionEntity extends TileEntity{
|
||||
|
||||
@@ -60,8 +60,8 @@ public class ImpactReactor extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name)};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{bottomRegion, region};
|
||||
}
|
||||
|
||||
public class FusionReactorEntity extends GeneratorEntity{
|
||||
|
||||
@@ -51,8 +51,8 @@ public class Cultivator extends GenericCrafter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top"),};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, topRegion};
|
||||
}
|
||||
|
||||
public class CultivatorEntity extends GenericCrafterEntity{
|
||||
|
||||
@@ -164,8 +164,8 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator"), Core.atlas.find(name + "-top")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, rotatorRegion, topRegion};
|
||||
}
|
||||
|
||||
void countOre(Tile tile){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.production;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -30,8 +29,8 @@ public class Fracker extends SolidPump{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator"), Core.atlas.find(name + "-top")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, rotatorRegion, topRegion};
|
||||
}
|
||||
|
||||
public class FrackerEntity extends SolidPumpEntity{
|
||||
|
||||
@@ -61,8 +61,8 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return drawIcons == null ? super.generateIcons() : drawIcons.get();
|
||||
public TextureRegion[] icons(){
|
||||
return drawIcons == null ? super.icons() : drawIcons.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,8 +55,8 @@ public class Pump extends LiquidBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name)};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,8 +80,8 @@ public class SolidPump extends Pump{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator"), Core.atlas.find(name + "-top")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, rotatorRegion, topRegion};
|
||||
}
|
||||
|
||||
public class SolidPumpEntity extends PumpEntity{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
@@ -35,8 +34,8 @@ public class Reconstructor extends UnitBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-out"), Core.atlas.find(name + "-top")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, outRegion, topRegion};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
@@ -14,7 +13,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class RepairPoint extends Block{
|
||||
private static final Rect rect = new Rect();
|
||||
@@ -56,8 +55,8 @@ public class RepairPoint extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-base"), Core.atlas.find(name)};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
public class RepairPointEntity extends TileEntity{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
@@ -86,8 +85,8 @@ public class UnitFactory extends UnitBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-out"), Core.atlas.find(name + "-top")};
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, outRegion, topRegion};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -99,10 +99,11 @@ public class Generators{
|
||||
Image colors = new Image(content.blocks().size, 1);
|
||||
|
||||
for(Block block : content.blocks()){
|
||||
block.load();
|
||||
|
||||
TextureRegion[] regions = block.getGeneratedIcons();
|
||||
|
||||
if(block instanceof Floor){
|
||||
block.load();
|
||||
for(TextureRegion region : block.variantRegions()){
|
||||
GenRegion gen = (GenRegion)region;
|
||||
if(gen.path == null) continue;
|
||||
@@ -198,7 +199,7 @@ public class Generators{
|
||||
}catch(IllegalArgumentException e){
|
||||
Log.info("Skipping &ly'@'", block.name);
|
||||
}catch(NullPointerException e){
|
||||
Log.err("Block &ly'@'&lr has an null region!");
|
||||
Log.err("Block &ly'@'&lr has an null region!", block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +230,7 @@ public class Generators{
|
||||
});
|
||||
|
||||
ImagePacker.generate("item-icons", () -> {
|
||||
for(UnlockableContent item : (Seq<? extends UnlockableContent>)(Seq)Seq.withArrays(content.items(), content.liquids())){
|
||||
for(UnlockableContent item : Seq.<UnlockableContent>withArrays(content.items(), content.liquids())){
|
||||
Image base = ImagePacker.get(item.getContentType().name() + "-" + item.name);
|
||||
for(Cicon icon : Cicon.scaled){
|
||||
//if(icon.size == base.width) continue;
|
||||
@@ -339,7 +340,7 @@ public class Generators{
|
||||
}
|
||||
|
||||
try{
|
||||
Image image = gens.get(floor, ImagePacker.get(floor.generateIcons()[0]));
|
||||
Image image = gens.get(floor, ImagePacker.get(floor.getGeneratedIcons()[0]));
|
||||
Image edge = ImagePacker.get("edge-stencil");
|
||||
Image result = new Image(edge.width, edge.height);
|
||||
|
||||
|
||||
@@ -86,6 +86,14 @@ public class ImagePacker{
|
||||
return (AtlasRegion)regionCache.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AtlasRegion find(String name, String def){
|
||||
if(!regionCache.containsKey(name)){
|
||||
return (AtlasRegion)regionCache.get(def);
|
||||
}
|
||||
return (AtlasRegion)regionCache.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String s){
|
||||
return regionCache.containsKey(s);
|
||||
|
||||