diff --git a/android/build.gradle b/android/build.gradle index 2e1477ac1d..baac8e6d85 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -60,7 +60,7 @@ android{ def versionNameResult = "$versionNumber-$versionType-${getBuildVersion().replace(" ", "-")}" applicationId "io.anuke.mindustry" - minSdkVersion 14 + minSdkVersion 21 targetSdkVersion 36 versionName versionNameResult diff --git a/android/libs_old/arm64-v8a/libarc-freetype.so b/android/libs_old/arm64-v8a/libarc-freetype.so new file mode 100644 index 0000000000..a43110e046 Binary files /dev/null and b/android/libs_old/arm64-v8a/libarc-freetype.so differ diff --git a/android/libs_old/arm64-v8a/libarc.so b/android/libs_old/arm64-v8a/libarc.so new file mode 100644 index 0000000000..8c8711eee2 Binary files /dev/null and b/android/libs_old/arm64-v8a/libarc.so differ diff --git a/android/libs_old/armeabi-v7a/libarc-freetype.so b/android/libs_old/armeabi-v7a/libarc-freetype.so new file mode 100644 index 0000000000..543537cfc1 Binary files /dev/null and b/android/libs_old/armeabi-v7a/libarc-freetype.so differ diff --git a/android/libs_old/armeabi-v7a/libarc.so b/android/libs_old/armeabi-v7a/libarc.so new file mode 100644 index 0000000000..2502666ac3 Binary files /dev/null and b/android/libs_old/armeabi-v7a/libarc.so differ diff --git a/android/libs_old/x86/libarc-freetype.so b/android/libs_old/x86/libarc-freetype.so new file mode 100644 index 0000000000..b135fb29a7 Binary files /dev/null and b/android/libs_old/x86/libarc-freetype.so differ diff --git a/android/libs_old/x86/libarc.so b/android/libs_old/x86/libarc.so new file mode 100644 index 0000000000..08f47a1f09 Binary files /dev/null and b/android/libs_old/x86/libarc.so differ diff --git a/android/libs_old/x86_64/libarc-freetype.so b/android/libs_old/x86_64/libarc-freetype.so new file mode 100644 index 0000000000..c127ac528d Binary files /dev/null and b/android/libs_old/x86_64/libarc-freetype.so differ diff --git a/android/libs_old/x86_64/libarc.so b/android/libs_old/x86_64/libarc.so new file mode 100644 index 0000000000..a4e6f8b85c Binary files /dev/null and b/android/libs_old/x86_64/libarc.so differ diff --git a/core/assets-raw/sprites/blocks/environment/data-patch-reserved-env.png b/core/assets-raw/sprites/blocks/environment/data-patch-reserved-env.png deleted file mode 100644 index c24afbaa82..0000000000 Binary files a/core/assets-raw/sprites/blocks/environment/data-patch-reserved-env.png and /dev/null differ diff --git a/core/src/mindustry/ClientLauncher.java b/core/src/mindustry/ClientLauncher.java index 066a49ee7c..ff447af87c 100644 --- a/core/src/mindustry/ClientLauncher.java +++ b/core/src/mindustry/ClientLauncher.java @@ -139,7 +139,9 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform }); assets.load("sprites/error.png", Texture.class); - atlas = TextureAtlas.blankAtlas(); + atlas = new TextureAtlas(Core.files.internal("sprites/sprites.aatls")); + Fonts.loadDefaultFont(); + Vars.net = new Net(platform.getNet()); MapPreviewLoader.setupLoaders(); mods = new Mods(); @@ -149,13 +151,6 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform assets.load(new Vars()); - Fonts.loadDefaultFont(); - - //load fallback atlas if max texture size is below 4096 - assets.load(new AssetDescriptor<>("sprites/sprites.aatls", TextureAtlas.class)).loaded = t -> { - atlas = t; - Fonts.mergeFontAtlas(atlas); - }; assets.loadRun("maps", Map.class, () -> maps.loadPreviews()); Musics.load(); diff --git a/core/src/mindustry/ctype/UnlockableContent.java b/core/src/mindustry/ctype/UnlockableContent.java index 006f322b24..18b527a210 100644 --- a/core/src/mindustry/ctype/UnlockableContent.java +++ b/core/src/mindustry/ctype/UnlockableContent.java @@ -13,7 +13,6 @@ import mindustry.content.*; import mindustry.content.TechTree.*; import mindustry.game.EventType.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.mod.*; import mindustry.type.*; import mindustry.ui.*; @@ -167,7 +166,7 @@ public abstract class UnlockableContent extends MappableContent{ } - protected void makeOutline(PageType page, MultiPacker packer, TextureRegion region, boolean makeNew, Color outlineColor, int outlineRadius){ + protected void makeOutline(MultiPacker packer, TextureRegion region, boolean makeNew, Color outlineColor, int outlineRadius){ if(region instanceof AtlasRegion at && region.found()){ String name = at.name; if(!makeNew || !packer.has(name + "-outline")){ @@ -176,7 +175,7 @@ public abstract class UnlockableContent extends MappableContent{ PixmapRegion base = packer.get(region); var result = Pixmaps.outline(base, outlineColor, outlineRadius); Drawf.checkBleed(result); - packer.add(page, regName, result); + packer.add(regName, result); result.dispose(); } } @@ -188,7 +187,7 @@ public abstract class UnlockableContent extends MappableContent{ PixmapRegion base = packer.get(region); var result = Pixmaps.outline(base, outlineColor, outlineRadius); Drawf.checkBleed(result); - packer.add(PageType.main, name, result); + packer.add(name, result); result.dispose(); } } diff --git a/core/src/mindustry/graphics/FloorRenderer.java b/core/src/mindustry/graphics/FloorRenderer.java index 43bdf55136..9ddf740e6f 100644 --- a/core/src/mindustry/graphics/FloorRenderer.java +++ b/core/src/mindustry/graphics/FloorRenderer.java @@ -50,7 +50,6 @@ public class FloorRenderer{ private Shader shader; private Mat combinedMat = new Mat(); private Texture texture; - private TextureRegion error; private ChunkMesh[][][] cache; private boolean[][] dirty; @@ -370,7 +369,6 @@ public class FloorRenderer{ dirty = new boolean[chunksx][chunksy]; texture = Core.atlas.find("grass1").texture; - error = Core.atlas.find("env-error"); packWidth = world.unitWidth() + packPad *2f; packHeight = world.unitHeight() + packPad *2f; @@ -414,13 +412,6 @@ public class FloorRenderer{ @Override protected void draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float rotation){ - - //substitute invalid regions with error - if(region.texture != texture && region != error){ - draw(error, x, y, originX, originY, width, height, rotation); - return; - } - float[] verts = vertices; int idx = vidx; vidx += spriteSize; diff --git a/core/src/mindustry/graphics/LoadRenderer.java b/core/src/mindustry/graphics/LoadRenderer.java index da6e58c0ed..b681e6a879 100644 --- a/core/src/mindustry/graphics/LoadRenderer.java +++ b/core/src/mindustry/graphics/LoadRenderer.java @@ -90,10 +90,8 @@ public class LoadRenderer implements Disposable{ lastFrameTime = Time.millis(); } - if(fx.getWidth() != graphics.getWidth() || fx.getHeight() != graphics.getHeight()){ - fx.resize(graphics.getWidth(), graphics.getHeight()); - } - + fx.resize(graphics.getWidth(), graphics.getHeight()); + fx.clear(); fx.begin(); if(assets.getLoadedAssets() != lastLength){ diff --git a/core/src/mindustry/graphics/MultiPacker.java b/core/src/mindustry/graphics/MultiPacker.java index 0d40a489e3..e99ce59dd8 100644 --- a/core/src/mindustry/graphics/MultiPacker.java +++ b/core/src/mindustry/graphics/MultiPacker.java @@ -1,67 +1,53 @@ package mindustry.graphics; -import arc.*; import arc.graphics.*; import arc.graphics.Texture.*; import arc.graphics.g2d.*; +import arc.graphics.g2d.TextureAtlas.*; import arc.struct.*; import arc.util.*; import arc.util.Log.*; -import mindustry.*; +//TODO: this needs to pack to a texture array public class MultiPacker implements Disposable{ - private PixmapPacker[] packers; + private PixmapPacker packer; private ObjectSet outlined = new ObjectSet<>(); - public MultiPacker(){ - this(true); - } - - public MultiPacker(boolean initialize){ - if(initialize){ - packers = new PixmapPacker[PageType.all.length]; - for(int i = 0; i < packers.length; i++){ - packers[i] = new PixmapPacker(Math.min(Vars.maxTextureSize, PageType.all[i].width), Math.min(Vars.maxTextureSize, PageType.all[i].height), 2, true); - } + public MultiPacker(int size){ + if(size > 0){ + packer = new PixmapPacker(size, size, 2, true); } } public PixmapRegion get(TextureRegion region){ - return Core.atlas.getPixmap(region); + return get(((AtlasRegion)region).name); } public PixmapRegion get(String region){ - return Core.atlas.getPixmap(region); + PixmapRegion out = getOrNull(region); + //this should not happen in normal situations + if(out == null) return getOrNull("error"); + return out; } - public @Nullable PixmapRegion getPacked(String name){ - for(var packer : packers){ - var region = packer.getRegion(name); - if(region != null){ - return region; - } - } - return null; + public @Nullable PixmapRegion getOrNull(String name){ + return packer.getRegion(name); } public void printStats(){ if(Log.level != LogLevel.debug) return; - for(PageType type : PageType.all){ - var packer = packers[type.ordinal()]; - Log.debug("[Atlas] [&ly@&fr]", type); - Log.debug("[Atlas] - " + (packer.getPages().size > 1 ? "&fb&lr" : "&lg") + "@ page@&r", packer.getPages().size, packer.getPages().size > 1 ? "s" : ""); - int i = 0; - for(var page : packer.getPages()){ - float totalArea = 0; - for(var region : page.getRects().values()){ - totalArea += region.area(); - } - - Log.debug("[Atlas] - [@] @x@ (&lk@% used&fr)", i, page.getPixmap().width, page.getPixmap().height, (int)(totalArea / (page.getPixmap().width * page.getPixmap().height) * 100f)); - - i ++; + Log.debug("[Atlas] " + (packer.getPages().size > 1 ? "&fb&lr" : "&lg") + "@ page@&r", packer.getPages().size, packer.getPages().size > 1 ? "s" : ""); + int i = 0; + for(var page : packer.getPages()){ + float totalArea = 0; + for(var region : page.getRects().values()){ + totalArea += region.area(); } + + Log.debug("[Atlas] - [@] @x@ (&lk@% used&fr)", i, page.getPixmap().width, page.getPixmap().height, (int)(totalArea / (page.getPixmap().width * page.getPixmap().height) * 100f)); + + i ++; } } @@ -75,78 +61,33 @@ public class MultiPacker implements Disposable{ } public boolean has(String name){ - for(var page : PageType.all){ - if(packers[page.ordinal()].getRect(name) != null){ - return true; - } + if(packer.getRect(name) != null){ + return true; } return false; } - public boolean has(PageType type, String name){ - return packers[type.ordinal()].getRect(name) != null; + public void add(String name, Pixmap pix){ + packer.pack(name, new PixmapRegion(pix)); } - public void add(PageType type, String name, PixmapRegion region){ - add(type, name, region, null, null); + public void add(String name, PixmapRegion region){ + packer.pack(name, region, null, null); } - public void add(PageType type, String name, PixmapRegion region, int[] splits, int[] pads){ - packers[type.ordinal()].pack(name, region, splits, pads); - } - - public void add(PageType type, String name, Pixmap pix){ - add(type, name, new PixmapRegion(pix)); + public void add(String name, PixmapRegion region, int[] splits, int[] pads){ + packer.pack(name, region, splits, pads); } public TextureAtlas flush(TextureFilter filter, TextureAtlas atlas){ - for(PixmapPacker p : packers){ - p.updateTextureAtlas(atlas, filter, filter, false, false); - } + packer.updateTextureAtlas(atlas, filter, filter, false, false); return atlas; } @Override public void dispose(){ - if(packers == null) return; - for(int i = 0; i < PageType.all.length; i ++){ - var packer = packers[i]; - //the UI packer's image is later used when merging with the font, don't dispose it - if(i != PageType.ui.ordinal()){ - packer.forceDispose(); - } - } - } - - //There are several pages for sprites. - //main page (sprites.png) - all sprites for units, weapons, placeable blocks, effects, bullets, etc - //environment page (sprites2.png) - all sprites for things in the environmental cache layer - //ui page (sprites3.png) - content icons, white icons, fonts and UI elements - //rubble page (sprites4.png) - scorch textures for unit deaths & wrecks - //editor page (sprites5.png) - all sprites needed for rendering in the editor, including block icons and a few minor sprites - public enum PageType{ - //main page can be massive, but 8192 throws GL_OUT_OF_MEMORY on some GPUs and I can't deal with it yet. - main(4096), - - environment(4096), - ui(4096), - rubble(4096, 2048); - - public static final PageType[] all = values(); - - public int width = 2048, height = 2048; - - PageType(int defaultSize){ - this.width = this.height = defaultSize; - } - - PageType(int width, int height){ - this.width = width; - this.height = height; - } - - PageType(){ - + if(packer != null){ + packer.forceDispose(); } } } diff --git a/core/src/mindustry/mod/DataImagePacker.java b/core/src/mindustry/mod/DataImagePacker.java index 0640d3649b..7daac1a882 100644 --- a/core/src/mindustry/mod/DataImagePacker.java +++ b/core/src/mindustry/mod/DataImagePacker.java @@ -5,7 +5,6 @@ import arc.files.*; import arc.graphics.*; import arc.graphics.Texture.*; import arc.graphics.g2d.*; -import arc.graphics.g2d.PixmapPacker.*; import arc.math.*; import arc.struct.*; import arc.util.*; @@ -65,11 +64,6 @@ public class DataImagePacker{ PixmapPacker packer = new PixmapPacker(targetSize, targetSize, 2, true); - //env regions are packed onto a special reserved region - boolean anyEnv = images.contains(p -> p.path.contains("blocks/environment/")); - TextureRegion envReserveRegion = Core.atlas.find("data-patch-reserved-env"); - PixmapPacker envPacker = anyEnv ? new PixmapPacker(envReserveRegion.width, envReserveRegion.height, 2, true) : null; - Seq toPack = new Seq<>(), pending = new Seq<>(); ObjectSet generatedNames = new ObjectSet<>(); @@ -100,11 +94,7 @@ public class DataImagePacker{ Pixmap pixmap = new Pixmap(cacheFile); String name = regionPrefix + image.name; - if(anyEnv && image.path.contains("blocks/environment/")){ - envPacker.pack(name, pixmap); - }else{ - packer.pack(name, pixmap); - } + packer.pack(name, pixmap); pixmap.dispose(); }catch(Throwable e){ @@ -118,43 +108,8 @@ public class DataImagePacker{ TextureFilter filter = Core.settings.getBool("linear", !Vars.mobile) ? TextureFilter.linear : TextureFilter.nearest; patchAtlas = packer.generateTextureAtlas(filter, filter, false); - if(envPacker != null && envPacker.getPages().size > 0){ - if(envPacker.getPages().size > 1){ - Log.warn("[Patch Atlas] Unable to fit all environment images into a " + envPacker.getPageWidth() + "x" + envPacker.getPageHeight() + " page. Reduce the size or number of images."); - } - //directly update existing atlas page's reserved region - var page = envPacker.getPages().first(); - envReserveRegion.texture.draw(page.getPixmap(), envReserveRegion.getX(), envReserveRegion.getY()); - - //manually add rects to the patch atlas with texture and offsets based on env atlas - for(String name : page.addedRects){ - PixmapPackerRect rect = page.rects.get(name); - TextureAtlas.AtlasRegion region = new TextureAtlas.AtlasRegion(envReserveRegion.texture, (int)rect.x + envReserveRegion.getX(), (int)rect.y + envReserveRegion.getY(), (int)rect.width, (int)rect.height); - - if(rect.splits != null){ - region.splits = rect.splits; - region.pads = rect.pads; - } - - region.name = name; - region.offsetX = rect.offsetX; - region.offsetY = (int)(rect.originalHeight - rect.height - rect.offsetY); - region.originalWidth = rect.originalWidth; - region.originalHeight = rect.originalHeight; - - patchAtlas.getRegions().add(region); - patchAtlas.getRegionMap().put(name, region); - } - - } - - printStats(packer, envPacker); - packer.forceDispose(); - //textures are never updated, so force disposal - if(envPacker != null) envPacker.forceDispose(); - Core.atlas.getTextures().addAll(patchAtlas.getTextures()); Core.atlas.getRegionMap().putAll(patchAtlas.getRegionMap()); //getRegions is intentionally not modified, it's a hassle to manage, O(n) to unapply, and not used anywhere important. there's no point. //the drawable map isn't used, and thus not modified either @@ -164,9 +119,6 @@ public class DataImagePacker{ public void unload(){ if(patchAtlas != null){ - for(var texture : patchAtlas.getTextures()){ - patchAtlas.getTextures().remove(texture); - } for(var region : patchAtlas.getRegions()){ patchAtlas.getRegionMap().remove(region.name); } @@ -182,7 +134,7 @@ public class DataImagePacker{ if(packer == null) continue; int total = packer.getPages().sum(p -> p.rects.size); - Log.debug("[Patch Atlas] " + (packer == mainPacker ? "Main: " : "Env: ") + (packer.getPages().size > 1 ? "&fb&lr" : "&lg") + "@ page@&lc (" + total + " sprites)", packer.getPages().size, packer.getPages().size > 1 ? "s" : ""); + Log.debug("[Patch Atlas] " + (packer.getPages().size > 1 ? "&fb&lr" : "&lg") + "@ page@&lc (" + total + " sprites)", packer.getPages().size, packer.getPages().size > 1 ? "s" : ""); int i = 0; for(var page : packer.getPages()){ float totalArea = 0; diff --git a/core/src/mindustry/mod/DataManager.java b/core/src/mindustry/mod/DataManager.java index 76998eca6a..d6a8692daf 100644 --- a/core/src/mindustry/mod/DataManager.java +++ b/core/src/mindustry/mod/DataManager.java @@ -75,9 +75,9 @@ public class DataManager{ UnlockableContent[] currentContent = {null}; String[] currentHash = {null}; - MultiPacker saver = new MultiPacker(false){ + MultiPacker saver = new MultiPacker(0){ @Override - public void add(PageType type, String name, PixmapRegion region, int[] splits, int[] pads){ + public void add(String name, PixmapRegion region, int[] splits, int[] pads){ try{ if(region.pixmap.width > 2000) throw new IllegalArgumentException("Max image size exceeded"); @@ -102,11 +102,6 @@ public class DataManager{ return imageMap.containsKey(name); } - @Override - public boolean has(PageType type, String name){ - return has(name); - } - @Override public @Nullable PixmapRegion get(TextureRegion region){ return get(((AtlasRegion)region).name); diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index eb0683a037..d9b422c0f6 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -19,7 +19,6 @@ import mindustry.ctype.*; import mindustry.game.EventType.*; import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.mod.ContentParser.*; import mindustry.type.*; import mindustry.ui.*; @@ -139,6 +138,41 @@ public class Mods implements Loadable{ } } + /* + + TODO: getPixmap: + + + public PixmapRegion getPixmap(String name){ + return getPixmap(find(name)); + } + + public PixmapRegion getPixmap(AtlasRegion region){ + if(region.pixmapRegion == null){ + Pixmap pix = pixmaps.get(region.texture, () -> region.texture.getTextureData().getPixmap()); + region.pixmapRegion = new PixmapRegion(pix, region.getX(), region.getY(), region.width, region.height); + } + + return region.pixmapRegion; + } + + public PixmapRegion getPixmap(TextureRegion region){ + return getPixmap((AtlasRegion)region); + } + + public ObjectMap getPixmaps(){ + return pixmaps; + } + + public void disposePixmap(Texture texture){ + if(pixmaps.containsKey(texture) && !pixmaps.get(texture).isDisposed()){ + pixmaps.get(texture).dispose(); + } + pixmaps.remove(texture); + } + + */ + /** Repacks all in-game sprites. */ @Override public void loadAsync(){ @@ -147,7 +181,7 @@ public class Mods implements Loadable{ long startTime = Time.millis(); //TODO this should estimate sprite sizes per page - MultiPacker packer = new MultiPacker(); + MultiPacker packer = new MultiPacker(4096); var textureResize = new ObjectFloatMap(); int[] totalSprites = {0}; //all packing tasks to await @@ -204,36 +238,26 @@ public class Mods implements Loadable{ } } - Seq[] entries = new Seq[PageType.all.length]; - for(int i = 0; i < PageType.all.length; i++){ - entries[i] = new Seq<>(); + Seq pageToPixmap = new Seq<>(); + Seq entries = new Seq<>(); + var pages = Core.atlas.getPages(); + + for(var page : pages){ + pageToPixmap.add(new Pixmap(page.textureFile)); } - ObjectMap pageTypes = ObjectMap.of( - Core.atlas.find("white").texture, PageType.main, - Core.atlas.find("stone1").texture, PageType.environment, - Core.atlas.find("whiteui").texture, PageType.ui, - Core.atlas.find("rubble-1-0").texture, PageType.rubble - ); - + //TODO: handle aliases correctly + //TODO: for most mods, it is not necessary to load vanilla regions at all for(AtlasRegion region : Core.atlas.getRegions()){ - PageType type = pageTypes.get(region.texture, PageType.main); - - if(!packer.has(type, region.name)){ - entries[type.ordinal()].add(new RegionEntry(region.name, Core.atlas.getPixmap(region), region.splits, region.pads)); + if(!packer.has(region.name)){ + entries.add(new RegionEntry(region.name, new PixmapRegion(pageToPixmap.get(region.texture.getDepth()), region.getX(), region.getY(), region.width, region.height), region.splits, region.pads)); } } - //sort each page type by size first, for optimal packing - for(int i = 0; i < PageType.all.length; i++){ - var rects = entries[i]; - var type = PageType.all[i]; - //TODO is this in reverse order? - rects.sort(Structs.comparingInt(o -> -Math.max(o.region.width, o.region.height))); + entries.sort(Structs.comparingInt(o -> -Math.max(o.region.width, o.region.height))); - for(var entry : rects){ - packer.add(type, entry.name, entry.region, entry.splits, entry.pads); - } + for(var entry : entries){ + packer.add(entry.name, entry.region, entry.splits, entry.pads); } Pixmap[] whitePixmap = {null}; @@ -263,12 +287,11 @@ public class Mods implements Loadable{ @Override public AtlasRegion find(String name){ - var base = packer.getPacked(name); + var base = packer.getOrNull(name); if(base != null){ var reg = new AtlasRegion(shadow.find(name).texture, base.x, base.y, base.width, base.height); reg.name = name; - reg.pixmapRegion = base; return reg; } @@ -287,16 +310,7 @@ public class Mods implements Loadable{ @Override public boolean has(String s){ - return shadow.has(s) || packer.getPacked(s) != null; - } - - //return the *actual* pixmap regions, not the disposed ones. - @Override - public PixmapRegion getPixmap(AtlasRegion region){ - PixmapRegion out = packer.getPacked(region.name); - //this should not happen in normal situations - if(out == null) return packer.getPacked("error"); - return out; + return shadow.has(s) || packer.getOrNull(s) != null; } }; }); @@ -319,23 +333,12 @@ public class Mods implements Loadable{ whiteTex[0].dispose(); //replace old atlas data - Core.atlas = packer.flush(filter, new TextureAtlas(){ - - @Override - public PixmapRegion getPixmap(AtlasRegion region){ - var other = super.getPixmap(region); - if(other.pixmap.isDisposed()){ - throw new RuntimeException("Calling getPixmap outside of createIcons is not supported!"); - } - - return other; - } - }); + Core.atlas = packer.flush(filter, new TextureAtlas()); textureResize.each(e -> Core.atlas.find(e.key).scale = e.value); Core.atlas.setErrorRegion("error"); - Log.debug("Total pages: @", Core.atlas.getTextures().size); + Log.debug("Total pages: @", Core.atlas.getPages().size); packer.printStats(); @@ -399,7 +402,7 @@ public class Mods implements Loadable{ int hyphen = baseName.indexOf('-'); String fullName = ((prefix && !(hyphen != -1 && baseName.substring(hyphen + 1).startsWith(mod.name + "-"))) ? mod.name + "-" : "") + baseName; - packer.add(getPage(file), fullName, new PixmapRegion(pix)); + packer.add(fullName, new PixmapRegion(pix)); if(textureScale != 1.0f){ textureResize.put(fullName, textureScale); } @@ -431,15 +434,6 @@ public class Mods implements Loadable{ loadIcons(); } - private PageType getPage(Fi file){ - String path = file.path(); - return - path.contains("sprites/blocks/environment") || path.contains("sprites-override/blocks/environment") ? PageType.environment : - path.contains("sprites/rubble") || path.contains("sprites-override/rubble") ? PageType.rubble : - path.contains("sprites/ui") || path.contains("sprites-override/ui") ? PageType.ui : - PageType.main; - } - /** Removes a mod file and marks it for requiring a restart. */ public void removeMod(LoadedMod mod){ boolean deleted = true; diff --git a/core/src/mindustry/type/Item.java b/core/src/mindustry/type/Item.java index 97a0f71a0d..728446b342 100644 --- a/core/src/mindustry/type/Item.java +++ b/core/src/mindustry/type/Item.java @@ -8,7 +8,6 @@ import arc.util.*; import mindustry.ctype.*; import mindustry.game.EventType.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.logic.*; import mindustry.world.blocks.environment.*; import mindustry.world.meta.*; @@ -138,7 +137,7 @@ public class Item extends UnlockableContent implements Senseable{ int index = i * (transitionFrames + 1) + j; Pixmap res = Pixmaps.blend(pixmaps[i], pixmaps[(i + 1) % frames], f); - packer.add(PageType.main, name + "-t" + index, res); + packer.add(name + "-t" + index, res); res.dispose(); } } diff --git a/core/src/mindustry/type/StatusEffect.java b/core/src/mindustry/type/StatusEffect.java index 4dd107300c..13d51aa779 100644 --- a/core/src/mindustry/type/StatusEffect.java +++ b/core/src/mindustry/type/StatusEffect.java @@ -11,7 +11,6 @@ import mindustry.entities.*; import mindustry.entities.units.*; import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.world.meta.*; public class StatusEffect extends UnlockableContent{ @@ -236,7 +235,7 @@ public class StatusEffect extends UnlockableContent{ super.createIcons(packer); if(outline){ - makeOutline(PageType.ui, packer, uiIcon, true, Pal.gray, 3); + makeOutline(packer, uiIcon, true, Pal.gray, 3); } } diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index db3a4ebd6b..9f5953937f 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -27,7 +27,6 @@ import mindustry.entities.units.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.logic.*; import mindustry.ui.*; import mindustry.world.*; @@ -1236,7 +1235,7 @@ public class UnitType extends UnlockableContent implements Senseable{ Drawf.checkBleed(outlined); - packer.add(PageType.main, regionName + "-outline", outlined); + packer.add(regionName + "-outline", outlined); outlined.dispose(); } } @@ -1251,7 +1250,7 @@ public class UnitType extends UnlockableContent implements Senseable{ for(var outlineTarget : outlineSeq){ if(!outlineTarget.found()) continue; - makeOutline(PageType.main, packer, outlineTarget, alwaysCreateOutline && region == outlineTarget, outlineColor, outlineRadius); + makeOutline(packer, outlineTarget, alwaysCreateOutline && region == outlineTarget, outlineColor, outlineRadius); } if(sample instanceof Crawlc){ @@ -1262,7 +1261,7 @@ public class UnitType extends UnlockableContent implements Senseable{ for(Weapon weapon : weapons){ if(!weapon.name.isEmpty() && (minfo.mod == null || weapon.name.startsWith(minfo.mod.name)) && (weapon.top || !packer.isOutlined(weapon.name) || weapon.parts.contains(p -> p.under))){ - makeOutline(PageType.main, packer, weapon.region, !weapon.top || weapon.parts.contains(p -> p.under), outlineColor, outlineRadius); + makeOutline(packer, weapon.region, !weapon.top || weapon.parts.contains(p -> p.under), outlineColor, outlineRadius); } } } @@ -1289,7 +1288,7 @@ public class UnitType extends UnlockableContent implements Senseable{ frame.setRaw(0, y, slice.getRaw(0, idx)); } - packer.add(PageType.main, name + "-treads" + r + "-" + i, frame); + packer.add(name + "-treads" + r + "-" + i, frame); frame.dispose(); } slice.dispose(); diff --git a/core/src/mindustry/ui/Fonts.java b/core/src/mindustry/ui/Fonts.java index 3fc4a8fdf3..168807fdf7 100644 --- a/core/src/mindustry/ui/Fonts.java +++ b/core/src/mindustry/ui/Fonts.java @@ -11,7 +11,6 @@ import arc.graphics.*; import arc.graphics.Texture.*; import arc.graphics.g2d.*; import arc.graphics.g2d.Font.*; -import arc.graphics.g2d.PixmapPacker.*; import arc.math.geom.*; import arc.scene.style.*; import arc.scene.ui.layout.*; @@ -237,6 +236,7 @@ public class Fonts{ public static void loadDefaultFont(){ //TOOD: which size to use? UI.packer = new PixmapPacker(4096, 2048, 2, true); + UI.packer.setTargetTexture(Core.atlas.find("ui-page-placeholder").texture); Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(Core.files::internal)); Core.assets.setLoader(Font.class, null, new FreetypeFontLoader(Core.files::internal){ @@ -277,17 +277,6 @@ public class Fonts{ }; } - /** Merges the UI and font atlas together for better performance. */ - //TODO: does nothing at the moment. - public static void mergeFontAtlas(TextureAtlas atlas){ - if(true) return; - Texture texture = atlas.find("ui-page-placeholder").texture; - - Page page = UI.packer.getPages().first(); - page.setDirty(true); - page.texture = texture; - } - public static TextureRegionDrawable getGlyph(Font font, char glyph){ Glyph found = font.getData().getGlyph(glyph); if(found == null){ diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index 60ae162d82..34b90befc0 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -3,7 +3,6 @@ package mindustry.ui.dialogs; import arc.*; import arc.files.*; import arc.func.*; -import arc.graphics.*; import arc.graphics.Texture.*; import arc.input.*; import arc.scene.*; @@ -23,7 +22,7 @@ import mindustry.game.EventType.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.input.*; -import mindustry.type.Planet; +import mindustry.type.*; import mindustry.ui.*; import java.io.*; @@ -550,17 +549,11 @@ public class SettingsMenuDialog extends BaseDialog{ //iOS (and possibly Android) devices do not support linear filtering well, so disable it graphics.checkPref("linear", !mobile, b -> { - for(Texture tex : Core.atlas.getTextures()){ - TextureFilter filter = b ? TextureFilter.linear : TextureFilter.nearest; - tex.setFilter(filter, filter); - } + atlas.getTexture().setFilter(b ? TextureFilter.linear : TextureFilter.nearest); }); if(Core.settings.getBool("linear")){ - for(Texture tex : Core.atlas.getTextures()){ - TextureFilter filter = TextureFilter.linear; - tex.setFilter(filter, filter); - } + atlas.getTexture().setFilter(TextureFilter.linear); } graphics.checkPref("skipcoreanimation", false); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 50ee93dcc3..1d3e71bb2c 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -23,7 +23,6 @@ import mindustry.entities.units.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.input.InputHandler.*; import mindustry.logic.*; import mindustry.mod.*; @@ -1569,7 +1568,7 @@ public class Block extends UnlockableContent implements Senseable{ Drawf.checkBleed(out); - packer.add(PageType.main, name + "-team-" + team.name, out); + packer.add(name + "-team-" + team.name, out); toDispose.add(out); } } @@ -1589,7 +1588,7 @@ public class Block extends UnlockableContent implements Senseable{ PixmapRegion region = packer.get(atlasRegion); Pixmap out = last = Pixmaps.outline(region, outlineColor, outlineRadius); Drawf.checkBleed(out); - packer.add(PageType.main, atlasRegion.name, out); + packer.add(atlasRegion.name, out); toDispose.add(out); } @@ -1603,7 +1602,7 @@ public class Block extends UnlockableContent implements Senseable{ Drawf.checkBleed(outlined); - packer.add(PageType.main, regionName + "-outline", outlined); + packer.add(regionName + "-outline", outlined); toDispose.add(outlined); } } @@ -1617,11 +1616,11 @@ public class Block extends UnlockableContent implements Senseable{ base.draw(packer.get(gen[i]), true); } } - packer.add(PageType.main, "block-" + name + "-full", base); + packer.add("block-" + name + "-full", base); toDispose.add(base); }else{ - if(gen[0] != null) packer.add(PageType.main, "block-" + name + "-full", packer.get(gen[0])); + if(gen[0] != null) packer.add("block-" + name + "-full", packer.get(gen[0])); } toDispose.each(Pixmap::dispose); diff --git a/core/src/mindustry/world/blocks/environment/Floor.java b/core/src/mindustry/world/blocks/environment/Floor.java index ab4b3366ae..e561b8d3b3 100644 --- a/core/src/mindustry/world/blocks/environment/Floor.java +++ b/core/src/mindustry/world/blocks/environment/Floor.java @@ -12,7 +12,6 @@ import mindustry.content.*; import mindustry.entities.*; import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.type.*; import mindustry.world.*; import mindustry.world.blocks.*; @@ -230,7 +229,7 @@ public class Floor extends Block{ } } - packer.add(PageType.environment, name + "-edge", result); + packer.add(name + "-edge", result); result.dispose(); } diff --git a/core/src/mindustry/world/blocks/environment/OreBlock.java b/core/src/mindustry/world/blocks/environment/OreBlock.java index ed7db5f32d..d07fa1c39f 100644 --- a/core/src/mindustry/world/blocks/environment/OreBlock.java +++ b/core/src/mindustry/world/blocks/environment/OreBlock.java @@ -5,7 +5,6 @@ import arc.graphics.*; import arc.graphics.g2d.*; import mindustry.annotations.Annotations.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.type.*; import mindustry.world.*; @@ -62,10 +61,10 @@ public class OreBlock extends OverlayFloor{ } } - packer.add(PageType.environment, name + (i + 1), image); + packer.add(name + (i + 1), image); if(i == 0){ - packer.add(PageType.main, "block-" + name + "-full", image); + packer.add("block-" + name + "-full", image); } image.dispose(); diff --git a/core/src/mindustry/world/blocks/environment/ShallowLiquid.java b/core/src/mindustry/world/blocks/environment/ShallowLiquid.java index 76a119fe69..1317b9532c 100644 --- a/core/src/mindustry/world/blocks/environment/ShallowLiquid.java +++ b/core/src/mindustry/world/blocks/environment/ShallowLiquid.java @@ -4,7 +4,6 @@ import arc.graphics.*; import arc.graphics.g2d.*; import arc.util.*; import mindustry.graphics.*; -import mindustry.graphics.MultiPacker.*; import mindustry.world.*; /** @@ -46,8 +45,7 @@ public class ShallowLiquid extends Floor{ } } - String baseName = this.name + (++index); - packer.add(PageType.environment, baseName, res); + packer.add(this.name + (++index), res); res.dispose(); } diff --git a/gradle.properties b/gradle.properties index ece5b8aae5..30dbfd1956 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ org.gradle.caching=true org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 android.enableR8.fullMode=false -archash=f4336eefed +archash=1d92c52fcc