From e9290af4d2212ae035fbe2056c7accba27a86a62 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 14 May 2022 01:42:49 -0400 Subject: [PATCH] Misc fixes for mods (2) --- core/src/mindustry/ctype/UnlockableContent.java | 4 +--- core/src/mindustry/graphics/Drawf.java | 6 ++++++ core/src/mindustry/mod/Mods.java | 13 ++++++++----- core/src/mindustry/type/UnitType.java | 2 +- core/src/mindustry/world/Block.java | 10 +++------- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/core/src/mindustry/ctype/UnlockableContent.java b/core/src/mindustry/ctype/UnlockableContent.java index 2538a84219..15dc0f8d01 100644 --- a/core/src/mindustry/ctype/UnlockableContent.java +++ b/core/src/mindustry/ctype/UnlockableContent.java @@ -100,9 +100,7 @@ public abstract class UnlockableContent extends MappableContent{ if(!makeNew || !packer.has(name + "-outline")){ PixmapRegion base = Core.atlas.getPixmap(region); var result = Pixmaps.outline(base, outlineColor, outlineRadius); - if(Core.settings.getBool("linear", true)){ - Pixmaps.bleed(result); - } + Drawf.checkBleed(result); packer.add(page, name + (makeNew ? "-outline" : ""), result); } } diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index d20367cf0a..4e01e5179b 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -1,5 +1,6 @@ package mindustry.graphics; +import arc.*; import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; @@ -18,6 +19,11 @@ public class Drawf{ private static final Vec2[] vecs = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()}; private static final FloatSeq points = new FloatSeq(); + /** Bleeds a mod pixmap if linear filtering is enabled. */ + public static void checkBleed(Pixmap pixmap){ + if(Core.settings.getBool("linear", true)) Pixmaps.bleed(pixmap); + } + //TODO offset unused public static void flame(float x, float y, int divisions, float rotation, float length, float width, float pan){ float len1 = length * pan, len2 = length * (1f - pan); diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index f450840504..d962a7b061 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -188,12 +188,15 @@ public class Mods implements Loadable{ if(!prefix && !Core.atlas.has(name)){ Log.warn("Sprite '@' in mod '@' attempts to override a non-existent sprite. Ignoring.", name, mod.name); continue; - } - //TODO !!! document this on the wiki !!! - //do not allow packing standard outline sprites for now, they are no longer necessary and waste space! - //TODO also full regions are bad: || name.endsWith("-full") - if(prefix && (name.endsWith("-outline"))) continue; + //(horrible code below) + }else if(prefix && name.endsWith("-outline") && file.path().contains("units") && !file.path().contains("blocks")){ + Log.warn("Sprite '@' in mod '@' is likely to be an unnecessary unit outline. These should not be separate sprites. Ignoring.", name, mod.name); + //TODO !!! document this on the wiki !!! + //do not allow packing standard outline sprites for now, they are no longer necessary and waste space! + //TODO also full regions are bad: || name.endsWith("-full") + continue; + } //read and bleed pixmaps in parallel tasks.add(mainExecutor.submit(() -> { diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 7a4ba69c6c..76fac1a871 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -860,7 +860,7 @@ public class UnitType extends UnlockableContent{ String regionName = atlas.name; Pixmap outlined = Pixmaps.outline(Core.atlas.getPixmap(region), outlineColor, outlineRadius); - if(Core.settings.getBool("linear", true)) Pixmaps.bleed(outlined); + Drawf.checkBleed(outlined); packer.add(PageType.main, regionName + "-outline", outlined); } diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 79c0bf36ce..e7b777b4fe 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -1250,9 +1250,7 @@ public class Block extends UnlockableContent implements Senseable{ } } - if(Core.settings.getBool("linear", true)){ - Pixmaps.bleed(out); - } + Drawf.checkBleed(out); packer.add(PageType.main, name + "-team-" + team.name, out); } @@ -1272,9 +1270,7 @@ public class Block extends UnlockableContent implements Senseable{ AtlasRegion atlasRegion = (AtlasRegion)gen[outlinedIcon >= 0 ? Math.min(outlinedIcon, gen.length - 1) : gen.length -1]; PixmapRegion region = Core.atlas.getPixmap(atlasRegion); Pixmap out = last = Pixmaps.outline(region, outlineColor, outlineRadius); - if(Core.settings.getBool("linear", true)){ - Pixmaps.bleed(out); - } + Drawf.checkBleed(out); packer.add(PageType.main, atlasRegion.name, out); } @@ -1286,7 +1282,7 @@ public class Block extends UnlockableContent implements Senseable{ String regionName = atlas.name; Pixmap outlined = Pixmaps.outline(Core.atlas.getPixmap(region), outlineColor, outlineRadius); - if(Core.settings.getBool("linear", true)) Pixmaps.bleed(outlined); + Drawf.checkBleed(outlined); packer.add(PageType.main, regionName + "-outline", outlined); }