Prechádzať zdrojové kódy

[libgdx] Added bone and slot visibility nonessential data.

Nathan Sweet 1 rok pred
rodič
commit
4f58767740

+ 10 - 0
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/BoneData.java

@@ -47,6 +47,7 @@ public class BoneData {
 	// Nonessential.
 	final Color color = new Color(0.61f, 0.61f, 0.61f, 1); // 9b9b9bff
 	@Null String icon;
+	boolean visible;
 
 	public BoneData (int index, String name, @Null BoneData parent) {
 		if (index < 0) throw new IllegalArgumentException("index must be >= 0.");
@@ -205,6 +206,15 @@ public class BoneData {
 		this.icon = icon;
 	}
 
+	/** False if the bone was hidden in Spine and nonessential data was exported. Does not affect runtime rendering. */
+	public boolean getVisible () {
+		return visible;
+	}
+
+	public void setVisible (boolean visible) {
+		this.visible = visible;
+	}
+
 	public String toString () {
 		return name;
 	}

+ 2 - 0
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java

@@ -211,6 +211,7 @@ public class SkeletonBinary extends SkeletonLoader {
 				if (nonessential) {
 					Color.rgba8888ToColor(data.color, input.readInt());
 					data.icon = input.readString();
+					data.visible = input.readBoolean();
 				}
 				bones[i] = data;
 			}
@@ -228,6 +229,7 @@ public class SkeletonBinary extends SkeletonLoader {
 
 				data.attachmentName = input.readStringRef();
 				data.blendMode = BlendMode.values[input.readInt(true)];
+				if (nonessential) data.visible = input.readBoolean();
 				slots[i] = data;
 			}
 

+ 6 - 0
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java

@@ -171,6 +171,7 @@ public class SkeletonJson extends SkeletonLoader {
 			if (color != null) Color.valueOf(color, data.getColor());
 
 			data.icon = boneMap.getString("icon", null);
+			data.visible = boneMap.getBoolean("visible", true);
 
 			skeletonData.bones.add(data);
 		}
@@ -191,6 +192,7 @@ public class SkeletonJson extends SkeletonLoader {
 
 			data.attachmentName = slotMap.getString("attachment", null);
 			data.blendMode = BlendMode.valueOf(slotMap.getString("blend", BlendMode.normal.name()));
+			data.visible = slotMap.getBoolean("visible", true);
 			skeletonData.slots.add(data);
 		}
 
@@ -351,6 +353,10 @@ public class SkeletonJson extends SkeletonLoader {
 					}
 				}
 			}
+
+			String color = skinMap.getString("color", null);
+			if (color != null) Color.valueOf(color, skin.getColor());
+
 			skeletonData.skins.add(skin);
 			if (skin.name.equals("default")) skeletonData.defaultSkin = skin;
 		}

+ 12 - 0
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SlotData.java

@@ -42,6 +42,9 @@ public class SlotData {
 	@Null String attachmentName;
 	BlendMode blendMode;
 
+	// Nonessential.
+	boolean visible = true;
+
 	public SlotData (int index, String name, BoneData boneData) {
 		if (index < 0) throw new IllegalArgumentException("index must be >= 0.");
 		if (name == null) throw new IllegalArgumentException("name cannot be null.");
@@ -101,6 +104,15 @@ public class SlotData {
 		this.blendMode = blendMode;
 	}
 
+	/** False if the slot was hidden in Spine and nonessential data was exported. Does not affect runtime rendering. */
+	public boolean getVisible () {
+		return visible;
+	}
+
+	public void setVisible (boolean visible) {
+		this.visible = visible;
+	}
+
 	public String toString () {
 		return name;
 	}