use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.
the class FamilyWindowCitizen method onOpened.
@Override
public void onOpened() {
super.onOpened();
final String firstParent = citizen.getParents().getA();
final String secondParent = citizen.getParents().getB();
findPaneOfTypeByID("parentA", Text.class).setText(firstParent.isEmpty() ? new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.family.unknown") : new StringTextComponent(firstParent));
findPaneOfTypeByID("parentB", Text.class).setText(secondParent.isEmpty() ? new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.family.unknown") : new StringTextComponent(secondParent));
final int partner = citizen.getPartner();
final ICitizenDataView partnerView = colony.getCitizen(partner);
final Text partnerText = findPaneOfTypeByID("partner", Text.class);
if (partnerView == null) {
partnerText.setText(new StringTextComponent("-"));
} else {
partnerText.setText(new StringTextComponent(partnerView.getName()));
}
childrenList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return citizen.getChildren().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) {
rowPane.findPaneOfTypeByID("name", Text.class).setText(new StringTextComponent(colony.getCitizen(citizen.getChildren().get(index)).getName()));
}
});
siblingList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return citizen.getSiblings().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) {
rowPane.findPaneOfTypeByID("name", Text.class).setText(new StringTextComponent(colony.getCitizen(citizen.getSiblings().get(index)).getName()));
}
});
}
use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.
the class WindowHireWorker method onOpened.
/**
* Called when the GUI has been opened. Will fill the fields and lists.
*/
@Override
public void onOpened() {
updateCitizens();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).off();
citizenList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return citizens.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
@NotNull final ICitizenDataView citizen = citizens.get(index);
final Button isPaused = rowPane.findPaneOfTypeByID(BUTTON_PAUSE, Button.class);
if (selectedModule.canAssign(citizen) && !selectedModule.isFull() && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).on();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else if ((selectedModule.isFull()) && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else {
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).on();
if ((!selectedModule.getColony().isManualHiring() && selectedModule.getHiringMode() == HiringMode.DEFAULT) || (selectedModule.getHiringMode() == HiringMode.AUTO)) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).disable();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).on();
}
isPaused.on();
isPaused.setText(LanguageHandler.format(citizen.isPaused() ? COM_MINECOLONIES_COREMOD_GUI_HIRE_UNPAUSE : COM_MINECOLONIES_COREMOD_GUI_HIRE_PAUSE));
}
if (citizen.isPaused()) {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).on();
} else {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
}
final StringTextComponent intermString = new StringTextComponent(" ");
final TextBuilder textBuilder = PaneBuilders.textBuilder();
textBuilder.append(new StringTextComponent(""));
int skillCount = citizen.getCitizenSkillHandler().getSkills().entrySet().size();
final Skill primary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getPrimarySkill() : null;
final Skill secondary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getSecondarySkill() : null;
for (final Map.Entry<Skill, Tuple<Integer, Double>> entry : citizen.getCitizenSkillHandler().getSkills().entrySet()) {
final String skillName = entry.getKey().name().toLowerCase(Locale.US);
final int skillLevel = entry.getValue().getA();
final Style skillStyle = createColor(primary, secondary, entry.getKey());
textBuilder.append(new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.skills." + skillName).setStyle(skillStyle));
textBuilder.append(new StringTextComponent(": " + skillLevel).setStyle(skillStyle));
if (--skillCount > 0) {
textBuilder.append(intermString);
}
}
// finish the current line
textBuilder.newLine();
rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Text.class).setText((citizen.getJob().isEmpty() ? "" : LanguageHandler.format(citizen.getJob()) + ": ") + citizen.getName());
rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Text.class).setText(textBuilder.getText());
}
});
jobList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return moduleViews.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final JobEntry entry = moduleViews.get(index).getJobEntry();
final Button button = rowPane.findPaneOfTypeByID(BUTTON_JOB, Button.class);
button.setText(new TranslationTextComponent(entry.getTranslationKey()));
if (entry.equals(selectedModule.getJobEntry())) {
button.disable();
} else {
button.enable();
}
}
});
}
use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.
the class WindowBuilderResModule method transferItems.
/**
* On Button click transfert Items.
*
* @param button the clicked button.
*/
private void transferItems(@NotNull final Button button) {
final Pane pane = button.getParent();
button.disable();
final Text idLabel = pane.findPaneOfTypeByID(RESOURCE_ID, Text.class);
final int index = Integer.parseInt(idLabel.getTextAsString());
final BuildingBuilderResource res = resources.get(index);
if (res == null) {
Log.getLogger().warn("WindowHutBuilder.transferItems: Error - Could not find the resource.");
} else {
// The itemStack size should not be greater than itemStack.getMaxStackSize, We send 1 instead
// and use quantity for the size
@NotNull final ItemStack itemStack = res.getItemStack().copy();
itemStack.setCount(1);
final Text quantityLabel = pane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class);
final int quantity = Integer.parseInt(quantityLabel.getTextAsString());
final int needed = res.getAmount() - res.getAvailable();
res.setAvailable(Math.min(res.getAmount(), res.getAvailable() + res.getPlayerAmount()));
res.setPlayerAmount(Math.max(0, res.getPlayerAmount() - needed));
resources.sort(new BuildingBuilderResource.ResourceComparator());
Network.getNetwork().sendToServer(new TransferItemsRequestMessage(this.buildingView, itemStack, quantity, true));
}
}
use of com.ldtteam.blockout.Pane 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.ldtteam.blockout.Pane 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());
}
});
}
Aggregations