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