Example #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);
     }
   }
 }
Example #2
0
  /**
   * Loads language files from a {@link FileHandle}. This allows loading languages outside of the
   * internal file system.
   *
   * <p>Valid language files have a '.lang' extension.
   *
   * @param files The {@link FileHandle} of the directory
   * @return True if successful, otherwise false
   */
  public static boolean load(FileHandle files) {
    if (!files.isDirectory()) return loadFile(files);

    boolean outcome = true;

    for (FileHandle file : files.list()) {
      if (!loadFile(file)) outcome = false;
    }

    return outcome;
  }
Example #3
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);
     }
   }
 }
Example #4
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);
    }
  }
Example #5
0
  public void load(String loadingPath, boolean internal) {
    project = null;
    game = null;
    scenes.clear();

    projectAssets.setLoadingPath(loadingPath, internal);
    projectAssets.loadGame(this);
    FileHandle scenesPath = projectAssets.resolve(ProjectAssets.SCENES_PATH);
    for (FileHandle sceneFile : scenesPath.list()) {
      projectAssets.loadScene(sceneFile.nameWithoutExtension(), this);
    }
    projectAssets.loadProject(this);
  }
Example #6
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);
     }
   }
 }
  private boolean prepareMediaRecorder(String path) {

    this.camera.unlock();
    try {
      this.recorder.setCamera(this.camera);
    } catch (Exception ex) {
      Gdx.app.error(VIDEO_LOGTAG, "Setting camera failed!", ex);
      return false;
    }
    this.recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    this.recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    this.recorder.setProfile(this.mRecorderProfile);

    final FileHandle rootPathHandle = Gdx.files.absolute(path);
    if (!rootPathHandle.exists()) {
      rootPathHandle.mkdirs();
    }
    final int id = 1 + rootPathHandle.list().length;
    this.auxVideoPath = path + File.separator + id + File.separator;
    final FileHandle videoPathHandle = Gdx.files.absolute(this.auxVideoPath);
    if (!videoPathHandle.exists()) {
      videoPathHandle.mkdirs();
    }
    this.recorder.setOutputFile(this.auxVideoPath + VIDEO_ID);
    this.recorder.setMaxDuration(MAX_RECORDING_DURATION);

    this.recorder.setPreviewDisplay(this.holder.getSurface());

    try {
      this.recorder.prepare();
    } catch (IllegalStateException ille) {
      Gdx.app.error(VIDEO_LOGTAG, "Illegal State Exception preparing recorder!", ille);
      releaseRecorder();
      return false;
    } catch (IOException ioex) {
      Gdx.app.error(VIDEO_LOGTAG, "IO Exception preparing recorder!", ioex);
      releaseRecorder();
      return false;
    }
    return true;
  }
  @Override
  public void init() {
    settings = new Settings();
    settings.maxWidth = 4096;
    settings.maxHeight = 4096;
    settings.combineSubdirectories = true;
    settings.silent = true;
    settings.useIndexes = false;
    settings.fast = true;

    loadingRegion = Assets.icons.findRegion("refresh-big");
    missingRegion = Assets.icons.findRegion("file-question-big");

    FileHandle out = fileAccess.getModuleFolder(".textureCache");
    cachePath = out.path();
    cacheFile = out.child("cache.atlas");

    gfxPath = fileAccess.getAssetsFolder().child("gfx").path();
    atlasesFolder = fileAccess.getAssetsFolder().child("atlas");

    watcher.addListener(this);

    try {
      if (cacheFile.exists()) cache = new TextureAtlas(cacheFile);
    } catch (Exception e) {
      Log.error("Error while loading texture cache, texture cache will be regenerated");
    }

    try {
      if (atlasesFolder.exists()) {
        FileHandle[] files = atlasesFolder.list();

        for (FileHandle file : files) if (file.extension().equals("atlas")) updateAtlas(file);
      }
    } catch (Exception e) {
      Log.error("Error encountered while loading one of atlases");
      Log.exception(e);
    }

    updateCache();
  }
  public void buildGameSaveList() {
    FileHandle storage = Gdx.files.external(TowerConsts.GAME_SAVE_DIRECTORY);
    FileHandle[] files = storage.list(".json");

    if (files != null && files.length > 0) {
      for (FileHandle file : files) {
        Table fileRow = makeGameFileRow(file);
        if (fileRow != null) {
          row().fillX();
          add(fileRow).expandX();
          foundSaveFile = true;
        }
      }
    }

    if (!foundSaveFile) {
      add(FontManager.RobotoBold18.makeLabel("No saved games were found on this device."));
    } else {
      shoveContentUp();
    }

    progressDialog.dismiss();
  }