Search in sources :

Example 61 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.

the class WindowBuilderResModule 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
    Network.getNetwork().sendToServer(new MarkBuildingDirtyMessage(this.buildingView));
    findPaneOfTypeByID(LABEL_CONSTRUCTION_NAME, Text.class).setText(moduleView.getConstructionName());
    findPaneOfTypeByID(STEP_PROGRESS, Text.class).setText(new TranslationTextComponent("com.minecolonies.coremod.gui.progress.step", moduleView.getCurrentStage(), moduleView.getTotalStages()));
}
Also used : TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) MarkBuildingDirtyMessage(com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)

Example 62 with Pane

use of com.ldtteam.blockout.Pane 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)

Example 63 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.

the class WindowInfoPage method fillEventsList.

private void fillEventsList() {
    eventList = findPaneOfTypeByID(EVENTS_LIST, ScrollingList.class);
    eventList.setDataProvider(new ScrollingList.DataProvider() {

        @Override
        public int getElementCount() {
            return permissionEvents ? building.getPermissionEvents().size() : building.getColonyEvents().size();
        }

        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            final Text nameLabel = rowPane.findPaneOfTypeByID(NAME_LABEL, Text.class);
            final Text actionLabel = rowPane.findPaneOfTypeByID(ACTION_LABEL, Text.class);
            if (permissionEvents) {
                final PermissionEvent event = building.getPermissionEvents().get(index);
                nameLabel.setText(event.getName() + (event.getId() == null ? " <fake>" : ""));
                rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getPosition().getX() + " " + event.getPosition().getY() + " " + event.getPosition().getZ());
                if (event.getId() == null) {
                    rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
                }
                final String name = LanguageHandler.format(KEY_TO_PERMISSIONS + event.getAction().toString().toLowerCase(Locale.US));
                if (name.contains(KEY_TO_PERMISSIONS)) {
                    Log.getLogger().warn("Didn't work for:" + name);
                    return;
                }
                actionLabel.setText(name);
            } else {
                final IColonyEventDescription event = building.getColonyEvents().get(index);
                if (event instanceof CitizenDiedEvent) {
                    actionLabel.setText(((CitizenDiedEvent) event).getDeathCause());
                } else {
                    actionLabel.setText(event.getName());
                }
                if (event instanceof ICitizenEventDescription) {
                    nameLabel.setText(((ICitizenEventDescription) event).getCitizenName());
                } else if (event instanceof IBuildingEventDescription) {
                    IBuildingEventDescription buildEvent = (IBuildingEventDescription) event;
                    nameLabel.setText(buildEvent.getBuildingName() + " " + buildEvent.getLevel());
                }
                rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getEventPos().getX() + " " + event.getEventPos().getY() + " " + event.getEventPos().getZ());
                rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
            }
        }
    });
}
Also used : ICitizenEventDescription(com.minecolonies.api.colony.colonyEvents.descriptions.ICitizenEventDescription) IColonyEventDescription(com.minecolonies.api.colony.colonyEvents.descriptions.IColonyEventDescription) IBuildingEventDescription(com.minecolonies.api.colony.colonyEvents.descriptions.IBuildingEventDescription) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) CitizenDiedEvent(com.minecolonies.coremod.colony.colonyEvents.citizenEvents.CitizenDiedEvent)

Example 64 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.

the class GuardTaskSetting method render.

@Override
public void render(final ISettingKey<?> key, final Pane pane, final ISettingsModuleView settingsModuleView, final IBuildingView building, final Window window) {
    final String setting = getSettings().get(getCurrentIndex());
    final ButtonImage targetButton = pane.findPaneOfTypeByID("setTarget", ButtonImage.class);
    final Text mineLabel = pane.findPaneOfTypeByID("minePos", Text.class);
    if (setting.equals(PATROL_MINE) && building instanceof AbstractBuildingGuards.View) {
        mineLabel.setVisible(true);
        if (((AbstractBuildingGuards.View) building).getMinePos() != null) {
            mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.worherhuts.patrollingmine", ((AbstractBuildingGuards.View) building).getMinePos().toShortString()));
        } else {
            mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.job.guard.assignmine"));
        }
        targetButton.setVisible(false);
    } else if (!setting.equals(FOLLOW)) {
        mineLabel.setVisible(false);
        targetButton.setVisible(true);
        if (setting.equals(PATROL)) {
            if (!settingsModuleView.getSetting(AbstractBuildingGuards.PATROL_MODE).getValue().equals(PatrolModeSetting.MANUAL)) {
                targetButton.setVisible(false);
            } else {
                targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetpatrol"));
            }
        } else {
            targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetguard"));
        }
        targetButton.setHandler(button -> building.getModuleView(ToolModuleView.class).getWindow().open());
    } else {
        mineLabel.setVisible(false);
        targetButton.setVisible(false);
    }
    pane.findPaneOfTypeByID("trigger", ButtonImage.class).setText(new TranslationTextComponent(setting));
}
Also used : ISettingsModuleView(com.minecolonies.api.colony.buildings.modules.settings.ISettingsModuleView) Window(com.ldtteam.blockout.views.Window) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ISettingKey(com.minecolonies.api.colony.buildings.modules.settings.ISettingKey) Pane(com.ldtteam.blockout.Pane) View(com.ldtteam.blockout.views.View) Text(com.ldtteam.blockout.controls.Text) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Dist(net.minecraftforge.api.distmarker.Dist) Loader(com.ldtteam.blockout.Loader) List(java.util.List) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) ToolModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.ToolModuleView) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) ButtonImage(com.ldtteam.blockout.controls.ButtonImage) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text)

Aggregations

Pane (com.ldtteam.blockout.Pane)64 ScrollingList (com.ldtteam.blockout.views.ScrollingList)40 Text (com.ldtteam.blockout.controls.Text)26 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)25 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)20 ItemStack (net.minecraft.item.ItemStack)13 Button (com.ldtteam.blockout.controls.Button)10 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)10 NotNull (org.jetbrains.annotations.NotNull)9 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)8 ArrayList (java.util.ArrayList)8 ItemStorage (com.minecolonies.api.crafting.ItemStorage)6 Tuple (com.minecolonies.api.util.Tuple)6 BlockPos (net.minecraft.util.math.BlockPos)6 List (java.util.List)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)5 Skill (com.minecolonies.api.entity.citizen.Skill)4 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)4 MarkBuildingDirtyMessage (com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)4 TileEntity (net.minecraft.tileentity.TileEntity)4