Search in sources :

Example 1 with AbstractBuildingBuilderView

use of com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView 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 WorkOrderView 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;
                }
            }
            rowPane.findPaneOfTypeByID(WORK_LABEL, Text.class).setText(workOrder.getDisplayName());
            rowPane.findPaneOfTypeByID(ASSIGNEE_LABEL, Text.class).setText(claimingCitizen);
            rowPane.findPaneOfTypeByID(HIDDEN_WORKORDER_ID, Text.class).setText(Integer.toString(workOrder.getId()));
        }
    });
}
Also used : WorkOrderView(com.minecolonies.api.colony.workorders.WorkOrderView) AbstractBuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView) Button(com.ldtteam.blockout.controls.Button) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 2 with AbstractBuildingBuilderView

use of com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView in project minecolonies by ldtteam.

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 WorkOrderView 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;
                }
            }
            rowPane.findPaneOfTypeByID(WORK_LABEL, Text.class).setText(workOrder.getDisplayName());
            rowPane.findPaneOfTypeByID(ASSIGNEE_LABEL, Text.class).setText(claimingCitizen);
            rowPane.findPaneOfTypeByID(HIDDEN_WORKORDER_ID, Text.class).setText(Integer.toString(workOrder.getId()));
        }
    });
}
Also used : WorkOrderView(com.minecolonies.api.colony.workorders.WorkOrderView) AbstractBuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView) Button(com.ldtteam.blockout.controls.Button) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 3 with AbstractBuildingBuilderView

use of com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView in project minecolonies by Minecolonies.

the class WindowBuildDecoration method updateBuilders.

/**
 * Update the builders list but try to keep the same one.
 */
private void updateBuilders() {
    IColonyView colony = (IColonyView) IColonyManager.getInstance().getIColony(Minecraft.getInstance().level, structurePos);
    if (colony == null) {
        if (structureName.getStyle().equals("supplycamp") || structureName.getStyle().equals("supplyship")) {
            LanguageHandler.sendPlayerMessage(Minecraft.getInstance().player, TranslationConstants.NO_COLONY_YET);
        } else {
            LanguageHandler.sendPlayerMessage(Minecraft.getInstance().player, TranslationConstants.OUT_OF_COLONY, structureName.getSchematic(), structurePos.getX(), structurePos.getZ());
        }
        close();
        return;
    }
    builders.clear();
    builders.add(new Tuple<>(new TranslationTextComponent(ModJobs.builder.getTranslationKey()).getString() + ":", BlockPos.ZERO));
    builders.addAll(colony.getBuildings().stream().filter(build -> build instanceof AbstractBuildingBuilderView && !((AbstractBuildingBuilderView) build).getWorkerName().isEmpty() && build.getBuildingType() != ModBuildings.miner).map(build -> new Tuple<>(((AbstractBuildingBuilderView) build).getWorkerName(), build.getPosition())).sorted(Comparator.comparing(item -> item.getB().distSqr(structurePos))).collect(Collectors.toList()));
    initBuilderNavigation();
}
Also used : StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) java.util(java.util) LanguageHandler(com.ldtteam.structurize.util.LanguageHandler) DropDownList(com.ldtteam.blockout.views.DropDownList) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) Structures(com.ldtteam.structurize.management.Structures) ScrollingList(com.ldtteam.blockout.views.ScrollingList) LoadOnlyStructureHandler(com.minecolonies.api.util.LoadOnlyStructureHandler) BuildToolPlaceMessage(com.minecolonies.coremod.network.messages.server.BuildToolPlaceMessage) ItemIcon(com.ldtteam.blockout.controls.ItemIcon) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) ServerLifecycleHooks(net.minecraftforge.fml.server.ServerLifecycleHooks) Minecraft(net.minecraft.client.Minecraft) ModJobs(com.minecolonies.api.colony.jobs.ModJobs) SchematicRequestMessage(com.ldtteam.structurize.network.messages.SchematicRequestMessage) Network(com.minecolonies.coremod.Network) Log(com.minecolonies.api.util.Log) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) Constants(com.minecolonies.api.util.constant.Constants) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) Color(com.ldtteam.blockout.Color) IColonyView(com.minecolonies.api.colony.IColonyView) StructureName(com.ldtteam.structurize.management.StructureName) AbstractBuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView) World(net.minecraft.world.World) IColonyManager(com.minecolonies.api.colony.IColonyManager) Tuple(net.minecraft.util.Tuple) BlockPos(net.minecraft.util.math.BlockPos) NULL_POS(com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS) Pane(com.ldtteam.blockout.Pane) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) Collectors(java.util.stream.Collectors) Text(com.ldtteam.blockout.controls.Text) ModBuildings(com.minecolonies.api.colony.buildings.ModBuildings) Nullable(org.jetbrains.annotations.Nullable) Button(com.ldtteam.blockout.controls.Button) WindowConstants(com.minecolonies.api.util.constant.WindowConstants) BlockPlacementResult(com.ldtteam.structurize.placement.BlockPlacementResult) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) AbstractBuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) IColonyView(com.minecolonies.api.colony.IColonyView) Tuple(net.minecraft.util.Tuple)

Example 4 with AbstractBuildingBuilderView

use of com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView in project minecolonies by ldtteam.

the class WindowBuildDecoration method updateBuilders.

/**
 * Update the builders list but try to keep the same one.
 */
private void updateBuilders() {
    IColonyView colony = (IColonyView) IColonyManager.getInstance().getIColony(Minecraft.getInstance().level, structurePos);
    if (colony == null) {
        if (structureName.getStyle().equals("supplycamp") || structureName.getStyle().equals("supplyship")) {
            LanguageHandler.sendPlayerMessage(Minecraft.getInstance().player, TranslationConstants.NO_COLONY_YET);
        } else {
            LanguageHandler.sendPlayerMessage(Minecraft.getInstance().player, TranslationConstants.OUT_OF_COLONY, structureName.getSchematic(), structurePos.getX(), structurePos.getZ());
        }
        close();
        return;
    }
    builders.clear();
    builders.add(new Tuple<>(new TranslationTextComponent(ModJobs.builder.getTranslationKey()).getString() + ":", BlockPos.ZERO));
    builders.addAll(colony.getBuildings().stream().filter(build -> build instanceof AbstractBuildingBuilderView && !((AbstractBuildingBuilderView) build).getWorkerName().isEmpty() && build.getBuildingType() != ModBuildings.miner).map(build -> new Tuple<>(((AbstractBuildingBuilderView) build).getWorkerName(), build.getPosition())).sorted(Comparator.comparing(item -> item.getB().distSqr(structurePos))).collect(Collectors.toList()));
    initBuilderNavigation();
}
Also used : StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) java.util(java.util) LanguageHandler(com.ldtteam.structurize.util.LanguageHandler) DropDownList(com.ldtteam.blockout.views.DropDownList) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) Structures(com.ldtteam.structurize.management.Structures) ScrollingList(com.ldtteam.blockout.views.ScrollingList) LoadOnlyStructureHandler(com.minecolonies.api.util.LoadOnlyStructureHandler) BuildToolPlaceMessage(com.minecolonies.coremod.network.messages.server.BuildToolPlaceMessage) ItemIcon(com.ldtteam.blockout.controls.ItemIcon) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) ServerLifecycleHooks(net.minecraftforge.fml.server.ServerLifecycleHooks) Minecraft(net.minecraft.client.Minecraft) ModJobs(com.minecolonies.api.colony.jobs.ModJobs) SchematicRequestMessage(com.ldtteam.structurize.network.messages.SchematicRequestMessage) Network(com.minecolonies.coremod.Network) Log(com.minecolonies.api.util.Log) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) Constants(com.minecolonies.api.util.constant.Constants) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) Color(com.ldtteam.blockout.Color) IColonyView(com.minecolonies.api.colony.IColonyView) StructureName(com.ldtteam.structurize.management.StructureName) AbstractBuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView) World(net.minecraft.world.World) IColonyManager(com.minecolonies.api.colony.IColonyManager) Tuple(net.minecraft.util.Tuple) BlockPos(net.minecraft.util.math.BlockPos) NULL_POS(com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS) Pane(com.ldtteam.blockout.Pane) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) Collectors(java.util.stream.Collectors) Text(com.ldtteam.blockout.controls.Text) ModBuildings(com.minecolonies.api.colony.buildings.ModBuildings) Nullable(org.jetbrains.annotations.Nullable) Button(com.ldtteam.blockout.controls.Button) WindowConstants(com.minecolonies.api.util.constant.WindowConstants) BlockPlacementResult(com.ldtteam.structurize.placement.BlockPlacementResult) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) AbstractBuildingBuilderView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) IColonyView(com.minecolonies.api.colony.IColonyView) Tuple(net.minecraft.util.Tuple)

Aggregations

Pane (com.ldtteam.blockout.Pane)4 Button (com.ldtteam.blockout.controls.Button)4 ScrollingList (com.ldtteam.blockout.views.ScrollingList)4 AbstractBuildingBuilderView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingBuilderView)4 Color (com.ldtteam.blockout.Color)2 ItemIcon (com.ldtteam.blockout.controls.ItemIcon)2 Text (com.ldtteam.blockout.controls.Text)2 DropDownList (com.ldtteam.blockout.views.DropDownList)2 StructureName (com.ldtteam.structurize.management.StructureName)2 Structures (com.ldtteam.structurize.management.Structures)2 SchematicRequestMessage (com.ldtteam.structurize.network.messages.SchematicRequestMessage)2 NULL_POS (com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS)2 BlockPlacementResult (com.ldtteam.structurize.placement.BlockPlacementResult)2 StructurePhasePlacementResult (com.ldtteam.structurize.placement.StructurePhasePlacementResult)2 StructurePlacer (com.ldtteam.structurize.placement.StructurePlacer)2 LanguageHandler (com.ldtteam.structurize.util.LanguageHandler)2 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 IColonyView (com.minecolonies.api.colony.IColonyView)2 ModBuildings (com.minecolonies.api.colony.buildings.ModBuildings)2