Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
https://github.com/soarteam/SuperSpineViewer/issues/6
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloento committed Jan 18, 2021
1 parent 799f550 commit b9aab12
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 187 deletions.
24 changes: 23 additions & 1 deletion src/main/java/com/QYun/Spine/Spine32.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import com.QYun.SuperSpineViewer.GUI.Controller;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData;
import com.badlogic.gdx.utils.Array;
import com.esotericsoftware.spine32.*;
import com.esotericsoftware.spine32.AnimationState.TrackEntry;
Expand All @@ -31,6 +35,25 @@ private void animates(Array<Animation> animations) {
}

private boolean loadSkel() {
TextureAtlasData atlasData;
atlasData = new TextureAtlasData(atlasFile, atlasFile.parent(), false);

atlas = new TextureAtlas(atlasData) {
public AtlasRegion findRegion (String name) {
AtlasRegion region = super.findRegion(name);
if (region == null) {
FileHandle file = skelFile.sibling(name + ".png");
if (file.exists()) {
Texture texture = new Texture(file);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
region = new AtlasRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
region.name = name;
}
}
return region;
}
};

SkeletonData skeletonData;
if (isBinary) {
SkeletonBinary binary = new SkeletonBinary(atlas);
Expand Down Expand Up @@ -164,7 +187,6 @@ public void create() {
renderer = new SkeletonMeshRenderer();
renderer.setPremultipliedAlpha(true);

atlas = new TextureAtlas(atlasFile);
if (loadSkel())
listeners();
}
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/QYun/Spine/Standard.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import com.QYun.SuperSpineViewer.GUI.Controller;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData;
import com.badlogic.gdx.utils.Array;
import com.esotericsoftware.SpineStandard.*;
import com.esotericsoftware.SpineStandard.AnimationState.TrackEntry;
Expand All @@ -31,6 +35,25 @@ private void animates(Array<Animation> animations) {
}

private boolean loadSkel() {
TextureAtlasData atlasData;
atlasData = new TextureAtlasData(atlasFile, atlasFile.parent(), false);

atlas = new TextureAtlas(atlasData) {
public AtlasRegion findRegion (String name) {
AtlasRegion region = super.findRegion(name);
if (region == null) {
FileHandle file = skelFile.sibling(name + ".png");
if (file.exists()) {
Texture texture = new Texture(file);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
region = new AtlasRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
region.name = name;
}
}
return region;
}
};

SkeletonData skeletonData;
if (isBinary) {
SkeletonBinary binary = new SkeletonBinary(atlas);
Expand Down Expand Up @@ -171,7 +194,6 @@ public void create() {
renderer = new SkeletonRenderer();
renderer.setPremultipliedAlpha(true);

atlas = new TextureAtlas(atlasFile);
if (loadSkel())
listeners();
}
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/com/QYun/SuperSpineViewer/RuntimesLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,6 @@ private FileHandle atlasFile(FileHandle skelFile) {
}

public boolean init(File file) {
if (!isLoad.get()) {
spineVersion.addListener((observable, oldValue, newValue) -> {
if (!newValue.equals(oldValue) && isLoad.get()) {
if (Controller.class.getResource("").getProtocol().equals("jar")) {
new Thread(() -> {
try {
Runtime.getRuntime().exec("cmd /k start "
+ "java -jar "
+ System.getProperty("java.class.path")
+ " " + openPath, null, new File(System.getProperty("user.dir")));
} catch (IOException ignored) {
}
System.out.println("重新加载LibGDX");
}).start();
} else System.out.println("重新加载,从源码启动请自行重启");
System.exit(0);
}
});
}

FileHandle skelFile = new FileHandle(new File(file.getAbsolutePath()));
spine.setAtlasFile(atlasFile(skelFile));
spine.setSkelFile(skelFile);
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit b9aab12

Please sign in to comment.