Search in sources :

Example 16 with Text

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;
    }
}
Also used : TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text) Image(com.ldtteam.blockout.controls.Image)

Example 17 with Text

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()));
        }
    });
}
Also used : TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text) StringTextComponent(net.minecraft.util.text.StringTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 18 with Text

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));
    }
}
Also used : Text(com.ldtteam.blockout.controls.Text) BuildingBuilderResource(com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource) ItemStack(net.minecraft.item.ItemStack) Pane(com.ldtteam.blockout.Pane) NotNull(org.jetbrains.annotations.NotNull) TransferItemsRequestMessage(com.minecolonies.coremod.network.messages.server.colony.building.TransferItemsRequestMessage)

Example 19 with Text

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"));
    }
}
Also used : ButtonImage(com.ldtteam.blockout.controls.ButtonImage) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text) IWorkOrderView(com.minecolonies.api.colony.workorders.IWorkOrderView)

Example 20 with Text

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();
            }
        }
    });
}
Also used : IBuildingEventDescription(com.minecolonies.api.colony.colonyEvents.descriptions.IBuildingEventDescription) Text(com.ldtteam.blockout.controls.Text) Pane(com.ldtteam.blockout.Pane) CitizenDiedEvent(com.minecolonies.coremod.colony.colonyEvents.citizenEvents.CitizenDiedEvent) ICitizenEventDescription(com.minecolonies.api.colony.colonyEvents.descriptions.ICitizenEventDescription) IColonyEventDescription(com.minecolonies.api.colony.colonyEvents.descriptions.IColonyEventDescription) PermissionEvent(com.minecolonies.api.colony.permissions.PermissionEvent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ScrollingList(com.ldtteam.blockout.views.ScrollingList) ScrollingList(com.ldtteam.blockout.views.ScrollingList)

Aggregations

Text (com.ldtteam.blockout.controls.Text)31 Pane (com.ldtteam.blockout.Pane)15 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)13 ItemStack (net.minecraft.item.ItemStack)12 ScrollingList (com.ldtteam.blockout.views.ScrollingList)11 Button (com.ldtteam.blockout.controls.Button)9 BuildingBuilderResource (com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource)8 ItemIcon (com.ldtteam.blockout.controls.ItemIcon)6 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)6 StringTextComponent (net.minecraft.util.text.StringTextComponent)6 ButtonImage (com.ldtteam.blockout.controls.ButtonImage)5 Image (com.ldtteam.blockout.controls.Image)5 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)4 ItemStorage (com.minecolonies.api.crafting.ItemStorage)4 View (com.ldtteam.blockout.views.View)3 ITextComponent (net.minecraft.util.text.ITextComponent)3 NotNull (org.jetbrains.annotations.NotNull)3 Loader (com.ldtteam.blockout.Loader)2 TextField (com.ldtteam.blockout.controls.TextField)2 Box (com.ldtteam.blockout.views.Box)2