Search in sources :

Example 1 with Image

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

the class CitizenWindowUtils method updateHappiness.

/**
 * Update the display for the happiness.
 *
 * @param citizen the citizen to update it for.
 * @param window  the window to add things to.
 */
public static void updateHappiness(final ICitizenDataView citizen, final AbstractWindowSkeleton window) {
    window.findPaneOfTypeByID("happinessModifier", Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.happiness.happinessmodifier"));
    int yPos = 62;
    for (final String name : citizen.getHappinessHandler().getModifiers()) {
        final double value = citizen.getHappinessHandler().getModifier(name).getFactor();
        final Image image = new Image();
        image.setSize(11, 11);
        image.setPosition(45, yPos);
        window.addChild(image);
        final Text label = new Text();
        label.setSize(136, 11);
        label.setPosition(70, yPos);
        label.setColors(BLACK);
        label.setText(LanguageHandler.format("com.minecolonies.coremod.gui.townhall.happiness." + name));
        window.addChild(label);
        PaneBuilders.tooltipBuilder().hoverPane(label).append(new TranslationTextComponent("com.minecolonies.coremod.gui.townhall.happiness.desc." + name)).build();
        if (value > 1.0) {
            image.setImage(GREEN_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.positive")).hoverPane(image).build();
        } else if (value == 1) {
            image.setImage(BLUE_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.neutral")).hoverPane(image).build();
        } else if (value > 0.75) {
            image.setImage(YELLOW_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.slightlynegative")).hoverPane(image).build();
        } else {
            image.setImage(RED_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.negative")).hoverPane(image).build();
        }
        yPos += 12;
    }
}
Also used : Text(com.ldtteam.blockout.controls.Text) Image(com.ldtteam.blockout.controls.Image)

Example 2 with Image

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

the class CitizenWindowUtils method addHeart.

/**
 * Adds a heart to the healthbarView at the given Position
 *
 * @param healthBarView the health bar to add the heart to.
 * @param heartPos      the number of the heart to add.
 * @param heart         the heart to add.
 */
private static void addHeart(final View healthBarView, final int heartPos, final HeartsEnum heart) {
    @NotNull final Image heartImage = new Image();
    heartImage.setImage(heart.Image, heart.X, heart.Y, HEART_ICON_HEIGHT_WIDTH, HEART_ICON_HEIGHT_WIDTH, false);
    heartImage.setPosition(heartPos * HEART_ICON_POS_X + HEART_ICON_OFFSET_X, HEART_ICON_POS_Y);
    healthBarView.addChild(heartImage);
}
Also used : Image(com.ldtteam.blockout.controls.Image) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with Image

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

the class CitizenWindowUtils method createSaturationBar.

/**
 * Creates an health bar according to the citizen maxHealth and currentHealth.
 *
 * @param citizen the citizen.
 * @param view    the view to add these to.
 */
public static void createSaturationBar(final ICitizenDataView citizen, final View view) {
    view.findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).setAlignment(Alignment.MIDDLE_RIGHT);
    // Max saturation (Black food items).
    for (int i = 0; i < ICitizenData.MAX_SATURATION; i++) {
        @NotNull final Image saturation = new Image();
        saturation.setImage(Screen.GUI_ICONS_LOCATION, EMPTY_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH, false);
        saturation.setPosition(getXOffsetModifier(i) * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y + getYOffset(i));
        view.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(Screen.GUI_ICONS_LOCATION, FULL_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH, false);
        saturation.setPosition(getXOffsetModifier(saturationPos) * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y + getYOffset(saturationPos));
        view.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(Screen.GUI_ICONS_LOCATION, HALF_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH, false);
        saturation.setPosition(getXOffsetModifier(saturationPos) * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y + getYOffset(saturationPos));
        view.findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).addChild(saturation);
    }
}
Also used : Image(com.ldtteam.blockout.controls.Image) View(com.ldtteam.blockout.views.View) IColonyView(com.minecolonies.api.colony.IColonyView) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with Image

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

the class CitizenWindowUtils method createHappinessBar.

/**
 * Creates an Happiness bar according to the citizen maxHappiness and currentHappiness.
 *
 * @param citizen pointer to the citizen data view
 * @param window  pointer to the current window
 */
public static void createHappinessBar(final ICitizenDataView citizen, final AbstractWindowSkeleton window) {
    // Calculates how much percent of the next level has been completed.
    final double experienceRatio = (citizen.getHappiness() / HappinessConstants.MAX_HAPPINESS) * XP_BAR_WIDTH;
    window.findPaneOfTypeByID(WINDOW_ID_HAPPINESS_BAR, View.class).setAlignment(Alignment.MIDDLE_RIGHT);
    window.findPaneOfTypeByID(WINDOW_ID_HAPPINESS, Text.class).setText(Integer.toString((int) citizen.getHappiness()));
    @NotNull final Image xpBar = new Image();
    xpBar.setImage(Screen.GUI_ICONS_LOCATION, XP_BAR_ICON_COLUMN, HAPPINESS_BAR_EMPTY_ROW, XP_BAR_WIDTH, XP_HEIGHT, false);
    xpBar.setPosition(LEFT_BORDER_X, LEFT_BORDER_Y);
    @NotNull final Image xpBar2 = new Image();
    xpBar2.setImage(Screen.GUI_ICONS_LOCATION, XP_BAR_ICON_COLUMN_END, HAPPINESS_BAR_EMPTY_ROW, XP_BAR_ICON_COLUMN_END_WIDTH, XP_HEIGHT, false);
    xpBar2.setPosition(XP_BAR_ICON_END_OFFSET + LEFT_BORDER_X, LEFT_BORDER_Y);
    window.findPaneOfTypeByID(WINDOW_ID_HAPPINESS_BAR, View.class).addChild(xpBar);
    window.findPaneOfTypeByID(WINDOW_ID_HAPPINESS_BAR, View.class).addChild(xpBar2);
    if (experienceRatio > 0) {
        @NotNull final Image xpBarFull = new Image();
        xpBarFull.setImage(Screen.GUI_ICONS_LOCATION, XP_BAR_ICON_COLUMN, HAPPINESS_BAR_FULL_ROW, (int) experienceRatio, XP_HEIGHT, false);
        xpBarFull.setPosition(LEFT_BORDER_X, LEFT_BORDER_Y);
        window.findPaneOfTypeByID(WINDOW_ID_HAPPINESS_BAR, View.class).addChild(xpBarFull);
    }
}
Also used : Text(com.ldtteam.blockout.controls.Text) Image(com.ldtteam.blockout.controls.Image) View(com.ldtteam.blockout.views.View) IColonyView(com.minecolonies.api.colony.IColonyView) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with Image

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

the class CitizenWindowUtils method updateHappiness.

/**
 * Update the display for the happiness.
 *
 * @param citizen the citizen to update it for.
 * @param window  the window to add things to.
 */
public static void updateHappiness(final ICitizenDataView citizen, final AbstractWindowSkeleton window) {
    window.findPaneOfTypeByID("happinessModifier", Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.happiness.happinessmodifier"));
    int yPos = 62;
    for (final String name : citizen.getHappinessHandler().getModifiers()) {
        final double value = citizen.getHappinessHandler().getModifier(name).getFactor();
        final Image image = new Image();
        image.setSize(11, 11);
        image.setPosition(45, yPos);
        window.addChild(image);
        final Text label = new Text();
        label.setSize(136, 11);
        label.setPosition(70, yPos);
        label.setColors(BLACK);
        label.setText(LanguageHandler.format("com.minecolonies.coremod.gui.townhall.happiness." + name));
        window.addChild(label);
        PaneBuilders.tooltipBuilder().hoverPane(label).append(new TranslationTextComponent("com.minecolonies.coremod.gui.townhall.happiness.desc." + name)).build();
        if (value > 1.0) {
            image.setImage(GREEN_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.positive")).hoverPane(image).build();
        } else if (value == 1) {
            image.setImage(BLUE_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.neutral")).hoverPane(image).build();
        } else if (value > 0.75) {
            image.setImage(YELLOW_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.slightlynegative")).hoverPane(image).build();
        } else {
            image.setImage(RED_ICON);
            PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.happiness.negative")).hoverPane(image).build();
        }
        yPos += 12;
    }
}
Also used : Text(com.ldtteam.blockout.controls.Text) Image(com.ldtteam.blockout.controls.Image)

Aggregations

Image (com.ldtteam.blockout.controls.Image)10 NotNull (org.jetbrains.annotations.NotNull)8 Text (com.ldtteam.blockout.controls.Text)6 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)6 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)6 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)6 View (com.ldtteam.blockout.views.View)4 IColonyView (com.minecolonies.api.colony.IColonyView)4 AbstractBuildingView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)4 Pane (com.ldtteam.blockout.Pane)2 ScrollingList (com.ldtteam.blockout.views.ScrollingList)2 LanguageHandler (com.ldtteam.structurize.util.LanguageHandler)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 IDeliverymanRequestable (com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable)2 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)2 COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY (com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY)2 WindowConstants (com.minecolonies.api.util.constant.WindowConstants)2 AbstractModuleWindow (com.minecolonies.coremod.client.gui.AbstractModuleWindow)2 CrafterJobView (com.minecolonies.coremod.colony.jobs.views.CrafterJobView)2 DmanJobView (com.minecolonies.coremod.colony.jobs.views.DmanJobView)2