Search in sources :

Example 16 with ScrollingList

use of com.ldtteam.blockout.views.ScrollingList 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 17 with ScrollingList

use of com.ldtteam.blockout.views.ScrollingList in project minecolonies by Minecolonies.

the class AbstractWindowWorkerModuleBuilding method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<Tuple<String, Integer>> workers = new ArrayList<>();
    for (final WorkerBuildingModuleView module : buildingView.getModuleViews(WorkerBuildingModuleView.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 = building.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());
                }
            }
        });
    }
    updatePriorityLabel();
}
Also used : ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) Tuple(com.minecolonies.api.util.Tuple)

Example 18 with ScrollingList

use of com.ldtteam.blockout.views.ScrollingList in project minecolonies by Minecolonies.

the class WindowResourceList method onOpened.

@Override
public void onOpened() {
    final ClientPlayerEntity player = Minecraft.getInstance().player;
    if (this.builder == null) {
        player.sendMessage(new TranslationTextComponent("com.minecolonies.coremod.resourcescroll.nobuilder"), player.getUUID());
        close();
        return;
    }
    super.onOpened();
    pullResourcesFromHut();
    final ScrollingList resourceList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
    if (resourceList == null) {
        player.sendMessage(new TranslationTextComponent("com.minecolonies.coremod.resourcescroll.null"), player.getUUID());
        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 : TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) 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)

Example 19 with ScrollingList

use of com.ldtteam.blockout.views.ScrollingList 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);
        }
    });
}
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 20 with ScrollingList

use of com.ldtteam.blockout.views.ScrollingList in project minecolonies by ldtteam.

the class AbstractWindowWorkerModuleBuilding method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<Tuple<String, Integer>> workers = new ArrayList<>();
    for (final WorkerBuildingModuleView module : buildingView.getModuleViews(WorkerBuildingModuleView.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 = building.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());
                }
            }
        });
    }
    updatePriorityLabel();
}
Also used : ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) Tuple(com.minecolonies.api.util.Tuple)

Aggregations

Pane (com.ldtteam.blockout.Pane)24 ScrollingList (com.ldtteam.blockout.views.ScrollingList)24 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)12 Text (com.ldtteam.blockout.controls.Text)10 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)10 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)6 Tuple (com.minecolonies.api.util.Tuple)6 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)6 ArrayList (java.util.ArrayList)6 ItemStorage (com.minecolonies.api.crafting.ItemStorage)4 MarkBuildingDirtyMessage (com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)4 ItemStack (net.minecraft.item.ItemStack)4 NotNull (org.jetbrains.annotations.NotNull)4 Button (com.ldtteam.blockout.controls.Button)2 Image (com.ldtteam.blockout.controls.Image)2 LanguageHandler (com.ldtteam.structurize.util.LanguageHandler)2 IAssignmentModuleView (com.minecolonies.api.colony.buildings.modules.IAssignmentModuleView)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 IDeliverymanRequestable (com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable)2 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)2