package com.blarg.gdx.graphics.atlas;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.Json;

public final class TextureAtlasLoader {
	public static TextureAtlas load(FileHandle configFile) {
		Json json = new Json();
		JsonTextureAtlasDefinition config = json.fromJson(JsonTextureAtlasDefinition.class, configFile);

		if (config.texture == null)
			throw new RuntimeException("No texture specified.");
		if (config.tiles == null || config.tiles.size() == 0)
			throw new RuntimeException("No tiles defined.");

		// TODO: loading via AssetManager
		Texture texture = new Texture(Gdx.files.internal(config.texture));
		CustomGridTextureAtlas atlas = new CustomGridTextureAtlas(texture);

		for (int i = 0; i < config.tiles.size(); ++i) {
			JsonTextureAtlasTile tile = config.tiles.get(i);
			// TODO: parameter value error checking
			if (tile.autogrid)
				atlas.addGrid(tile.x, tile.y, tile.tileWidth, tile.tileHeight, tile.numTilesX, tile.numTilesY, tile.border);
			else
				atlas.add(tile.x, tile.y, tile.width, tile.height);
		}

		return atlas;
	}
}

@@ -180,16 +180,53 @@
 ls.Json;
+%0Aimport com.blarg.gdx.io.FileHelpers;
 %0A%0Apublic
@@ -296,32 +296,445 @@
 oad(
-FileHandle configFile) %7B
+String configFile) %7B%0A%09%09return load(configFile, null);%0A%09%7D%0A%0A%09public static TextureAtlas load(String configFile, TextureAtlasAnimator animator) %7B%0A%09%09return load(Gdx.files.internal(configFile), animator);%0A%09%7D%0A%0A%09public static TextureAtlas load(FileHandle configFile) %7B%0A%09%09return load(configFile, null);%0A%09%7D%0A%0A%09public static TextureAtlas load(FileHandle configFile, TextureAtlasAnimator animator) %7B%0A%09%09String path = FileHelpers.getPath(configFile);%0A
 %0A%09%09J
@@ -1119,35 +1119,59 @@
 Texture(
-Gdx.files.internal(
+FileHelpers.open(configFile.type(), path + 
 config.t

allow for relative texture paths in TextureAtlas config files. start adding support for populating TextureAtlasAnimator objects