use of com.ldtteam.blockout.controls.Text in project minecolonies by ldtteam.
the class WindowBuildDecoration 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().getString());
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 ldtteam.
the class WindowAssignCitizen method onOpened.
@Override
public void onOpened() {
super.onOpened();
updateCitizens();
citizenList.enable();
citizenList.show();
// Creates a dataProvider for the homeless citizenList.
citizenList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return citizens.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) {
@NotNull final ICitizenDataView citizen = citizens.get(index);
final Button done = rowPane.findPaneOfTypeByID(CITIZEN_DONE, Button.class);
final BlockPos home = citizen.getHomeBuilding();
final BlockPos work = citizen.getWorkBuilding();
boolean assign = false;
if (home != null && home.equals(building.getPosition())) {
done.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonunassign"));
} else {
assign = true;
done.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonassign"));
}
final Text citizenLabel = rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Text.class);
citizenLabel.setText(citizen.getName());
if (assign) {
citizenLabel.setColors(YELLOW);
} else {
citizenLabel.setColors(DARKGREEN);
}
String workString = "";
double newDistance = 0;
if (work != null) {
newDistance = BlockPosUtil.getDistance2D(work, building.getPosition());
workString = " " + new TranslationTextComponent("com.minecolonies.coremod.gui.home.new", newDistance).getString();
}
String homeString = new TranslationTextComponent("com.minecolonies.coremod.gui.home.homeless").getString();
boolean better = false;
boolean badCurrentLiving = true;
if (home != null) {
if (work != null) {
final double oldDistance = BlockPosUtil.getDistance2D(work, home);
homeString = new TranslationTextComponent("com.minecolonies.coremod.gui.home.currently", oldDistance).getString();
better = newDistance < oldDistance;
if (oldDistance < FAR_DISTANCE_THRESHOLD) {
badCurrentLiving = false;
}
} else {
homeString = new TranslationTextComponent("com.minecolonies.coremod.gui.home.currently", home.getX(), home.getY(), home.getZ()).getString();
}
}
final Text newLivingLabel = rowPane.findPaneOfTypeByID(CITIZEN_JOB, Text.class);
if (citizen.getJobView() != null) {
newLivingLabel.setText(new TranslationTextComponent(citizen.getJobView().getEntry().getTranslationKey()).getString() + ":" + workString);
if (better) {
newLivingLabel.setColors(DARKGREEN);
}
}
final Text currentLivingLabel = rowPane.findPaneOfTypeByID(CITIZEN_LIVING, Text.class);
if (assign) {
currentLivingLabel.setText(homeString);
if (badCurrentLiving) {
currentLivingLabel.setColors(RED);
}
} else {
currentLivingLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.home.liveshere"));
}
if ((colony.isManualHousing() || building.getHiringMode() == HiringMode.MANUAL) && !(building.getHiringMode() == HiringMode.AUTO) && (!assign || building.getResidents().size() < building.getMax())) {
done.enable();
} else {
done.disable();
}
}
});
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by ldtteam.
the class WarehouseOptionsModuleWindow method updateResourcePane.
/**
* Update one row pad with its resource informations.
*/
private void updateResourcePane() {
final BuildingBuilderResource resource = new BuildingBuilderResource(new ItemStack(Blocks.EMERALD_BLOCK, 1), 1);
final int amountToSet;
final PlayerInventory inventory = this.mc.player.inventory;
final boolean isCreative = this.mc.player.isCreative();
if (isCreative) {
amountToSet = resource.getAmount();
} else {
amountToSet = InventoryUtils.getItemCountInItemHandler(new InvWrapper(inventory), resource.getItem());
}
resource.setPlayerAmount(amountToSet);
final Text resourceLabel = findPaneOfTypeByID(RESOURCE_NAME, Text.class);
final Text resourceMissingLabel = findPaneOfTypeByID(RESOURCE_MISSING, Text.class);
final Text neededLabel = findPaneOfTypeByID(RESOURCE_AVAILABLE_NEEDED, Text.class);
final Button addButton = findPaneOfTypeByID(RESOURCE_ADD, Button.class);
BuildingBuilderResource.RessourceAvailability availability = resource.getAvailabilityStatus();
if (module.getStorageUpgradeLevel() >= BuildingWareHouse.MAX_STORAGE_UPGRADE || buildingView.getBuildingLevel() < buildingView.getBuildingMaxLevel() || lockUpgrade) {
availability = BuildingBuilderResource.RessourceAvailability.NOT_NEEDED;
}
findPaneOfTypeByID(UPGRADE_PROGRESS_LABEL, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.xofz", module.getStorageUpgradeLevel(), BuildingWareHouse.MAX_STORAGE_UPGRADE));
switch(availability) {
case DONT_HAVE:
addButton.disable();
resourceLabel.setColors(RED);
resourceMissingLabel.setColors(RED);
neededLabel.setColors(RED);
break;
case NEED_MORE:
addButton.enable();
resourceLabel.setColors(RED);
resourceMissingLabel.setColors(RED);
neededLabel.setColors(RED);
break;
case HAVE_ENOUGH:
addButton.enable();
resourceLabel.setColors(DARKGREEN);
resourceMissingLabel.setColors(DARKGREEN);
neededLabel.setColors(DARKGREEN);
break;
case NOT_NEEDED:
default:
addButton.disable();
resourceLabel.setColors(BLACK);
resourceMissingLabel.setColors(BLACK);
neededLabel.setColors(BLACK);
if (buildingView.getBuildingLevel() < buildingView.getBuildingMaxLevel()) {
resourceLabel.hide();
resourceMissingLabel.hide();
neededLabel.hide();
addButton.setText(new StringTextComponent("X").setStyle(Style.EMPTY.withColor(TextFormatting.DARK_RED)));
PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.upgrade.disabled.1", buildingView.getBuildingMaxLevel())).appendNL(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.upgrade.disabled.2", buildingView.getBuildingMaxLevel())).hoverPane(addButton).build();
}
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());
findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class).setText(Integer.toString(resource.getAmount() - resource.getAvailable()));
if (buildingView.getBuildingLevel() >= buildingView.getBuildingMaxLevel()) {
final ItemStack resourceStackOfOne = new ItemStack(resource.getItem(), 1);
resourceStackOfOne.setTag(resource.getItemStack().getTag());
findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(resourceStackOfOne);
}
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by ldtteam.
the class WindowBuilderResModule 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);
final Button addButton = rowPane.findPaneOfTypeByID(RESOURCE_ADD, Button.class);
switch(resource.getAvailabilityStatus()) {
case DONT_HAVE:
addButton.disable();
resourceLabel.setColors(RED);
resourceMissingLabel.setColors(RED);
neededLabel.setColors(RED);
break;
case NEED_MORE:
addButton.enable();
resourceLabel.setColors(ORANGE);
resourceMissingLabel.setColors(ORANGE);
neededLabel.setColors(ORANGE);
break;
case HAVE_ENOUGH:
addButton.enable();
resourceLabel.setColors(DARKGREEN);
resourceMissingLabel.setColors(DARKGREEN);
neededLabel.setColors(DARKGREEN);
break;
case NOT_NEEDED:
default:
addButton.disable();
resourceLabel.setColors(BLACK);
resourceMissingLabel.setColors(BLACK);
neededLabel.setColors(BLACK);
break;
}
// position the addResource Button to the right
final int buttonX = rowPane.getWidth() - addButton.getWidth() - (rowPane.getHeight() - addButton.getHeight()) / 2;
final int buttonY = rowPane.getHeight() - addButton.getHeight() - 2;
addButton.setPosition(buttonX, buttonY);
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 ldtteam.
the class WindowPermissionsPage method addRank.
/**
* Read the text input with the name of the rank to be added
* If the chosen name is valid, send a message to the server, hide the error label and empty the input
* else show the error label
*/
private void addRank() {
final Text label = findPaneOfTypeByID(TOWNHALL_ADD_RANK_ERROR, Text.class);
final TextField input = findPaneOfTypeByID(INPUT_ADDRANK_NAME, TextField.class);
if (isValidRankname(input.getText())) {
Network.getNetwork().sendToServer(new PermissionsMessage.AddRank(building.getColony(), input.getText()));
input.setText("");
label.hide();
} else {
label.show();
}
}
Aggregations