use of org.pepsoft.worldpainter.themes.Theme in project WorldPainter by Captain-Chaos.
the class ImportHeightMapOp method go.
@Override
public World2 go() throws ScriptException {
goCalled();
if (heightMap == null) {
throw new ScriptException("heightMap not set");
}
HeightMap adjustedHeightMap = heightMap;
if ((scale != 100) || (offsetX != 0) || (offsetY != 0)) {
heightMap.setSmoothScaling(true);
adjustedHeightMap = new TransformingHeightMap(heightMap.getName() + " transformed", heightMap, scale, scale, offsetX, offsetY, 0);
}
importer.setHeightMap(adjustedHeightMap);
importer.setImageFile(heightMap.getImageFile());
HeightMapTileFactory tileFactory = TileFactoryFactory.createNoiseTileFactory(new Random().nextLong(), Terrain.GRASS, DEFAULT_MAX_HEIGHT_2, 58, 62, false, true, 20, 1.0);
Theme defaults = Configuration.getInstance().getHeightMapDefaultTheme();
if (defaults != null) {
tileFactory.setTheme(defaults);
}
importer.setTileFactory(tileFactory);
String name = heightMap.getName();
int p = name.lastIndexOf('.');
if (p != -1) {
name = name.substring(0, p);
}
importer.setName(name);
try {
return importer.importToNewWorld(null);
} catch (ProgressReceiver.OperationCancelled e) {
// Can never happen since we don't pass a progress receiver in
throw new InternalError();
}
}
use of org.pepsoft.worldpainter.themes.Theme in project WorldPainter by Captain-Chaos.
the class ImportHeightMapDialog method saveAsDefaults.
private void saveAsDefaults() {
if (heightMapTileFactoryEditor1.save()) {
Theme defaults = heightMapTileFactoryEditor1.getTheme();
Configuration.getInstance().setHeightMapDefaultTheme(defaults);
buttonResetDefaults.setEnabled(true);
buttonLoadDefaults.setEnabled(false);
buttonSaveAsDefaults.setEnabled(false);
}
}
use of org.pepsoft.worldpainter.themes.Theme in project WorldPainter by Captain-Chaos.
the class ImportHeightMapDialog method loadDefaults.
private void loadDefaults() {
Theme defaults = Configuration.getInstance().getHeightMapDefaultTheme();
if (defaults == null) {
HeightMapTileFactory tmpTileFactory = TileFactoryFactory.createNoiseTileFactory(seed, Terrain.GRASS, DEFAULT_MAX_HEIGHT_2, 58, 62, false, true, 20, 1.0);
defaults = tmpTileFactory.getTheme();
if (currentDimension == null) {
buttonResetDefaults.setEnabled(false);
}
} else {
buttonResetDefaults.setEnabled(true);
}
tileFactory.setTheme(defaults);
spinnerWorldMiddle.setValue(defaults.getWaterHeight());
updateImageWaterLevel();
heightMapTileFactoryEditor1.setTheme((SimpleTheme) defaults);
buttonLoadDefaults.setEnabled(false);
buttonSaveAsDefaults.setEnabled(false);
}
use of org.pepsoft.worldpainter.themes.Theme in project WorldPainter by Captain-Chaos.
the class NewWorldDialog2 method createTileFactory.
private TileFactory createTileFactory() {
long seed = 0L;
int waterLevel = (Integer) spinnerWaterLevel.getValue();
int oceanFloorLevel = (Integer) spinnerOceanFloorLevel.getValue();
int landLevel = (Integer) spinnerLandLevel.getValue();
int continentSize = (Integer) spinnerContinentSize.getValue();
HeightMap oceanFloor = new ConstantHeightMap("Ocean Floor", oceanFloorLevel);
HeightMap hills = new ProductHeightMap("Hills", new NoiseHeightMap(1.0f, 10f, 1), new NoiseHeightMap(20f, 1.0, 2));
HeightMap continent;
if (jRadioButton4.isSelected()) {
// Round
continent = new NinePatchHeightMap("Continent", continentSize, 50, landLevel - oceanFloorLevel);
} else {
// Square
continent = new NinePatchHeightMap("Continent", continentSize, 0, 50, landLevel - oceanFloorLevel);
}
HeightMap heightMap;
if (jRadioButton1.isSelected()) {
// All ocean
heightMap = oceanFloor;
} else if (jRadioButton2.isSelected()) {
// Continent surrounded by ocean
heightMap = new SumHeightMap(oceanFloor, continent);
} else {
// All land
heightMap = new ConstantHeightMap("Land", landLevel);
}
if (jCheckBox1.isSelected()) {
// With hills
heightMap = new SumHeightMap(heightMap, hills);
}
// Theme theme = new FancyTheme(org.pepsoft.minecraft.Constants.DEFAULT_MAX_HEIGHT_2, waterLevel, heightMap, Terrain.GRASS);
SortedMap<Integer, Terrain> terrainRanges = new TreeMap<>();
terrainRanges.put(-1, Terrain.BEACHES);
terrainRanges.put(waterLevel - 4, Terrain.GRASS);
Theme theme = new SimpleTheme(seed, waterLevel, terrainRanges, null, org.pepsoft.minecraft.Constants.DEFAULT_MAX_HEIGHT_2, true, true);
return new HeightMapTileFactory(seed, heightMap, org.pepsoft.minecraft.Constants.DEFAULT_MAX_HEIGHT_2, false, theme);
}
use of org.pepsoft.worldpainter.themes.Theme in project WorldPainter by Captain-Chaos.
the class ImportHeightMapDialog method resetDefaults.
private void resetDefaults() {
if (currentDimension != null) {
Theme theme = ((HeightMapTileFactory) currentDimension.getTileFactory()).getTheme();
buttonResetDefaults.setEnabled(false);
tileFactory.setTheme(theme);
spinnerWorldMiddle.setValue(theme.getWaterHeight());
updateImageWaterLevel();
heightMapTileFactoryEditor1.setTheme((SimpleTheme) theme);
buttonLoadDefaults.setEnabled(true);
buttonSaveAsDefaults.setEnabled(true);
} else {
Configuration.getInstance().setHeightMapDefaultTheme(null);
loadDefaults();
buttonSaveAsDefaults.setEnabled(false);
JOptionPane.showMessageDialog(this, "Theme reset to factory defaults.", "Default Theme Reset", JOptionPane.INFORMATION_MESSAGE);
}
}
Aggregations