use of com.ldtteam.blockout.Pane 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.ldtteam.blockout.Pane in project minecolonies by Minecolonies.
the class WindowInfoPage method fillEventsList.
private void fillEventsList() {
eventList = findPaneOfTypeByID(EVENTS_LIST, ScrollingList.class);
eventList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return permissionEvents ? building.getPermissionEvents().size() : building.getColonyEvents().size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final Text nameLabel = rowPane.findPaneOfTypeByID(NAME_LABEL, Text.class);
final Text actionLabel = rowPane.findPaneOfTypeByID(ACTION_LABEL, Text.class);
if (permissionEvents) {
final List<PermissionEvent> permissionEvents = building.getPermissionEvents();
Collections.reverse(permissionEvents);
final PermissionEvent event = permissionEvents.get(index);
nameLabel.setText(event.getName() + (event.getId() == null ? " <fake>" : ""));
rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getPosition().getX() + " " + event.getPosition().getY() + " " + event.getPosition().getZ());
if (event.getId() == null) {
rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
}
actionLabel.setText(new TranslationTextComponent(KEY_TO_PERMISSIONS + event.getAction().toString().toLowerCase(Locale.US)));
} else {
final List<IColonyEventDescription> colonyEvents = building.getColonyEvents();
Collections.reverse(colonyEvents);
final IColonyEventDescription event = colonyEvents.get(index);
if (event instanceof CitizenDiedEvent) {
actionLabel.setText(((CitizenDiedEvent) event).getDeathCause());
} else {
actionLabel.setText(event.getName());
}
if (event instanceof ICitizenEventDescription) {
nameLabel.setText(((ICitizenEventDescription) event).getCitizenName());
} else if (event instanceof IBuildingEventDescription) {
IBuildingEventDescription buildEvent = (IBuildingEventDescription) event;
nameLabel.setText(MessageUtils.format(buildEvent.getBuildingName()).append(" " + buildEvent.getLevel()).create());
}
rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getEventPos().getX() + " " + event.getEventPos().getY() + " " + event.getEventPos().getZ());
rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
}
}
});
}
use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.
the class WindowBuildDecoration 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().getString());
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 Minecolonies.
the class WindowPostBox method requestClicked.
/**
* Action executed when request is clicked.
*
* @param button the clicked button.
*/
private void requestClicked(final Button button) {
final int row = stackList.getListElementIndexByPane(button);
final ItemStack stack = allItems.get(row);
int qty = stack.getMaxStackSize();
for (final Pane child : button.getParent().getChildren()) {
if (child.getID().equals(INPUT_QTY)) {
try {
qty = Integer.parseInt(((TextField) child).getText());
} catch (final NumberFormatException ex) {
// Be quiet about it.
}
}
}
Network.getNetwork().sendToServer(new PostBoxRequestMessage(buildingView, stack.copy(), qty, deliverAvailable));
}
use of com.ldtteam.blockout.Pane in project minecolonies by Minecolonies.
the class WindowResourceList method onOpened.
@Override
public void onOpened() {
final ClientPlayerEntity player = Minecraft.getInstance().player;
if (this.builder == null) {
MessageUtils.format(TOOL_RESOURCE_SCROLL_NO_BUILDER).sendTo(player);
close();
return;
}
super.onOpened();
pullResourcesFromHut();
pullResourcesFromWarehouse();
final ScrollingList resourceList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
if (resourceList == null) {
MessageUtils.format(TOOL_RESOURCE_SCROLL_ERROR).sendTo(player);
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());
}
Aggregations