use of org.pepsoft.worldpainter.NoiseSettings in project WorldPainter by Captain-Chaos.
the class TunnelLayerDialog method saveSettingsTo.
private void saveSettingsTo(TunnelLayer layer, boolean registerMaterials) {
layer.setFloorLevel((Integer) spinnerFloorLevel.getValue());
layer.setFloorMin((Integer) spinnerFloorMin.getValue());
layer.setFloorMax((Integer) spinnerFloorMax.getValue());
MixedMaterial floorMaterial = mixedMaterialSelectorFloor.getMaterial();
if ((floorMaterial != null) && registerMaterials) {
// Make sure the material is registered, in case it's new
floorMaterial = MixedMaterialManager.getInstance().register(floorMaterial);
}
layer.setFloorMaterial(floorMaterial);
if (radioButtonFloorFixedDepth.isSelected()) {
layer.setFloorMode(Mode.CONSTANT_DEPTH);
} else if (radioButtonFloorFixedLevel.isSelected()) {
layer.setFloorMode(Mode.FIXED_HEIGHT);
} else {
layer.setFloorMode(Mode.INVERTED_DEPTH);
}
NoiseSettings floorNoiseSettings = noiseSettingsEditorFloor.getNoiseSettings();
if (floorNoiseSettings.getRange() == 0) {
layer.setFloorNoise(null);
} else {
layer.setFloorNoise(floorNoiseSettings);
}
layer.setRoofLevel((Integer) spinnerRoofLevel.getValue());
layer.setRoofMin((Integer) spinnerRoofMin.getValue());
layer.setRoofMax((Integer) spinnerRoofMax.getValue());
MixedMaterial roofMaterial = mixedMaterialSelectorRoof.getMaterial();
if ((roofMaterial != null) && registerMaterials) {
// Make sure the material is registered, in case it's new
roofMaterial = MixedMaterialManager.getInstance().register(roofMaterial);
}
layer.setRoofMaterial(roofMaterial);
if (radioButtonRoofFixedDepth.isSelected()) {
layer.setRoofMode(Mode.CONSTANT_DEPTH);
} else if (radioButtonRoofFixedLevel.isSelected()) {
layer.setRoofMode(Mode.FIXED_HEIGHT);
} else {
layer.setRoofMode(Mode.INVERTED_DEPTH);
}
NoiseSettings roofNoiseSettings = noiseSettingsEditorRoof.getNoiseSettings();
if (roofNoiseSettings.getRange() == 0) {
layer.setRoofNoise(null);
} else {
layer.setRoofNoise(roofNoiseSettings);
}
layer.setFloorWallDepth((Integer) spinnerWallFloorDepth.getValue());
layer.setRoofWallDepth((Integer) spinnerWallRoofDepth.getValue());
MixedMaterial wallMaterial = mixedMaterialSelectorWall.getMaterial();
if ((wallMaterial != null) && registerMaterials) {
// Make sure the material is registered, in case it's new
wallMaterial = MixedMaterialManager.getInstance().register(wallMaterial);
}
layer.setWallMaterial(wallMaterial);
layer.setName(textFieldName.getText().trim());
layer.setColour(colourEditor1.getColour());
layer.setRemoveWater(checkBoxRemoveWater.isSelected());
layer.setFloodLevel(checkBoxFlood.isSelected() ? (Integer) spinnerFloodLevel.getValue() : 0);
layer.setFloodWithLava(checkBoxFloodWithLava.isSelected());
Map<Layer, TunnelLayer.LayerSettings> floorLayers = floorLayersTableModel.getLayers();
layer.setFloorLayers(((floorLayers != null) && (!floorLayers.isEmpty())) ? floorLayers : null);
}
use of org.pepsoft.worldpainter.NoiseSettings in project WorldPainter by Captain-Chaos.
the class TunnelLayerDialog method loadSettings.
private void loadSettings() {
programmaticChange = true;
try {
spinnerFloorLevel.setValue(layer.getFloorLevel());
spinnerFloorMin.setValue(layer.getFloorMin());
spinnerFloorMax.setValue(Math.min(layer.getFloorMax(), maxHeight - 1));
mixedMaterialSelectorFloor.setMaterial(layer.getFloorMaterial());
switch(layer.getFloorMode()) {
case CONSTANT_DEPTH:
radioButtonFloorFixedDepth.setSelected(true);
break;
case FIXED_HEIGHT:
radioButtonFloorFixedLevel.setSelected(true);
break;
case INVERTED_DEPTH:
radioButtonFloorInverse.setSelected(true);
break;
}
NoiseSettings floorNoise = layer.getFloorNoise();
if (floorNoise == null) {
floorNoise = new NoiseSettings();
}
noiseSettingsEditorFloor.setNoiseSettings(floorNoise);
spinnerRoofLevel.setValue(layer.getRoofLevel());
spinnerRoofMin.setValue(layer.getRoofMin());
spinnerRoofMax.setValue(Math.min(layer.getRoofMax(), maxHeight - 1));
mixedMaterialSelectorRoof.setMaterial(layer.getRoofMaterial());
switch(layer.getRoofMode()) {
case CONSTANT_DEPTH:
radioButtonRoofFixedDepth.setSelected(true);
break;
case FIXED_HEIGHT:
radioButtonRoofFixedLevel.setSelected(true);
break;
case INVERTED_DEPTH:
radioButtonRoofInverse.setSelected(true);
break;
}
NoiseSettings roofNoise = layer.getRoofNoise();
if (roofNoise == null) {
roofNoise = new NoiseSettings();
}
noiseSettingsEditorRoof.setNoiseSettings(roofNoise);
spinnerWallFloorDepth.setValue(layer.getFloorWallDepth());
spinnerWallRoofDepth.setValue(layer.getRoofWallDepth());
mixedMaterialSelectorWall.setMaterial(layer.getWallMaterial());
textFieldName.setText(layer.getName());
colourEditor1.setColour(layer.getColour());
checkBoxRemoveWater.setSelected(layer.isRemoveWater());
checkBoxFlood.setSelected(layer.getFloodLevel() > 0);
spinnerFloodLevel.setValue((layer.getFloodLevel() > 0) ? layer.getFloodLevel() : waterLevel);
checkBoxFloodWithLava.setSelected(layer.isFloodWithLava());
Map<Layer, TunnelLayer.LayerSettings> floorLayers = layer.getFloorLayers();
floorLayersTableModel = new TunnelFloorLayersTableModel(floorLayers, maxHeight);
tableFloorLayers.setModel(floorLayersTableModel);
tableFloorLayers.getColumnModel().getColumn(TunnelFloorLayersTableModel.COLUMN_NAME).setCellRenderer(new LayerTableCellRenderer());
} finally {
programmaticChange = false;
}
setControlStates();
}
use of org.pepsoft.worldpainter.NoiseSettings in project WorldPainter by Captain-Chaos.
the class GroundCoverLayerEditor method saveSettings.
private GroundCoverLayer saveSettings(GroundCoverLayer layer) {
if (layer == null) {
layer = new GroundCoverLayer(fieldName.getText(), mixedMaterialSelector1.getMaterial(), selectedColour);
} else {
layer.setName(fieldName.getText());
layer.setColour(selectedColour);
}
layer.setThickness((Integer) spinnerThickness.getValue());
if (radioButtonSheerEdge.isSelected()) {
layer.setEdgeShape(GroundCoverLayer.EdgeShape.SHEER);
} else if (radioButtonLinearEdge.isSelected()) {
layer.setEdgeShape(GroundCoverLayer.EdgeShape.LINEAR);
} else if (radioButtonSmoothEdge.isSelected()) {
layer.setEdgeShape(GroundCoverLayer.EdgeShape.SMOOTH);
} else if (radioButtonRoundedEdge.isSelected()) {
layer.setEdgeShape(GroundCoverLayer.EdgeShape.ROUNDED);
}
layer.setEdgeWidth((Integer) spinnerEdgeWidth.getValue());
NoiseSettings noiseSettings = noiseSettingsEditor1.getNoiseSettings();
if (noiseSettings.getRange() == 0) {
layer.setNoiseSettings(null);
} else {
layer.setNoiseSettings(noiseSettings);
}
layer.setSmooth(checkBoxSmooth.isSelected());
return layer;
}
Aggregations