Search in sources :

Example 1 with ScrollingList

use of com.minecolonies.blockout.views.ScrollingList in project minecolonies by Minecolonies.

the class WindowTownHall method fillWorkOrderList.

/**
     * Fills the workOrder list inside the townhall GUI.
     */
private void fillWorkOrderList() {
    final ScrollingList workOrderList = findPaneOfTypeByID(LIST_WORKORDER, ScrollingList.class);
    workOrderList.enable();
    workOrderList.show();
    //Creates a dataProvider for the unemployed citizenList.
    workOrderList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final WorkOrderView workOrder = workOrders.get(index);
            String claimingCitizen = "";
            if (index == 0) {
                if (getElementCount() == 1) {
                    rowPane.findPaneOfTypeByID(BUTTON_DOWN, Button.class).hide();
                } else {
                    rowPane.findPaneOfTypeByID(BUTTON_DOWN, Button.class).show();
                }
                rowPane.findPaneOfTypeByID(BUTTON_UP, Button.class).hide();
            } else if (index == getElementCount() - 1) {
                rowPane.findPaneOfTypeByID(BUTTON_DOWN, Button.class).hide();
            }
            //Searches citizen of id x
            for (@NotNull final CitizenDataView citizen : citizens) {
                if (citizen.getID() == workOrder.getClaimedBy()) {
                    claimingCitizen = citizen.getName();
                    break;
                }
            }
            rowPane.findPaneOfTypeByID(WORK_LABEL, Label.class).setLabelText(workOrder.getValue());
            rowPane.findPaneOfTypeByID(ASSIGNEE_LABEL, Label.class).setLabelText(claimingCitizen);
            rowPane.findPaneOfTypeByID(HIDDEN_WORKORDER_ID, Label.class).setLabelText(Integer.toString(workOrder.getId()));
        }
    });
}
Also used : WorkOrderView(com.minecolonies.coremod.colony.WorkOrderView) Button(com.minecolonies.blockout.controls.Button) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) ScrollingList(com.minecolonies.blockout.views.ScrollingList) Pane(com.minecolonies.blockout.Pane)

Example 2 with ScrollingList

use of com.minecolonies.blockout.views.ScrollingList in project minecolonies by Minecolonies.

the class WindowTownHall method fillCitizensList.

/**
     * Fills the citizens list in the GUI.
     */
private void fillCitizensList() {
    final ScrollingList citizenList = findPaneOfTypeByID(LIST_CITIZENS, ScrollingList.class);
    citizenList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final CitizenDataView citizen = citizens.get(index);
            rowPane.findPaneOfTypeByID("name", Label.class).setLabelText(citizen.getName());
        }
    });
}
Also used : CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) ScrollingList(com.minecolonies.blockout.views.ScrollingList) Pane(com.minecolonies.blockout.Pane)

Example 3 with ScrollingList

use of com.minecolonies.blockout.views.ScrollingList in project minecolonies by Minecolonies.

the class WindowHutBuilder method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    pullResourcesFromHut();
    final ScrollingList resourceList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
    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);
        }
    });
    //Make sure we have a fresh view
    MineColonies.getNetwork().sendToServer(new MarkBuildingDirtyMessage(this.building));
}
Also used : ScrollingList(com.minecolonies.blockout.views.ScrollingList) Pane(com.minecolonies.blockout.Pane) MarkBuildingDirtyMessage(com.minecolonies.coremod.network.messages.MarkBuildingDirtyMessage)

Example 4 with ScrollingList

use of com.minecolonies.blockout.views.ScrollingList in project minecolonies by Minecolonies.

the class WindowHireWorker method onOpened.

/**
     * Called when the GUI has been opened.
     * Will fill the fields and lists.
     */
@Override
public void onOpened() {
    updateCitizens();
    final ScrollingList citizenList = findPaneOfTypeByID(CITIZEN_LIST, ScrollingList.class);
    citizenList.enable();
    citizenList.show();
    //Creates a dataProvider for the unemployed citizenList.
    citizenList.setDataProvider(new ScrollingList.DataProvider() {

        /**
             * The number of rows of the list.
             * @return the number.
             */
        @Override
        public int getElementCount() {
            return citizens.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) {
            @NotNull final CitizenDataView citizen = citizens.get(index);
            if (building instanceof AbstractBuildingWorker.View) {
                final AbstractBuildingWorker.Skill primary = ((AbstractBuildingWorker.View) building).getPrimarySkill();
                final AbstractBuildingWorker.Skill secondary = ((AbstractBuildingWorker.View) building).getSecondarySkill();
                @NotNull final String strength = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.STRENGTH), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_STRENGTH, citizen.getStrength()));
                @NotNull final String charisma = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.CHARISMA), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_CHARISMA, citizen.getCharisma()));
                @NotNull final String dexterity = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.DEXTERITY), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_DEXTERITY, citizen.getDexterity()));
                @NotNull final String endurance = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.ENDURANCE), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_ENDURANCE, citizen.getEndurance()));
                @NotNull final String intelligence = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.INTELLIGENCE), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_INTELLIGENCE, citizen.getIntelligence()));
                //Creates the list of attributes for each citizen
                @NotNull final String attributes = strength + charisma + dexterity + endurance + intelligence;
                rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Label.class).setLabelText(citizen.getName());
                rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Label.class).setLabelText(attributes);
                //Invisible id textContent.
                rowPane.findPaneOfTypeByID(ID_LABEL, Label.class).setLabelText(Integer.toString(citizen.getID()));
            }
        }
    });
}
Also used : AbstractBuildingWorker(com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) ScrollingList(com.minecolonies.blockout.views.ScrollingList) Pane(com.minecolonies.blockout.Pane)

Aggregations

Pane (com.minecolonies.blockout.Pane)4 ScrollingList (com.minecolonies.blockout.views.ScrollingList)4 CitizenDataView (com.minecolonies.coremod.colony.CitizenDataView)3 Button (com.minecolonies.blockout.controls.Button)1 WorkOrderView (com.minecolonies.coremod.colony.WorkOrderView)1 AbstractBuildingWorker (com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker)1 MarkBuildingDirtyMessage (com.minecolonies.coremod.network.messages.MarkBuildingDirtyMessage)1