/** @param flip If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner. * @see #TextureAtlas(FileHandle) */ public TextureAtlas (FileHandle packFile, boolean flip) { this(packFile, packFile.parent(), flip); }
/** Loads the specified pack file, using the parent directory of the pack file to find the page images. */ public TextureAtlas (FileHandle packFile) { this(packFile, packFile.parent()); }
/** @param flip If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner. * @see #TextureAtlas(FileHandle) */ public TextureAtlas (FileHandle packFile, boolean flip) { this(packFile, packFile.parent(), flip); }
/** Loads the specified pack file, using the parent directory of the pack file to find the page images. */ public TextureAtlas (FileHandle packFile) { this(packFile, packFile.parent()); }
private static FileHandle getRelativeFileHandle (FileHandle file, String path) { StringTokenizer tokenizer = new StringTokenizer(path, "\\/"); FileHandle result = file.parent(); while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); if (token.equals("..")) result = result.parent(); else { result = result.child(token); } } return result; }
private static FileHandle getRelativeFileHandle (FileHandle file, String path) { StringTokenizer tokenizer = new StringTokenizer(path, "\\/"); FileHandle result = file.parent(); while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); if (token.equals("..")) result = result.parent(); else { result = result.child(token); } } return result; }
protected static FileHandle getRelativeFileHandle (FileHandle file, String path) { StringTokenizer tokenizer = new StringTokenizer(path, "\\/"); FileHandle result = file.parent(); while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); if (token.equals("..")) result = result.parent(); else { result = result.child(token); } } return result; }
protected static FileHandle getRelativeFileHandle (FileHandle file, String path) { StringTokenizer tokenizer = new StringTokenizer(path, "\\/"); FileHandle result = file.parent(); while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); if (token.equals("..")) result = result.parent(); else { result = result.child(token); } } return result; }
protected String resolve (FileHandle originalHandle, String suffix) { String parentString = ""; FileHandle parent = originalHandle.parent(); if (parent != null && !parent.name().equals("")) { parentString = parent + "/"; } return parentString + suffix + "/" + originalHandle.name(); }
protected String resolve (FileHandle originalHandle, String suffix) { String parentString = ""; FileHandle parent = originalHandle.parent(); if (parent != null && !parent.name().equals("")) { parentString = parent + "/"; } return parentString + suffix + "/" + originalHandle.name(); }
/** Returns a writer for writing to this file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @param charset May be null to use the default charset. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public Writer writer (boolean append, String charset) { if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file); if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file); parent().mkdirs(); try { FileOutputStream output = new FileOutputStream(file(), append); if (charset == null) return new OutputStreamWriter(output); else return new OutputStreamWriter(output, charset); } catch (IOException ex) { if (file().isDirectory()) throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex); throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } }
/** Returns a stream for writing to this file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public OutputStream write (boolean append) { if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file); if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file); parent().mkdirs(); try { return new FileOutputStream(file(), append); } catch (Exception ex) { if (file().isDirectory()) throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex); throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } }
/** Returns a stream for writing to this file. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public OutputStream write (boolean append) { if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file); if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file); parent().mkdirs(); try { return new FileOutputStream(file(), append); } catch (Exception ex) { if (file().isDirectory()) throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex); throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } }
@Override public ParticleEffect load (AssetManager am, String fileName, FileHandle file, ParticleEffectParameter param) { ParticleEffect effect = new ParticleEffect(); if (param != null && param.atlasFile != null) effect.load(file, am.get(param.atlasFile, TextureAtlas.class), param.atlasPrefix); else if (param != null && param.imagesDir != null) effect.load(file, param.imagesDir); else effect.load(file, file.parent()); return effect; }
@Override public ParticleEffect load (AssetManager am, String fileName, FileHandle file, ParticleEffectParameter param) { ParticleEffect effect = new ParticleEffect(); if (param != null && param.atlasFile != null) effect.load(file, am.get(param.atlasFile, TextureAtlas.class), param.atlasPrefix); else if (param != null && param.imagesDir != null) effect.load(file, param.imagesDir); else effect.load(file, file.parent()); return effect; }
/** A utility method which writes the given font data to a file. * * The specified pixmaps are written to the parent directory of <tt>outFntFile</tt>, using that file's name without an * extension for the PNG file name(s). * * The specified FontInfo is optional, and can be null. * * Typical usage looks like this: * * <pre> * BitmapFontWriter.writeFont(myFontData, myFontPixmaps, Gdx.files.external("fonts/output.fnt"), new FontInfo("Arial", 16)); * </pre> * * @param fontData the font data * @param pages the pixmaps to write as PNGs * @param outFntFile the output file for the font definition * @param info the optional font info for the header file, can be null */ public static void writeFont (BitmapFontData fontData, Pixmap[] pages, FileHandle outFntFile, FontInfo info) { String[] pageRefs = writePixmaps(pages, outFntFile.parent(), outFntFile.nameWithoutExtension()); // write the font data writeFont(fontData, pageRefs, outFntFile, info, pages[0].getWidth(), pages[0].getHeight()); }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle atlasFile, TextureAtlasParameter parameter) { FileHandle imgDir = atlasFile.parent(); if (parameter != null) data = new TextureAtlasData(atlasFile, imgDir, parameter.flip); else { data = new TextureAtlasData(atlasFile, imgDir, false); } Array<AssetDescriptor> dependencies = new Array(); for (Page page : data.getPages()) { TextureParameter params = new TextureParameter(); params.format = page.format; params.genMipMaps = page.useMipMaps; params.minFilter = page.minFilter; params.magFilter = page.magFilter; dependencies.add(new AssetDescriptor(page.textureFile, Texture.class, params)); } return dependencies; }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle atlasFile, TextureAtlasParameter parameter) { FileHandle imgDir = atlasFile.parent(); if (parameter != null) data = new TextureAtlasData(atlasFile, imgDir, parameter.flip); else { data = new TextureAtlasData(atlasFile, imgDir, false); } Array<AssetDescriptor> dependencies = new Array(); for (Page page : data.getPages()) { TextureParameter params = new TextureParameter(); params.format = page.format; params.genMipMaps = page.useMipMaps; params.minFilter = page.minFilter; params.magFilter = page.magFilter; dependencies.add(new AssetDescriptor(page.textureFile, Texture.class, params)); } return dependencies; }
public ModelData parseModel (FileHandle handle) { JsonValue json = reader.parse(handle); ModelData model = new ModelData(); JsonValue version = json.require("version"); model.version[0] = version.getShort(0); model.version[1] = version.getShort(1); if (model.version[0] != VERSION_HI || model.version[1] != VERSION_LO) throw new GdxRuntimeException("Model version not supported"); model.id = json.getString("id", ""); parseMeshes(model, json); parseMaterials(model, json, handle.parent().path()); parseNodes(model, json); parseAnimations(model, json); return model; }
public ModelData parseModel (FileHandle handle) { JsonValue json = reader.parse(handle); ModelData model = new ModelData(); JsonValue version = json.require("version"); model.version[0] = version.getShort(0); model.version[1] = version.getShort(1); if (model.version[0] != VERSION_HI || model.version[1] != VERSION_LO) throw new GdxRuntimeException("Model version not supported"); model.id = json.getString("id", ""); parseMeshes(model, json); parseMaterials(model, json, handle.parent().path()); parseNodes(model, json); parseAnimations(model, json); return model; }