Search in sources :

Example 1 with GardenOfEdenOperation

use of org.pepsoft.worldpainter.gardenofeden.GardenOfEdenOperation in project WorldPainter by Captain-Chaos.

the class App method updateStatusBar.

public void updateStatusBar(int x, int y) {
    setTextIfDifferent(locationLabel, MessageFormat.format(strings.getString("location.0.1"), x, y));
    if (dimension == null) {
        setTextIfDifferent(heightLabel, " ");
        setTextIfDifferent(waterLabel, " ");
        setTextIfDifferent(materialLabel, " ");
        setTextIfDifferent(biomeLabel, " ");
        return;
    }
    Tile tile = dimension.getTile(x >> TILE_SIZE_BITS, y >> TILE_SIZE_BITS);
    if (tile == null) {
        // Not on a tile
        setTextIfDifferent(heightLabel, " ");
        setTextIfDifferent(slopeLabel, " ");
        setTextIfDifferent(waterLabel, " ");
        if (dimension.isBorderTile(x >> TILE_SIZE_BITS, y >> TILE_SIZE_BITS)) {
            setTextIfDifferent(materialLabel, "Border");
        } else {
            setTextIfDifferent(materialLabel, "Minecraft Generated");
        }
        setTextIfDifferent(biomeLabel, " ");
        return;
    }
    final int xInTile = x & TILE_SIZE_MASK, yInTile = y & TILE_SIZE_MASK;
    if (tile.getBitLayerValue(NotPresent.INSTANCE, xInTile, yInTile)) {
        // Marked as not present
        setTextIfDifferent(heightLabel, " ");
        setTextIfDifferent(slopeLabel, " ");
        setTextIfDifferent(waterLabel, " ");
        setTextIfDifferent(materialLabel, "Minecraft Generated");
        setTextIfDifferent(biomeLabel, " ");
        return;
    }
    int height = tile.getIntHeight(xInTile, yInTile);
    setTextIfDifferent(heightLabel, MessageFormat.format(strings.getString("height.0.of.1"), height, dimension.getMaxHeight() - 1));
    setTextIfDifferent(slopeLabel, MessageFormat.format("Slope: {0}°", (int) (Math.atan(dimension.getSlope(x, y)) * 180 / Math.PI + 0.5)));
    if ((activeOperation instanceof PaintOperation) && (paint instanceof LayerPaint)) {
        Layer layer = ((LayerPaint) paint).getLayer();
        switch(layer.getDataSize()) {
            case BIT:
            case BIT_PER_CHUNK:
                setTextIfDifferent(waterLabel, MessageFormat.format(strings.getString("layer.0.on.off"), layer.getName(), (tile.getBitLayerValue(layer, xInTile, yInTile) ? 1 : 0)));
                break;
            case NIBBLE:
                int value, strength;
                if (!layer.equals(Annotations.INSTANCE)) {
                    value = tile.getLayerValue(layer, xInTile, yInTile);
                    strength = (value > 0) ? ((value - 1) * 100 / 14 + 1) : 0;
                    if ((strength == 51) || (strength == 101)) {
                        strength--;
                    }
                    setTextIfDifferent(waterLabel, MessageFormat.format(strings.getString("layer.0.level.1"), layer.getName(), strength));
                } else {
                    setTextIfDifferent(waterLabel, " ");
                }
                break;
            case BYTE:
                if (!layer.equals(Biome.INSTANCE)) {
                    value = tile.getLayerValue(layer, xInTile, yInTile);
                    strength = (value > 0) ? ((value - 1) * 100 / 254 + 1) : 0;
                    setTextIfDifferent(waterLabel, MessageFormat.format(strings.getString("layer.0.level.1"), layer.getName(), strength));
                } else {
                    setTextIfDifferent(waterLabel, " ");
                }
                break;
            default:
                // Do nothing
                break;
        }
    } else if (activeOperation instanceof GardenOfEdenOperation) {
        setTextIfDifferent(waterLabel, strings.getString("structure") + ": " + GardenCategory.getLabel(strings, tile.getLayerValue(GardenCategory.INSTANCE, xInTile, yInTile)));
    } else {
        int waterLevel = tile.getWaterLevel(xInTile, yInTile);
        if (waterLevel > height) {
            setTextIfDifferent(waterLabel, MessageFormat.format(strings.getString("fluid.level.1.depth.2"), tile.getBitLayerValue(FloodWithLava.INSTANCE, xInTile, yInTile) ? 1 : 0, waterLevel, waterLevel - height));
        } else {
            setTextIfDifferent(waterLabel, " ");
        }
    }
    Terrain terrain = tile.getTerrain(xInTile, yInTile);
    if (terrain.isCustom()) {
        int index = terrain.getCustomTerrainIndex();
        setTextIfDifferent(materialLabel, MessageFormat.format(strings.getString("material.custom.1.0"), getCustomMaterial(index), index + 1));
    } else {
        setTextIfDifferent(materialLabel, MessageFormat.format(strings.getString("material.0"), terrain.getName()));
    }
    // with biomeNames being null, causing a NPE. How is this possible?
    if (dimension.getDim() == 0) {
        int biome = tile.getLayerValue(Biome.INSTANCE, xInTile, yInTile);
        // TODO: is this too slow?
        if (biome == 255) {
            biome = dimension.getAutoBiome(x, y);
            if (biome != -1) {
                if (biomeNames[biome] == null) {
                    setTextIfDifferent(biomeLabel, "Auto biome: biome " + biome);
                } else {
                    setTextIfDifferent(biomeLabel, "Auto biome: " + biomeNames[biome]);
                }
            }
        } else if (biome != -1) {
            if (biomeNames[biome] == null) {
                setTextIfDifferent(biomeLabel, MessageFormat.format(strings.getString("biome.0"), biome));
            } else {
                setTextIfDifferent(biomeLabel, MessageFormat.format(strings.getString("biome.0"), biomeNames[biome]));
            }
        }
    } else {
        setTextIfDifferent(biomeLabel, strings.getString("biome-"));
    }
}
Also used : Terrain(org.pepsoft.worldpainter.Terrain) GardenOfEdenOperation(org.pepsoft.worldpainter.gardenofeden.GardenOfEdenOperation) TunnelLayer(org.pepsoft.worldpainter.layers.tunnel.TunnelLayer) UndergroundPocketsLayer(org.pepsoft.worldpainter.layers.pockets.UndergroundPocketsLayer) GroundCoverLayer(org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer) PlantLayer(org.pepsoft.worldpainter.layers.plants.PlantLayer) Paint(org.pepsoft.worldpainter.painting.Paint)

Aggregations

Terrain (org.pepsoft.worldpainter.Terrain)1 GardenOfEdenOperation (org.pepsoft.worldpainter.gardenofeden.GardenOfEdenOperation)1 GroundCoverLayer (org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer)1 PlantLayer (org.pepsoft.worldpainter.layers.plants.PlantLayer)1 UndergroundPocketsLayer (org.pepsoft.worldpainter.layers.pockets.UndergroundPocketsLayer)1 TunnelLayer (org.pepsoft.worldpainter.layers.tunnel.TunnelLayer)1 Paint (org.pepsoft.worldpainter.painting.Paint)1