Misc fixes for mods (2)

This commit is contained in:
Anuken 2022-05-14 01:42:49 -04:00
parent b66283fbd0
commit e9290af4d2
5 changed files with 19 additions and 16 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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(() -> {

View File

@ -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);
}

View File

@ -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);
}