Esempio n. 1
0
 private void loadCurrentProjectSpineAnimations(String path, String curResolution) {
   spineAnimAtlases.clear();
   FileHandle sourceDir = new FileHandle(path + "orig/spine-animations");
   for (FileHandle entry : sourceDir.list()) {
     if (entry.file().isDirectory()) {
       String animName = FilenameUtils.removeExtension(entry.file().getName());
       TextureAtlas atlas =
           new TextureAtlas(
               Gdx.files.internal(
                   path
                       + curResolution
                       + "/spine-animations/"
                       + File.separator
                       + animName
                       + File.separator
                       + animName
                       + ".atlas"));
       FileHandle animJsonFile =
           Gdx.files.internal(
               entry.file().getAbsolutePath() + File.separator + animName + ".json");
       SpineAnimData data = new SpineAnimData();
       data.atlas = atlas;
       data.jsonFile = animJsonFile;
       data.animName = animName;
       spineAnimAtlases.put(animName, data);
     }
   }
 }
Esempio n. 2
0
 private void loadCurrentProjectSpriterAnimations(String path, String curResolution) {
   spriterAnimFiles.clear();
   FileHandle sourceDir = new FileHandle(path + "orig" + "/spriter-animations");
   for (FileHandle entry : sourceDir.list()) {
     if (entry.file().isDirectory()) {
       String animName = entry.file().getName();
       FileHandle scmlFile =
           new FileHandle(
               path + "orig" + "/spriter-animations/" + animName + "/" + animName + ".scml");
       spriterAnimFiles.put(animName, scmlFile);
     }
   }
 }
Esempio n. 3
0
 private void loadCurrentProjectSpriteAnimations(String path, String curResolution) {
   spriteAnimAtlases.clear();
   FileHandle sourceDir = new FileHandle(path + curResolution + "/sprite-animations");
   for (FileHandle entry : sourceDir.list()) {
     if (entry.file().isDirectory()) {
       String animName = FilenameUtils.removeExtension(entry.file().getName());
       TextureAtlas atlas =
           new TextureAtlas(
               Gdx.files.internal(
                   entry.file().getAbsolutePath() + File.separator + animName + ".atlas"));
       spriteAnimAtlases.put(animName, atlas);
     }
   }
 }
Esempio n. 4
0
 public static void write(FileHandle file, Pixmap pix) {
   try {
     ImageIO.write(pixmapToBufferedImage(pix), "JPG", file.file());
   } catch (IOException e) {
     Logger.error(e, JPGWriter.class.getSimpleName());
   }
 }
Esempio n. 5
0
 public void buildScenes(String targetPath) {
   ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
   String srcPath =
       projectManager.getCurrentWorkingPath()
           + "/"
           + projectManager.currentProjectVO.projectName
           + "/scenes";
   FileHandle scenesDirectoryHandle = Gdx.files.absolute(srcPath);
   File fileTarget = new File(targetPath + "/" + scenesDirectoryHandle.name());
   try {
     FileUtils.copyDirectory(scenesDirectoryHandle.file(), fileTarget);
   } catch (IOException e) {
     e.printStackTrace();
   }
   // copy project dt
   try {
     FileUtils.copyFile(
         new File(
             projectManager.getCurrentWorkingPath()
                 + "/"
                 + projectManager.currentProjectVO.projectName
                 + "/project.dt"),
         new File(targetPath + "/project.dt"));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  public DesktopMP3Decoder(FileHandle file) {
    super(file);
    if (file == null) return;
    File f = file.file();
    AudioInputStream ain = null;
    try {
      AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(f);
      // AudioFormat baseFormat = baseFileFormat.getFormat();
      if (baseFileFormat instanceof TAudioFileFormat) {
        Map<String, Object> properties = ((TAudioFileFormat) baseFileFormat).properties();
        sampleRate = (Integer) properties.get("mp3.frequency.hz");
      } else {
        sampleRate = 44100;
      }
      ain = AudioSystem.getAudioInputStream(f);
    } catch (Exception e) {

    }
    System.out.println("SampleRate: " + sampleRate);
    try {
      din = AudioFileUtils.readMP3AsMono(f, ain);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Esempio n. 7
0
 @Override
 public boolean delete(FileHandle file) throws IOException {
   if (hasTrash()) {
     fileUtils.moveToTrash(new File[] {file.file()});
     return true;
   } else {
     return file.delete();
   }
 }
Esempio n. 8
0
  private void loadCurrentProjectParticles(String path) {
    particleEffects.clear();
    FileHandle sourceDir = new FileHandle(path);
    for (FileHandle entry : sourceDir.list()) {
      File file = entry.file();
      String filename = file.getName();
      if (file.isDirectory() || filename.endsWith(".DS_Store")) continue;

      ParticleEffect particleEffect = new ParticleEffect();
      particleEffect.load(Gdx.files.internal(file.getAbsolutePath()), currentProjectAtlas, "");
      particleEffects.put(filename, particleEffect);
    }
  }
Esempio n. 9
0
  public EditorScene load(FileHandle fullPathFile) {
    try {
      if (fullPathFile.length() == 0)
        throw new EditorRuntimeException("Scene file does not contain any data");

      BufferedReader reader = new BufferedReader(new FileReader(fullPathFile.file()));
      EditorScene scene = gson.fromJson(reader, EditorScene.class);
      scene.path = fileAccessModule.relativizeToAssetsFolder(fullPathFile);
      reader.close();

      scene.onDeserialize();

      return scene;
    } catch (IOException e) {
      throw new IllegalStateException("There was an IO error during scene loading", e);
    }
  }
Esempio n. 10
0
  public FileHandle getTTFSafely(String fontName) throws IOException {
    FontManager fontManager = facade.retrieveProxy(FontManager.NAME);

    ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
    String expectedPath = projectManager.getFreeTypeFontPath() + File.separator + fontName + ".ttf";
    FileHandle expectedFile = Gdx.files.internal(expectedPath);
    if (!expectedFile.exists()) {
      // let's check if system fonts fot it
      HashMap<String, String> fonts = fontManager.getFontsMap();
      if (fonts.containsKey(fontName)) {
        File source = new File(fonts.get(fontName));
        FileUtils.copyFile(source, expectedFile.file());
        expectedFile = Gdx.files.internal(expectedPath);
      } else {
        throw new FileNotFoundException();
      }
    }

    return expectedFile;
  }
Esempio n. 11
0
  public Assets() {
    FileHandle f;
    if (Gdx.files != null) f = Gdx.files.internal("assets.pak");
    else f = new FileHandle("assets.pak");

    System.out.println("[Assets] Loading assets from " + f.file().getAbsolutePath() + "...");

    NBTInputStream nis;
    TagCompound t = null;
    try {
      nis = new NBTInputStream(f.read());

      if (nis == null) {
        System.err.println("[Assets] Input stream is null!");
        return;
      }

      t = (TagCompound) nis.readTag();

      nis.close();

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

    if (t == null) {
      System.err.println("[Assets] Failed to read the file!");
      return;
    }

    this.assets = t;

    this.sounds = (TagCompound) assets.getTag("snd");
    this.images = (TagCompound) assets.getTag("img");
    this.icons = (TagCompound) assets.getTag("icons");

    System.out.println("[Assets] Done loading.");
  }