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;
}
}
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);
}
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);
}
}
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);
}
}
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;
}
}
Aggregations