Search in sources :

Example 1 with EditLayerDialog

use of org.pepsoft.worldpainter.layers.EditLayerDialog in project WorldPainter by Captain-Chaos.

the class TunnelLayerDialog method editFloorLayer.

private void editFloorLayer() {
    int selectedRow = tableFloorLayers.getSelectedRow();
    if (selectedRow != -1) {
        Layer layer = floorLayersTableModel.getLayer(selectedRow);
        if (layer instanceof CustomLayer) {
            EditLayerDialog<Layer> dialog = new EditLayerDialog<>(this, layer);
            dialog.setVisible(true);
            if (!dialog.isCancelled()) {
                floorLayersTableModel.layerChanged(selectedRow);
            }
        }
    }
}
Also used : CustomLayer(org.pepsoft.worldpainter.layers.CustomLayer) Bo2Layer(org.pepsoft.worldpainter.layers.Bo2Layer) CustomLayer(org.pepsoft.worldpainter.layers.CustomLayer) PlantLayer(org.pepsoft.worldpainter.layers.plants.PlantLayer) Layer(org.pepsoft.worldpainter.layers.Layer) GroundCoverLayer(org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer) EditLayerDialog(org.pepsoft.worldpainter.layers.EditLayerDialog)

Example 2 with EditLayerDialog

use of org.pepsoft.worldpainter.layers.EditLayerDialog in project WorldPainter by Captain-Chaos.

the class TunnelLayerDialog method newFloorLayer.

private void newFloorLayer() {
    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem item = new JMenuItem("Custom Objects Layer");
    item.addActionListener(e -> {
        EditLayerDialog<Bo2Layer> dialog = new EditLayerDialog(TunnelLayerDialog.this, Bo2Layer.class);
        dialog.setVisible(true);
        if (!dialog.isCancelled()) {
            Bo2Layer newLayer = dialog.getLayer();
            newLayer.setHide(true);
            floorLayersTableModel.addLayer(newLayer);
        }
    });
    popupMenu.add(item);
    item = new JMenuItem("Custom Ground Cover Layer");
    item.addActionListener(e -> {
        EditLayerDialog<GroundCoverLayer> dialog = new EditLayerDialog(TunnelLayerDialog.this, GroundCoverLayer.class);
        dialog.setVisible(true);
        if (!dialog.isCancelled()) {
            GroundCoverLayer newLayer = dialog.getLayer();
            newLayer.setHide(true);
            floorLayersTableModel.addLayer(newLayer);
        }
    });
    popupMenu.add(item);
    item = new JMenuItem("Custom Plants Layer");
    item.addActionListener(e -> {
        EditLayerDialog<PlantLayer> dialog = new EditLayerDialog(TunnelLayerDialog.this, PlantLayer.class);
        dialog.setVisible(true);
        if (!dialog.isCancelled()) {
            PlantLayer newLayer = dialog.getLayer();
            newLayer.setHide(true);
            floorLayersTableModel.addLayer(newLayer);
        }
    });
    popupMenu.add(item);
    popupMenu.show(buttonNewFloorLayer, buttonNewFloorLayer.getWidth(), 0);
}
Also used : PlantLayer(org.pepsoft.worldpainter.layers.plants.PlantLayer) GroundCoverLayer(org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer) Bo2Layer(org.pepsoft.worldpainter.layers.Bo2Layer) EditLayerDialog(org.pepsoft.worldpainter.layers.EditLayerDialog)

Aggregations

Bo2Layer (org.pepsoft.worldpainter.layers.Bo2Layer)2 EditLayerDialog (org.pepsoft.worldpainter.layers.EditLayerDialog)2 GroundCoverLayer (org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer)2 PlantLayer (org.pepsoft.worldpainter.layers.plants.PlantLayer)2 CustomLayer (org.pepsoft.worldpainter.layers.CustomLayer)1 Layer (org.pepsoft.worldpainter.layers.Layer)1