mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 10:46:53 +08:00
[libgdx] Added SkeletonLoader#readSkeletonData(InputStream).
This commit is contained in:
parent
365b242a46
commit
b05422bf0d
@ -31,6 +31,7 @@ package com.esotericsoftware.spine;
|
|||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
@ -128,13 +129,18 @@ public class SkeletonBinary extends SkeletonLoader {
|
|||||||
|
|
||||||
public SkeletonData readSkeletonData (FileHandle file) {
|
public SkeletonData readSkeletonData (FileHandle file) {
|
||||||
if (file == null) throw new IllegalArgumentException("file cannot be null.");
|
if (file == null) throw new IllegalArgumentException("file cannot be null.");
|
||||||
|
SkeletonData skeletonData = readSkeletonData(file.read());
|
||||||
|
skeletonData.name = file.nameWithoutExtension();
|
||||||
|
return skeletonData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SkeletonData readSkeletonData (InputStream dataInput) {
|
||||||
|
if (dataInput == null) throw new IllegalArgumentException("dataInput cannot be null.");
|
||||||
|
|
||||||
float scale = this.scale;
|
float scale = this.scale;
|
||||||
|
|
||||||
|
SkeletonInput input = new SkeletonInput(dataInput);
|
||||||
SkeletonData skeletonData = new SkeletonData();
|
SkeletonData skeletonData = new SkeletonData();
|
||||||
skeletonData.name = file.nameWithoutExtension();
|
|
||||||
|
|
||||||
SkeletonInput input = new SkeletonInput(file);
|
|
||||||
try {
|
try {
|
||||||
long hash = input.readLong();
|
long hash = input.readLong();
|
||||||
skeletonData.hash = hash == 0 ? null : Long.toString(hash);
|
skeletonData.hash = hash == 0 ? null : Long.toString(hash);
|
||||||
@ -1054,6 +1060,10 @@ public class SkeletonBinary extends SkeletonLoader {
|
|||||||
private char[] chars = new char[32];
|
private char[] chars = new char[32];
|
||||||
String[] strings;
|
String[] strings;
|
||||||
|
|
||||||
|
public SkeletonInput (InputStream input) {
|
||||||
|
super(input);
|
||||||
|
}
|
||||||
|
|
||||||
public SkeletonInput (FileHandle file) {
|
public SkeletonInput (FileHandle file) {
|
||||||
super(file.read(512));
|
super(file.read(512));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,8 @@ package com.esotericsoftware.spine;
|
|||||||
|
|
||||||
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
@ -100,22 +102,25 @@ public class SkeletonJson extends SkeletonLoader {
|
|||||||
super(atlas);
|
super(atlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JsonValue parse (FileHandle file) {
|
|
||||||
if (file == null) throw new IllegalArgumentException("file cannot be null.");
|
|
||||||
return new JsonReader().parse(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SkeletonData readSkeletonData (FileHandle file) {
|
public SkeletonData readSkeletonData (FileHandle file) {
|
||||||
if (file == null) throw new IllegalArgumentException("file cannot be null.");
|
if (file == null) throw new IllegalArgumentException("file cannot be null.");
|
||||||
|
SkeletonData skeletonData = readSkeletonData(new JsonReader().parse(file));
|
||||||
|
skeletonData.name = file.nameWithoutExtension();
|
||||||
|
return skeletonData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SkeletonData readSkeletonData (InputStream input) {
|
||||||
|
if (input == null) throw new IllegalArgumentException("dataInput cannot be null.");
|
||||||
|
return readSkeletonData(new JsonReader().parse(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SkeletonData readSkeletonData (JsonValue root) {
|
||||||
|
if (root == null) throw new IllegalArgumentException("root cannot be null.");
|
||||||
|
|
||||||
float scale = this.scale;
|
float scale = this.scale;
|
||||||
|
|
||||||
SkeletonData skeletonData = new SkeletonData();
|
|
||||||
skeletonData.name = file.nameWithoutExtension();
|
|
||||||
|
|
||||||
JsonValue root = parse(file);
|
|
||||||
|
|
||||||
// Skeleton.
|
// Skeleton.
|
||||||
|
SkeletonData skeletonData = new SkeletonData();
|
||||||
JsonValue skeletonMap = root.get("skeleton");
|
JsonValue skeletonMap = root.get("skeleton");
|
||||||
if (skeletonMap != null) {
|
if (skeletonMap != null) {
|
||||||
skeletonData.hash = skeletonMap.getString("hash", null);
|
skeletonData.hash = skeletonMap.getString("hash", null);
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine;
|
package com.esotericsoftware.spine;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
@ -46,4 +48,6 @@ abstract public class SkeletonLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract public SkeletonData readSkeletonData (FileHandle file);
|
abstract public SkeletonData readSkeletonData (FileHandle file);
|
||||||
|
|
||||||
|
abstract public SkeletonData readSkeletonData (InputStream input);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user