@Override public FreeTypeFontGenerator load (AssetManager assetManager, String fileName, FileHandle file, FreeTypeFontGeneratorParameters parameter) { FreeTypeFontGenerator generator = null; if (file.extension().equals("gen")) { generator = new FreeTypeFontGenerator(file.sibling(file.nameWithoutExtension())); } else { generator = new FreeTypeFontGenerator(file); } return generator; }
@Override public FreeTypeFontGenerator load (AssetManager assetManager, String fileName, FileHandle file, FreeTypeFontGeneratorParameters parameter) { FreeTypeFontGenerator generator = null; if (file.extension().equals("gen")) { generator = new FreeTypeFontGenerator(file.sibling(file.nameWithoutExtension())); } else { generator = new FreeTypeFontGenerator(file); } return generator; }
/** If the PSH file contains a line starting with {@link PolygonRegionParameters#texturePrefix params.texturePrefix}, an * {@link AssetDescriptor} for the file referenced on that line will be added to the returned Array. Otherwise a sibling of the * given file with the same name and the first found extension in {@link PolygonRegionParameters#textureExtensions * params.textureExtensions} will be used. If no suitable file is found, the returned Array will be empty. */ @Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, PolygonRegionParameters params) { if (params == null) params = defaultParameters; String image = null; try { BufferedReader reader = file.reader(params.readerBuffer); for (String line = reader.readLine(); line != null; line = reader.readLine()) if (line.startsWith(params.texturePrefix)) { image = line.substring(params.texturePrefix.length()); break; } reader.close(); } catch (IOException e) { throw new GdxRuntimeException("Error reading " + fileName, e); } if (image == null && params.textureExtensions != null) for (String extension : params.textureExtensions) { FileHandle sibling = file.sibling(file.nameWithoutExtension().concat("." + extension)); if (sibling.exists()) image = sibling.name(); } if (image != null) { Array<AssetDescriptor> deps = new Array<AssetDescriptor>(1); deps.add(new AssetDescriptor<Texture>(file.sibling(image), Texture.class)); return deps; } return null; }
/** If the PSH file contains a line starting with {@link PolygonRegionParameters#texturePrefix params.texturePrefix}, an * {@link AssetDescriptor} for the file referenced on that line will be added to the returned Array. Otherwise a sibling of the * given file with the same name and the first found extension in {@link PolygonRegionParameters#textureExtensions * params.textureExtensions} will be used. If no suitable file is found, the returned Array will be empty. */ @Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, PolygonRegionParameters params) { if (params == null) params = defaultParameters; String image = null; try { BufferedReader reader = file.reader(params.readerBuffer); for (String line = reader.readLine(); line != null; line = reader.readLine()) if (line.startsWith(params.texturePrefix)) { image = line.substring(params.texturePrefix.length()); break; } reader.close(); } catch (IOException e) { throw new GdxRuntimeException("Error reading " + fileName, e); } if (image == null && params.textureExtensions != null) for (String extension : params.textureExtensions) { FileHandle sibling = file.sibling(file.nameWithoutExtension().concat("." + extension)); if (sibling.exists()) image = sibling.name(); } if (image != null) { Array<AssetDescriptor> deps = new Array<AssetDescriptor>(1); deps.add(new AssetDescriptor<Texture>(file.sibling(image), Texture.class)); return deps; } return null; }
for (Page page : packer.pages) { if (page.rects.size > 0) { FileHandle pageFile = file.sibling(file.nameWithoutExtension() + "_" + (++index) + parameters.format.getExtension()); switch (parameters.format) { case CIM:{
for (Page page : packer.pages) { if (page.rects.size > 0) { FileHandle pageFile = file.sibling(file.nameWithoutExtension() + "_" + (++index) + parameters.format.getExtension()); switch (parameters.format) { case CIM:{
/** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas" * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is * automatically disposed when the skin is disposed. */ public Skin (FileHandle skinFile) { FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) { atlas = new TextureAtlas(atlasFile); addRegions(atlas); } load(skinFile); }
/** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas" * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is * automatically disposed when the skin is disposed. */ public Skin (FileHandle skinFile) { FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) { atlas = new TextureAtlas(atlasFile); addRegions(atlas); } load(skinFile); }
/** May return null. */ protected FileHandle loadAtlas (Element root, FileHandle tmxFile) throws IOException { Element e = root.getChildByName("properties"); if (e != null) { for (Element property : e.getChildrenByName("property")) { String name = property.getAttribute("name", null); String value = property.getAttribute("value", null); if (name.equals("atlas")) { if (value == null) { value = property.getText(); } if (value == null || value.length() == 0) { // keep trying until there are no more atlas properties continue; } return getRelativeFileHandle(tmxFile, value); } } } FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); return atlasFile.exists() ? atlasFile : null; }
/** May return null. */ protected FileHandle loadAtlas (Element root, FileHandle tmxFile) throws IOException { Element e = root.getChildByName("properties"); if (e != null) { for (Element property : e.getChildrenByName("property")) { String name = property.getAttribute("name", null); String value = property.getAttribute("value", null); if (name.equals("atlas")) { if (value == null) { value = property.getText(); } if (value == null || value.length() == 0) { // keep trying until there are no more atlas properties continue; } return getRelativeFileHandle(tmxFile, value); } } } FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); return atlasFile.exists() ? atlasFile : null; }
return baseFileHandle.sibling(sb.append(".properties").toString());
return baseFileHandle.sibling(sb.append(".properties").toString());
@Override public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) { if (parameter != null && parameter.atlasName != null) { TextureAtlas atlas = manager.get(parameter.atlasName, TextureAtlas.class); String name = file.sibling(data.imagePaths[0]).nameWithoutExtension().toString(); AtlasRegion region = atlas.findRegion(name); if (region == null) throw new GdxRuntimeException("Could not find font region " + name + " in atlas " + parameter.atlasName); return new BitmapFont(file, region); } else { int n = data.getImagePaths().length; Array<TextureRegion> regs = new Array(n); for (int i = 0; i < n; i++) { regs.add(new TextureRegion(manager.get(data.getImagePath(i), Texture.class))); } return new BitmapFont(data, regs, true); } }
@Override public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) { if (parameter != null && parameter.atlasName != null) { TextureAtlas atlas = manager.get(parameter.atlasName, TextureAtlas.class); String name = file.sibling(data.imagePaths[0]).nameWithoutExtension().toString(); AtlasRegion region = atlas.findRegion(name); if (region == null) throw new GdxRuntimeException("Could not find font region " + name + " in atlas " + parameter.atlasName); return new BitmapFont(file, region); } else { int n = data.getImagePaths().length; Array<TextureRegion> regs = new Array(n); for (int i = 0; i < n; i++) { regs.add(new TextureRegion(manager.get(data.getImagePath(i), Texture.class))); } return new BitmapFont(data, regs, true); } }
FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) atlasFilePath = atlasFile.name();
FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) atlasFilePath = atlasFile.name();
FileHandle fileHandle = Gdx.files.internal("pathToMyJsonFile/fileNameForMyJson.json"); FileHandle atlasFile = fileHandle.sibling("fileNameForMyJson.atlas"); if (atlasFile.exists()) { Gdx.app.log("MyGame", "atlas file is loaded"); skin.addRegions(new TextureAtlas(atlasFile)); } else { Gdx.app.log("MyGame", "atlas file is NOT loaded"); }
/** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas" * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is * automatically disposed when the skin is disposed. */ public Skin (FileHandle skinFile) { FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) { atlas = new TextureAtlas(atlasFile); addRegions(atlas); } load(skinFile); }
/** May return null. */ protected FileHandle loadAtlas (Element root, FileHandle tmxFile) throws IOException { Element e = root.getChildByName("properties"); if (e != null) { for (Element property : e.getChildrenByName("property")) { String name = property.getAttribute("name", null); String value = property.getAttribute("value", null); if (name.equals("atlas")) { if (value == null) { value = property.getText(); } if (value == null || value.length() == 0) { // keep trying until there are no more atlas properties continue; } return getRelativeFileHandle(tmxFile, value); } } } FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); return atlasFile.exists() ? atlasFile : null; }
@Override public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) { if (parameter != null && parameter.atlasName != null) { TextureAtlas atlas = manager.get(parameter.atlasName, TextureAtlas.class); String name = file.sibling(data.imagePaths[0]).nameWithoutExtension().toString(); AtlasRegion region = atlas.findRegion(name); if (region == null) throw new GdxRuntimeException("Could not find font region " + name + " in atlas " + parameter.atlasName); return new BitmapFont(file, region); } else { int n = data.getImagePaths().length; Array<TextureRegion> regs = new Array(n); for (int i = 0; i < n; i++) { regs.add(new TextureRegion(manager.get(data.getImagePath(i), Texture.class))); } return new BitmapFont(data, regs, true); } }