Search in sources :

Example 1 with CustomBiomeManager

use of org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager in project WorldPainter by Captain-Chaos.

the class App method createBiomesPanel.

private JPanel createBiomesPanel() {
    final JPanel biomesPanel = new JPanel();
    biomesPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(1, 1, 1, 1);
    Configuration config = Configuration.getInstance();
    constraints.anchor = GridBagConstraints.FIRST_LINE_START;
    constraints.weightx = 0.0;
    biomesCheckBox = new JCheckBox("Show:");
    biomesCheckBox.setHorizontalTextPosition(SwingConstants.LEADING);
    biomesCheckBox.setToolTipText("Uncheck to hide biomes from view (it will still be exported)");
    biomesCheckBox.addActionListener(e -> {
        if (biomesCheckBox.isSelected()) {
            hiddenLayers.remove(Biome.INSTANCE);
        } else {
            hiddenLayers.add(Biome.INSTANCE);
        }
        updateLayerVisibility();
    });
    if (!config.isEasyMode()) {
        constraints.gridwidth = 1;
        constraints.weightx = 0.0;
        biomesPanel.add(biomesCheckBox, constraints);
    }
    biomesSoloCheckBox = new JCheckBox("Solo:");
    biomesSoloCheckBox.setHorizontalTextPosition(SwingConstants.LEADING);
    biomesSoloCheckBox.setToolTipText("<html>Check to show <em>only</em> the biomes (the other layers are still exported)</html>");
    biomesSoloCheckBox.addActionListener(e -> {
        if (biomesSoloCheckBox.isSelected()) {
            layerSoloCheckBoxes.values().stream().filter(otherSoloCheckBox -> otherSoloCheckBox != biomesSoloCheckBox).forEach(otherSoloCheckBox -> otherSoloCheckBox.setSelected(false));
            soloLayer = Biome.INSTANCE;
        } else {
            soloLayer = null;
        }
        updateLayerVisibility();
    });
    layerSoloCheckBoxes.put(Biome.INSTANCE, biomesSoloCheckBox);
    if (!config.isEasyMode()) {
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        biomesPanel.add(biomesSoloCheckBox, constraints);
    }
    biomesPanel.add(new BiomesPanel(defaultColourScheme, customBiomeManager, biomeId -> {
        paintUpdater = () -> {
            paint = PaintFactory.createDiscreteLayerPaint(Biome.INSTANCE, biomeId);
            paintChanged();
        };
        paintUpdater.updatePaint();
    }, paintButtonGroup), constraints);
    return biomesPanel;
}
Also used : RemoteJCheckBox(org.pepsoft.util.swing.RemoteJCheckBox) GZIPInputStream(java.util.zip.GZIPInputStream) CustomBiome(org.pepsoft.worldpainter.biomeschemes.CustomBiome) UI_SCALE(org.pepsoft.util.GUIUtils.UI_SCALE) AutoBiomeScheme(org.pepsoft.worldpainter.biomeschemes.AutoBiomeScheme) TunnelLayerDialog(org.pepsoft.worldpainter.layers.tunnel.TunnelLayerDialog) TunnelLayer(org.pepsoft.worldpainter.layers.tunnel.TunnelLayer) Paint(org.pepsoft.worldpainter.painting.Paint) DockableFrame(com.jidesoft.docking.DockableFrame) org.pepsoft.worldpainter.painting(org.pepsoft.worldpainter.painting) SET_SPAWN_POINT(org.pepsoft.worldpainter.Platform.Capability.SET_SPAWN_POINT) BiomeSchemeManager(org.pepsoft.worldpainter.biomeschemes.BiomeSchemeManager) Timer(javax.swing.Timer) Void(java.lang.Void) DefaultFilter(org.pepsoft.worldpainter.panels.DefaultFilter) InfoPanel(org.pepsoft.worldpainter.panels.InfoPanel) KeyEvent(java.awt.event.KeyEvent) AffineTransform(java.awt.geom.AffineTransform) Box(javax.swing.Box) InvocationTargetException(java.lang.reflect.InvocationTargetException) Direction(org.pepsoft.minecraft.Direction) org.pepsoft.worldpainter.operations(org.pepsoft.worldpainter.operations) Brush(org.pepsoft.worldpainter.brushes.Brush) PropertyChangeListener(java.beans.PropertyChangeListener) SymmetricBrush(org.pepsoft.worldpainter.brushes.SymmetricBrush) EmptyBorder(javax.swing.border.EmptyBorder) GZIPOutputStream(java.util.zip.GZIPOutputStream) CustomItemsTreeModel(org.pepsoft.worldpainter.importing.CustomItemsTreeModel) GardenOfEdenOperation(org.pepsoft.worldpainter.gardenofeden.GardenOfEdenOperation) java.util(java.util) SimpleDateFormat(java.text.SimpleDateFormat) DOCK_SIDE_WEST(com.jidesoft.docking.DockContext.DOCK_SIDE_WEST) BrushOptions(org.pepsoft.worldpainter.panels.BrushOptions) AffineTransformOp(java.awt.image.AffineTransformOp) MapImportDialog(org.pepsoft.worldpainter.importing.MapImportDialog) com.jidesoft.docking(com.jidesoft.docking) RotatedBrush(org.pepsoft.worldpainter.brushes.RotatedBrush) BetterAction(org.pepsoft.worldpainter.util.BetterAction) ScriptRunner(org.pepsoft.worldpainter.tools.scripts.ScriptRunner) BevelBorder(javax.swing.border.BevelBorder) FileFilter(javax.swing.filechooser.FileFilter) CustomLayerProvider(org.pepsoft.worldpainter.plugins.CustomLayerProvider) java.awt(java.awt) RemoteJCheckBox(org.pepsoft.util.swing.RemoteJCheckBox) LayoutUtils(org.pepsoft.worldpainter.util.LayoutUtils) WPPluginManager(org.pepsoft.worldpainter.plugins.WPPluginManager) RespawnPlayerDialog(org.pepsoft.worldpainter.tools.RespawnPlayerDialog) URL(java.net.URL) EventVO(org.pepsoft.worldpainter.vo.EventVO) PropertyVetoException(java.beans.PropertyVetoException) TiledImageViewerContainer(org.pepsoft.util.swing.TiledImageViewerContainer) FLUIDS_AS_LAYER(org.pepsoft.worldpainter.TileRenderer.FLUIDS_AS_LAYER) CustomBiomeListener(org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager.CustomBiomeListener) PlatformManager(org.pepsoft.worldpainter.plugins.PlatformManager) Material(org.pepsoft.minecraft.Material) BackupUtil(org.pepsoft.worldpainter.util.BackupUtil) BitmapBrush(org.pepsoft.worldpainter.brushes.BitmapBrush) UndergroundPocketsDialog(org.pepsoft.worldpainter.layers.pockets.UndergroundPocketsDialog) ImageIO(javax.imageio.ImageIO) WorldHistoryDialog(org.pepsoft.worldpainter.history.WorldHistoryDialog) BufferedImage(java.awt.image.BufferedImage) DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme) Collectors(java.util.stream.Collectors) JideLabel(com.jidesoft.swing.JideLabel) ProgressTask(org.pepsoft.util.swing.ProgressTask) List(java.util.List) Constants(org.pepsoft.minecraft.Constants) UndergroundPocketsLayer(org.pepsoft.worldpainter.layers.pockets.UndergroundPocketsLayer) org.pepsoft.worldpainter.selection(org.pepsoft.worldpainter.selection) java.awt.event(java.awt.event) BIOMES(org.pepsoft.worldpainter.Platform.Capability.BIOMES) GroundCoverLayer(org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer) CustomBiomeManager(org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager) org.pepsoft.util(org.pepsoft.util) NonNls(org.jetbrains.annotations.NonNls) org.pepsoft.worldpainter.layers(org.pepsoft.worldpainter.layers) Listener(org.pepsoft.worldpainter.panels.BrushOptions.Listener) BufferedImageOp(java.awt.image.BufferedImageOp) ThreeDeeFrame(org.pepsoft.worldpainter.threedeeview.ThreeDeeFrame) MessageFormat(java.text.MessageFormat) VoidRenderer(org.pepsoft.worldpainter.layers.renderers.VoidRenderer) UndoManager(org.pepsoft.util.undo.UndoManager) UsageVO(org.pepsoft.worldpainter.vo.UsageVO) PropertyChangeEvent(java.beans.PropertyChangeEvent) Constants(org.pepsoft.worldpainter.Constants) TERRAIN_AS_LAYER(org.pepsoft.worldpainter.TileRenderer.TERRAIN_AS_LAYER) PlantLayer(org.pepsoft.worldpainter.layers.plants.PlantLayer) AttributeKeyVO(org.pepsoft.worldpainter.vo.AttributeKeyVO) MalformedURLException(java.net.MalformedURLException) BiomesViewerFrame(org.pepsoft.worldpainter.tools.BiomesViewerFrame) ProgressDialog(org.pepsoft.util.swing.ProgressDialog) HistoryEntry(org.pepsoft.worldpainter.history.HistoryEntry) JOptionPane(javax.swing.JOptionPane) Terrain(org.pepsoft.worldpainter.Terrain) DOCK_SIDE_EAST(com.jidesoft.docking.DockContext.DOCK_SIDE_EAST) URLEncoder(java.net.URLEncoder) java.io(java.io) OperationCancelled(org.pepsoft.util.ProgressReceiver.OperationCancelled) WritableRaster(java.awt.image.WritableRaster) ImportMaskDialog(org.pepsoft.worldpainter.importing.ImportMaskDialog) ImportCustomItemsDialog(org.pepsoft.worldpainter.importing.ImportCustomItemsDialog) javax.swing(javax.swing)

Example 2 with CustomBiomeManager

use of org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager in project WorldPainter by Captain-Chaos.

the class BrushOptions method createObjectSelectionMenu.

private JPopupMenu createObjectSelectionMenu(final ObjectSelectionListener listener) {
    JMenuItem waterItem = new JMenuItem("Water");
    waterItem.addActionListener(e -> listener.objectSelected(DefaultFilter.WATER, "Water", null));
    JMenu popupMenu = new JMenu();
    popupMenu.add(waterItem);
    JMenuItem lavaItem = new JMenuItem("Lava");
    lavaItem.addActionListener(e -> listener.objectSelected(DefaultFilter.LAVA, "Lava", null));
    popupMenu.add(lavaItem);
    JMenuItem landItem = new JMenuItem("Land");
    landItem.addActionListener(e -> listener.objectSelected(DefaultFilter.LAND, "Land", null));
    popupMenu.add(landItem);
    JMenu terrainMenu = new JMenu("Terrain");
    JMenu customTerrainMenu = new JMenu("Custom");
    JMenu stainedClayTerrainMenu = new JMenu("Stained Clay");
    App app = App.getInstance();
    ColourScheme colourScheme = app.getColourScheme();
    for (Terrain terrain : Terrain.getConfiguredValues()) {
        final Terrain selectedTerrain = terrain;
        final String name = terrain.getName();
        final Icon icon = new ImageIcon(terrain.getIcon(colourScheme));
        JMenuItem menuItem = new JMenuItem(name, icon);
        menuItem.addActionListener(e -> listener.objectSelected(selectedTerrain, name, icon));
        if (terrain.isCustom()) {
            customTerrainMenu.add(menuItem);
        } else if (terrain.getName().endsWith(" Clay") && (terrain != Terrain.HARDENED_CLAY)) {
            stainedClayTerrainMenu.add(menuItem);
        } else {
            terrainMenu.add(menuItem);
        }
    }
    terrainMenu.add(stainedClayTerrainMenu);
    if (customTerrainMenu.getMenuComponentCount() > 0) {
        terrainMenu.add(customTerrainMenu);
    }
    popupMenu.add(terrainMenu);
    JMenu layerMenu = new JMenu("Layer");
    LayerManager.getInstance().getLayers().stream().filter(l -> !l.equals(Biome.INSTANCE)).forEach(l -> {
        JMenuItem menuItem = new JMenuItem(l.getName(), new ImageIcon(l.getIcon()));
        menuItem.addActionListener(e -> listener.objectSelected(l, l.getName(), new ImageIcon(l.getIcon())));
        layerMenu.add(menuItem);
    });
    Set<CustomLayer> customLayers = app.getCustomLayers();
    if (customLayers.size() > 15) {
        // If there are fifteen or more custom layers, split them by palette
        // and move them to separate submenus to try and conserve screen
        // space
        app.getCustomLayersByPalette().entrySet().stream().map((entry) -> {
            String palette = entry.getKey();
            JMenu paletteMenu = new JMenu(palette != null ? palette : "Hidden Layers");
            entry.getValue().forEach(l -> {
                JMenuItem menuItem = new JMenuItem(l.getName(), new ImageIcon(l.getIcon()));
                menuItem.addActionListener(e -> listener.objectSelected(l, l.getName(), new ImageIcon(l.getIcon())));
                paletteMenu.add(menuItem);
            });
            return paletteMenu;
        }).forEach(layerMenu::add);
    } else {
        customLayers.forEach(l -> {
            JMenuItem menuItem = new JMenuItem(l.getName(), new ImageIcon(l.getIcon()));
            menuItem.addActionListener(e -> listener.objectSelected(l, l.getName(), new ImageIcon(l.getIcon())));
            layerMenu.add(menuItem);
        });
    }
    popupMenu.add(layerMenu);
    final JMenu biomeMenu = new JMenu("Biome");
    final CustomBiomeManager customBiomeManager = app.getCustomBiomeManager();
    final BiomeHelper biomeHelper = new BiomeHelper(autoBiomeScheme, colourScheme, customBiomeManager);
    List<CustomBiome> customBiomes = customBiomeManager.getCustomBiomes();
    if ((customBiomes != null) && (!customBiomes.isEmpty())) {
        JMenu customBiomeMenu = new JMenu("Custom");
        for (CustomBiome customBiome : customBiomes) {
            final int selectedBiome = customBiome.getId();
            final String name = biomeHelper.getBiomeName(selectedBiome) + " (" + selectedBiome + ")";
            final Icon icon = biomeHelper.getBiomeIcon(selectedBiome);
            final JMenuItem menuItem = new JMenuItem(name, icon);
            menuItem.addActionListener(e -> listener.objectSelected(new DefaultFilter.LayerValue(Biome.INSTANCE, selectedBiome), name, icon));
            customBiomeMenu.add(menuItem);
        }
        biomeMenu.add(customBiomeMenu);
    }
    for (int i = 0; i < autoBiomeScheme.getBiomeCount(); i++) {
        if (autoBiomeScheme.isBiomePresent(i)) {
            final int selectedBiome = i;
            final String name = biomeHelper.getBiomeName(i) + " (" + selectedBiome + ")";
            final Icon icon = biomeHelper.getBiomeIcon(i);
            final JMenuItem menuItem = new JMenuItem(name, icon);
            menuItem.addActionListener(e -> listener.objectSelected(new DefaultFilter.LayerValue(Biome.INSTANCE, selectedBiome), name, icon));
            biomeMenu.add(menuItem);
        }
    }
    JMenu autoBiomeSubMenu = new JMenu("Auto Biomes");
    JMenuItem autoBiomesMenuItem = new JMenuItem("All Auto Biomes");
    autoBiomesMenuItem.addActionListener(e -> listener.objectSelected(DefaultFilter.AUTO_BIOMES, "All Auto Biomes", null));
    autoBiomeSubMenu.add(autoBiomesMenuItem);
    for (int autoBiome : Dimension.POSSIBLE_AUTO_BIOMES) {
        final int selectedBiome = -autoBiome;
        final String name = biomeHelper.getBiomeName(autoBiome);
        final Icon icon = biomeHelper.getBiomeIcon(autoBiome);
        final JMenuItem menuItem = new JMenuItem(name, icon);
        menuItem.addActionListener(e -> listener.objectSelected(new DefaultFilter.LayerValue(Biome.INSTANCE, selectedBiome), name, icon));
        autoBiomeSubMenu.add(menuItem);
    }
    biomeMenu.add(autoBiomeSubMenu);
    popupMenu.add(biomeMenu);
    JMenu annotationsMenu = new JMenu("Annotations");
    JMenuItem menuItem = new JMenuItem("All Annotations");
    menuItem.addActionListener(e -> listener.objectSelected(new DefaultFilter.LayerValue(Annotations.INSTANCE), "All Annotations", null));
    annotationsMenu.add(menuItem);
    for (int i = 1; i < 16; i++) {
        final int selectedColour = i, dataValue = selectedColour - ((selectedColour < 8) ? 1 : 0);
        final Icon icon = IconUtils.createScaledColourIcon(colourScheme.getColour(Constants.BLK_WOOL, dataValue));
        menuItem = new JMenuItem(Constants.COLOUR_NAMES[dataValue], icon);
        menuItem.addActionListener(e -> listener.objectSelected(new DefaultFilter.LayerValue(Annotations.INSTANCE, selectedColour), Constants.COLOUR_NAMES[dataValue] + " Annotations", icon));
        annotationsMenu.add(menuItem);
    }
    popupMenu.add(annotationsMenu);
    popupMenu = breakUpLongMenus(popupMenu, 25);
    JPopupMenu result = new JPopupMenu();
    Arrays.stream(popupMenu.getMenuComponents()).forEach(result::add);
    return result;
}
Also used : org.pepsoft.worldpainter(org.pepsoft.worldpainter) CustomBiomeManager(org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager) BiomeHelper(org.pepsoft.worldpainter.biomeschemes.BiomeHelper) java.util(java.util) Logger(org.slf4j.Logger) CustomBiome(org.pepsoft.worldpainter.biomeschemes.CustomBiome) IconUtils(org.pepsoft.util.IconUtils) AutoBiomeScheme(org.pepsoft.worldpainter.biomeschemes.AutoBiomeScheme) LoggerFactory(org.slf4j.LoggerFactory) NumberEditor(javax.swing.JSpinner.NumberEditor) org.pepsoft.worldpainter.layers(org.pepsoft.worldpainter.layers) ActionEvent(java.awt.event.ActionEvent) Dimension(org.pepsoft.worldpainter.Dimension) java.awt(java.awt) List(java.util.List) ObservableBoolean(org.pepsoft.util.ObservableBoolean) Constants(org.pepsoft.minecraft.Constants) Filter(org.pepsoft.worldpainter.operations.Filter) LevelType(org.pepsoft.worldpainter.panels.DefaultFilter.LevelType) javax.swing(javax.swing) CustomBiome(org.pepsoft.worldpainter.biomeschemes.CustomBiome) BiomeHelper(org.pepsoft.worldpainter.biomeschemes.BiomeHelper) CustomBiomeManager(org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager)

Example 3 with CustomBiomeManager

use of org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager in project WorldPainter by Captain-Chaos.

the class CombinedLayerEditor method setContext.

@Override
public void setContext(LayerEditorContext context) {
    super.setContext(context);
    CustomBiomeManager customBiomeManager = context.getCustomBiomeManager();
    ColourScheme colourScheme = context.getColourScheme();
    comboBoxTerrain.setRenderer(new TerrainListCellRenderer(colourScheme, "none"));
    comboBoxBiome.setRenderer(new BiomeListCellRenderer(colourScheme, customBiomeManager, "none"));
    List<Integer> allBiomes = new ArrayList<>();
    allBiomes.add(-1);
    for (int i = 0; i < Minecraft1_7Biomes.BIOME_NAMES.length; i++) {
        if (Minecraft1_7Biomes.BIOME_NAMES[i] != null) {
            allBiomes.add(i);
        }
    }
    List<CustomBiome> customBiomes = customBiomeManager.getCustomBiomes();
    if (customBiomes != null) {
        allBiomes.addAll(customBiomes.stream().map(CustomBiome::getId).collect(Collectors.toList()));
    }
    comboBoxBiome.setModel(new DefaultComboBoxModel(allBiomes.toArray()));
    allLayers = context.getAllLayers();
}
Also used : ColourScheme(org.pepsoft.worldpainter.ColourScheme) CustomBiome(org.pepsoft.worldpainter.biomeschemes.CustomBiome) ArrayList(java.util.ArrayList) CustomBiomeManager(org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager) TerrainListCellRenderer(org.pepsoft.worldpainter.themes.TerrainListCellRenderer) BiomeListCellRenderer(org.pepsoft.worldpainter.BiomeListCellRenderer)

Aggregations

java.awt (java.awt)2 java.util (java.util)2 List (java.util.List)2 javax.swing (javax.swing)2 Constants (org.pepsoft.minecraft.Constants)2 CustomBiome (org.pepsoft.worldpainter.biomeschemes.CustomBiome)2 CustomBiomeManager (org.pepsoft.worldpainter.biomeschemes.CustomBiomeManager)2 com.jidesoft.docking (com.jidesoft.docking)1 DOCK_SIDE_EAST (com.jidesoft.docking.DockContext.DOCK_SIDE_EAST)1 DOCK_SIDE_WEST (com.jidesoft.docking.DockContext.DOCK_SIDE_WEST)1 DockableFrame (com.jidesoft.docking.DockableFrame)1 JideLabel (com.jidesoft.swing.JideLabel)1 java.awt.event (java.awt.event)1 ActionEvent (java.awt.event.ActionEvent)1 KeyEvent (java.awt.event.KeyEvent)1 AffineTransform (java.awt.geom.AffineTransform)1 AffineTransformOp (java.awt.image.AffineTransformOp)1 BufferedImage (java.awt.image.BufferedImage)1 BufferedImageOp (java.awt.image.BufferedImageOp)1 WritableRaster (java.awt.image.WritableRaster)1