/** Creates an AssetDescriptor with an already resolved name. */ public AssetDescriptor (FileHandle file, Class<T> assetType, AssetLoaderParameters<T> params) { this.fileName = file.path().replaceAll("\\\\", "/"); this.file = file; this.type = assetType; this.params = params; }
/** Creates an AssetDescriptor with an already resolved name. */ public AssetDescriptor (FileHandle file, Class<T> assetType, AssetLoaderParameters<T> params) { this.fileName = file.path().replaceAll("\\\\", "/"); this.file = file; this.type = assetType; this.params = params; }
@Override public int hashCode () { int hash = 1; hash = hash * 37 + type.hashCode(); hash = hash * 67 + path().hashCode(); return hash; }
@Override public int hashCode () { int hash = 1; hash = hash * 37 + type.hashCode(); hash = hash * 67 + path().hashCode(); return hash; }
@Override public TextureAtlas load (AssetManager assetManager, String fileName, FileHandle file, TextureAtlasParameter parameter) { for (Page page : data.getPages()) { Texture texture = assetManager.get(page.textureFile.path().replaceAll("\\\\", "/"), Texture.class); page.texture = texture; } TextureAtlas atlas = new TextureAtlas(data); data = null; return atlas; }
@Override public TextureAtlas load (AssetManager assetManager, String fileName, FileHandle file, TextureAtlasParameter parameter) { for (Page page : data.getPages()) { Texture texture = assetManager.get(page.textureFile.path().replaceAll("\\\\", "/"), Texture.class); page.texture = texture; } TextureAtlas atlas = new TextureAtlas(data); data = null; return atlas; }
/** Looks for subdirectories inside parentHandle, processes maps in subdirectory, repeat. * @param currentDir The directory to look for maps and other directories * @throws IOException */ private void processSubdirectories (FileHandle currentDir, Settings texturePackerSettings) throws IOException { File parentPath = new File(currentDir.path()); File[] directories = parentPath.listFiles(new DirFilter()); for (File directory : directories) { currentDir = new FileHandle(directory.getCanonicalPath()); File[] mapFilesInCurrentDir = directory.listFiles(new TmxFilter()); for (File mapFile : mapFilesInCurrentDir) { processSingleMap(mapFile, currentDir, texturePackerSettings); } processSubdirectories(currentDir, texturePackerSettings); } }
/** Looks for subdirectories inside parentHandle, processes maps in subdirectory, repeat. * @param currentDir The directory to look for maps and other directories * @throws IOException */ private void processSubdirectories (FileHandle currentDir, Settings texturePackerSettings) throws IOException { File parentPath = new File(currentDir.path()); File[] directories = parentPath.listFiles(new DirFilter()); for (File directory : directories) { currentDir = new FileHandle(directory.getCanonicalPath()); File[] mapFilesInCurrentDir = directory.listFiles(new TmxFilter()); for (File mapFile : mapFilesInCurrentDir) { processSingleMap(mapFile, currentDir, texturePackerSettings); } processSubdirectories(currentDir, texturePackerSettings); } }
public GwtMusic (FileHandle file) { String url = ((GwtApplication)Gdx.app).getBaseUrl() + file.path(); sound = SoundManager.createSound(url); soundOptions = new SMSoundOptions(); soundOptions.callback = this; }
public GwtMusic (FileHandle file) { String url = ((GwtApplication)Gdx.app).getBaseUrl() + file.path(); sound = SoundManager.createSound(url); soundOptions = new SMSoundOptions(); soundOptions.callback = this; }
protected void load (final StringBuilder out, final String name) { final int idx = name.lastIndexOf(':'); final String fileName = idx < 0 ? name : name.substring(0, idx); final String snipName = idx < 0 || (idx >= name.length() - 1) ? "" : name.substring(idx + 1); ObjectMap<String, String> snips = snippets.get(fileName, null); if (snips == null) { snips = parse(root.child(fileName)); snippets.put(fileName, snips); } String result = snips.get(snipName, null); if (result == null) throw new GdxRuntimeException("No snippet [" + snipName + "] in file " + root.child(fileName).path()); parse(out, fileName, result); }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle tmxFile, Parameters parameter) { Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>(); try { root = xml.parse(tmxFile); for (FileHandle image : loadTileSheets(root, tmxFile)) { dependencies.add(new AssetDescriptor(image.path(), Texture.class)); } return dependencies; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle tmxFile, Parameters parameter) { Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>(); try { root = xml.parse(tmxFile); for (FileHandle image : loadTileSheets(root, tmxFile)) { dependencies.add(new AssetDescriptor(image.path(), Texture.class)); } return dependencies; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
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; }
public TiledMap load (String fileName) { try { FileHandle tideFile = resolve(fileName); root = xml.parse(tideFile); ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>(); for (FileHandle textureFile : loadTileSheets(root, tideFile)) { textures.put(textureFile.path(), new Texture(textureFile)); } DirectImageResolver imageResolver = new DirectImageResolver(textures); TiledMap map = loadMap(root, tideFile, imageResolver); map.setOwnedResources(textures.values().toArray()); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
public TiledMap load (String fileName) { try { FileHandle tideFile = resolve(fileName); root = xml.parse(tideFile); ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>(); for (FileHandle textureFile : loadTileSheets(root, tideFile)) { textures.put(textureFile.path(), new Texture(textureFile)); } DirectImageResolver imageResolver = new DirectImageResolver(textures); TiledMap map = loadMap(root, tideFile, imageResolver); map.setOwnedResources(textures.values().toArray()); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
public TiledMap load (String fileName, AtlasTiledMapLoaderParameters parameter) { try { if (parameter != null) { convertObjectToTileSpace = parameter.convertObjectToTileSpace; flipY = parameter.flipY; } else { convertObjectToTileSpace = false; flipY = true; } FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>(); FileHandle atlasFile = loadAtlas(root, tmxFile); if (atlasFile == null) { throw new GdxRuntimeException("Couldn't load atlas"); } TextureAtlas atlas = new TextureAtlas(atlasFile); atlases.put(atlasFile.path(), atlas); AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases); TiledMap map = loadMap(root, tmxFile, atlasResolver); map.setOwnedResources(atlases.values().toArray()); setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }