Search in sources :

Example 31 with Pane

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

the class WindowPermissionsPage method fillUserList.

/**
 * Fills the userList in the GUI.
 */
private void fillUserList() {
    userList = findPaneOfTypeByID(LIST_USERS, ScrollingList.class);
    userList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final Player player = users.get(index);
            Rank rank = player.getRank();
            rowPane.findPaneOfTypeByID(NAME_LABEL, Text.class).setText(player.getName());
            DropDownList dropdown = rowPane.findPaneOfTypeByID(TOWNHALL_RANK_PICKER, DropDownList.class);
            if (rank.getId() == building.getColony().getPermissions().OWNER_RANK_ID) {
                rowPane.findPaneOfTypeByID(BUTTON_REMOVE_PLAYER, Button.class).setEnabled(false);
                rowPane.findPaneOfTypeByID("rank", Text.class).setText(rank.getName());
                dropdown.setEnabled(false);
            } else {
                dropdown.setDataProvider(new DropDownList.DataProvider() {

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

                    @Override
                    public String getLabel(final int i) {
                        Rank rank = rankList.get(i);
                        return rank.getName();
                    }
                });
                dropdown.setSelectedIndex(rankList.indexOf(rank));
                dropdown.setHandler(WindowPermissionsPage.this::onRankSelected);
            }
        }
    });
}
Also used : Player(com.minecolonies.api.colony.permissions.Player) DropDownList(com.ldtteam.blockout.views.DropDownList) Rank(com.minecolonies.api.colony.permissions.Rank) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 32 with Pane

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

the class WindowWorkOrderPage method fillWorkOrderList.

/**
 * Fills the workOrder list inside the townhall GUI.
 */
private void fillWorkOrderList() {
    final ScrollingList workOrderList = findPaneOfTypeByID(LIST_WORKORDER, ScrollingList.class);
    workOrderList.enable();
    workOrderList.show();
    // Creates a dataProvider for the unemployed citizenList.
    workOrderList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final IWorkOrderView workOrder = workOrders.get(index);
            String claimingCitizen = "";
            final int numElements = getElementCount();
            if (index == 0) {
                if (numElements == 1) {
                    rowPane.findPaneOfTypeByID(BUTTON_DOWN, Button.class).hide();
                } else {
                    rowPane.findPaneOfTypeByID(BUTTON_DOWN, Button.class).show();
                }
                rowPane.findPaneOfTypeByID(BUTTON_UP, Button.class).hide();
            } else if (index == numElements - 1) {
                rowPane.findPaneOfTypeByID(BUTTON_DOWN, Button.class).hide();
            }
            // Searches citizen of id x
            for (@NotNull final IBuildingView buildingView : building.getColony().getBuildings()) {
                if (buildingView.getPosition().equals(workOrder.getClaimedBy()) && buildingView instanceof AbstractBuildingBuilderView) {
                    claimingCitizen = ((AbstractBuildingBuilderView) buildingView).getWorkerName();
                    break;
                }
            }
            Text workOrderTextPanel = rowPane.findPaneOfTypeByID(WORK_LABEL, Text.class);
            PaneBuilders.tooltipBuilder().append(workOrder.getDisplayName()).hoverPane(workOrderTextPanel).build();
            workOrderTextPanel.setText(workOrder.getDisplayName());
            rowPane.findPaneOfTypeByID(ASSIGNEE_LABEL, Text.class).setText(new StringTextComponent(claimingCitizen));
            rowPane.findPaneOfTypeByID(HIDDEN_WORKORDER_ID, Text.class).setText(new StringTextComponent(Integer.toString(workOrder.getId())));
        }
    });
}
Also used : AbstractBuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView) Button(com.ldtteam.blockout.controls.Button) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) Text(com.ldtteam.blockout.controls.Text) StringTextComponent(net.minecraft.util.text.StringTextComponent) IWorkOrderView(com.minecolonies.api.colony.workorders.IWorkOrderView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 33 with Pane

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

the class FarmerFieldsModuleWindow method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    if (moduleView.assignFieldManually()) {
        findPaneOfTypeByID(TAG_BUTTON_ASSIGNMENT_MODE, Button.class).setText(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_GUI_HIRING_ON) {
        });
    } else {
        findPaneOfTypeByID(TAG_BUTTON_ASSIGNMENT_MODE, Button.class).setText(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_GUI_HIRING_OFF));
    }
    fieldList = findPaneOfTypeByID(LIST_FIELDS, ScrollingList.class);
    fieldList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final BlockPos field = fields.get(index);
            @NotNull final String distance = Integer.toString((int) Math.sqrt(BlockPosUtil.getDistanceSquared(field, buildingView.getPosition())));
            final ITextComponent direction = BlockPosUtil.calcDirection(buildingView.getPosition(), field);
            final TileEntity entity = world.getBlockEntity(field);
            if (entity instanceof ScarecrowTileEntity) {
                final ScarecrowTileEntity scarecrowTileEntity = (ScarecrowTileEntity) entity;
                @NotNull final ITextComponent owner = scarecrowTileEntity.getOwner().isEmpty() ? new StringTextComponent("<").append(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_GUI_WORKER_HUTS_FARMER_HUT_UNUSED)).append(">") : new StringTextComponent(scarecrowTileEntity.getOwner());
                rowPane.findPaneOfTypeByID(TAG_WORKER, Text.class).setText(owner);
                rowPane.findPaneOfTypeByID(TAG_DISTANCE, Text.class).setText(distance + "m");
                rowPane.findPaneOfTypeByID(TAG_DIRECTION, Text.class).setText(direction);
                final Button assignButton = rowPane.findPaneOfTypeByID(TAG_BUTTON_ASSIGN, Button.class);
                assignButton.setEnabled(moduleView.assignFieldManually());
                if (((ScarecrowTileEntity) entity).isTaken()) {
                    assignButton.setText(RED_X);
                } else {
                    assignButton.setText(APPROVE);
                    if (buildingView.getBuildingLevel() <= moduleView.getAmountOfFields()) {
                        assignButton.disable();
                    }
                }
                if (((ScarecrowTileEntity) entity).getSeed() != null) {
                    rowPane.findPaneOfTypeByID(TAG_ICON, ItemIcon.class).setItem(((ScarecrowTileEntity) entity).getSeed());
                }
            }
        }
    });
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) Pane(com.ldtteam.blockout.Pane) TileEntity(net.minecraft.tileentity.TileEntity) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) Button(com.ldtteam.blockout.controls.Button) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) StringTextComponent(net.minecraft.util.text.StringTextComponent) ScrollingList(com.ldtteam.blockout.views.ScrollingList)

Example 34 with Pane

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

the class GraveyardManagementWindow method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    /*
         * ScrollList with the graves.
         */
    final ScrollingList graveList = findPaneOfTypeByID(LIST_GRAVES, ScrollingList.class);
    graveList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final BlockPos grave = moduleView.getGraves().get(index);
            @NotNull final String distance = Integer.toString((int) Math.sqrt(BlockPosUtil.getDistanceSquared(grave, buildingView.getPosition())));
            final ITextComponent direction = BlockPosUtil.calcDirection(buildingView.getPosition(), grave);
            final TileEntity entity = world.getBlockEntity(grave);
            if (entity instanceof TileEntityGrave) {
                rowPane.findPaneOfTypeByID(TAG_NAME, Text.class).setText("Grave of " + ((((TileEntityGrave) entity).getGraveData() != null) ? ((TileEntityGrave) entity).getGraveData().getCitizenName() : "Unknown Citizen"));
                rowPane.findPaneOfTypeByID(TAG_DISTANCE, Text.class).setText(distance + "m");
                rowPane.findPaneOfTypeByID(TAG_DIRECTION, Text.class).setText(direction);
            }
        }
    });
    /*
         * ScrollList with the resting citizen.
         */
    final ScrollingList ripList = findPaneOfTypeByID(LIST_CITIZEN, ScrollingList.class);
    ripList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final String citizenName = moduleView.getRestingCitizen().get(index);
            rowPane.findPaneOfTypeByID(TAG_CITIZEN_NAME, Text.class).setText(citizenName);
        }
    });
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITextComponent(net.minecraft.util.text.ITextComponent) BlockPos(net.minecraft.util.math.BlockPos) TileEntityGrave(com.minecolonies.api.tileentities.TileEntityGrave) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 35 with Pane

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

the class SpecialAssignmentModuleWindow method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<Tuple<String, Integer>> workers = new ArrayList<>();
    for (final IAssignmentModuleView module : buildingView.getModuleViews(IAssignmentModuleView.class)) {
        for (final int worker : module.getAssignedCitizens()) {
            workers.add(new Tuple<>(new TranslationTextComponent(module.getJobEntry().getTranslationKey()).getString(), worker));
        }
    }
    if (findPaneByID(LIST_WORKERS) != null) {
        ScrollingList workerList = findPaneOfTypeByID(LIST_WORKERS, ScrollingList.class);
        workerList.setDataProvider(new ScrollingList.DataProvider() {

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

            @Override
            public void updateElement(final int index, @NotNull final Pane rowPane) {
                final ICitizenDataView worker = buildingView.getColony().getCitizen(workers.get(index).getB());
                if (worker != null) {
                    rowPane.findPaneOfTypeByID(LABEL_WORKERNAME, Text.class).setText(new TranslationTextComponent(workers.get(index).getA()).getString() + ": " + worker.getName());
                }
            }
        });
    }
}
Also used : IAssignmentModuleView(com.minecolonies.api.colony.buildings.modules.IAssignmentModuleView) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) Tuple(com.minecolonies.api.util.Tuple)

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