use AssetLoadingException for throwing exceptions during asset loading

duh
This commit is contained in:
Gered 2014-04-15 15:38:44 -04:00
parent ebbd00c265
commit 02d65f6a7d
2 changed files with 5 additions and 4 deletions

View file

@ -1,5 +1,6 @@
package ca.blarg.gdx.assets.textureatlas; package ca.blarg.gdx.assets.textureatlas;
import ca.blarg.gdx.assets.AssetLoadingException;
import ca.blarg.gdx.graphics.atlas.CustomGridTextureAtlas; import ca.blarg.gdx.graphics.atlas.CustomGridTextureAtlas;
import ca.blarg.gdx.graphics.atlas.TextureAtlas; import ca.blarg.gdx.graphics.atlas.TextureAtlas;
import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.AssetManager;
@ -13,11 +14,11 @@ class TextureAtlasJsonLoader {
return json.fromJson(JsonTextureAtlasDefinition.class, file); return json.fromJson(JsonTextureAtlasDefinition.class, file);
} }
public static TextureAtlas create(JsonTextureAtlasDefinition definition, AssetManager assetManager) { public static TextureAtlas create(FileHandle file, JsonTextureAtlasDefinition definition, AssetManager assetManager) {
if (definition.texture == null) if (definition.texture == null)
throw new RuntimeException("No texture specified."); throw new AssetLoadingException(file.path(), "No texture specified.");
if (definition.tiles == null || definition.tiles.size() == 0) if (definition.tiles == null || definition.tiles.size() == 0)
throw new RuntimeException("No tiles defined."); throw new AssetLoadingException(file.path(), "No tiles defined.");
Texture texture = assetManager.get(definition.texture, Texture.class); Texture texture = assetManager.get(definition.texture, Texture.class);

View file

@ -30,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 = TextureAtlasJsonLoader.create(definition, manager); atlas = TextureAtlasJsonLoader.create(file, definition, manager);
} }
@Override @Override