Search in sources :

Example 1 with CrafterJobView

use of com.minecolonies.coremod.colony.jobs.views.CrafterJobView in project minecolonies by Minecolonies.

the class WindowHutCrafterTaskModule method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<IToken<?>> tasks = new ArrayList<>();
    for (final WorkerBuildingModuleView moduleView : buildingView.getModuleViews(WorkerBuildingModuleView.class)) {
        for (final int citizenId : moduleView.getAssignedCitizens()) {
            ICitizenDataView citizen = buildingView.getColony().getCitizen(citizenId);
            if (citizen != null) {
                if (citizen.getJobView() instanceof CrafterJobView) {
                    tasks.addAll(((CrafterJobView) citizen.getJobView()).getDataStore().getQueue());
                } else if (citizen.getJobView() instanceof DmanJobView) {
                    tasks.addAll(((DmanJobView) citizen.getJobView()).getDataStore().getQueue());
                }
            }
        }
    }
    final ScrollingList deliveryList = findPaneOfTypeByID(LIST_TASKS, ScrollingList.class);
    deliveryList.setDataProvider(new ScrollingList.DataProvider() {

        @Override
        public int getElementCount() {
            tasks.removeIf(token -> buildingView.getColony().getRequestManager().getRequestForToken(token) == null);
            return tasks.size();
        }

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final IRequest<?> request = buildingView.getColony().getRequestManager().getRequestForToken(tasks.get(index));
            final IRequest<?> parent = buildingView.getColony().getRequestManager().getRequestForToken(request.getParent());
            if (parent != null) {
                rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request).getString() + " ->");
                rowPane.findPaneOfTypeByID(PARENT, Text.class).setText(parent.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), parent));
            } else {
                rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request));
                rowPane.findPaneOfTypeByID(PARENT, Text.class).clearText();
            }
            rowPane.findPaneOfTypeByID(REQUEST_SHORT_DETAIL, Text.class).setText(request.getShortDisplayString().getString().replace("§f", ""));
            if (request.getRequest() instanceof IDeliverymanRequestable) {
                rowPane.findPaneOfTypeByID(REQUEST_PRIORITY, Text.class).setText(LanguageHandler.format(COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY) + ((IDeliverymanRequestable) (request.getRequest())).getPriority());
            }
            final Image logo = rowPane.findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
            logo.setImage(request.getDisplayIcon());
        }
    });
}
Also used : IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) LanguageHandler(com.ldtteam.structurize.util.LanguageHandler) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY(com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY) Text(com.ldtteam.blockout.controls.Text) ArrayList(java.util.ArrayList) DmanJobView(com.minecolonies.coremod.colony.jobs.views.DmanJobView) List(java.util.List) Image(com.ldtteam.blockout.controls.Image) IDeliverymanRequestable(com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable) WindowConstants(com.minecolonies.api.util.constant.WindowConstants) AbstractModuleWindow(com.minecolonies.coremod.client.gui.AbstractModuleWindow) CrafterJobView(com.minecolonies.coremod.colony.jobs.views.CrafterJobView) NotNull(org.jetbrains.annotations.NotNull) ArrayList(java.util.ArrayList) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) Image(com.ldtteam.blockout.controls.Image) Pane(com.ldtteam.blockout.Pane) CrafterJobView(com.minecolonies.coremod.colony.jobs.views.CrafterJobView) IDeliverymanRequestable(com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable) DmanJobView(com.minecolonies.coremod.colony.jobs.views.DmanJobView) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) ScrollingList(com.ldtteam.blockout.views.ScrollingList)

Example 2 with CrafterJobView

use of com.minecolonies.coremod.colony.jobs.views.CrafterJobView in project minecolonies by ldtteam.

the class WindowHutCrafterTaskModule method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    final List<IToken<?>> tasks = new ArrayList<>();
    for (final WorkerBuildingModuleView moduleView : buildingView.getModuleViews(WorkerBuildingModuleView.class)) {
        for (final int citizenId : moduleView.getAssignedCitizens()) {
            ICitizenDataView citizen = buildingView.getColony().getCitizen(citizenId);
            if (citizen != null) {
                if (citizen.getJobView() instanceof CrafterJobView) {
                    tasks.addAll(((CrafterJobView) citizen.getJobView()).getDataStore().getQueue());
                } else if (citizen.getJobView() instanceof DmanJobView) {
                    tasks.addAll(((DmanJobView) citizen.getJobView()).getDataStore().getQueue());
                }
            }
        }
    }
    final ScrollingList deliveryList = findPaneOfTypeByID(LIST_TASKS, ScrollingList.class);
    deliveryList.setDataProvider(new ScrollingList.DataProvider() {

        @Override
        public int getElementCount() {
            tasks.removeIf(token -> buildingView.getColony().getRequestManager().getRequestForToken(token) == null);
            return tasks.size();
        }

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final IRequest<?> request = buildingView.getColony().getRequestManager().getRequestForToken(tasks.get(index));
            final IRequest<?> parent = buildingView.getColony().getRequestManager().getRequestForToken(request.getParent());
            if (parent != null) {
                rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request).getString() + " ->");
                rowPane.findPaneOfTypeByID(PARENT, Text.class).setText(parent.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), parent));
            } else {
                rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request));
                rowPane.findPaneOfTypeByID(PARENT, Text.class).clearText();
            }
            rowPane.findPaneOfTypeByID(REQUEST_SHORT_DETAIL, Text.class).setText(request.getShortDisplayString().getString().replace("§f", ""));
            if (request.getRequest() instanceof IDeliverymanRequestable) {
                rowPane.findPaneOfTypeByID(REQUEST_PRIORITY, Text.class).setText(LanguageHandler.format(COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY) + ((IDeliverymanRequestable) (request.getRequest())).getPriority());
            }
            final Image logo = rowPane.findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
            logo.setImage(request.getDisplayIcon());
        }
    });
}
Also used : IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) LanguageHandler(com.ldtteam.structurize.util.LanguageHandler) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY(com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY) Text(com.ldtteam.blockout.controls.Text) ArrayList(java.util.ArrayList) DmanJobView(com.minecolonies.coremod.colony.jobs.views.DmanJobView) List(java.util.List) Image(com.ldtteam.blockout.controls.Image) IDeliverymanRequestable(com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable) WindowConstants(com.minecolonies.api.util.constant.WindowConstants) AbstractModuleWindow(com.minecolonies.coremod.client.gui.AbstractModuleWindow) CrafterJobView(com.minecolonies.coremod.colony.jobs.views.CrafterJobView) NotNull(org.jetbrains.annotations.NotNull) ArrayList(java.util.ArrayList) WorkerBuildingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView) Image(com.ldtteam.blockout.controls.Image) Pane(com.ldtteam.blockout.Pane) CrafterJobView(com.minecolonies.coremod.colony.jobs.views.CrafterJobView) IDeliverymanRequestable(com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable) DmanJobView(com.minecolonies.coremod.colony.jobs.views.DmanJobView) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) ScrollingList(com.ldtteam.blockout.views.ScrollingList)

Aggregations

Pane (com.ldtteam.blockout.Pane)2 Image (com.ldtteam.blockout.controls.Image)2 Text (com.ldtteam.blockout.controls.Text)2 ScrollingList (com.ldtteam.blockout.views.ScrollingList)2 LanguageHandler (com.ldtteam.structurize.util.LanguageHandler)2 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)2 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 IDeliverymanRequestable (com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable)2 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)2 COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY (com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY)2 WindowConstants (com.minecolonies.api.util.constant.WindowConstants)2 AbstractModuleWindow (com.minecolonies.coremod.client.gui.AbstractModuleWindow)2 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)2 CrafterJobView (com.minecolonies.coremod.colony.jobs.views.CrafterJobView)2 DmanJobView (com.minecolonies.coremod.colony.jobs.views.DmanJobView)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NotNull (org.jetbrains.annotations.NotNull)2