Search in sources :

Example 1 with ICitizenDataView

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());
}
Also used : ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) PauseCitizenMessage(com.minecolonies.coremod.network.messages.server.colony.citizen.PauseCitizenMessage) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ICitizenDataView

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();
}
Also used : ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ICitizenDataView

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();
}
Also used : ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ICitizenDataView

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()));
        }
    });
}
Also used : TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text) StringTextComponent(net.minecraft.util.text.StringTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 5 with ICitizenDataView

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);
    }
}
Also used : Image(com.ldtteam.blockout.controls.Image) View(com.ldtteam.blockout.views.View) IColonyView(com.minecolonies.api.colony.IColonyView) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)35 Pane (com.ldtteam.blockout.Pane)19 ScrollingList (com.ldtteam.blockout.views.ScrollingList)19 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)18 NotNull (org.jetbrains.annotations.NotNull)14 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)12 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)12 Text (com.ldtteam.blockout.controls.Text)9 Image (com.ldtteam.blockout.controls.Image)6 View (com.ldtteam.blockout.views.View)6 Tuple (com.minecolonies.api.util.Tuple)6 AbstractBuildingView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)6 ArrayList (java.util.ArrayList)6 Button (com.ldtteam.blockout.controls.Button)5 IColonyView (com.minecolonies.api.colony.IColonyView)4 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)4 SettingsModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.SettingsModuleView)4 StringTextComponent (net.minecraft.util.text.StringTextComponent)4 TextBuilder (com.ldtteam.blockout.controls.AbstractTextBuilder.TextBuilder)2 LanguageHandler (com.ldtteam.structurize.util.LanguageHandler)2