Example #1
0
  private void CreateTextureAndCopy() {

    Settings textureSettings = new Settings();

    textureSettings.pot = true;
    textureSettings.paddingX = 2;
    textureSettings.paddingY = 2;
    textureSettings.duplicatePadding = true;
    textureSettings.edgePadding = true;
    textureSettings.rotation = false;
    textureSettings.minWidth = 16;
    textureSettings.minHeight = 16;
    textureSettings.maxWidth = 512;
    textureSettings.maxHeight = 1024;
    textureSettings.stripWhitespaceX = false;
    textureSettings.stripWhitespaceY = false;
    textureSettings.alphaThreshold = 0;
    textureSettings.filterMin = TextureFilter.Linear;
    textureSettings.filterMag = TextureFilter.Linear;
    textureSettings.wrapX = TextureWrap.ClampToEdge;
    textureSettings.wrapY = TextureWrap.ClampToEdge;
    textureSettings.format = Format.RGBA8888;
    textureSettings.alias = true;
    textureSettings.outputFormat = "png";
    textureSettings.jpegQuality = 0.9f;
    textureSettings.ignoreBlankImages = true;
    textureSettings.fast = false;
    textureSettings.debug = false;

    // Pack Default day
    String inputFolder = imageWorkPath + "\\LibgdxPacker\\default\\input\\day\\UI_IconPack";
    String outputFolder = imageWorkPath + "\\LibgdxPacker\\default\\Output\\day";
    String Name = "UI_IconPack.spp";
    ArrayList<String> outPutFolders = new ArrayList<String>();

    try {
      TexturePacker.process(textureSettings, inputFolder, outputFolder, Name);
    } catch (Exception e1) {
      writeMsg(e1.getCause().getMessage());
      writeMsg(e1.getCause().getCause().getMessage());
    }

    // Pack Default night
    inputFolder = imageWorkPath + "\\LibgdxPacker\\default\\input\\night\\UI_IconPack";
    outputFolder = imageWorkPath + "\\LibgdxPacker\\default\\Output\\night";
    outPutFolders.add(outputFolder);
    Name = "UI_IconPack.spp";
    TexturePacker.process(textureSettings, inputFolder, outputFolder, Name);

    // Pack small day
    inputFolder = imageWorkPath + "\\LibgdxPacker\\small\\input\\day\\UI_IconPack";
    outputFolder = imageWorkPath + "\\LibgdxPacker\\small\\Output\\day";
    outPutFolders.add(outputFolder);
    Name = "UI_IconPack.spp";
    TexturePacker.process(textureSettings, inputFolder, outputFolder, Name);

    // Pack small night
    inputFolder = imageWorkPath + "\\LibgdxPacker\\small\\input\\night\\UI_IconPack";
    outputFolder = imageWorkPath + "\\LibgdxPacker\\small\\Output\\night";
    outPutFolders.add(outputFolder);
    Name = "UI_IconPack.spp";
    TexturePacker.process(textureSettings, inputFolder, outputFolder, Name);

    // Pack Default day
    inputFolder = imageWorkPath + "\\LibgdxPacker\\default\\input\\splash";
    outputFolder = imageWorkPath + "\\LibgdxPacker\\default\\Output\\day";
    outPutFolders.add(outputFolder);
    Name = "SplashPack.spp";
    TexturePacker.process(textureSettings, inputFolder, outputFolder, Name);

    writeMsg("Copy Textures");
    writeMsg("Copy: ");

    // Change TexturFilter at *.spp files with in all output folder
    String br = Global.br;
    for (String folder : outPutFolders) {
      File dir = new File(folder);
      File[] files =
          dir.listFiles(
              new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                  if (pathname.getName().endsWith(".spp")) {
                    if (pathname.getName().endsWith("_MipMap.spp")) return false;
                    return true;
                  }
                  return false;
                }
              });

      for (File tmp : files) {
        // now open and change Line
        // "filter: Linear,Linear"
        // to
        // "filter: MipMapLinearNearest,Nearest"

        BufferedReader in;
        try {
          in = new BufferedReader(new FileReader(tmp));

          String line; // a line in the file

          StringBuilder builder = new StringBuilder();

          while ((line = in.readLine()) != null) {
            if (line.contains("filter:")) {
              builder.append("filter: MipMapLinearNearest,Nearest" + br);
            } else {
              builder.append(line + br);
            }
          }

          in.close();

          FileWriter writer;

          String newName = tmp.getAbsolutePath().replace(".spp", "_MipMap.spp");
          File newPerformanceFile = new File(newName);

          writer = new FileWriter(newPerformanceFile, false);
          writer.write(builder.toString());
          writer.close();

        } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }

    Copy copy = new Copy(getCopyRulesTexture());
    try {
      copy.Run(
          new CopyMsg() {
            @Override
            public void Msg(String msg) {
              writeMsg(msg, true);
            }
          });
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    writeMsg("Ready", true);
    writeMsg("");
    writeMsg("Don�t forgot refresh and clean on Eclipse");
  }