package net.alcuria.umbracraft.definitions.anim;

import net.alcuria.umbracraft.annotations.Tooltip;
import net.alcuria.umbracraft.definitions.Definition;

import com.badlogic.gdx.utils.Array;

/** Defines an entire animation.
 * @author Andrew Keturi */
public class AnimationDefinition extends Definition implements Comparable<AnimationDefinition> {

	@Tooltip("Filename, inside to the internal /sprites/animations/\n folder, to the asset.")
	public String filename;
	@Tooltip("The frames for the animation")
	public Array<AnimationFrameDefinition> frames;
	@Tooltip("The height of a single frame")
	public int height;
	@Tooltip("Whether or not to hold on last frame")
	public boolean keepLast;
	@Tooltip("Whether or not the animation loops")
	public boolean loop;
	@Tooltip("A friendly name")
	public String name;
	@Tooltip("The x origin of a frame")
	public int originX;
	@Tooltip("The x origin of a frame")
	public int originY;
	@Tooltip("A tag for the animation to help with sorting")
	public String tag = "";
	@Tooltip("The width of a frame")
	public int width;

	/** Uused for serialization */
	public AnimationDefinition() {
	}

	/** Creates an {@link AnimationDefinition} from an existing animation, by
	 * making a copy
	 * @param nextId
	 * @param definition */
	public AnimationDefinition(AnimationDefinition definition, int id) {
		filename = definition.filename;
		frames = new Array<AnimationFrameDefinition>();
		for (int i = 0; i < definition.frames.size; i++) {
			frames.add(definition.frames.get(i).copy());
		}
		height = definition.height;
		keepLast = definition.keepLast;
		loop = definition.loop;
		name = definition.name + " Copy " + id;
		width = definition.width;
		originX = definition.originX;
		originY = definition.originY;
		tag = definition.tag;
	}

	public AnimationDefinition(int id) {
		name = "Animation " + id;
		tag = "!New";
	}

	@Override
	public int compareTo(AnimationDefinition other) {
		if (tag.equals(other.tag)) {
			return name.compareTo(other.name);
		}
		return tag.compareTo(other.tag);
	}

	@Override
	public String getName() {
		return name;
	}
}

@@ -43,16 +43,65 @@
 .anim;%0A%0A
+import net.alcuria.umbracraft.annotations.Order;%0A
 import n
@@ -143,16 +143,16 @@
 ooltip;%0A
-
 import n
@@ -486,16 +486,27 @@
 sset.%22)%0A
+%09@Order(3)%0A
 %09public 
@@ -646,32 +646,43 @@
  single frame%22)%0A
+%09@Order(5)%0A
 %09public int heig
@@ -856,24 +856,35 @@
 ndly name%22)%0A
+%09@Order(1)%0A
 %09public Stri
@@ -921,32 +921,43 @@
 in of a frame%22)%0A
+%09@Order(6)%0A
 %09public int orig
@@ -990,32 +990,43 @@
 in of a frame%22)%0A
+%09@Order(7)%0A
 %09public int orig
@@ -1088,16 +1088,27 @@
 rting%22)%0A
+%09@Order(2)%0A
 %09public 
@@ -1124,16 +1124,16 @@
 g = %22%22;%0A
-
 %09@Toolti
@@ -1150,32 +1150,43 @@
 th of a frame%22)%0A
+%09@Order(4)%0A
 %09public int widt

Order AnimationDefinitions