use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class WindowHireWorker method pauseClicked.
/**
* Pause citizen clicked to pause the citizen.
*
* @param button the clicked button.
*/
private void pauseClicked(@NotNull final Button button) {
final int row = citizenList.getListElementIndexByPane(button);
final int id = citizens.toArray(new CitizenDataView[0])[row].getId();
@NotNull final ICitizenDataView citizen = citizens.get(row);
Network.getNetwork().sendToServer(new PauseCitizenMessage(this.building, id));
citizen.setPaused(!citizen.isPaused());
}
use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class WindowHireWorker method doneClicked.
/**
* Hire clicked to persist the changes.
*
* @param button the clicked button.
*/
private void doneClicked(@NotNull final Button button) {
final int row = citizenList.getListElementIndexByPane(button);
@NotNull final ICitizenDataView citizen = citizens.get(row);
selectedModule.addCitizen(citizen);
onOpened();
}
use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class WindowHireWorker method fireClicked.
/**
* Fire citizen clicked to fire a citizen.
*
* @param button the clicked button.
*/
private void fireClicked(@NotNull final Button button) {
final int row = citizenList.getListElementIndexByPane(button);
@NotNull final ICitizenDataView citizen = citizens.get(row);
selectedModule.removeCitizen(citizen);
onOpened();
}
use of com.minecolonies.api.colony.ICitizenDataView 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.minecolonies.api.colony.ICitizenDataView in project minecolonies by Minecolonies.
the class CitizenWindowUtils method createSaturationBar.
/**
* Creates an health bar according to the citizen maxHealth and currentHealth.
*
* @param citizen the citizen.
* @param view the view to add these to.
*/
public static void createSaturationBar(final ICitizenDataView citizen, final View view) {
view.findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).setAlignment(Alignment.MIDDLE_RIGHT);
// Max saturation (Black food items).
for (int i = 0; i < ICitizenData.MAX_SATURATION; i++) {
@NotNull final Image saturation = new Image();
saturation.setImage(Screen.GUI_ICONS_LOCATION, EMPTY_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH, false);
saturation.setPosition(getXOffsetModifier(i) * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y + getYOffset(i));
view.findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).addChild(saturation);
}
// Current saturation (Full food hearts).
int saturationPos;
for (saturationPos = 0; saturationPos < ((int) citizen.getSaturation()); saturationPos++) {
@NotNull final Image saturation = new Image();
saturation.setImage(Screen.GUI_ICONS_LOCATION, FULL_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH, false);
saturation.setPosition(getXOffsetModifier(saturationPos) * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y + getYOffset(saturationPos));
view.findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).addChild(saturation);
}
// Half food items.
if (citizen.getSaturation() / 2 % 1 > 0) {
@NotNull final Image saturation = new Image();
saturation.setImage(Screen.GUI_ICONS_LOCATION, HALF_SATURATION_ITEM_ROW_POS, SATURATION_ICON_COLUMN, SATURATION_ICON_HEIGHT_WIDTH, SATURATION_ICON_HEIGHT_WIDTH, false);
saturation.setPosition(getXOffsetModifier(saturationPos) * SATURATION_ICON_POS_X + SATURATION_ICON_OFFSET_X, SATURATION_ICON_POS_Y + getYOffset(saturationPos));
view.findPaneOfTypeByID(WINDOW_ID_SATURATION_BAR, View.class).addChild(saturation);
}
}
Aggregations