Tar shader / Spritesheet split / Font cleanup

This commit is contained in:
Anuken
2019-03-10 11:11:16 -04:00
parent f861b75c7d
commit 1feb4a5e6d
33 changed files with 4717 additions and 2975 deletions

View File

@@ -36,7 +36,7 @@ public class Blocks implements ContentList{
//environment
air, part, spawn, deepwater, water, tar, stone, craters, charr, sand, ice, snow,
holostone, rocks, icerocks, cliffs, pine, whiteTree, whiteTreeDead, sporeCluster,
iceSnow, sandWater, duneRocks, sandRocks, stainedRocks, stainedStone, stainedRocksRed, stainedStoneRed, stainedRocksYellow, stainedStoneYellow, stainedBoulder,
iceSnow, sandWater, duneRocks, sandRocks, stainedRocks, stainedStone, stainedRocksRed, stainedStoneRed, stainedRocksYellow, stainedStoneYellow, stainedBoulder, grass,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks,
//crafting
@@ -141,7 +141,7 @@ public class Blocks implements ContentList{
variants = 0;
liquidDrop = Liquids.oil;
isLiquid = true;
cacheLayer = CacheLayer.oil;
cacheLayer = CacheLayer.tar;
}};
stone = new Floor("stone"){{
@@ -179,6 +179,10 @@ public class Blocks implements ContentList{
edgeStyle = "blocky";
}};
grass = new Floor("grass"){{
}};
iceSnow = new Floor("ice-snow"){{
variants = 3;
}};

View File

@@ -63,10 +63,11 @@ public class Control implements ApplicationListener{
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
content.initialize(Content::load);
/*
if(Core.atlas.getTextures().size != 1){
throw new IllegalStateException("Atlas must be exactly one texture. " +
"If more textures are used, the map editor will not display them correctly.");
}
}*/
data.load();

View File

@@ -130,7 +130,6 @@ public class UI implements ApplicationListener{
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf"));
FreeTypeFontParameter param = new FreeTypeFontParameter();
param.size = (int)(9*2 * Math.max(Unit.dp.scl(1f), 0.5f));
//param.size = (int)(14*2 * Math.max(Unit.dp.scl(1f), 0.5f));
param.shadowColor = Color.DARK_GRAY;
param.shadowOffsetY = 2;
param.incremental = true;

View File

@@ -4,6 +4,7 @@ import io.anuke.arc.Core;
import io.anuke.arc.collection.IntSet;
import io.anuke.arc.collection.IntSet.IntSetIterator;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.Texture;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf;
@@ -14,7 +15,6 @@ import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.IndexedRenderer;
import io.anuke.mindustry.maps.MapTileData.DataPosition;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Block.Icon;
import static io.anuke.mindustry.Vars.content;
import static io.anuke.mindustry.Vars.tilesize;
@@ -26,9 +26,11 @@ public class MapRenderer implements Disposable{
private IntSet delayedUpdates = new IntSet();
private MapEditor editor;
private int width, height;
private Texture texture;
public MapRenderer(MapEditor editor){
this.editor = editor;
texture = Core.atlas.find("clear-editor").getTexture();
}
public void resize(int width, int height){
@@ -52,7 +54,6 @@ public class MapRenderer implements Disposable{
updateAll();
}
public void draw(float tx, float ty, float tw, float th){
Draw.flush();
@@ -80,7 +81,7 @@ public class MapRenderer implements Disposable{
mesh.getTransformMatrix().setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize));
mesh.setProjectionMatrix(Draw.proj());
mesh.render(Core.atlas.getTextures().first());
mesh.render(texture);
}
}
}
@@ -116,7 +117,7 @@ public class MapRenderer implements Disposable{
int idxDecal = (wx % chunksize) + (wy % chunksize) * chunksize + chunksize * chunksize;
if(bw != 0 && (wall.synthetic() || wall == Blocks.part)){
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
if(wall.rotate){
mesh.draw(idxWall, region,
@@ -129,7 +130,7 @@ public class MapRenderer implements Disposable{
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
}
}else{
region = floor.variantRegions()[Mathf.randomSeed(idxWall, 0, floor.variantRegions().length-1)];
region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length-1)];
mesh.draw(idxWall, region, wx * tilesize, wy * tilesize, 8, 8);
}
@@ -138,13 +139,13 @@ public class MapRenderer implements Disposable{
if(wall.update || wall.destructible){
mesh.setColor(team.color);
region = Core.atlas.find("block-border");
region = Core.atlas.find("block-border-editor");
}else if(!wall.synthetic() && bw != 0){
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
offsetX = tilesize/2f - region.getWidth()/2f * Draw.scl;
offsetY = tilesize/2f - region.getHeight()/2f * Draw.scl;
}else{
region = Core.atlas.find("clear");
region = Core.atlas.find("clear-editor");
}
mesh.draw(idxDecal, region,

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.graphics;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.glutils.Shader;
import static io.anuke.arc.Core.camera;
import static io.anuke.mindustry.Vars.renderer;
@@ -11,31 +12,25 @@ public enum CacheLayer{
water{
@Override
public void begin(){
if(!Core.settings.getBool("animatedwater")) return;
renderer.blocks.floor.endc();
renderer.shieldBuffer.begin();
Core.graphics.clear(Color.CLEAR);
renderer.blocks.floor.beginc();
beginShader();
}
@Override
public void end(){
if(!Core.settings.getBool("animatedwater")) return;
endShader(Shaders.water);
}
},
tar{
@Override
public void begin(){
beginShader();
}
renderer.blocks.floor.endc();
renderer.shieldBuffer.end();
Draw.shader(Shaders.water);
Draw.rect(Draw.wrap(renderer.shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
Draw.shader();
renderer.blocks.floor.beginc();
@Override
public void end(){
endShader(Shaders.tar);
}
},
lava,
oil,
space,
normal,
walls;
@@ -46,4 +41,26 @@ public enum CacheLayer{
public void end(){
}
void beginShader(){
if(!Core.settings.getBool("animatedwater")) return;
renderer.blocks.floor.endc();
renderer.shieldBuffer.begin();
Core.graphics.clear(Color.CLEAR);
renderer.blocks.floor.beginc();
}
void endShader(Shader shader){
if(!Core.settings.getBool("animatedwater")) return;
renderer.blocks.floor.endc();
renderer.shieldBuffer.end();
Draw.shader(shader);
Draw.rect(Draw.wrap(renderer.shieldBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
Draw.shader();
renderer.blocks.floor.beginc();
}
}

View File

@@ -14,7 +14,7 @@ public class Shaders{
public static UnitBuild build;
public static FogShader fog;
public static MenuShader menu;
public static SurfaceShader water;
public static SurfaceShader water, tar;
public static void init(){
shadow = new Shadow();
@@ -24,6 +24,7 @@ public class Shaders{
fog = new FogShader();
menu = new MenuShader();
water = new SurfaceShader("water");
tar = new SurfaceShader("tar");
}
public static class MenuShader extends LoadShader{

View File

@@ -75,7 +75,7 @@ public class DeployDialog extends FloatingDialog{
show();
}
});
}).size(200f).get();
}).size(230f).get();
b[0] = button;
String color = "[lightgray]";

View File

@@ -10,6 +10,7 @@ import io.anuke.arc.function.Function;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.scene.ui.layout.Table;
@@ -110,8 +111,8 @@ public class Block extends BlockStorage{
protected Array<Tile> tempTiles = new Array<>();
protected TextureRegion[] icons = new TextureRegion[Icon.values().length];
protected TextureRegion[] generatedIcons;
protected TextureRegion[] variantRegions;
protected TextureRegion region;
protected TextureRegion[] variantRegions, editorVariantRegions;
protected TextureRegion region, editorIcon;
public Block(String name){
super(name);
@@ -513,6 +514,24 @@ public class Block extends BlockStorage{
return icons[icon.ordinal()];
}
/**Never use outside of the editor!*/
public TextureRegion editorIcon(){
if(editorIcon == null) editorIcon = Core.atlas.find(name + "-icon-editor");
return editorIcon;
}
/**Never use outside of the editor!*/
public TextureRegion[] editorVariantRegions(){
if(editorVariantRegions == null){
editorVariantRegions = new TextureRegion[variantRegions.length];
for(int i = 0; i < variantRegions.length; i ++){
AtlasRegion region = (AtlasRegion)variantRegions[i];
editorVariantRegions[i] = Core.atlas.find("editor-" + region.name);
}
}
return editorVariantRegions;
}
protected TextureRegion[] generateIcons(){
return new TextureRegion[]{Core.atlas.find(name)};
}

View File

@@ -8,7 +8,6 @@ import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.math.Mathf;
public class Rock extends Block{
protected TextureRegion[] regions;
protected int variants;
public Rock(String name){
@@ -20,17 +19,12 @@ public class Rock extends Block{
@Override
public void draw(Tile tile){
if(variants > 0){
Draw.rect(regions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, regions.length - 1))], tile.worldx(), tile.worldy());
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
}else{
Draw.rect(region, tile.worldx(), tile.worldy());
}
}
@Override
public TextureRegion[] variantRegions(){
return regions;
}
@Override
public TextureRegion[] generateIcons(){
return variants == 0 ? super.generateIcons() : new TextureRegion[]{Core.atlas.find(name + "1")};
@@ -41,10 +35,10 @@ public class Rock extends Block{
super.load();
if(variants > 0){
regions = new TextureRegion[variants];
variantRegions = new TextureRegion[variants];
for(int i = 0; i < variants; i++){
regions[i] = Core.atlas.find(name + (i + 1));
variantRegions[i] = Core.atlas.find(name + (i + 1));
}
}
}

View File

@@ -31,7 +31,7 @@ public class StaticWall extends Rock{
Draw.rect(large, tile.worldx() + tilesize/2f, tile.worldy() + tilesize/2f);
}
}else if(variants > 0){
Draw.rect(regions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, regions.length - 1))], tile.worldx(), tile.worldy());
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
}else{
Draw.rect(region, tile.worldx(), tile.worldy());
}