@Override public String getDescription(float relativeX, float relativeY) { return Labels.getName(material, plural); }
@Override public String getDescription(float relativeX, float relativeY) { return Labels.getName(material, plural); }
public PlaceMovableTool(EMovableType type, IPlayerSetter player) { super(null); this.type = type; this.player = player; this.translatedName = String.format(Locale.ENGLISH, EditorLabels.getLabel("tool.place"), Labels.getName(type)); }
private static String getName(int row) { if (row >= BUILDING_START) { return Labels.getName(EBuildingType.values()[row - BUILDING_START]); } else if (row >= MOVABLE_START) { return Labels.getName(EMovableType.values()[row - MOVABLE_START]); } else if (row >= MATERIAL_START) { return Labels.getName(EMaterialType.values()[row - MATERIAL_START], true); } return ""; }
@Override public String getDescription(float relativeX, float relativeY) { return Labels.getString("upgrade_warriors", Labels.getName(soldierType)); }
public SimpleActionButton(EActionType actionType, ImageLink image, ImageLink active) { super(new Action(actionType), image, active, Labels.getName(actionType)); }
/** * Constructor * * @param type * Type of the building to place * @param player * Interface to query which player owns the building */ public PlaceBuildingTool(EBuildingType type, IPlayerSetter player) { super(null); this.type = type; this.player = player; this.translatedName = String.format(Locale.ENGLISH, EditorLabels.getLabel("tool.building"), Labels.getName(type)); }
/** * Constructor * * @param type * Type to place, <code>null</code> to delete resources */ public PlaceResource(EResourceType type) { super(type == null ? ToolIcon.loadIcon("remove-resource.png") : null, type == null ? EditorLabels.getLabel("tool.remove-resource") : Labels.getName(type)); this.type = type; shapeTypes.add(EShapeType.POINT); shapeTypes.add(EShapeType.LINE); shapeTypes.add(EShapeType.LINE_CIRCLE); shapeTypes.add(EShapeType.NOISY_LINE_CIRCLE); shapeTypes.add(EShapeType.GRID_CIRCLE); }
public PlaceStackTool(EMaterialType type, int count) { super(new StackMapDataObject(type, count)); this.translatedName = String.format(Locale.ENGLISH, EditorLabels.getLabel("tool.place_n"), count, Labels.getName(type, count != 1)); } }
/** * Sets the type of the building to display. * * @param type * The type. * @param workplace * <code>true</code> if it is currently under construction. */ public void setType(EBuildingType type, boolean workplace) { String text = Labels.getName(type); if (workplace) { text = Labels.getString("building-build-in-progress", text); } setText(text); } }
/** * Constructor * * @param type * Type to place * @param maxCount * max count */ public PlaceStackToolbox(EMaterialType type, int maxCount) { super(String.format(Locale.ENGLISH, EditorLabels.getLabel("place_stacks"), Labels.getName(type, true))); for (int i = 0; i < maxCount; i++) { add(new PlaceStackTool(type, i + 1)); } } }
public BuildingButton(EBuildingType buildingType) { super(new ShowConstructionMarksAction(buildingType), null, null, Labels.getName(buildingType)); this.buildingType = buildingType; buildingImageLink = buildingType.getGuiImage(); addChild(constructedLabel, 0.05f, 0.05f, .95f, .95f); }
/** * Check minimum Resource, do not check if they are reachable by all player etc. */ private void checkResources() { Set<EResourceType> foundResources = new HashSet<>(); for (short x = 0; x < data.getWidth(); x++) { for (short y = 0; y < data.getHeight(); y++) { EResourceType resource = data.getResourceType(x, y); if (data.getResourceAmount(x, y) > 0) { foundResources.add(resource); } } } for (EResourceType r : REQUIRED) { if (!foundResources.contains(r)) { addWarningMessage(ErrorMarker.MISSING_LIFE_RESOURCE, "minlife.missing", null, Labels.getName(r)); } } }
BuildingDistributionSettingPanel(EMaterialType materialType, EBuildingType buildingType, IPositionSupplier positionSupplier) { this.buildingType = buildingType; barFill = new ActionProvidedBarFill(ratio -> { ShortPoint2D position = positionSupplier.getPosition(); if (position != null) { return new SetMaterialDistributionSettingsAction(position, materialType, buildingType, ratio); } else { return null; } }, Labels.getName(buildingType) + "-distribution-barfill"); Label rowTitle = new Label(Labels.getName(buildingType), EFontSize.SMALL, EHorizontalAlignment.LEFT); addChild(rowTitle, 0f, 1f - textHeight, 1f, 1f); addChild(lblPercentage, 0f, 0f, textPercentageWidth, 1f - (textHeight + textMarginBottom)); addChild(barFill, textPercentageWidth, 0f, 1f, 1f - (textHeight + textMarginBottom)); }
/** * Draws the stack directly to the screen. * * @param x * The x coordinate of the building * @param y * The y coordinate of the building * @param material * The material the stack should have. * @param count * The number of elements on the stack */ private void drawStackAtScreen(int x, int y, EMaterialType material, int count, float color) { int stackIndex = material.getStackIndex(); Sequence<? extends Image> seq = this.imageProvider.getSettlerSequence(OBJECTS_FILE, stackIndex); draw(seq.getImageSafe(count - 1, () -> Labels.getName(material, count != 1) + "@" + count), x, y, 0, color); }
public MaterialButton(Action action, EMaterialType material) { super(action, material.getIcon(), material.getIcon(), Labels.getName(material, false)); this.material = material; setBackground(material.getIcon()); addChild(dot, .1f, .6f, .4f, .9f); addChild(selected, 0, 0, 1, 1); }
/** * Test if this movable object is valid at this position * * @param x * X Pos * @param y * Y Pos * @param movableObject * MovableObject */ private void testMoveableObject(int x, int y, MovableObject movableObject) { EMovableType type = movableObject.getType(); if (!type.needsPlayersGround()) { // don't need player ground, so don't check it here return; } if (players[x][y] != movableObject.getPlayerId()) { ShortPoint2D point = new ShortPoint2D(x, y); addErrorMessage("settler.wrong-land", point, Labels.getName(type), movableObject.getPlayerId(), players[x][y]); fix.addInvalidObject(point); } }
@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); } } } }
public Row(final EMaterialType materialType) { type = materialType; goodsIcon = new UIPanel(); goodsIcon.setBackground(materialType.getIcon()); lblQuantity = new Label(Labels.getString(Integer.toString(quantity)), EFontSize.NORMAL); IPositionSupplier positionSupplier = () -> position; Button upButton = new SetMaterialProductionButton(positionSupplier, type, SetMaterialProductionAction.EMaterialProductionType.INCREASE); Button downButton = new SetMaterialProductionButton(positionSupplier, type, SetMaterialProductionAction.EMaterialProductionType.DECREASE); arrows = new UIPanel(); arrows.setBackground(arrowsImageLink); arrows.addChild(upButton, 0f, 0.5f, 1f, 1f); arrows.addChild(downButton, 0f, 0f, 1f, 0.5f); barFill = new ActionProvidedBarFill(fillForClick -> new SetMaterialProductionAction(position, materialType, SetMaterialProductionAction.EMaterialProductionType.SET_RATIO, fillForClick), Labels.getName(materialType, false) + "-production-barfill"); float left = 0; addChild(goodsIcon, left, 0f, left += iconWidth, 1f); addChild(lblQuantity, left, quantityTextMarginV, left += quantityTextWidth, 1f - quantityTextMarginV); addChild(arrows, left, 0f, left += arrowsWidth, 1f); addChild(barFill, left + barPaddingLeft, barMarginV, 1f, 1f - barMarginV); }
@Override public void drawAt(GLDrawContext gl) { float width = getPosition().getWidth(); Image image = SettlerImageMap.getInstance().getImageForSettler(type, EMovableAction.NO_ACTION, EMaterialType.NO_MATERIAL, EDirection.SOUTH_EAST, 0); Color color = getColor(); float bottomy = getPosition() .getMinY() + getPosition().getHeight() / 4; float left = getPosition().getMinX(); float imagex = left + width / 20; image.drawAt(gl, imagex, bottomy, 0, color, 1); TextDrawer drawer = gl.getTextDrawer(EFontSize.NORMAL); drawer.drawString(left + width / 5, getPosition().getMinY() + getPosition().getHeight() * .75f, "" + count); drawer.drawString(left + width / 5, bottomy, Labels.getName(type)); }