Example usage for com.badlogic.gdx.files FileHandle pathWithoutExtension

List of usage examples for com.badlogic.gdx.files FileHandle pathWithoutExtension

Introduction

In this page you can find the example usage for com.badlogic.gdx.files FileHandle pathWithoutExtension.

Prototype

public String pathWithoutExtension() 

Source Link

Usage

From source file:br.com.questingsoftware.libgdx.g3db.G3DBConverter.java

License:Apache License

/** <p>
 * Convert a text JSON file into binary JSON. The new file will be saved in the same folder as the original one with the
 * {@code gd3b} extension.//from  ww  w  .j  a  va 2 s  .  c o  m
 * </p>
 * 
 * @param g3djFile Handle to the original G3DJ file.
 * @param overwrite If {@code true} the new file will overwrite any previous file with the same name. Otherwise append a
 *           counter at the end of the file name to make it unique.
 * @throws IOException If there's an exception while reading the input file or writing the output file. */
public void convert(FileHandle g3djFile, boolean overwrite) throws IOException {
    FileHandle newFile = new FileHandle(g3djFile.pathWithoutExtension() + ".g3db");
    int noOverwriteCounter = 0;
    while (!overwrite && newFile.exists()) {
        newFile = new FileHandle(g3djFile.pathWithoutExtension() + "(" + (++noOverwriteCounter) + ").g3db");
    }

    OutputStream fileOutputStream = newFile.write(false);
    UBJsonWriter writer = new UBJsonWriter(fileOutputStream);
    JsonReader reader = new JsonReader();

    try {
        JsonValue root = reader.parse(g3djFile);
        writeObject(root, writer);

    } finally {
        writer.close();
    }
}

From source file:ca.viaware.game.assets.TilesetManager.java

License:Open Source License

public static void loadTileset(String name, FileHandle imageFile) {
    if (tilesets == null)
        tilesets = new HashMap<String, Tileset>();

    System.out.println("Loading tileset " + name + " at " + imageFile.path());

    try {//ww  w .ja v a  2s  . c om
        Texture texture = new Texture(imageFile);
        Tileset tileset = new Tileset(texture);
        DataInputStream input = new DataInputStream(
                Gdx.files.internal(imageFile.pathWithoutExtension() + ".regions").read());

        while (true) {
            int[] read = new int[4];
            for (int i = 0; i < read.length; i++) {
                int r = input.readShort();
                if (r == -100) { //TODO This is stupid
                    input.close();
                    tilesets.put(name, tileset);
                    System.out.println("Done loading tileset.");
                    return;
                }
                read[i] = r;
            }
            String tileName = input.readUTF();
            System.out.println("Adding region " + tileName + "(" + read[0] + "," + read[1] + ")(" + read[2]
                    + "," + read[3] + ")");
            tileset.addRegion(tileName, read[0], read[1], read[2], read[3]);
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.intrepid.studio.animation.GenerateAnimationPackInfo.java

private void generateNewAnimationInfo(Json json) {
    rootContent.foreachFilesInContentDirectoriesExec(new FileExec() {
        @Override/*w ww.  j  a  va2 s.c  o m*/
        public void runOver(FileHandle fHandle) {
            if (fHandle.extension().equals(NEW_EXTENSION)) {
                String line = null;
                try (BufferedReader br = new BufferedReader(new FileReader(fHandle.file()))) {
                    line = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                String path = fHandle.path();
                String[] split = path.split("/");
                String dir = split[split.length - 2];
                String name = split[split.length - 1];
                String tagName = dir + "." + name;
                AnimationInfo animationInfo = AnimationInfoFactory.create(tagName, line);

                System.out.println("  new found: [ " + fHandle.path() + " ]");

                String toWrite = json.prettyPrint(animationInfo);
                String output = fHandle.pathWithoutExtension() + "." + SAI_EXTENSION;
                files.local(output).writeString(toWrite, false);

                fHandle.delete();
            }
        }
    });
}

From source file:com.kotcrab.vis.editor.module.project.TextureNameCheckerModule.java

License:Apache License

@Override
public void fileCreated(FileHandle file) {
    if (warningShown)
        return;//from w w  w  .j  av  a2s  .  c  o m

    if (ProjectPathUtils.isTexture(file) == false)
        return;

    String pathWithoutExt = file.pathWithoutExtension();
    if (paths.contains(pathWithoutExt)) {
        //TODO details dialog supporting auto text wrapping
        toastModule.show(new DetailsToast("Warning, found invalid textures in gfx directory", "Details",
                "Files inside gfx subdirectories cannot have same name but different extension."
                        + "\nVisEditor does not store image extension in TextureAtlas thus you cannot have "
                        + "2 files\nin single directory that have the same name but different extension eg. `image.png` "
                        + "\nand `image.jpg`. It is recommend to remove one of those conflicting files, otherwise "
                        + "\nonly one of them will be available.\n\nFile: " + pathWithoutExt));
        warningShown = true;
    } else {
        paths.add(pathWithoutExt);
    }
}

From source file:com.kotcrab.vis.editor.module.project.TextureNameCheckerModule.java

License:Apache License

@Override
public void fileDeleted(FileHandle file) {
    if (warningShown)
        return;// w  w  w . ja v a  2 s  .co m
    String pathWithoutExt = file.pathWithoutExtension();
    paths.remove(pathWithoutExt);
}

From source file:es.eucm.ead.engine.assets.loaders.ExtendedSkinLoader.java

License:Open Source License

@Override
public Skin loadSync(AssetManager manager, String fileName, FileHandle file, SkinParameter parameter) {
    String textureAtlasPath;/*from  w ww . j a v  a2s  . c  om*/
    ObjectMap<String, Object> resources;
    if (parameter == null) {
        textureAtlasPath = file.pathWithoutExtension() + ".atlas";
        resources = null;
    } else {
        textureAtlasPath = parameter.textureAtlasPath;
        resources = parameter.resources;
    }
    TextureAtlas atlas = manager.get(textureAtlasPath, TextureAtlas.class);
    Skin skin = new ExtendedSkin(assets, atlas);
    if (resources != null) {
        for (Entry<String, Object> entry : resources.entries()) {
            skin.add(entry.key, entry.value);
        }
    }
    skin.load(file);
    return skin;
}