mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +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.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
@ -128,13 +129,18 @@ public class SkeletonBinary extends SkeletonLoader {
|
||||
|
||||
public SkeletonData readSkeletonData (FileHandle file) {
|
||||
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;
|
||||
|
||||
SkeletonInput input = new SkeletonInput(dataInput);
|
||||
SkeletonData skeletonData = new SkeletonData();
|
||||
skeletonData.name = file.nameWithoutExtension();
|
||||
|
||||
SkeletonInput input = new SkeletonInput(file);
|
||||
try {
|
||||
long hash = input.readLong();
|
||||
skeletonData.hash = hash == 0 ? null : Long.toString(hash);
|
||||
@ -1054,6 +1060,10 @@ public class SkeletonBinary extends SkeletonLoader {
|
||||
private char[] chars = new char[32];
|
||||
String[] strings;
|
||||
|
||||
public SkeletonInput (InputStream input) {
|
||||
super(input);
|
||||
}
|
||||
|
||||
public SkeletonInput (FileHandle file) {
|
||||
super(file.read(512));
|
||||
}
|
||||
|
||||
@ -31,6 +31,8 @@ package com.esotericsoftware.spine;
|
||||
|
||||
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
@ -100,22 +102,25 @@ public class SkeletonJson extends SkeletonLoader {
|
||||
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) {
|
||||
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;
|
||||
|
||||
SkeletonData skeletonData = new SkeletonData();
|
||||
skeletonData.name = file.nameWithoutExtension();
|
||||
|
||||
JsonValue root = parse(file);
|
||||
|
||||
// Skeleton.
|
||||
SkeletonData skeletonData = new SkeletonData();
|
||||
JsonValue skeletonMap = root.get("skeleton");
|
||||
if (skeletonMap != null) {
|
||||
skeletonData.hash = skeletonMap.getString("hash", null);
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
package com.esotericsoftware.spine;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@ -46,4 +48,6 @@ abstract public class SkeletonLoader {
|
||||
}
|
||||
|
||||
abstract public SkeletonData readSkeletonData (FileHandle file);
|
||||
|
||||
abstract public SkeletonData readSkeletonData (InputStream input);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user