Search in sources :

Example 21 with Text

use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.

the class WindowBuildDecoration method updateResourceList.

public void updateResourceList() {
    final ScrollingList recourseList = findPaneOfTypeByID(LIST_RESOURCES, ScrollingList.class);
    recourseList.enable();
    recourseList.show();
    final List<ItemStorage> tempRes = new ArrayList<>(resources.values());
    // Creates a dataProvider for the unemployed recourseList.
    recourseList.setDataProvider(new ScrollingList.DataProvider() {

        /**
         * The number of rows of the list.
         * @return the number.
         */
        @Override
        public int getElementCount() {
            return tempRes.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) {
            final ItemStorage resource = tempRes.get(index);
            final Text resourceLabel = rowPane.findPaneOfTypeByID(RESOURCE_NAME, Text.class);
            final Text quantityLabel = rowPane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class);
            resourceLabel.setText(resource.getItemStack().getHoverName().getString());
            quantityLabel.setText(Integer.toString(resource.getAmount()));
            resourceLabel.setColors(WHITE);
            quantityLabel.setColors(WHITE);
            final ItemStack itemIcon = new ItemStack(resource.getItem(), 1);
            itemIcon.setTag(resource.getItemStack().getTag());
            rowPane.findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(itemIcon);
        }
    });
}
Also used : Text(com.ldtteam.blockout.controls.Text) ItemStack(net.minecraft.item.ItemStack) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 22 with Text

use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.

the class WindowAssignCitizen method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    updateCitizens();
    citizenList.enable();
    citizenList.show();
    // Creates a dataProvider for the homeless 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 ICitizenDataView citizen = citizens.get(index);
            final Button done = rowPane.findPaneOfTypeByID(CITIZEN_DONE, Button.class);
            final BlockPos home = citizen.getHomeBuilding();
            final BlockPos work = citizen.getWorkBuilding();
            boolean assign = false;
            if (home != null && home.equals(building.getPosition())) {
                done.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonunassign"));
            } else {
                assign = true;
                done.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonassign"));
            }
            final Text citizenLabel = rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Text.class);
            citizenLabel.setText(citizen.getName());
            if (assign) {
                citizenLabel.setColors(YELLOW);
            } else {
                citizenLabel.setColors(DARKGREEN);
            }
            String workString = "";
            double newDistance = 0;
            if (work != null) {
                newDistance = BlockPosUtil.getDistance2D(work, building.getPosition());
                workString = " " + new TranslationTextComponent("com.minecolonies.coremod.gui.home.new", newDistance).getString();
            }
            String homeString = new TranslationTextComponent("com.minecolonies.coremod.gui.home.homeless").getString();
            boolean better = false;
            boolean badCurrentLiving = true;
            if (home != null) {
                if (work != null) {
                    final double oldDistance = BlockPosUtil.getDistance2D(work, home);
                    homeString = new TranslationTextComponent("com.minecolonies.coremod.gui.home.currently", oldDistance).getString();
                    better = newDistance < oldDistance;
                    if (oldDistance < FAR_DISTANCE_THRESHOLD) {
                        badCurrentLiving = false;
                    }
                } else {
                    homeString = new TranslationTextComponent("com.minecolonies.coremod.gui.home.currently", home.getX(), home.getY(), home.getZ()).getString();
                }
            }
            final Text newLivingLabel = rowPane.findPaneOfTypeByID(CITIZEN_JOB, Text.class);
            if (citizen.getJobView() != null) {
                newLivingLabel.setText(new TranslationTextComponent(citizen.getJobView().getEntry().getTranslationKey()).getString() + ":" + workString);
                if (better) {
                    newLivingLabel.setColors(DARKGREEN);
                }
            }
            final Text currentLivingLabel = rowPane.findPaneOfTypeByID(CITIZEN_LIVING, Text.class);
            if (assign) {
                currentLivingLabel.setText(homeString);
                if (badCurrentLiving) {
                    currentLivingLabel.setColors(RED);
                }
            } else {
                currentLivingLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.home.liveshere"));
            }
            if ((colony.isManualHousing() || building.getHiringMode() == HiringMode.MANUAL) && !(building.getHiringMode() == HiringMode.AUTO) && (!assign || building.getResidents().size() < building.getMax())) {
                done.enable();
            } else {
                done.disable();
            }
        }
    });
}
Also used : Button(com.ldtteam.blockout.controls.Button) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) Text(com.ldtteam.blockout.controls.Text) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane)

Example 23 with Text

use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.

the class WindowPermissionsPage method addRank.

/**
 * Read the text input with the name of the rank to be added
 * If the chosen name is valid, send a message to the server, hide the error label and empty the input
 * else show the error label
 */
private void addRank() {
    final Text label = findPaneOfTypeByID(TOWNHALL_ADD_RANK_ERROR, Text.class);
    final TextField input = findPaneOfTypeByID(INPUT_ADDRANK_NAME, TextField.class);
    if (isValidRankname(input.getText())) {
        Network.getNetwork().sendToServer(new PermissionsMessage.AddRank(building.getColony(), input.getText()));
        input.setText("");
        label.hide();
    } else {
        label.show();
    }
}
Also used : PermissionsMessage(com.minecolonies.coremod.network.messages.PermissionsMessage) TextField(com.ldtteam.blockout.controls.TextField) Text(com.ldtteam.blockout.controls.Text)

Example 24 with Text

use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.

the class WindowPermissionsPage method onOpened.

/**
 * Executed when <code>WindowTownHall</code> is opened. Does tasks like setting buttons.
 */
@Override
public void onOpened() {
    super.onOpened();
    fillUserList();
    fillFreeBlockList();
    fillRanks();
    fillPermissionList();
    PlayerEntity player = Minecraft.getInstance().player;
    Text label = findPaneOfTypeByID(TOWNHALL_PERMISSION_ERROR, Text.class);
    Button button = findPaneOfTypeByID(BUTTON_ADD_PLAYER, Button.class);
    if (building.getColony().getPermissions().hasPermission(player, Action.EDIT_PERMISSIONS)) {
        label.hide();
        button.setEnabled(true);
    } else {
        label.show();
        button.setEnabled(false);
    }
}
Also used : Button(com.ldtteam.blockout.controls.Button) Text(com.ldtteam.blockout.controls.Text) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 25 with Text

use of com.ldtteam.blockout.controls.Text in project minecolonies by Minecolonies.

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

Text (com.ldtteam.blockout.controls.Text)31 Pane (com.ldtteam.blockout.Pane)15 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)13 ItemStack (net.minecraft.item.ItemStack)12 ScrollingList (com.ldtteam.blockout.views.ScrollingList)11 Button (com.ldtteam.blockout.controls.Button)9 BuildingBuilderResource (com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource)8 ItemIcon (com.ldtteam.blockout.controls.ItemIcon)6 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)6 StringTextComponent (net.minecraft.util.text.StringTextComponent)6 ButtonImage (com.ldtteam.blockout.controls.ButtonImage)5 Image (com.ldtteam.blockout.controls.Image)5 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)4 ItemStorage (com.minecolonies.api.crafting.ItemStorage)4 View (com.ldtteam.blockout.views.View)3 ITextComponent (net.minecraft.util.text.ITextComponent)3 NotNull (org.jetbrains.annotations.NotNull)3 Loader (com.ldtteam.blockout.Loader)2 TextField (com.ldtteam.blockout.controls.TextField)2 Box (com.ldtteam.blockout.views.Box)2