Unit name changes
This commit is contained in:
@@ -21,7 +21,7 @@ import java.io.*;
|
||||
|
||||
public class ImagePacker{
|
||||
static ObjectMap<String, TextureRegion> regionCache = new ObjectMap<>();
|
||||
static ObjectMap<TextureRegion, BufferedImage> imageCache = new ObjectMap<>();
|
||||
static ObjectMap<String, BufferedImage> imageCache = new ObjectMap<>();
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
Vars.headless = true;
|
||||
@@ -33,10 +33,14 @@ public class ImagePacker{
|
||||
Log.setLogger(new DefaultLogHandler());
|
||||
|
||||
Fi.get("../../../assets-raw/sprites_out").walk(path -> {
|
||||
if(!path.extEquals("png")) return;
|
||||
|
||||
String fname = path.nameWithoutExtension();
|
||||
|
||||
try{
|
||||
BufferedImage image = ImageIO.read(path.file());
|
||||
|
||||
if(image == null) throw new IOException("image " + path.absolutePath() + " is null for terrible reasons");
|
||||
GenRegion region = new GenRegion(fname, path){
|
||||
|
||||
@Override
|
||||
@@ -61,7 +65,7 @@ public class ImagePacker{
|
||||
};
|
||||
|
||||
regionCache.put(fname, region);
|
||||
imageCache.put(region, image);
|
||||
imageCache.put(fname, image);
|
||||
}catch(IOException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -152,7 +156,7 @@ public class ImagePacker{
|
||||
}
|
||||
|
||||
static BufferedImage buf(TextureRegion region){
|
||||
return imageCache.get(region);
|
||||
return imageCache.get(((AtlasRegion)region).name);
|
||||
}
|
||||
|
||||
static Image create(int width, int height){
|
||||
@@ -170,7 +174,7 @@ public class ImagePacker{
|
||||
static Image get(TextureRegion region){
|
||||
GenRegion.validate(region);
|
||||
|
||||
return new Image(imageCache.get(region));
|
||||
return new Image(imageCache.get(((AtlasRegion)region).name));
|
||||
}
|
||||
|
||||
static void err(String message, Object... args){
|
||||
@@ -178,11 +182,11 @@ public class ImagePacker{
|
||||
}
|
||||
|
||||
static class GenRegion extends AtlasRegion{
|
||||
String name;
|
||||
boolean invalid;
|
||||
Fi path;
|
||||
|
||||
GenRegion(String name, Fi path){
|
||||
if(name == null) throw new IllegalArgumentException("name is null");
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user