Search in sources :

Example 1 with SimpleTheme

use of org.pepsoft.worldpainter.themes.SimpleTheme 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);
}
Also used : SimpleTheme(org.pepsoft.worldpainter.themes.SimpleTheme) Theme(org.pepsoft.worldpainter.themes.Theme)

Example 2 with SimpleTheme

use of org.pepsoft.worldpainter.themes.SimpleTheme 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);
}
Also used : SimpleTheme(org.pepsoft.worldpainter.themes.SimpleTheme) SimpleTheme(org.pepsoft.worldpainter.themes.SimpleTheme) Theme(org.pepsoft.worldpainter.themes.Theme)

Example 3 with SimpleTheme

use of org.pepsoft.worldpainter.themes.SimpleTheme in project WorldPainter by Captain-Chaos.

the class PreferencesDialog method editTerrainAndLayerSettings.

private void editTerrainAndLayerSettings() {
    Configuration config = Configuration.getInstance();
    Dimension defaultSettings = config.getDefaultTerrainAndLayerSettings();
    DimensionPropertiesDialog dialog = new DimensionPropertiesDialog(this, defaultSettings, colourScheme, true);
    dialog.setVisible(true);
    TileFactory tileFactory = defaultSettings.getTileFactory();
    if ((tileFactory instanceof HeightMapTileFactory) && (((HeightMapTileFactory) tileFactory).getTheme() instanceof SimpleTheme)) {
        HeightMapTileFactory heightMapTileFactory = (HeightMapTileFactory) tileFactory;
        SimpleTheme theme = (SimpleTheme) ((HeightMapTileFactory) tileFactory).getTheme();
        checkBoxBeaches.setSelected(theme.isBeaches());
        int waterLevel = heightMapTileFactory.getWaterHeight();
        spinnerWaterLevel.setValue(waterLevel);
        defaultSettings.setBorderLevel(heightMapTileFactory.getWaterHeight());
        SortedMap<Integer, Terrain> terrainRanges = theme.getTerrainRanges();
        comboBoxSurfaceMaterial.setSelectedItem(terrainRanges.get(terrainRanges.headMap(waterLevel + 3).lastKey()));
    }
}
Also used : SimpleTheme(org.pepsoft.worldpainter.themes.SimpleTheme)

Example 4 with SimpleTheme

use of org.pepsoft.worldpainter.themes.SimpleTheme in project WorldPainter by Captain-Chaos.

the class NewWorldDialog method createTileFactory.

private TileFactory createTileFactory(long seed) {
    Terrain terrain = (Terrain) comboBoxSurfaceMaterial.getSelectedItem();
    int baseHeight = (Integer) spinnerTerrainLevel.getValue();
    int waterHeight = (Integer) spinnerWaterLevel.getValue();
    float range = ((Number) spinnerRange.getValue()).floatValue();
    double scale = ((Integer) spinnerScale.getValue()) / 100.0;
    boolean floodWithLava = checkBoxLava.isSelected();
    boolean beaches = checkBoxBeaches.isSelected();
    int maxHeight = (Integer) comboBoxMaxHeight.getSelectedItem();
    HeightMapTileFactory tileFactory;
    if ("true".equals(System.getProperty("org.pepsoft.worldpainter.fancyworlds"))) {
        tileFactory = TileFactoryFactory.createFancyTileFactory(seed, terrain, maxHeight, baseHeight, waterHeight, floodWithLava, range, scale);
    } else {
        // HeightMapTileFactory tileFactory = new ExperimentalTileFactory(maxHeight);
        if (radioButtonHilly.isSelected()) {
            tileFactory = TileFactoryFactory.createNoiseTileFactory(seed, terrain, maxHeight, baseHeight, waterHeight, floodWithLava, beaches, range, scale);
        } else {
            tileFactory = TileFactoryFactory.createFlatTileFactory(seed, terrain, maxHeight, baseHeight, waterHeight, floodWithLava, beaches);
        }
        if (radioButtonAdvancedTerrain.isSelected()) {
            theme.setWaterHeight((Integer) spinnerWaterLevel.getValue());
            theme.setBeaches(checkBoxBeaches.isSelected());
            tileFactory.setTheme(theme);
        }
        Configuration config = Configuration.getInstance();
        Dimension defaults = config.getDefaultTerrainAndLayerSettings();
        if ((dim == DIM_NORMAL) && (defaults.getTileFactory() instanceof HeightMapTileFactory) && (((HeightMapTileFactory) defaults.getTileFactory()).getTheme() instanceof SimpleTheme) && (((SimpleTheme) ((HeightMapTileFactory) defaults.getTileFactory()).getTheme()).getTerrainRanges() != null)) {
            HeightMapTileFactory defaultTileFactory = (HeightMapTileFactory) defaults.getTileFactory();
            SimpleTheme defaultTheme = (SimpleTheme) defaultTileFactory.getTheme();
            if (radioButtonSimpleTerrain.isSelected()) {
                SortedMap<Integer, Terrain> terrainRanges = new TreeMap<>(defaultTheme.getTerrainRanges());
                int surfaceLevel = terrainRanges.headMap(waterHeight + 3).lastKey();
                terrainRanges.put(surfaceLevel, terrain);
                SimpleTheme theme = (SimpleTheme) tileFactory.getTheme();
                theme.setTerrainRanges(terrainRanges);
                theme.setRandomise(defaultTheme.isRandomise());
            }
        } else if ((dim != DIM_NORMAL) && radioButtonSimpleTerrain.isSelected()) {
            // Override the default terrain map:
            SortedMap<Integer, Terrain> terrainMap = new TreeMap<>();
            terrainMap.put(-1, terrain);
            SimpleTheme theme = (SimpleTheme) tileFactory.getTheme();
            theme.setTerrainRanges(terrainMap);
        }
    }
    return tileFactory;
}
Also used : SimpleTheme(org.pepsoft.worldpainter.themes.SimpleTheme) Terrain(org.pepsoft.worldpainter.Terrain)

Example 5 with SimpleTheme

use of org.pepsoft.worldpainter.themes.SimpleTheme in project WorldPainter by Captain-Chaos.

the class WorldFactory method createDefaultWorldWithoutTiles.

public static World2 createDefaultWorldWithoutTiles(final Configuration config, final long seed) {
    final HeightMapTileFactory tileFactory;
    if (config.isHilly()) {
        tileFactory = TileFactoryFactory.createNoiseTileFactory(seed, config.getSurface(), config.getDefaultMaxHeight(), config.getLevel(), config.getWaterLevel(), config.isLava(), config.isBeaches(), config.getDefaultRange(), config.getDefaultScale());
    } else {
        tileFactory = TileFactoryFactory.createFlatTileFactory(seed, config.getSurface(), config.getDefaultMaxHeight(), config.getLevel(), config.getWaterLevel(), config.isLava(), config.isBeaches());
    }
    final Dimension defaults = config.getDefaultTerrainAndLayerSettings();
    if ((defaults.getTileFactory() instanceof HeightMapTileFactory) && ((((HeightMapTileFactory) defaults.getTileFactory()).getTheme() instanceof SimpleTheme) && ((SimpleTheme) ((HeightMapTileFactory) defaults.getTileFactory()).getTheme()).getTerrainRanges() != null)) {
        HeightMapTileFactory defaultTileFactory = (HeightMapTileFactory) defaults.getTileFactory();
        SimpleTheme defaultTheme = (SimpleTheme) defaultTileFactory.getTheme();
        SimpleTheme theme = (SimpleTheme) tileFactory.getTheme();
        theme.setTerrainRanges(new TreeMap<>(defaultTheme.getTerrainRanges()));
        theme.setRandomise(defaultTheme.isRandomise());
    }
    final World2 world = new World2(config.getDefaultPlatform(), World2.DEFAULT_OCEAN_SEED, tileFactory, tileFactory.getMaxHeight());
    world.addHistoryEntry(HistoryEntry.WORLD_CREATED);
    final ResourceBundle strings = ResourceBundle.getBundle("org.pepsoft.worldpainter.resources.strings");
    world.setName(strings.getString("generated.world"));
    // Export settings
    world.setCreateGoodiesChest(config.isDefaultCreateGoodiesChest());
    Generator generator = config.getDefaultGenerator();
    if ((world.getMaxHeight() == DEFAULT_MAX_HEIGHT_1) && (generator == Generator.LARGE_BIOMES)) {
        generator = Generator.DEFAULT;
    } else if ((world.getMaxHeight() == DEFAULT_MAX_HEIGHT_2) && (generator == Generator.DEFAULT)) {
        generator = Generator.LARGE_BIOMES;
    }
    world.setGenerator(generator);
    if (generator == Generator.FLAT) {
        world.setGeneratorOptions(config.getDefaultGeneratorOptions());
    }
    world.setMapFeatures(config.isDefaultMapFeatures());
    world.setGameType(config.getDefaultGameType());
    world.setAllowCheats(config.isDefaultAllowCheats());
    final Dimension dim0 = world.getDimension(0);
    dim0.setEventsInhibited(true);
    try {
        dim0.setBorder(defaults.getBorder());
        dim0.setBorderSize(defaults.getBorderSize());
        dim0.setBedrockWall(defaults.isBedrockWall());
        dim0.setBorderLevel(defaults.getBorderLevel());
        dim0.setSubsurfaceMaterial(defaults.getSubsurfaceMaterial());
        dim0.setPopulate(defaults.isPopulate());
        for (Map.Entry<Layer, ExporterSettings> entry : defaults.getAllLayerSettings().entrySet()) {
            dim0.setLayerSettings(entry.getKey(), entry.getValue().clone());
        }
        dim0.setGridEnabled(config.isDefaultGridEnabled());
        dim0.setGridSize(config.getDefaultGridSize());
        dim0.setContoursEnabled(config.isDefaultContoursEnabled());
        dim0.setContourSeparation(config.getDefaultContourSeparation());
        dim0.setTopLayerMinDepth(defaults.getTopLayerMinDepth());
        dim0.setTopLayerVariation(defaults.getTopLayerVariation());
        dim0.setBottomless(defaults.isBottomless());
        dim0.setCoverSteepTerrain(defaults.isCoverSteepTerrain());
    } finally {
        dim0.setEventsInhibited(false);
    }
    world.setDirty(false);
    return world;
}
Also used : SimpleTheme(org.pepsoft.worldpainter.themes.SimpleTheme) ResourceBundle(java.util.ResourceBundle) ExporterSettings(org.pepsoft.worldpainter.layers.exporters.ExporterSettings) TreeMap(java.util.TreeMap) Map(java.util.Map) Layer(org.pepsoft.worldpainter.layers.Layer)

Aggregations

SimpleTheme (org.pepsoft.worldpainter.themes.SimpleTheme)9 FrostSettings (org.pepsoft.worldpainter.layers.exporters.FrostExporter.FrostSettings)3 ResourcesExporterSettings (org.pepsoft.worldpainter.layers.exporters.ResourcesExporter.ResourcesExporterSettings)3 Theme (org.pepsoft.worldpainter.themes.Theme)3 Layer (org.pepsoft.worldpainter.layers.Layer)2 File (java.io.File)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 TreeMap (java.util.TreeMap)1 SubProgressReceiver (org.pepsoft.util.SubProgressReceiver)1 Dimension (org.pepsoft.worldpainter.Dimension)1 Terrain (org.pepsoft.worldpainter.Terrain)1 CustomLayer (org.pepsoft.worldpainter.layers.CustomLayer)1 AnnotationsSettings (org.pepsoft.worldpainter.layers.exporters.AnnotationsExporter.AnnotationsSettings)1 CavernsSettings (org.pepsoft.worldpainter.layers.exporters.CavernsExporter.CavernsSettings)1 ChasmsSettings (org.pepsoft.worldpainter.layers.exporters.ChasmsExporter.ChasmsSettings)1 ExporterSettings (org.pepsoft.worldpainter.layers.exporters.ExporterSettings)1 TreeLayerSettings (org.pepsoft.worldpainter.layers.exporters.TreesExporter.TreeLayerSettings)1 Filter (org.pepsoft.worldpainter.themes.Filter)1 HeightFilter (org.pepsoft.worldpainter.themes.HeightFilter)1