All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.llbit.chunky.main.ChunkyOptions Maven / Gradle / Ivy

There is a newer version: 1.4.5
Show newest version
/* Copyright (c) 2014 Jesper Öqvist 
 *
 * This file is part of Chunky.
 *
 * Chunky is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Chunky is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Chunky.  If not, see .
 */
package se.llbit.chunky.main;

import se.llbit.chunky.PersistentSettings;
import se.llbit.chunky.renderer.RenderConstants;
import se.llbit.chunky.renderer.scene.SceneDescription;

import java.io.File;

/**
 * Current configuration
 *
 * @author Jesper Öqvist 
 */
public class ChunkyOptions {
  // The scene directory can be updated by the scene directory chooser dialog.
  public volatile File sceneDir = null;

  public String sceneName = null;

  /** The output filename when doing a headless snapshot. */
  public String imageOutputFile = "";

  public String texturePack = null;
  public int renderThreads = -1;
  public File worldDir = null;
  public int target = -1;

  public int tileWidth = RenderConstants.TILE_WIDTH_DEFAULT;

  private ChunkyOptions() {
  }

  public static ChunkyOptions getDefaults() {
    ChunkyOptions defaults = new ChunkyOptions();
    defaults.sceneDir = PersistentSettings.getSceneDirectory();
    defaults.renderThreads = PersistentSettings.getNumThreads();
    defaults.texturePack = PersistentSettings.getLastTexturePack();
    return defaults;
  }

  @Override public ChunkyOptions clone() {
    ChunkyOptions clone = new ChunkyOptions();
    clone.sceneDir = sceneDir;
    clone.sceneName = sceneName;
    clone.texturePack = texturePack;
    clone.renderThreads = renderThreads;
    clone.worldDir = worldDir;
    return clone;
  }

  /**
   * Retrieve the scene description file for the selected scene.
   *
   * @return the scene description file handle
   */
  public File getSceneDescriptionFile() {
    if (sceneName.endsWith(SceneDescription.EXTENSION)) {
      return new File(sceneName);
    } else {
      if (sceneDir != null) {
        return new File(sceneDir,
            sceneName + SceneDescription.EXTENSION);
      } else {
        return new File(PersistentSettings.getSceneDirectory(),
            sceneName + SceneDescription.EXTENSION);
      }
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy