Merge branch '6.0' of https://github.com/Anuken/Mindustry into sprite-sorting

This commit is contained in:
Anuken
2020-04-22 14:34:34 -04:00
5 changed files with 30 additions and 22 deletions

View File

@@ -51,7 +51,9 @@ public class Schematics implements Loadable{
private OptimizedByteArrayOutputStream out = new OptimizedByteArrayOutputStream(1024); private OptimizedByteArrayOutputStream out = new OptimizedByteArrayOutputStream(1024);
private Array<Schematic> all = new Array<>(); private Array<Schematic> all = new Array<>();
private OrderedMap<Schematic, FrameBuffer> previews = new OrderedMap<>(); private OrderedMap<Schematic, FrameBuffer> previews = new OrderedMap<>();
private ObjectSet<Schematic> errored = new ObjectSet<>();
private FrameBuffer shadowBuffer; private FrameBuffer shadowBuffer;
private Texture errorTexture;
private long lastClearTime; private long lastClearTime;
public Schematics(){ public Schematics(){
@@ -59,6 +61,9 @@ public class Schematics implements Loadable{
previews.each((schem, m) -> m.dispose()); previews.each((schem, m) -> m.dispose());
previews.clear(); previews.clear();
shadowBuffer.dispose(); shadowBuffer.dispose();
if(errorTexture != null){
errorTexture.dispose();
}
}); });
Events.on(ContentReloadEvent.class, event -> { Events.on(ContentReloadEvent.class, event -> {
@@ -66,6 +71,12 @@ public class Schematics implements Loadable{
previews.clear(); previews.clear();
load(); load();
}); });
Events.on(ClientLoadEvent.class, event -> {
Pixmap pixmap = Core.atlas.getPixmap("error").crop();
errorTexture = new Texture(pixmap);
pixmap.dispose();
});
} }
@Override @Override
@@ -163,7 +174,15 @@ public class Schematics implements Loadable{
} }
public Texture getPreview(Schematic schematic){ public Texture getPreview(Schematic schematic){
return getBuffer(schematic).getTexture(); if(errored.contains(schematic)) return errorTexture;
try{
return getBuffer(schematic).getTexture();
}catch(Throwable t){
Log.err(t);
errored.add(schematic);
return errorTexture;
}
} }
public boolean hasPreview(Schematic schematic){ public boolean hasPreview(Schematic schematic){

View File

@@ -1,11 +1,10 @@
package mindustry.graphics; package mindustry.graphics;
import arc.Core; import arc.*;
import arc.graphics.Color; import arc.graphics.*;
import arc.graphics.g2d.Draw; import arc.graphics.g2d.*;
import arc.graphics.gl.Shader; import arc.graphics.gl.*;
import static arc.Core.camera;
import static mindustry.Vars.renderer; import static mindustry.Vars.renderer;
public enum CacheLayer{ public enum CacheLayer{
@@ -81,7 +80,7 @@ public enum CacheLayer{
renderer.effectBuffer.end(); renderer.effectBuffer.end();
Draw.shader(shader); Draw.shader(shader);
Draw.rect(Draw.wrap(renderer.effectBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height); Draw.rect(renderer.effectBuffer);
Draw.shader(); Draw.shader();
renderer.blocks.floor.beginc(); renderer.blocks.floor.beginc();

View File

@@ -203,7 +203,7 @@ public class LightRenderer{
Draw.color(); Draw.color();
Shaders.light.ambient.set(state.rules.ambientLight); Shaders.light.ambient.set(state.rules.ambientLight);
Draw.shader(Shaders.light); Draw.shader(Shaders.light);
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height); Draw.rect(buffer);
Draw.shader(); Draw.shader();
lights.clear(); lights.clear();

View File

@@ -43,7 +43,7 @@ public class Pixelator implements Disposable{
buffer.end(); buffer.end();
Draw.blend(Blending.disabled); Draw.blend(Blending.disabled);
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height); Draw.rect(buffer);
Draw.blend(); Draw.blend();
Groups.drawNames(); Groups.drawNames();

View File

@@ -1,19 +1,9 @@
package power; package power;
import mindustry.content.Items;
import mindustry.content.UnitTypes;
import mindustry.type.ItemStack;
import mindustry.world.Tile;
import mindustry.world.blocks.power.PowerGenerator;
import mindustry.world.blocks.power.PowerGraph;
import mindustry.world.blocks.units.UnitFactory;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/** Tests for direct power consumers. */ /** Tests for direct power consumers. */
public class DirectConsumerTests extends PowerTestFixture{ public class DirectConsumerTests extends PowerTestFixture{
//TODO reimplement
/*
@Test @Test
void noPowerRequestedWithNoItems(){ void noPowerRequestedWithNoItems(){
testUnitFactory(0, 0, 0.08f, 0.08f, 1f); testUnitFactory(0, 0, 0.08f, 0.08f, 1f);
@@ -52,5 +42,5 @@ public class DirectConsumerTests extends PowerTestFixture{
graph.update(); graph.update();
assertEquals(expectedSatisfaction, consumerTile.entity.power().status); assertEquals(expectedSatisfaction, consumerTile.entity.power().status);
} }*/
} }