use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.
the class WindowResourceList method onOpened.
@Override
public void onOpened() {
final ClientPlayerEntity player = Minecraft.getInstance().player;
if (this.builder == null) {
player.sendMessage(new TranslationTextComponent("com.minecolonies.coremod.resourcescroll.nobuilder"), player.getUUID());
close();
return;
}
super.onOpened();
pullResourcesFromHut();
final ScrollingList resourceList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
if (resourceList == null) {
player.sendMessage(new TranslationTextComponent("com.minecolonies.coremod.resourcescroll.null"), player.getUUID());
close();
return;
}
resourceList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return resources.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
updateResourcePane(index, rowPane);
}
});
final BuildingResourcesModuleView moduleView = builder.getModuleView(BuildingResourcesModuleView.class);
// Make sure we have a fresh view
Network.getNetwork().sendToServer(new MarkBuildingDirtyMessage(builder));
findPaneOfTypeByID(LABEL_WORKERNAME, Text.class).setText(builder.getWorkerName());
findPaneOfTypeByID(LABEL_CONSTRUCTION_NAME, Text.class).setText(moduleView.getConstructionName());
}
use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.
the class WindowBuildBuilding method updateResourceList.
public void updateResourceList() {
final ScrollingList recourseList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
recourseList.enable();
recourseList.show();
final List<ItemStorage> tempRes = new ArrayList<>(resources.values());
// Creates a dataProvider for the unemployed recourseList.
recourseList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return tempRes.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) {
final ItemStorage resource = tempRes.get(index);
final Text resourceLabel = rowPane.findPaneOfTypeByID(RESOURCE_NAME, Text.class);
final Text quantityLabel = rowPane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class);
resourceLabel.setText(resource.getItemStack().getHoverName());
quantityLabel.setText(Integer.toString(resource.getAmount()));
resourceLabel.setColors(WHITE);
quantityLabel.setColors(WHITE);
final ItemStack itemIcon = new ItemStack(resource.getItem(), 1);
itemIcon.setTag(resource.getItemStack().getTag());
rowPane.findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(itemIcon);
}
});
}
use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.
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());
final JobEntry entry = selectedModule.getJobEntry();
PaneBuilders.tooltipBuilder().hoverPane(rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Text.class)).build().setText(new TranslationTextComponent(entry.getKey().toString() + ".skills.desc"));
}
});
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();
}
PaneBuilders.tooltipBuilder().hoverPane(button).build().setText(new TranslationTextComponent(entry.getKey().toString() + ".job.desc"));
}
});
}
use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.
the class WindowHutAllInventory method updateResourceList.
/**
* Updates the resource list in the GUI with the info we need.
*/
private void updateResourceList() {
stackList.enable();
// Creates a dataProvider for the unemployed stackList.
stackList.setDataProvider(new ScrollingList.DataProvider() {
/**
* The number of rows of the list.
* @return the number.
*/
@Override
public int getElementCount() {
return allItems.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) {
final ItemStorage resource = allItems.get(index);
final Text resourceLabel = rowPane.findPaneOfTypeByID("ressourceStackName", Text.class);
final String name = resource.getItemStack().getHoverName().getString();
resourceLabel.setText(name.substring(0, Math.min(17, name.length())));
final Text qtys = rowPane.findPaneOfTypeByID("quantities", Text.class);
if (!Screen.hasShiftDown()) {
qtys.setText(Utils.format(resource.getAmount()));
} else {
qtys.setText(Integer.toString(resource.getAmount()));
}
final Item imagesrc = resource.getItemStack().getItem();
final ItemStack image = new ItemStack(imagesrc, 1);
image.setTag(resource.getItemStack().getTag());
rowPane.findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(image);
}
});
}
use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.
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 String 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);
}
});
}
Aggregations