Just so you guys know there's more to it than just making another image and trying to put it in the resource.
Whenever you extract all the resources you notice you get those files that end with something like "nonimageLayer" which are where the whole Resource Layers are stored.
There are 9 different layers:
Image,Tile,Neg,Anim,Tileset,Pagina,AButton,Audio,Tooltip
Some are obvious as to what they do and the one for animation is Anim.
So basically if you want to make something animated you would most likely have to edit this Anim nonimageLayer file to include your extra Images
further lets take a look at what the Anim layer even is:
- Code: Select all
public class Anim extends Layer {
private int[] ids;
public int id, d;
public Image[][] f;
public Anim(byte[] buf) {
id = Utils.int16d(buf, 0);
d = Utils.uint16d(buf, 2);
ids = new int[Utils.uint16d(buf, 4)];
if(buf.length - 6 != ids.length * 2)
throw(new LoadException("Invalid anim descriptor in " + name, Resource.this));
for(int i = 0; i < ids.length; i++)
ids[i] = Utils.int16d(buf, 6 + (i * 2));
}
public void init() {
f = new Image[ids.length][];
Image[] typeinfo = new Image[0];
for(int i = 0; i < ids.length; i++) {
LinkedList<Image> buf = new LinkedList<Image>();
for(Image img : layers(Image.class)) {
if(img.id == ids[i])
buf.add(img);
}
f[i] = buf.toArray(typeinfo);
}
}
}
So first of all you can see in the constructor of this layer it'll fetch its own id, 'd' (not sure what that does) and then inits the array of ids which would be the Images that are part of the animation.
Now move on to the init method and that's where you see the actual storing of the Images that are part of the animation and if you look closely you'll notice one of the lines in the inner loop is : "if(img.id == ids[i])" thus showing if you wanted to add an image to an existing animation or make a new animation you would have to provide the Image's id. One could also conclude from this source snipit that it seems that one set of images for 1 type of animation should have the same id as the other images that are part of that animation set. The Image Object is a 2D array so it can hold multiple sets given by the length of the ids array.
- Code: Select all
public Image(byte[] buf) {
z = Utils.int16d(buf, 0);
subz = Utils.int16d(buf, 2);
/* Obsolete flag 1: Layered */
nooff = (buf[4] & 2) != 0;
id = Utils.int16d(buf, 5);
o = cdec(buf, 7);
try {
img = ImageIO.read(new ByteArrayInputStream(buf, 11, buf.length - 11));
} catch(IOException e) {
throw(new LoadException(e, Resource.this));
}
if(img == null)
throw(new LoadException("Invalid image data in " + name, Resource.this));
sz = Utils.imgsz(img);
}
The above is a snip it of the Image constructor which shows the structure of its layer. This layer also obviously contains the actual Image.
whenever you use the extractor on resource files you also get those things called "png.flags" which might be what these refer to, I can't confirm that though.
So anyway, none of you are probably going to be able to make new/edit animations until you can come up with your own anim layer decoder/encoder and image decoder/encoder (that includes the images data along with the image, my guess is within that "png.flags" file) And actually it probably wouldn't be hard at all to write your own decoder/encoder since you can literally just copy the Layer's constructor to decode it into ints,etc and then to encode it back to proper form my guess is that loftar is saving them just by saving the whole class since they are Serializable which allows java to write the whole object to a file.
Edit: I don't think the Anim is saved by Serializable actually since if it was then he would be saving the Image[][] 2d array in the nonimageLayer which he isn't.
Edit #2:
https://github.com/boshaw/LayerUtilI put together a quick Anim Layer decoder that you guys can use, read the README for instructions
I'll make it more formal + gui based later on when i have the time and allow it to support all non-image layers since im sure some of you will find use for editing the other layers