Package com.badlogic.gdx.files

Examples of com.badlogic.gdx.files.FileHandle


    // 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);
  }
View Full Code Here


   
    public TransientGDXFont (GDXFonts fromFonts) {
//        this (fromFonts.file1, fromFonts.file2);       

        FileHandle path1 = new FileHandle (fromFonts.file1);
        FileHandle path2 = new FileHandle (fromFonts.file2);
       
        //if (fromFonts.font.font.isFlipped()) {
        font = new BitmapFont (path1, path2, false);       
        //} else {
        //font = new BitmapFont (path1, path2, true);                   
View Full Code Here

       
        fontInfo = fromFonts;               
    }
   
    public TransientGDXFont (String fromFile, String fromFile2) {
        FileHandle path1 = new FileHandle (fromFile);
        FileHandle path2 = new FileHandle (fromFile2);
        font = new BitmapFont (path1, path2, false);
    }
View Full Code Here

    default:
      System.out.println("Usage: inputDir [outputDir] [packFileName]");
      System.exit(0);
    }

    FileHandle inputFileHandle = new FileHandle(input);
    File inputFile = inputFileHandle.file();

    if (output == null) {
      File outputFile = new File(inputFile.getParentFile(), "output");
      if (!outputFile.exists()) {
        outputFile.mkdir();
      }
      output = outputFile.getAbsolutePath();
    }

    TextureAtlasData atlasData = new TextureAtlasData(inputFileHandle, inputFileHandle.parent(), false);

    process(atlasData, output);
  }
View Full Code Here

      if (properties != null) {
        for (Element property : properties.getChildrenByName("property")) {
          String name = property.getAttribute("name");
          String value = property.getAttribute("value");
          if (name.startsWith("atlas")) {
            FileHandle atlasHandle = getRelativeFileHandle(tmxFile, value);
            dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
          }
        }
      }
    } catch (IOException e) {
View Full Code Here

        convertObjectToTileSpace = parameter.convertObjectToTileSpace;
      } else {
        convertObjectToTileSpace = false;
      }

      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, parameter);
      map.setOwnedResources(atlases.values().toArray());
      setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter);
View Full Code Here

          return getRelativeFileHandle(tmxFile, value);
        }
      }
    } else {
      FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas");
      return atlasFile.exists() ? atlasFile : null;
    }

    return null;
  }
View Full Code Here

      int offsetY = 0;

      String imageSource = "";
      int imageWidth = 0, imageHeight = 0;

      FileHandle image = null;
      if (source != null) {
        FileHandle tsx = getRelativeFileHandle(tmxFile, source);
        try {
          element = xml.parse(tsx);
          name = element.get("name", null);
          tilewidth = element.getIntAttribute("tilewidth", 0);
          tileheight = element.getIntAttribute("tileheight", 0);
          spacing = element.getIntAttribute("spacing", 0);
          margin = element.getIntAttribute("margin", 0);
          Element offset = element.getChildByName("tileoffset");
          if (offset != null) {
            offsetX = offset.getIntAttribute("x", 0);
            offsetY = offset.getIntAttribute("y", 0);
          }
          Element imageElement = element.getChildByName("image");
          imageSource = imageElement.getAttribute("source");
          imageWidth = imageElement.getIntAttribute("width", 0);
          imageHeight = imageElement.getIntAttribute("height", 0);
        } catch (IOException e) {
          throw new GdxRuntimeException("Error parsing external tileset.");
        }
      } else {
        Element offset = element.getChildByName("tileoffset");
        if (offset != null) {
          offsetX = offset.getIntAttribute("x", 0);
          offsetY = offset.getIntAttribute("y", 0);
        }
        Element imageElement = element.getChildByName("image");
        if (imageElement != null) {
          imageSource = imageElement.getAttribute("source");
          imageWidth = imageElement.getIntAttribute("width", 0);
          imageHeight = imageElement.getIntAttribute("height", 0);
        }
      }

      String atlasFilePath = map.getProperties().get("atlas", String.class);
      if (atlasFilePath == null) {
        FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas");
        if (atlasFile.exists()) atlasFilePath = atlasFile.name();
      }
      if (atlasFilePath == null) {
        throw new GdxRuntimeException("The map is missing the 'atlas' property");
      }

      // get the TextureAtlas for this tileset
      FileHandle atlasHandle = getRelativeFileHandle(tmxFile, atlasFilePath);
      atlasHandle = resolve(atlasHandle.path());
      TextureAtlas atlas = resolver.getAtlas(atlasHandle.path());
      String regionsName = atlasHandle.nameWithoutExtension();

      if (parameter != null && parameter.forceTextureFilters) {
        for (Texture texture : atlas.getTextures()) {
          trackedTextures.add(texture);
        }
View Full Code Here

    return cell;
  }

  public 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;
  }
View Full Code Here

  }

  @Override
  public FileHandle resolve (String fileName) {
    Resolution bestDesc = choose(descriptors);
    FileHandle originalHandle = new FileHandle(fileName);
    FileHandle handle = baseResolver.resolve(resolve(originalHandle, bestDesc.suffix));
    if (!handle.exists()) handle = baseResolver.resolve(fileName);
    return handle;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.files.FileHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.