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()));
}
});
}
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()));
}
});
}
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();
}
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();
}
Aggregations