Search in sources :

Example 1 with Image

use of com.minecolonies.blockout.controls.Image in project minecolonies by Minecolonies.

the class WindowCitizen method createSaturationBar.

/**
     * Creates an health bar according to the citizen maxHealth and currentHealth.
     */
private void createSaturationBar() {
    findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).setAlignment(Alignment.MIDDLE_RIGHT);
    //Max saturation (Black food items).
    for (int i = 0; i < CitizenData.MAX_SATURATION; i++) {
        @NotNull final Image saturation = new Image();
        saturation.setImage(Gui.ICONS, EMPTY_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH);
        saturation.setPosition(i * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y);
        findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).addChild(saturation);
    }
    //Current saturation (Full food hearts).
    int saturationPos;
    for (saturationPos = 0; saturationPos < ((int) citizen.getSaturation()); saturationPos++) {
        @NotNull final Image saturation = new Image();
        saturation.setImage(Gui.ICONS, FULL_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH);
        saturation.setPosition(saturationPos * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y);
        findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).addChild(saturation);
    }
    //Half food items.
    if (citizen.getSaturation() / 2 % 1 > 0) {
        @NotNull final Image saturation = new Image();
        saturation.setImage(Gui.ICONS, HALF_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH);
        saturation.setPosition(saturationPos * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y);
        findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).addChild(saturation);
    }
}
Also used : Image(com.minecolonies.blockout.controls.Image) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) View(com.minecolonies.blockout.views.View) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Image

use of com.minecolonies.blockout.controls.Image in project minecolonies by Minecolonies.

the class WindowClipBoard method onOpened.

/**
 * Called when the window is opened.
 * Sets up the buttons for either hut mode or decoration mode.
 */
@Override
public void onOpened() {
    resourceList.setDataProvider(() -> getOpenRequests().size(), (index, rowPane) -> {
        final ImmutableList<IRequest> openRequests = getOpenRequests();
        if (index < 0 || index >= openRequests.size()) {
            return;
        }
        final IRequest request = openRequests.get(index);
        final ItemIcon exampleStackDisplay = rowPane.findPaneOfTypeByID(LIST_ELEMENT_ID_REQUEST_STACK, ItemIcon.class);
        final List<ItemStack> displayStacks = request.getDisplayStacks();
        if (!displayStacks.isEmpty()) {
            if (exampleStackDisplay != null) {
                exampleStackDisplay.setItem(displayStacks.get((lifeCount / LIFE_COUNT_DIVIDER) % displayStacks.size()));
            }
        } else {
            final Image logo = findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
            logo.setVisible(true);
            logo.setImage(request.getDisplayIcon());
        }
        final ColonyView view = ColonyManager.getColonyView(colonyId);
        rowPane.findPaneOfTypeByID(REQUESTER, Label.class).setLabelText(request.getRequester().getDisplayName(view.getRequestManager(), request.getToken()).getFormattedText());
        rowPane.findPaneOfTypeByID(REQUEST_SHORT_DETAIL, Label.class).setLabelText(request.getShortDisplayString().getFormattedText().replace("§f", ""));
    });
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) ItemIcon(com.minecolonies.blockout.controls.ItemIcon) Label(com.minecolonies.blockout.controls.Label) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) ItemStack(net.minecraft.item.ItemStack) Image(com.minecolonies.blockout.controls.Image)

Example 3 with Image

use of com.minecolonies.blockout.controls.Image in project minecolonies by Minecolonies.

the class WindowCitizen method createXpBar.

/**
     * Creates the xp bar for each citizen.
     * Calculates an xpBarCap which is the maximum of xp to fit into the bar.
     * Then creates an xp bar and fills it up with the available xp.
     */
private void createXpBar() {
    //Calculates how much percent of the next level has been completed.
    final double experienceRatio = ExperienceUtils.getPercentOfLevelCompleted(citizen.getExperience(), citizen.getLevel());
    findPaneOfTypeByID(WINDOW_ID_XP, Label.class).setLabelText(Integer.toString(citizen.getLevel()));
    findPaneOfTypeByID(WINDOW_ID_XP, Label.class).setPosition(XP_LABEL_X, XP_LABEL_Y);
    @NotNull final Image xpBar = new Image();
    xpBar.setImage(Gui.ICONS, XP_BAR_ICON_COLUMN, XP_BAR_EMPTY_ROW, XP_BAR_WIDTH, XP_HEIGHT);
    xpBar.setPosition(LEFT_BORDER_X, LEFT_BORDER_Y);
    @NotNull final Image xpBar2 = new Image();
    xpBar2.setImage(Gui.ICONS, XP_BAR_ICON_COLUMN_END, XP_BAR_EMPTY_ROW, XP_BAR_ICON_COLUMN_END_WIDTH, XP_HEIGHT);
    xpBar2.setPosition(XP_BAR_ICON_END_OFFSET + LEFT_BORDER_X, LEFT_BORDER_Y);
    findPaneOfTypeByID(WINDOW_ID_XPBAR, View.class).addChild(xpBar);
    findPaneOfTypeByID(WINDOW_ID_XPBAR, View.class).addChild(xpBar2);
    if (experienceRatio > 0) {
        @NotNull final Image xpBarFull = new Image();
        xpBarFull.setImage(Gui.ICONS, XP_BAR_ICON_COLUMN, XP_BAR_FULL_ROW, (int) experienceRatio, XP_HEIGHT);
        xpBarFull.setPosition(LEFT_BORDER_X, LEFT_BORDER_Y);
        findPaneOfTypeByID(WINDOW_ID_XPBAR, View.class).addChild(xpBarFull);
    }
}
Also used : Label(com.minecolonies.blockout.controls.Label) Image(com.minecolonies.blockout.controls.Image) NotNull(org.jetbrains.annotations.NotNull) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) View(com.minecolonies.blockout.views.View)

Example 4 with Image

use of com.minecolonies.blockout.controls.Image in project minecolonies by Minecolonies.

the class WindowCitizen method createHealthBar.

/**
     * Creates an health bar according to the citizen maxHealth and currentHealth.
     */
private void createHealthBar() {
    findPaneOfTypeByID(WINDOW_ID_HEALTHBAR, View.class).setAlignment(Alignment.MIDDLE_RIGHT);
    //MaxHealth (Black hearts).
    for (int i = 0; i < citizen.getMaxHealth() / 2; i++) {
        @NotNull final Image heart = new Image();
        heart.setImage(Gui.ICONS, EMPTY_HEART_ICON_ROW_POS, HEART_ICON_COLUMN, HEART_ICON_HEIGHT_WIDTH, HEART_ICON_HEIGHT_WIDTH);
        heart.setPosition(i * HEART_ICON_POS_X + HEART_ICON_OFFSET_X, HEART_ICON_POS_Y);
        findPaneOfTypeByID(WINDOW_ID_HEALTHBAR, View.class).addChild(heart);
    }
    //Current health (Red hearts).
    int heartPos;
    for (heartPos = 0; heartPos < ((int) citizen.getHealth() / 2); heartPos++) {
        @NotNull final Image heart = new Image();
        heart.setImage(Gui.ICONS, FULL_HEART_ICON_ROW_POS, HEART_ICON_COLUMN, HEART_ICON_HEIGHT_WIDTH, HEART_ICON_HEIGHT_WIDTH);
        heart.setPosition(heartPos * HEART_ICON_POS_X + HEART_ICON_OFFSET_X, HEART_ICON_POS_Y);
        findPaneOfTypeByID(WINDOW_ID_HEALTHBAR, View.class).addChild(heart);
    }
    //Half hearts.
    if (citizen.getHealth() / 2 % 1 > 0) {
        @NotNull final Image heart = new Image();
        heart.setImage(Gui.ICONS, HALF_HEART_ICON_ROW_POS, HEART_ICON_COLUMN, HEART_ICON_HEIGHT_WIDTH, HEART_ICON_HEIGHT_WIDTH);
        heart.setPosition(heartPos * HEART_ICON_POS_X + HEART_ICON_OFFSET_X, HEART_ICON_POS_Y);
        findPaneOfTypeByID(WINDOW_ID_HEALTHBAR, View.class).addChild(heart);
    }
}
Also used : Image(com.minecolonies.blockout.controls.Image) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) View(com.minecolonies.blockout.views.View) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Image (com.minecolonies.blockout.controls.Image)4 View (com.minecolonies.blockout.views.View)3 CitizenDataView (com.minecolonies.coremod.colony.CitizenDataView)3 NotNull (org.jetbrains.annotations.NotNull)3 Label (com.minecolonies.blockout.controls.Label)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)1 ItemIcon (com.minecolonies.blockout.controls.ItemIcon)1 ColonyView (com.minecolonies.coremod.colony.ColonyView)1 ItemStack (net.minecraft.item.ItemStack)1