Skeleton data is optional.

This commit is contained in:
NathanSweet 2014-10-07 20:08:55 +02:00
parent 74dc8062b0
commit 3b9dc8fd20
2 changed files with 8 additions and 6 deletions

View File

@ -108,15 +108,17 @@ public class SkeletonBinary {
DataInput input = new DataInput(file.read(512));
try {
skeletonData.hash = input.readString();
if (skeletonData.hash.isEmpty()) skeletonData.hash = null;
skeletonData.version = input.readString();
if (skeletonData.version.isEmpty()) skeletonData.version = null;
skeletonData.width = input.readFloat();
skeletonData.height = input.readFloat();
boolean nonessential = input.readBoolean();
if (nonessential) {
String imagesPath = input.readString();
if (imagesPath.length() > 0) skeletonData.imagesPath = imagesPath;
skeletonData.imagesPath = input.readString();
if (skeletonData.imagesPath.isEmpty()) skeletonData.imagesPath = null;
}
// Bones.

View File

@ -95,10 +95,10 @@ public class SkeletonJson {
// Skeleton.
JsonValue skeletonMap = root.get("skeleton");
if (skeletonMap != null) {
skeletonData.hash = skeletonMap.getString("hash");
skeletonData.version = skeletonMap.getString("spine");
skeletonData.width = skeletonMap.getFloat("width");
skeletonData.height = skeletonMap.getFloat("height");
skeletonData.hash = skeletonMap.getString("hash", null);
skeletonData.version = skeletonMap.getString("spine", null);
skeletonData.width = skeletonMap.getFloat("width", 0);
skeletonData.height = skeletonMap.getFloat("height", 0);
skeletonData.imagesPath = skeletonMap.getString("images", null);
}