Search in sources :

Example 1 with Bo2Layer

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

the class Bo2LayerEditor method saveSettings.

private Bo2Layer saveSettings(Bo2Layer layer) {
    String name = fieldName.getText();
    List<WPObject> objects = new ArrayList<>(listModel.getSize());
    for (int i = 0; i < listModel.getSize(); i++) {
        objects.add((WPObject) listModel.getElementAt(i));
    }
    Bo2ObjectProvider objectProvider = new Bo2ObjectTube(name, objects);
    if (layer == null) {
        layer = new Bo2Layer(objectProvider, "Custom (e.g. bo2, bo3 and/or schematic) objects", selectedColour);
    } else {
        layer.setObjectProvider(objectProvider);
        layer.setColour(selectedColour);
    }
    layer.setDensity((Integer) spinnerBlocksPerAttempt.getValue());
    return layer;
}
Also used : WPObject(org.pepsoft.worldpainter.objects.WPObject) Bo2Layer(org.pepsoft.worldpainter.layers.Bo2Layer)

Example 2 with Bo2Layer

use of org.pepsoft.worldpainter.layers.Bo2Layer 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)1 GroundCoverLayer (org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer)1 PlantLayer (org.pepsoft.worldpainter.layers.plants.PlantLayer)1 WPObject (org.pepsoft.worldpainter.objects.WPObject)1