Search in sources :

Example 41 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.

the class WindowCitizenPage method fillCitizenInfo.

/**
 * Executed when fill citizen is clicked.
 *
 * @param button the clicked button.
 */
private void fillCitizenInfo(final Button button) {
    final ScrollingList citizenList = findPaneOfTypeByID(LIST_CITIZENS, ScrollingList.class);
    for (final Pane pane : citizenList.getContainer().getChildren()) {
        pane.findPaneOfTypeByID(NAME_LABEL, ButtonImage.class).enable();
    }
    final int row = citizenList.getListElementIndexByPane(button);
    findPaneByID(CITIZEN_INFO).show();
    button.disable();
    final ICitizenDataView view = citizens.get(row);
    CitizenWindowUtils.createHappinessBar(view, this);
    CitizenWindowUtils.createSkillContent(view, this);
    String jobKey = view.getJob().trim().isEmpty() ? COM_MINECOLONIES_COREMOD_GUI_TOWNHALL_CITIZEN_UNEMPLOYED : view.getJob();
    findPaneOfTypeByID(JOB_LABEL, Text.class).setText(new TranslationTextComponent(jobKey).withStyle(TextFormatting.BOLD));
    findPaneOfTypeByID(HIDDEN_CITIZEN_ID, Text.class).setText(String.valueOf(view.getId()));
}
Also used : ButtonImage(com.ldtteam.blockout.controls.ButtonImage) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 42 with Pane

use of com.ldtteam.blockout.Pane 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)

Example 43 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.

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);
        }
    });
}
Also used : Text(com.ldtteam.blockout.controls.Text) ItemStack(net.minecraft.item.ItemStack) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 44 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.

the class WindowPostBox method requestClicked.

/**
 * Action executed when request is clicked.
 *
 * @param button the clicked button.
 */
private void requestClicked(final Button button) {
    final int row = stackList.getListElementIndexByPane(button);
    final ItemStack stack = allItems.get(row);
    int qty = stack.getMaxStackSize();
    for (final Pane child : button.getParent().getChildren()) {
        if (child.getID().equals(INPUT_QTY)) {
            try {
                qty = Integer.parseInt(((TextField) child).getText());
            } catch (final NumberFormatException ex) {
            // Be quiet about it.
            }
        }
    }
    Network.getNetwork().sendToServer(new PostBoxRequestMessage(buildingView, stack.copy(), qty, deliverAvailable));
}
Also used : PostBoxRequestMessage(com.minecolonies.coremod.network.messages.server.colony.building.postbox.PostBoxRequestMessage) TextField(com.ldtteam.blockout.controls.TextField) ItemStack(net.minecraft.item.ItemStack) Pane(com.ldtteam.blockout.Pane)

Example 45 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.

the class WindowResourceList method onOpened.

@Override
public void onOpened() {
    final ClientPlayerEntity player = Minecraft.getInstance().player;
    if (this.builder == null) {
        MessageUtils.format(TOOL_RESOURCE_SCROLL_NO_BUILDER).sendTo(player);
        close();
        return;
    }
    super.onOpened();
    pullResourcesFromHut();
    pullResourcesFromWarehouse();
    final ScrollingList resourceList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
    if (resourceList == null) {
        MessageUtils.format(TOOL_RESOURCE_SCROLL_ERROR).sendTo(player);
        close();
        return;
    }
    resourceList.setDataProvider(new ScrollingList.DataProvider() {

        @Override
        public int getElementCount() {
            return resources.size();
        }

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            updateResourcePane(index, rowPane);
        }
    });
    final BuildingResourcesModuleView moduleView = builder.getModuleView(BuildingResourcesModuleView.class);
    // Make sure we have a fresh view
    Network.getNetwork().sendToServer(new MarkBuildingDirtyMessage(builder));
    findPaneOfTypeByID(LABEL_WORKERNAME, Text.class).setText(builder.getWorkerName());
    findPaneOfTypeByID(LABEL_CONSTRUCTION_NAME, Text.class).setText(moduleView.getConstructionName());
}
Also used : Text(com.ldtteam.blockout.controls.Text) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) BuildingResourcesModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.BuildingResourcesModuleView) MarkBuildingDirtyMessage(com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)

Aggregations

Pane (com.ldtteam.blockout.Pane)64 ScrollingList (com.ldtteam.blockout.views.ScrollingList)40 Text (com.ldtteam.blockout.controls.Text)26 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)25 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)20 ItemStack (net.minecraft.item.ItemStack)13 Button (com.ldtteam.blockout.controls.Button)10 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)10 NotNull (org.jetbrains.annotations.NotNull)9 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)8 ArrayList (java.util.ArrayList)8 ItemStorage (com.minecolonies.api.crafting.ItemStorage)6 Tuple (com.minecolonies.api.util.Tuple)6 BlockPos (net.minecraft.util.math.BlockPos)6 List (java.util.List)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)5 Skill (com.minecolonies.api.entity.citizen.Skill)4 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)4 MarkBuildingDirtyMessage (com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)4 TileEntity (net.minecraft.tileentity.TileEntity)4