Support of mods with textures in different resolution (HD or low-res) (#7602)
* HDustry - scl() & private map Co-Authored-By: citrusMarmelade <20476281+citrusMarmelade@users.noreply.github.com> * MEEP stop doing stuff when i work <3 <3 * Replaced Draw.scl Co-authored-by: citrusMarmelade <20476281+citrusMarmelade@users.noreply.github.com> Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ public class Mods implements Loadable{
|
||||
private ObjectSet<String> specialFolders = ObjectSet.with("bundles", "sprites", "sprites-override");
|
||||
|
||||
private int totalSprites;
|
||||
private static ObjectFloatMap<String> textureResize = new ObjectFloatMap<>();
|
||||
private MultiPacker packer;
|
||||
private ModClassLoader mainLoader = new ModClassLoader(getClass().getClassLoader());
|
||||
|
||||
@@ -181,6 +182,7 @@ public class Mods implements Loadable{
|
||||
|
||||
private void packSprites(Seq<Fi> sprites, LoadedMod mod, boolean prefix, Seq<Future<Runnable>> tasks){
|
||||
boolean bleed = Core.settings.getBool("linear", true) && !mod.meta.pregenerated;
|
||||
float textureScale = mod.meta.texturescale;
|
||||
|
||||
for(Fi file : sprites){
|
||||
String name = file.nameWithoutExtension();
|
||||
@@ -209,7 +211,11 @@ public class Mods implements Loadable{
|
||||
}
|
||||
//this returns a *runnable* which actually packs the resulting pixmap; this has to be done synchronously outside the method
|
||||
return () -> {
|
||||
packer.add(getPage(file), (prefix ? mod.name + "-" : "") + name, new PixmapRegion(pix));
|
||||
String fullName = (prefix ? mod.name + "-" : "") + name;
|
||||
packer.add(getPage(file), fullName, new PixmapRegion(pix));
|
||||
if(textureScale != 1.0f){
|
||||
textureResize.put(fullName, textureScale);
|
||||
}
|
||||
pix.dispose();
|
||||
};
|
||||
}catch(Exception e){
|
||||
@@ -344,13 +350,17 @@ public class Mods implements Loadable{
|
||||
}
|
||||
Log.debug("Time to generate icons: @", Time.elapsed());
|
||||
|
||||
packer.printStats();
|
||||
|
||||
//dispose old atlas data
|
||||
Core.atlas = packer.flush(filter, new TextureAtlas());
|
||||
|
||||
Time.mark();
|
||||
textureResize.each(e -> { Core.atlas.find(e.key).scale = e.value; });
|
||||
Log.debug("Time to rescale textures: @", Time.elapsed());
|
||||
|
||||
Core.atlas.setErrorRegion("error");
|
||||
Log.debug("Total pages: @", Core.atlas.getTextures().size);
|
||||
|
||||
packer.printStats();
|
||||
}
|
||||
|
||||
packer.dispose();
|
||||
@@ -1141,6 +1151,8 @@ public class Mods implements Loadable{
|
||||
public boolean java;
|
||||
/** If true, -outline regions for units are kept when packing. Only use if you know exactly what you are doing. */
|
||||
public boolean keepOutlines;
|
||||
/** To rescale textures with a different size. Represents the size in pixels of the sprite of a 1x1 block. */
|
||||
public float texturescale = 1.0f;
|
||||
/** If true, bleeding is skipped and no content icons are generated. */
|
||||
public boolean pregenerated;
|
||||
|
||||
@@ -1176,6 +1188,7 @@ public class Mods implements Loadable{
|
||||
", minGameVersion='" + minGameVersion + '\'' +
|
||||
", hidden=" + hidden +
|
||||
", repo=" + repo +
|
||||
", texturescale=" + texturescale +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user