use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.
the class WindowBuildBuilding method updateResourceList.
public void updateResourceList() {
final ScrollingList recourseList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
recourseList.enable();
recourseList.show();
final List<ItemStorage> tempRes = new ArrayList<>(resources.values());
// Creates a dataProvider for the unemployed recourseList.
recourseList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return tempRes.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) {
final ItemStorage resource = tempRes.get(index);
final Text resourceLabel = rowPane.findPaneOfTypeByID(RESOURCE_NAME, Text.class);
final Text quantityLabel = rowPane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class);
resourceLabel.setText(resource.getItemStack().getHoverName());
quantityLabel.setText(Integer.toString(resource.getAmount()));
resourceLabel.setColors(WHITE);
quantityLabel.setColors(WHITE);
final ItemStack itemIcon = new ItemStack(resource.getItem(), 1);
itemIcon.setTag(resource.getItemStack().getTag());
rowPane.findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(itemIcon);
}
});
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.
the class WindowResourceList method updateResourcePane.
/**
* Update one row pad with its resource informations.
*
* @param index index in the list of resources.
* @param rowPane The Pane to use to display the information.
*/
private void updateResourcePane(final int index, @NotNull final Pane rowPane) {
final BuildingBuilderResource resource = resources.get(index);
final Text resourceLabel = rowPane.findPaneOfTypeByID(RESOURCE_NAME, Text.class);
final Text resourceMissingLabel = rowPane.findPaneOfTypeByID(RESOURCE_MISSING, Text.class);
final Text neededLabel = rowPane.findPaneOfTypeByID(RESOURCE_AVAILABLE_NEEDED, Text.class);
if (resource.getAmountInDelivery() > 0) {
rowPane.findPaneOfTypeByID(IN_DELIVERY_ICON, Image.class).setVisible(true);
rowPane.findPaneOfTypeByID(IN_DELIVERY_AMOUNT, Text.class).setText("" + resource.getAmountInDelivery());
} else {
rowPane.findPaneOfTypeByID(IN_DELIVERY_ICON, Image.class).setVisible(false);
rowPane.findPaneOfTypeByID(IN_DELIVERY_AMOUNT, Text.class).setText("");
}
switch(resource.getAvailabilityStatus()) {
case DONT_HAVE:
resourceLabel.setColors(RED);
resourceMissingLabel.setColors(RED);
neededLabel.setColors(RED);
break;
case NEED_MORE:
resourceLabel.setColors(ORANGE);
resourceMissingLabel.setColors(ORANGE);
neededLabel.setColors(ORANGE);
break;
case HAVE_ENOUGH:
resourceLabel.setColors(DARKGREEN);
resourceMissingLabel.setColors(DARKGREEN);
neededLabel.setColors(DARKGREEN);
break;
case NOT_NEEDED:
default:
resourceLabel.setColors(BLACK);
resourceMissingLabel.setColors(BLACK);
neededLabel.setColors(BLACK);
break;
}
resourceLabel.setText(resource.getName());
final int missing = resource.getMissingFromPlayer();
if (missing < 0) {
resourceMissingLabel.setText(Integer.toString(missing));
} else {
resourceMissingLabel.clearText();
}
neededLabel.setText(resource.getAvailable() + " / " + resource.getAmount());
rowPane.findPaneOfTypeByID(RESOURCE_ID, Text.class).setText(Integer.toString(index));
rowPane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class).setText(Integer.toString(resource.getAmount() - resource.getAvailable()));
final ItemStack stack = new ItemStack(resource.getItem(), 1);
stack.setTag(resource.getItemStack().getTag());
rowPane.findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(stack);
}
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 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.Text in project minecolonies by Minecolonies.
the class WindowInteraction method setupInteraction.
/**
* Setup the current interaction.
*/
private void setupInteraction() {
if (currentInteraction >= interactions.size()) {
close();
return;
}
final IInteractionResponseHandler handler = interactions.get(currentInteraction);
final Box group = findPaneOfTypeByID(RESPONSE_BOX_ID, Box.class);
int y = 0;
int x = 0;
final Text chatText = findPaneOfTypeByID(CHAT_LABEL_ID, Text.class);
chatText.setTextAlignment(Alignment.TOP_LEFT);
chatText.setAlignment(Alignment.TOP_LEFT);
chatText.setText(citizen.getName() + ": " + handler.getInquiry().getString());
int responseIndex = 1;
for (final ITextComponent component : handler.getPossibleResponses()) {
final ButtonImage button = new ButtonImage();
button.setImage(new ResourceLocation(Constants.MOD_ID, MEDIUM_SIZED_BUTTON_RES));
button.setSize(BUTTON_LENGTH, BUTTON_HEIGHT);
button.setColors(SLIGHTLY_BLUE);
button.setPosition(x, y);
button.setID(BUTTON_RESPONSE_ID + responseIndex);
button.setTextRenderBox(BUTTON_LENGTH, BUTTON_HEIGHT);
button.setTextAlignment(Alignment.MIDDLE);
button.setText(component);
group.addChild(button);
y += button.getHeight();
if (y + button.getHeight() >= group.getHeight()) {
y = 0;
x += BUTTON_HEIGHT + BUTTON_BUFFER + button.getWidth();
}
responseIndex++;
}
handler.onWindowOpened(this, citizen);
}
Aggregations