use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class WindowHutCrafterTaskModule method onOpened.
@Override
public void onOpened() {
super.onOpened();
final List<IToken<?>> tasks = new ArrayList<>();
for (final WorkerBuildingModuleView moduleView : buildingView.getModuleViews(WorkerBuildingModuleView.class)) {
for (final int citizenId : moduleView.getAssignedCitizens()) {
ICitizenDataView citizen = buildingView.getColony().getCitizen(citizenId);
if (citizen != null) {
if (citizen.getJobView() instanceof CrafterJobView) {
tasks.addAll(((CrafterJobView) citizen.getJobView()).getDataStore().getQueue());
} else if (citizen.getJobView() instanceof DmanJobView) {
tasks.addAll(((DmanJobView) citizen.getJobView()).getDataStore().getQueue());
}
}
}
}
final ScrollingList deliveryList = findPaneOfTypeByID(LIST_TASKS, ScrollingList.class);
deliveryList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
tasks.removeIf(token -> buildingView.getColony().getRequestManager().getRequestForToken(token) == null);
return tasks.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final IRequest<?> request = buildingView.getColony().getRequestManager().getRequestForToken(tasks.get(index));
final IRequest<?> parent = buildingView.getColony().getRequestManager().getRequestForToken(request.getParent());
if (parent != null) {
rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request).getString() + " ->");
rowPane.findPaneOfTypeByID(PARENT, Text.class).setText(parent.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), parent));
} else {
rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request));
rowPane.findPaneOfTypeByID(PARENT, Text.class).clearText();
}
rowPane.findPaneOfTypeByID(REQUEST_SHORT_DETAIL, Text.class).setText(request.getShortDisplayString().getString().replace("§f", ""));
if (request.getRequest() instanceof IDeliverymanRequestable) {
rowPane.findPaneOfTypeByID(REQUEST_PRIORITY, Text.class).setText(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY).append(String.valueOf(((IDeliverymanRequestable) request.getRequest()).getPriority())));
}
final Image logo = rowPane.findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
logo.setImage(request.getDisplayIcon());
}
});
}
use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class WindowMineGuardModule method assignGuardClicked.
private void assignGuardClicked(final Button button) {
final int guardRow = guardsList.getListElementIndexByPane(button);
final ICitizenDataView guard = guardsInfo.get(guardRow);
if (guard != null) {
final AbstractBuildingGuards.View guardbuilding = (AbstractBuildingGuards.View) buildingView.getColony().getBuilding(guard.getWorkBuilding());
if (guardbuilding.getMinePos() == null) {
if (assignedGuards < getMaxGuards()) {
Network.getNetwork().sendToServer(new GuardSetMinePosMessage(guardbuilding, buildingView.getPosition()));
button.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonunassign"));
guardbuilding.setMinePos(buildingView.getPosition());
assignedGuards++;
}
} else if (guardbuilding.getMinePos().equals(buildingView.getPosition())) {
Network.getNetwork().sendToServer(new GuardSetMinePosMessage(guardbuilding));
button.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonassign"));
guardbuilding.setMinePos(null);
assignedGuards--;
}
}
pullGuardsFromHut();
}
use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class WindowCitizenPage method fillCitizensList.
/**
* Fills the citizens list in the GUI.
*/
private void fillCitizensList() {
final ScrollingList citizenList = findPaneOfTypeByID(LIST_CITIZENS, ScrollingList.class);
citizenList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return citizens.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final ICitizenDataView citizen = citizens.get(index);
rowPane.findPaneOfTypeByID(NAME_LABEL, ButtonImage.class).setText(citizen.getName());
}
});
}
use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class WindowCitizenPage method fillCitizenInfo.
/**
* Executed when fill citizen is clicked.
*
* @param button the clicked button.
*/
private void fillCitizenInfo(final Button button) {
final ScrollingList citizenList = findPaneOfTypeByID(LIST_CITIZENS, ScrollingList.class);
for (final Pane pane : citizenList.getContainer().getChildren()) {
pane.findPaneOfTypeByID(NAME_LABEL, ButtonImage.class).enable();
}
final int row = citizenList.getListElementIndexByPane(button);
findPaneByID(CITIZEN_INFO).show();
button.disable();
final ICitizenDataView view = citizens.get(row);
CitizenWindowUtils.createHappinessBar(view, this);
CitizenWindowUtils.createSkillContent(view, this);
String jobKey = view.getJob().trim().isEmpty() ? COM_MINECOLONIES_COREMOD_GUI_TOWNHALL_CITIZEN_UNEMPLOYED : view.getJob();
findPaneOfTypeByID(JOB_LABEL, Text.class).setText(new TranslationTextComponent(jobKey).withStyle(TextFormatting.BOLD));
findPaneOfTypeByID(HIDDEN_CITIZEN_ID, Text.class).setText(String.valueOf(view.getId()));
}
use of com.minecolonies.api.colony.ICitizenDataView 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();
}
Aggregations