use of com.ldtteam.blockout.controls.Text 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(new TranslationTextComponent(LABEL_HAPPINESS_MODIFIER));
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(new TranslationTextComponent(PARTIAL_HAPPINESS_MODIFIER_NAME + name));
window.addChild(label);
PaneBuilders.tooltipBuilder().hoverPane(label).append(new TranslationTextComponent(PARTIAL_HAPPINESS_MODIFIER_DESCRIPTION + name)).build();
if (value > 1.0) {
image.setImage(GREEN_ICON);
PaneBuilders.tooltipBuilder().append(new TranslationTextComponent(LABEL_HAPPINESS_POSITIVE)).hoverPane(image).build();
} else if (value == 1) {
image.setImage(BLUE_ICON);
PaneBuilders.tooltipBuilder().append(new TranslationTextComponent(LABEL_HAPPINESS_NEUTRAL)).hoverPane(image).build();
} else if (value > 0.75) {
image.setImage(YELLOW_ICON);
PaneBuilders.tooltipBuilder().append(new TranslationTextComponent(LABEL_HAPPINESS_SLIGHTLY_NEGATIVE)).hoverPane(image).build();
} else {
image.setImage(RED_ICON);
PaneBuilders.tooltipBuilder().append(new TranslationTextComponent(LABEL_HAPPINESS_NEGATIVE)).hoverPane(image).build();
}
yPos += 12;
}
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.
the class FamilyWindowCitizen method onOpened.
@Override
public void onOpened() {
super.onOpened();
final String firstParent = citizen.getParents().getA();
final String secondParent = citizen.getParents().getB();
findPaneOfTypeByID("parentA", Text.class).setText(firstParent.isEmpty() ? new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.family.unknown") : new StringTextComponent(firstParent));
findPaneOfTypeByID("parentB", Text.class).setText(secondParent.isEmpty() ? new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.family.unknown") : new StringTextComponent(secondParent));
final int partner = citizen.getPartner();
final ICitizenDataView partnerView = colony.getCitizen(partner);
final Text partnerText = findPaneOfTypeByID("partner", Text.class);
if (partnerView == null) {
partnerText.setText(new StringTextComponent("-"));
} else {
partnerText.setText(new StringTextComponent(partnerView.getName()));
}
childrenList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return citizen.getChildren().size();
}
/**
* Inserts the elements into each row.
* @param index the index of the row/list element.
* @param rowPane the parent Pane for the row, containing the elements to update.
*/
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
rowPane.findPaneOfTypeByID("name", Text.class).setText(new StringTextComponent(colony.getCitizen(citizen.getChildren().get(index)).getName()));
}
});
siblingList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return citizen.getSiblings().size();
}
/**
* Inserts the elements into each row.
* @param index the index of the row/list element.
* @param rowPane the parent Pane for the row, containing the elements to update.
*/
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
rowPane.findPaneOfTypeByID("name", Text.class).setText(new StringTextComponent(colony.getCitizen(citizen.getSiblings().get(index)).getName()));
}
});
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.
the class WindowBuilderResModule method transferItems.
/**
* On Button click transfert Items.
*
* @param button the clicked button.
*/
private void transferItems(@NotNull final Button button) {
final Pane pane = button.getParent();
button.disable();
final Text idLabel = pane.findPaneOfTypeByID(RESOURCE_ID, Text.class);
final int index = Integer.parseInt(idLabel.getTextAsString());
final BuildingBuilderResource res = resources.get(index);
if (res == null) {
Log.getLogger().warn("WindowHutBuilder.transferItems: Error - Could not find the resource.");
} else {
// The itemStack size should not be greater than itemStack.getMaxStackSize, We send 1 instead
// and use quantity for the size
@NotNull final ItemStack itemStack = res.getItemStack().copy();
itemStack.setCount(1);
final Text quantityLabel = pane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class);
final int quantity = Integer.parseInt(quantityLabel.getTextAsString());
final int needed = res.getAmount() - res.getAvailable();
res.setAvailable(Math.min(res.getAmount(), res.getAvailable() + res.getPlayerAmount()));
res.setPlayerAmount(Math.max(0, res.getPlayerAmount() - needed));
resources.sort(new BuildingBuilderResource.ResourceComparator());
Network.getNetwork().sendToServer(new TransferItemsRequestMessage(this.buildingView, itemStack, quantity, true));
}
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.
the class WorkOrderModuleWindow method updateAvailableWorkOrders.
/**
* Updates the available work orders page.
*
* @param index index in the list of resources.
* @param rowPane The Pane to use to display the information.
*/
private void updateAvailableWorkOrders(final int index, @NotNull final Pane rowPane) {
final IWorkOrderView order = workOrders.get(index);
Text workOrderTextPanel = rowPane.findPaneOfTypeByID(WORK_ORDER_NAME, Text.class);
PaneBuilders.tooltipBuilder().append(order.getDisplayName()).hoverPane(workOrderTextPanel).build();
workOrderTextPanel.setText(order.getDisplayName());
rowPane.findPaneOfTypeByID(WORK_ORDER_POS, Text.class).setText(new TranslationTextComponent("com.minecolonies.coremod.gui.blocks.distance", BlockPosUtil.getDistance2D(order.getLocation(), buildingView.getPosition())));
if (order.getClaimedBy().equals(buildingView.getPosition())) {
rowPane.findPaneOfTypeByID(WORK_ORDER_SELECT, ButtonImage.class).setText(new TranslationTextComponent("com.minecolonies.coremod.gui.builder.cancel"));
} else if (manualMode) {
rowPane.findPaneOfTypeByID(WORK_ORDER_SELECT, ButtonImage.class).setText(new TranslationTextComponent("com.minecolonies.coremod.gui.builder.select"));
}
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.
the class WindowInfoPage method fillEventsList.
private void fillEventsList() {
eventList = findPaneOfTypeByID(EVENTS_LIST, ScrollingList.class);
eventList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return permissionEvents ? building.getPermissionEvents().size() : building.getColonyEvents().size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final Text nameLabel = rowPane.findPaneOfTypeByID(NAME_LABEL, Text.class);
final Text actionLabel = rowPane.findPaneOfTypeByID(ACTION_LABEL, Text.class);
if (permissionEvents) {
final List<PermissionEvent> permissionEvents = building.getPermissionEvents();
Collections.reverse(permissionEvents);
final PermissionEvent event = permissionEvents.get(index);
nameLabel.setText(event.getName() + (event.getId() == null ? " <fake>" : ""));
rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getPosition().getX() + " " + event.getPosition().getY() + " " + event.getPosition().getZ());
if (event.getId() == null) {
rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
}
actionLabel.setText(new TranslationTextComponent(KEY_TO_PERMISSIONS + event.getAction().toString().toLowerCase(Locale.US)));
} else {
final List<IColonyEventDescription> colonyEvents = building.getColonyEvents();
Collections.reverse(colonyEvents);
final IColonyEventDescription event = colonyEvents.get(index);
if (event instanceof CitizenDiedEvent) {
actionLabel.setText(((CitizenDiedEvent) event).getDeathCause());
} else {
actionLabel.setText(event.getName());
}
if (event instanceof ICitizenEventDescription) {
nameLabel.setText(((ICitizenEventDescription) event).getCitizenName());
} else if (event instanceof IBuildingEventDescription) {
IBuildingEventDescription buildEvent = (IBuildingEventDescription) event;
nameLabel.setText(MessageUtils.format(buildEvent.getBuildingName()).append(" " + buildEvent.getLevel()).create());
}
rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getEventPos().getX() + " " + event.getEventPos().getY() + " " + event.getEventPos().getZ());
rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
}
}
});
}
Aggregations