TextureAtlasDesc can really just be a static class like it was before..
This commit is contained in:
parent
8e1d8bf3d0
commit
49885cb5d8
|
@ -8,17 +8,17 @@ import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.utils.Json;
|
import com.badlogic.gdx.utils.Json;
|
||||||
|
|
||||||
public class TextureAtlasDesc {
|
public class TextureAtlasJsonLoader {
|
||||||
public JsonTextureAtlasDefinition load(FileHandle file) {
|
public static JsonTextureAtlasDefinition load(FileHandle file) {
|
||||||
Json json = new Json();
|
Json json = new Json();
|
||||||
return json.fromJson(JsonTextureAtlasDefinition.class, file);
|
return json.fromJson(JsonTextureAtlasDefinition.class, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextureAtlas create(JsonTextureAtlasDefinition definition) {
|
public static TextureAtlas create(JsonTextureAtlasDefinition definition) {
|
||||||
return create(definition, null);
|
return create(definition, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextureAtlas create(JsonTextureAtlasDefinition definition, AssetManager assetManager) {
|
public static TextureAtlas create(JsonTextureAtlasDefinition definition, AssetManager assetManager) {
|
||||||
if (definition.texture == null)
|
if (definition.texture == null)
|
||||||
throw new RuntimeException("No texture specified.");
|
throw new RuntimeException("No texture specified.");
|
||||||
if (definition.tiles == null || definition.tiles.size() == 0)
|
if (definition.tiles == null || definition.tiles.size() == 0)
|
|
@ -15,16 +15,14 @@ import com.badlogic.gdx.utils.Array;
|
||||||
public class TextureAtlasLoader extends AsynchronousAssetLoader<TextureAtlas, TextureAtlasLoader.TextureAtlasParameter> {
|
public class TextureAtlasLoader extends AsynchronousAssetLoader<TextureAtlas, TextureAtlasLoader.TextureAtlasParameter> {
|
||||||
public TextureAtlasLoader(FileHandleResolver resolver) {
|
public TextureAtlasLoader(FileHandleResolver resolver) {
|
||||||
super(resolver);
|
super(resolver);
|
||||||
desc = new TextureAtlasDesc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextureAtlasDesc desc;
|
|
||||||
JsonTextureAtlasDefinition definition;
|
JsonTextureAtlasDefinition definition;
|
||||||
TextureAtlas atlas;
|
TextureAtlas atlas;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasParameter parameter) {
|
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasParameter parameter) {
|
||||||
definition = desc.load(file);
|
definition = TextureAtlasJsonLoader.load(file);
|
||||||
Array<AssetDescriptor> deps = new Array<AssetDescriptor>();
|
Array<AssetDescriptor> deps = new Array<AssetDescriptor>();
|
||||||
deps.add(new AssetDescriptor(definition.texture, Texture.class));
|
deps.add(new AssetDescriptor(definition.texture, Texture.class));
|
||||||
return deps;
|
return deps;
|
||||||
|
@ -32,7 +30,7 @@ public class TextureAtlasLoader extends AsynchronousAssetLoader<TextureAtlas, Te
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureAtlasParameter parameter) {
|
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureAtlasParameter parameter) {
|
||||||
atlas = desc.create(definition, manager);
|
atlas = TextureAtlasJsonLoader.create(definition, manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue