use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class TmxMapLoader method getDependencies.
/** Retrieves TiledMap resource dependencies
*
* @param fileName
* @param parameter not used for now
* @return dependencies for the given .tmx file */
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile, Parameters parameter) {
Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
try {
root = xml.parse(tmxFile);
boolean generateMipMaps = (parameter != null ? parameter.generateMipMaps : false);
TextureLoader.TextureParameter texParams = new TextureParameter();
texParams.genMipMaps = generateMipMaps;
if (parameter != null) {
texParams.minFilter = parameter.textureMinFilter;
texParams.magFilter = parameter.textureMagFilter;
}
for (FileHandle image : loadTilesets(root, tmxFile)) {
dependencies.add(new AssetDescriptor(image, Texture.class, texParams));
}
for (FileHandle image : loadImages(root, tmxFile)) {
dependencies.add(new AssetDescriptor(image, Texture.class, texParams));
}
return dependencies;
} catch (IOException e) {
throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e);
}
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class Preloader method list.
public FileHandle[] list(String url, FilenameFilter filter) {
Array<FileHandle> files = new Array<FileHandle>();
for (String path : texts.keys()) {
if (isChild(path, url) && filter.accept(new File(url), path.substring(url.length() + 1))) {
files.add(new GwtFileHandle(this, path, FileType.Internal));
}
}
FileHandle[] list = new FileHandle[files.size];
System.arraycopy(files.items, 0, list, 0, list.length);
return list;
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class Preloader method list.
public FileHandle[] list(String url, FileFilter filter) {
Array<FileHandle> files = new Array<FileHandle>();
for (String path : texts.keys()) {
if (isChild(path, url) && filter.accept(new File(path))) {
files.add(new GwtFileHandle(this, path, FileType.Internal));
}
}
FileHandle[] list = new FileHandle[files.size];
System.arraycopy(files.items, 0, list, 0, list.length);
return list;
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class TextureUnpacker method main.
public static void main(String[] args) {
TextureUnpacker unpacker = new TextureUnpacker();
String atlasFile = null, imageDir = null, outputDir = null;
// parse the arguments and display the help text if there is a problem with the command line arguments
switch(unpacker.parseArguments(args)) {
case 0:
System.out.println(HELP);
return;
case 3:
outputDir = args[2];
case 2:
imageDir = args[1];
case 1:
atlasFile = args[0];
}
File atlasFileHandle = new File(atlasFile);
String atlasParentPath = atlasFileHandle.getParentFile().getAbsolutePath();
// Set the directory variables to a default when they weren't given in the variables
if (imageDir == null)
imageDir = atlasParentPath;
if (outputDir == null)
outputDir = (new File(atlasParentPath, DEFAULT_OUTPUT_PATH)).getAbsolutePath();
// Opens the atlas file from the specified filename
TextureAtlasData atlas = new TextureAtlasData(new FileHandle(atlasFile), new FileHandle(imageDir), false);
unpacker.splitAtlas(atlas, outputDir);
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class BitmapFontLoader method getDependencies.
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, BitmapFontParameter parameter) {
Array<AssetDescriptor> deps = new Array();
if (parameter != null && parameter.bitmapFontData != null) {
data = parameter.bitmapFontData;
return deps;
}
data = new BitmapFontData(file, parameter != null ? parameter.flip : false);
if (parameter != null && parameter.atlasName != null) {
deps.add(new AssetDescriptor(parameter.atlasName, TextureAtlas.class));
} else {
for (int i = 0; i < data.getImagePaths().length; i++) {
String path = data.getImagePath(i);
FileHandle resolved = resolve(path);
TextureLoader.TextureParameter textureParams = new TextureLoader.TextureParameter();
if (parameter != null) {
textureParams.genMipMaps = parameter.genMipMaps;
textureParams.minFilter = parameter.minFilter;
textureParams.magFilter = parameter.magFilter;
}
AssetDescriptor descriptor = new AssetDescriptor(resolved, Texture.class, textureParams);
deps.add(descriptor);
}
}
return deps;
}
Aggregations