mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[libgdx] Update version for JsonRollback.
This commit is contained in:
parent
c2c975921e
commit
be5efc5fa7
@ -67,6 +67,21 @@ public class JsonRollback {
|
|||||||
|
|
||||||
JsonValue root = new Json().fromJson(null, new FileHandle(args[0]));
|
JsonValue root = new Json().fromJson(null, new FileHandle(args[0]));
|
||||||
|
|
||||||
|
// Update Spine version.
|
||||||
|
JsonValue skeleton = root.get("skeleton");
|
||||||
|
if (skeleton == null) {
|
||||||
|
skeleton = new JsonValue(ValueType.object);
|
||||||
|
skeleton.name = "skeleton";
|
||||||
|
JsonValue first = root.child;
|
||||||
|
root.child = skeleton;
|
||||||
|
skeleton.next = first;
|
||||||
|
}
|
||||||
|
JsonValue spine = skeleton.get("spine");
|
||||||
|
if (spine != null)
|
||||||
|
spine.set(version + "-from-" + spine.asString());
|
||||||
|
else
|
||||||
|
skeleton.addChild("spine", new JsonValue(version));
|
||||||
|
|
||||||
if (version.equals("2.1")) {
|
if (version.equals("2.1")) {
|
||||||
// In 3.2 skinnedmesh was renamed to weightedmesh.
|
// In 3.2 skinnedmesh was renamed to weightedmesh.
|
||||||
setValue(root, "skinnedmesh", "skins", "*", "*", "*", "type", "weightedmesh");
|
setValue(root, "skinnedmesh", "skins", "*", "*", "*", "type", "weightedmesh");
|
||||||
@ -78,26 +93,26 @@ public class JsonRollback {
|
|||||||
rename(root, "ffd", "animations", "*", "deform");
|
rename(root, "ffd", "animations", "*", "deform");
|
||||||
|
|
||||||
// In 3.3 mesh is now a single type, previously they were skinnedmesh if they had weights.
|
// In 3.3 mesh is now a single type, previously they were skinnedmesh if they had weights.
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, "skins", "*", "*", "*", "type", "mesh"))
|
for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "mesh"))
|
||||||
if (value.parent.get("uvs").size != value.parent.get("vertices").size) value.set("skinnedmesh");
|
if (value.parent.get("uvs").size != value.parent.get("vertices").size) value.set("skinnedmesh");
|
||||||
|
|
||||||
// In 3.3 linkedmesh is now a single type, previously they were linkedweightedmesh if they had weights.
|
// In 3.3 linkedmesh is now a single type, previously they were linkedweightedmesh if they had weights.
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, "skins", "*", "*", "*", "type", "linkedmesh")) {
|
for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "linkedmesh")) {
|
||||||
String slot = value.parent.parent.name.replaceAll("", "");
|
String slot = value.parent.parent.name.replaceAll("", "");
|
||||||
String skinName = value.parent.getString("skin", "default");
|
String skinName = value.parent.getString("skin", "default");
|
||||||
String parentName = value.parent.getString("parent");
|
String parentName = value.parent.getString("parent");
|
||||||
if (find(root, new Array<JsonValue>(), 0,
|
if (find(root, new Array(), 0,
|
||||||
("skins~~" + skinName + "~~" + slot + "~~" + parentName + "~~type~~skinnedmesh").split("~~")).size > 0)
|
("skins~~" + skinName + "~~" + slot + "~~" + parentName + "~~type~~skinnedmesh").split("~~")).size > 0)
|
||||||
value.set("weightedlinkedmesh");
|
value.set("weightedlinkedmesh");
|
||||||
}
|
}
|
||||||
|
|
||||||
// In 3.3 bounding boxes can be weighted.
|
// In 3.3 bounding boxes can be weighted.
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, "skins", "*", "*", "*", "type", "boundingbox"))
|
for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "boundingbox"))
|
||||||
if (value.parent.getInt("vertexCount") * 2 != value.parent.get("vertices").size)
|
if (value.parent.getInt("vertexCount") * 2 != value.parent.get("vertices").size)
|
||||||
value.parent.parent.remove(value.parent.name);
|
value.parent.parent.remove(value.parent.name);
|
||||||
|
|
||||||
// In 3.3 paths were added.
|
// In 3.3 paths were added.
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, "skins", "*", "*", "*", "type", "path")) {
|
for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "path")) {
|
||||||
String attachment = value.parent.name;
|
String attachment = value.parent.name;
|
||||||
value.parent.parent.remove(attachment);
|
value.parent.parent.remove(attachment);
|
||||||
String slot = value.parent.parent.name;
|
String slot = value.parent.parent.name;
|
||||||
@ -106,7 +121,7 @@ public class JsonRollback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// In 3.3 IK constraint timelines no longer require bendPositive.
|
// In 3.3 IK constraint timelines no longer require bendPositive.
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, "animations", "*", "ik", "*"))
|
for (JsonValue value : find(root, new Array(), 0, "animations", "*", "ik", "*"))
|
||||||
for (JsonValue child = value.child; child != null; child = child.next)
|
for (JsonValue child = value.child; child != null; child = child.next)
|
||||||
if (!child.has("bendPositive")) child.addChild("bendPositive", new JsonValue(true));
|
if (!child.has("bendPositive")) child.addChild("bendPositive", new JsonValue(true));
|
||||||
|
|
||||||
@ -138,6 +153,7 @@ public class JsonRollback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
|
System.out.println("Writing: " + args[2]);
|
||||||
BufferedWriter fileWriter = new BufferedWriter(new FileHandle(args[2]).writer(false, "UTF-8"), 16 * 1024);
|
BufferedWriter fileWriter = new BufferedWriter(new FileHandle(args[2]).writer(false, "UTF-8"), 16 * 1024);
|
||||||
root.prettyPrint(OutputType.json, fileWriter);
|
root.prettyPrint(OutputType.json, fileWriter);
|
||||||
fileWriter.close();
|
fileWriter.close();
|
||||||
@ -150,7 +166,7 @@ public class JsonRollback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static private void constraintNames (JsonValue root, String... path) {
|
static private void constraintNames (JsonValue root, String... path) {
|
||||||
for (JsonValue map : find(root, new Array<JsonValue>(), 0, path)) {
|
for (JsonValue map : find(root, new Array(), 0, path)) {
|
||||||
for (JsonValue constraint = map.child; constraint != null; constraint = constraint.next) {
|
for (JsonValue constraint = map.child; constraint != null; constraint = constraint.next) {
|
||||||
for (JsonValue child = constraint.child; child != null; child = child.next) {
|
for (JsonValue child = constraint.child; child != null; child = child.next) {
|
||||||
if (child.name.equals("mixRotate"))
|
if (child.name.equals("mixRotate"))
|
||||||
@ -232,17 +248,17 @@ public class JsonRollback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void setValue (JsonValue root, String newValue, String... path) {
|
static void setValue (JsonValue root, String newValue, String... path) {
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, path))
|
for (JsonValue value : find(root, new Array(), 0, path))
|
||||||
value.set(newValue);
|
value.set(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rename (JsonValue root, String newName, String... path) {
|
static void rename (JsonValue root, String newName, String... path) {
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, path))
|
for (JsonValue value : find(root, new Array(), 0, path))
|
||||||
value.name = newName;
|
value.name = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete (JsonValue root, String... path) {
|
static void delete (JsonValue root, String... path) {
|
||||||
for (JsonValue value : find(root, new Array<JsonValue>(), 0, path))
|
for (JsonValue value : find(root, new Array(), 0, path))
|
||||||
value.parent.remove(value.name);
|
value.parent.remove(value.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user