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