From 0d4716f3b4c7714066c51f3dbd09844a7b8e054c Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 23 Aug 2019 14:16:51 -0400 Subject: [PATCH] Fallback shield shader --- core/src/io/anuke/mindustry/core/Renderer.java | 2 +- core/src/io/anuke/mindustry/graphics/Shaders.java | 11 +++++++++-- .../mindustry/ui/dialogs/SettingsMenuDialog.java | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 6041017533..c3005cbe79 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -256,7 +256,7 @@ public class Renderer implements ApplicationListener{ draw(playerGroup, p -> true, Player::drawBuildRequests); if(Entities.countInBounds(shieldGroup) > 0){ - if(settings.getBool("animatedshields")){ + if(settings.getBool("animatedshields") && Shaders.shield != null){ Draw.flush(); shieldBuffer.begin(); graphics.clear(Color.CLEAR); diff --git a/core/src/io/anuke/mindustry/graphics/Shaders.java b/core/src/io/anuke/mindustry/graphics/Shaders.java index 4aa6f02754..afa94cd6ec 100644 --- a/core/src/io/anuke/mindustry/graphics/Shaders.java +++ b/core/src/io/anuke/mindustry/graphics/Shaders.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.graphics; +import io.anuke.annotations.Annotations.*; import io.anuke.arc.Core; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.TextureRegion; @@ -10,7 +11,7 @@ import io.anuke.arc.util.Time; public class Shaders{ public static Shadow shadow; public static BlockBuild blockbuild; - public static Shield shield; + public static @Nullable Shield shield; public static UnitBuild build; public static FogShader fog; public static MenuShader menu; @@ -19,7 +20,13 @@ public class Shaders{ public static void init(){ shadow = new Shadow(); blockbuild = new BlockBuild(); - shield = new Shield(); + try{ + shield = new Shield(); + }catch(Throwable t){ + //don't load shield shader + shield = null; + t.printStackTrace(); + } build = new UnitBuild(); fog = new FogShader(); menu = new MenuShader(); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java index 19fbf6a4d3..21cd40a5dd 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -241,7 +241,9 @@ public class SettingsMenuDialog extends SettingsDialog{ graphics.checkPref("fps", false); graphics.checkPref("indicators", true); graphics.checkPref("animatedwater", false); - graphics.checkPref("animatedshields", !mobile); + if(Shaders.shield != null){ + graphics.checkPref("animatedshields", !mobile); + } graphics.checkPref("bloom", false, val -> renderer.toggleBloom(val)); graphics.checkPref("lasers", true); graphics.checkPref("pixelate", false);