@Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); ELandscapeType type = (ELandscapeType) value; setIcon(new RectIcon(22, new Color(type.color.getARGB()), Color.GRAY)); setText(EditorLabels.getLabel("landscape." + type.name())); return this; } });
private void testLandscape(int x, int y, int x2, int y2) { ELandscapeType l2 = data.getLandscape(x2, y2); ELandscapeType l1 = data.getLandscape(x, y); int maxHeightDiff = getMaxHeightDiff(l1, l2); if (Math.abs(data.getLandscapeHeight(x2, y2) - data.getLandscapeHeight(x, y)) > maxHeightDiff) { ShortPoint2D p = new ShortPoint2D(x, y); addErrorMessage("landscape.height", p); landscapeFix.addPosition(p); } if (!fader.canFadeTo(l2, l1)) { String landscapeName1 = EditorLabels.getLabel("landscape." + l2.name()); String landscapeName2 = EditorLabels.getLabel("landscape." + l1.name()); addErrorMessage("landscape.wrong-pair", new ShortPoint2D(x, y), landscapeName1, landscapeName2); // this cannot be automatically fixed } if (players[x][y] != players[x2][y2]) { if (players[x][y] != -1) { borders[x][y] = true; } if (players[x2][y2] != -1) { borders[x2][y2] = true; } } }
@Override public void doTest() { InvalidResourceFix fix = new InvalidResourceFix(); addHeader("resource.header", fix); for (short x = 0; x < data.getWidth(); x++) { for (short y = 0; y < data.getHeight(); y++) { ELandscapeType landacape = data.getLandscape(x, y); EResourceType resource = data.getResourceType(x, y); if (data.getResourceAmount(x, y) > 0 && !mayHoldResource(landacape, resource)) { String landscapeName = EditorLabels.getLabel("landscape." + landacape.name()); String resourceName = Labels.getName(resource); ShortPoint2D p = new ShortPoint2D(x, y); addErrorMessage("resource.text", p, landscapeName, resourceName); fix.addInvalidResource(p); } } } }
} else if (!type.getGroundTypes().contains(data.getLandscape(pos.x, pos.y))) { ELandscapeType landscape = data.getLandscape(pos.x, pos.y); String landscapeName = EditorLabels.getLabel("landscape." + landscape.name()); addErrorMessage("building.wrong-landscape", pos, Labels.getName(type), landscapeName); fix.addInvalidObject(pos);