use of com.ldtteam.blockout.controls.Text in project minecolonies by ldtteam.
the class WindowPermissionsPage method onOpened.
/**
* Executed when <code>WindowTownHall</code> is opened. Does tasks like setting buttons.
*/
@Override
public void onOpened() {
super.onOpened();
fillUserList();
fillFreeBlockList();
fillRanks();
fillPermissionList();
PlayerEntity player = Minecraft.getInstance().player;
Text label = findPaneOfTypeByID(TOWNHALL_PERMISSION_ERROR, Text.class);
Button button = findPaneOfTypeByID(BUTTON_ADD_PLAYER, Button.class);
if (building.getColony().getPermissions().hasPermission(player, Action.EDIT_PERMISSIONS)) {
label.hide();
button.setEnabled(true);
} else {
label.show();
button.setEnabled(false);
}
}
use of com.ldtteam.blockout.controls.Text in project minecolonies by ldtteam.
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 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);
}
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);
rowPane.findPaneOfTypeByID(IN_DELIVERY_ICON, Image.class).setVisible(false);
rowPane.findPaneOfTypeByID(IN_DELIVERY_AMOUNT, Text.class).clearText();
rowPane.findPaneOfTypeByID(IN_WAREHOUSE_ICON, Image.class).setVisible(false);
rowPane.findPaneOfTypeByID(IN_WAREHOUSE_AMOUNT, Text.class).clearText();
int resourceHashcode = resource.getItemStack().hasTag() ? resource.getItemStack().getTag().hashCode() : 0;
int warehouseAmount = warehouseSnapshot.getOrDefault(resource.getItem().getDescriptionId() + "-" + resourceHashcode, 0);
if (resource.getAmountInDelivery() > 0) {
rowPane.findPaneOfTypeByID(IN_DELIVERY_ICON, Image.class).setVisible(true);
rowPane.findPaneOfTypeByID(IN_DELIVERY_AMOUNT, Text.class).setText(new StringTextComponent(String.valueOf(resource.getAmountInDelivery())));
} else if (warehouseAmount > 0) {
rowPane.findPaneOfTypeByID(IN_WAREHOUSE_ICON, Image.class).setVisible(true);
rowPane.findPaneOfTypeByID(IN_DELIVERY_AMOUNT, Text.class).setText(new StringTextComponent(String.valueOf(warehouseAmount)));
}
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 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);
}
});
}
Aggregations