Search in sources :

Example 36 with ICitizenDataView

use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by ldtteam.

the class SpecialAssignmentModuleWindow method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<Tuple<String, Integer>> workers = new ArrayList<>();
    for (final IAssignmentModuleView module : buildingView.getModuleViews(IAssignmentModuleView.class)) {
        for (final int worker : module.getAssignedCitizens()) {
            workers.add(new Tuple<>(new TranslationTextComponent(module.getJobEntry().getTranslationKey()).getString(), worker));
        }
    }
    if (findPaneByID(LIST_WORKERS) != null) {
        ScrollingList workerList = findPaneOfTypeByID(LIST_WORKERS, ScrollingList.class);
        workerList.setDataProvider(new ScrollingList.DataProvider() {

            @Override
            public int getElementCount() {
                return workers.size();
            }

            @Override
            public void updateElement(final int index, @NotNull final Pane rowPane) {
                final ICitizenDataView worker = buildingView.getColony().getCitizen(workers.get(index).getB());
                if (worker != null) {
                    rowPane.findPaneOfTypeByID(LABEL_WORKERNAME, Text.class).setText(new TranslationTextComponent(workers.get(index).getA()).getString() + ": " + worker.getName());
                }
            }
        });
    }
}
Also used : IAssignmentModuleView(com.minecolonies.api.colony.buildings.modules.IAssignmentModuleView) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) Tuple(com.minecolonies.api.util.Tuple)

Example 37 with ICitizenDataView

use of com.minecolonies.api.colony.ICitizenDataView in project minecolonies by ldtteam.

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);
    findPaneOfTypeByID(JOB_LABEL, Text.class).setText("§l" + LanguageHandler.format(view.getJob().trim().isEmpty() ? COM_MINECOLONIES_COREMOD_GUI_TOWNHALL_CITIZEN_UNEMPLOYED : view.getJob()));
    findPaneOfTypeByID(HIDDEN_CITIZEN_ID, Text.class).setText(String.valueOf(view.getId()));
}
Also used : ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Aggregations

ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)37 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)22 Pane (com.ldtteam.blockout.Pane)21 ScrollingList (com.ldtteam.blockout.views.ScrollingList)21 Text (com.ldtteam.blockout.controls.Text)14 NotNull (org.jetbrains.annotations.NotNull)14 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)13 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)13 Button (com.ldtteam.blockout.controls.Button)7 Image (com.ldtteam.blockout.controls.Image)7 AbstractBuildingView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)7 View (com.ldtteam.blockout.views.View)6 Tuple (com.minecolonies.api.util.Tuple)6 ArrayList (java.util.ArrayList)6 IColonyView (com.minecolonies.api.colony.IColonyView)5 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)3 IAssignmentModuleView (com.minecolonies.api.colony.buildings.modules.IAssignmentModuleView)3