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 Array<Schematic> all = new Array<>();
private OrderedMap<Schematic, FrameBuffer> previews = new OrderedMap<>();
private ObjectSet<Schematic> errored = new ObjectSet<>();
private FrameBuffer shadowBuffer;
private Texture errorTexture;
private long lastClearTime;
public Schematics(){
@@ -59,6 +61,9 @@ public class Schematics implements Loadable{
previews.each((schem, m) -> m.dispose());
previews.clear();
shadowBuffer.dispose();
if(errorTexture != null){
errorTexture.dispose();
}
});
Events.on(ContentReloadEvent.class, event -> {
@@ -66,6 +71,12 @@ public class Schematics implements Loadable{
previews.clear();
load();
});
Events.on(ClientLoadEvent.class, event -> {
Pixmap pixmap = Core.atlas.getPixmap("error").crop();
errorTexture = new Texture(pixmap);
pixmap.dispose();
});
}
@Override
@@ -163,7 +174,15 @@ public class Schematics implements Loadable{
}
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){

View File

@@ -1,11 +1,10 @@
package mindustry.graphics;
import arc.Core;
import arc.graphics.Color;
import arc.graphics.g2d.Draw;
import arc.graphics.gl.Shader;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.graphics.gl.*;
import static arc.Core.camera;
import static mindustry.Vars.renderer;
public enum CacheLayer{
@@ -81,7 +80,7 @@ public enum CacheLayer{
renderer.effectBuffer.end();
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();
renderer.blocks.floor.beginc();

View File

@@ -203,7 +203,7 @@ public class LightRenderer{
Draw.color();
Shaders.light.ambient.set(state.rules.ambientLight);
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();
lights.clear();

View File

@@ -43,7 +43,7 @@ public class Pixelator implements Disposable{
buffer.end();
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();
Groups.drawNames();