Search in sources :

Example 1 with Button

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

the class WindowPermissionsPage method onRankButtonClicked.

/**
 * Change to currently selected rank to the one belonging to the clicked button
 *
 * @param button the clicked button
 */
private void onRankButtonClicked(@NotNull final Button button) {
    final int rankId = rankButtonList.getListElementIndexByPane(button);
    final Rank rank = allRankList.get(rankId);
    if (rank != null) {
        actionsRank = rank;
        button.setEnabled(false);
        findPaneOfTypeByID(BUTTON_REMOVE_RANK, Button.class).setEnabled(!actionsRank.isInitial());
        findPaneOfTypeByID(TOWNHALL_PERM_MANAGEMENT, SwitchView.class).setView(TOWNHALL_PERM_LIST);
    }
}
Also used : Button(com.ldtteam.blockout.controls.Button) SwitchView(com.ldtteam.blockout.views.SwitchView) Rank(com.minecolonies.api.colony.permissions.Rank)

Example 2 with Button

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

the class WarehouseOptionsModuleWindow method updateResourcePane.

/**
 * Update one row pad with its resource informations.
 */
private void updateResourcePane() {
    final BuildingBuilderResource resource = new BuildingBuilderResource(new ItemStack(Blocks.EMERALD_BLOCK, 1), 1);
    final int amountToSet;
    final PlayerInventory inventory = this.mc.player.inventory;
    final boolean isCreative = this.mc.player.isCreative();
    if (isCreative) {
        amountToSet = resource.getAmount();
    } else {
        amountToSet = InventoryUtils.getItemCountInItemHandler(new InvWrapper(inventory), resource.getItem());
    }
    resource.setPlayerAmount(amountToSet);
    final Text resourceLabel = findPaneOfTypeByID(RESOURCE_NAME, Text.class);
    final Text resourceMissingLabel = findPaneOfTypeByID(RESOURCE_MISSING, Text.class);
    final Text neededLabel = findPaneOfTypeByID(RESOURCE_AVAILABLE_NEEDED, Text.class);
    final Button addButton = findPaneOfTypeByID(RESOURCE_ADD, Button.class);
    BuildingBuilderResource.RessourceAvailability availability = resource.getAvailabilityStatus();
    if (module.getStorageUpgradeLevel() >= BuildingWareHouse.MAX_STORAGE_UPGRADE || buildingView.getBuildingLevel() < buildingView.getBuildingMaxLevel() || lockUpgrade) {
        availability = BuildingBuilderResource.RessourceAvailability.NOT_NEEDED;
    }
    findPaneOfTypeByID(UPGRADE_PROGRESS_LABEL, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.xofz", module.getStorageUpgradeLevel(), BuildingWareHouse.MAX_STORAGE_UPGRADE));
    switch(availability) {
        case DONT_HAVE:
            addButton.disable();
            resourceLabel.setColors(RED);
            resourceMissingLabel.setColors(RED);
            neededLabel.setColors(RED);
            break;
        case NEED_MORE:
            addButton.enable();
            resourceLabel.setColors(RED);
            resourceMissingLabel.setColors(RED);
            neededLabel.setColors(RED);
            break;
        case HAVE_ENOUGH:
            addButton.enable();
            resourceLabel.setColors(DARKGREEN);
            resourceMissingLabel.setColors(DARKGREEN);
            neededLabel.setColors(DARKGREEN);
            break;
        case NOT_NEEDED:
        default:
            addButton.disable();
            resourceLabel.setColors(BLACK);
            resourceMissingLabel.setColors(BLACK);
            neededLabel.setColors(BLACK);
            if (buildingView.getBuildingLevel() < buildingView.getBuildingMaxLevel()) {
                resourceLabel.hide();
                resourceMissingLabel.hide();
                neededLabel.hide();
                addButton.setText(new StringTextComponent("X").setStyle(Style.EMPTY.withColor(TextFormatting.DARK_RED)));
                PaneBuilders.tooltipBuilder().append(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.upgrade.disabled.1", buildingView.getBuildingMaxLevel())).appendNL(new TranslationTextComponent("com.minecolonies.coremod.gui.warehouse.upgrade.disabled.2", buildingView.getBuildingMaxLevel())).hoverPane(addButton).build();
            }
            break;
    }
    resourceLabel.setText(resource.getName());
    final int missing = resource.getMissingFromPlayer();
    if (missing < 0) {
        resourceMissingLabel.setText(Integer.toString(missing));
    } else {
        resourceMissingLabel.clearText();
    }
    neededLabel.setText(resource.getAvailable() + " / " + resource.getAmount());
    findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class).setText(Integer.toString(resource.getAmount() - resource.getAvailable()));
    if (buildingView.getBuildingLevel() >= buildingView.getBuildingMaxLevel()) {
        final ItemStack resourceStackOfOne = new ItemStack(resource.getItem(), 1);
        resourceStackOfOne.setTag(resource.getItemStack().getTag());
        findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(resourceStackOfOne);
    }
}
Also used : Button(com.ldtteam.blockout.controls.Button) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) ItemIcon(com.ldtteam.blockout.controls.ItemIcon) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Text(com.ldtteam.blockout.controls.Text) StringTextComponent(net.minecraft.util.text.StringTextComponent) PlayerInventory(net.minecraft.entity.player.PlayerInventory) BuildingBuilderResource(com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource) ItemStack(net.minecraft.item.ItemStack)

Example 3 with Button

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

the class WindowHutCitizen method refreshView.

/**
 * Refresh the view.
 */
private void refreshView() {
    final Button buttonAssign = findPaneOfTypeByID(BUTTON_ASSIGN, Button.class);
    final int sparePlaces = building.getBuildingLevel() - building.getResidents().size();
    buttonAssign.setText(LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_HOME_ASSIGN, sparePlaces));
    buttonAssign.setEnabled(sparePlaces > 0 && building.getColony().isManualHousing());
    citizen.refreshElementPanes();
}
Also used : Button(com.ldtteam.blockout.controls.Button)

Example 4 with Button

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

the class WindowBuilderResModule method updateResourcePane.

/**
 * Update one row pad with its resource informations.
 *
 * @param index   index in the list of resources.
 * @param rowPane The Pane to use to display the information.
 */
private void updateResourcePane(final int index, @NotNull final Pane rowPane) {
    final BuildingBuilderResource resource = resources.get(index);
    final Text resourceLabel = rowPane.findPaneOfTypeByID(RESOURCE_NAME, Text.class);
    final Text resourceMissingLabel = rowPane.findPaneOfTypeByID(RESOURCE_MISSING, Text.class);
    final Text neededLabel = rowPane.findPaneOfTypeByID(RESOURCE_AVAILABLE_NEEDED, Text.class);
    final Button addButton = rowPane.findPaneOfTypeByID(RESOURCE_ADD, Button.class);
    switch(resource.getAvailabilityStatus()) {
        case DONT_HAVE:
            addButton.disable();
            resourceLabel.setColors(RED);
            resourceMissingLabel.setColors(RED);
            neededLabel.setColors(RED);
            break;
        case NEED_MORE:
            addButton.enable();
            resourceLabel.setColors(ORANGE);
            resourceMissingLabel.setColors(ORANGE);
            neededLabel.setColors(ORANGE);
            break;
        case HAVE_ENOUGH:
            addButton.enable();
            resourceLabel.setColors(DARKGREEN);
            resourceMissingLabel.setColors(DARKGREEN);
            neededLabel.setColors(DARKGREEN);
            break;
        case NOT_NEEDED:
        default:
            addButton.disable();
            resourceLabel.setColors(BLACK);
            resourceMissingLabel.setColors(BLACK);
            neededLabel.setColors(BLACK);
            break;
    }
    // position the addResource Button to the right
    final int buttonX = rowPane.getWidth() - addButton.getWidth() - (rowPane.getHeight() - addButton.getHeight()) / 2;
    final int buttonY = rowPane.getHeight() - addButton.getHeight() - 2;
    addButton.setPosition(buttonX, buttonY);
    resourceLabel.setText(resource.getName());
    final int missing = resource.getMissingFromPlayer();
    if (missing < 0) {
        resourceMissingLabel.setText(Integer.toString(missing));
    } else {
        resourceMissingLabel.clearText();
    }
    neededLabel.setText(resource.getAvailable() + " / " + resource.getAmount());
    rowPane.findPaneOfTypeByID(RESOURCE_ID, Text.class).setText(Integer.toString(index));
    rowPane.findPaneOfTypeByID(RESOURCE_QUANTITY_MISSING, Text.class).setText(Integer.toString(resource.getAmount() - resource.getAvailable()));
    final ItemStack stack = new ItemStack(resource.getItem(), 1);
    stack.setTag(resource.getItemStack().getTag());
    rowPane.findPaneOfTypeByID(RESOURCE_ICON, ItemIcon.class).setItem(stack);
}
Also used : Button(com.ldtteam.blockout.controls.Button) ItemIcon(com.ldtteam.blockout.controls.ItemIcon) Text(com.ldtteam.blockout.controls.Text) BuildingBuilderResource(com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource) ItemStack(net.minecraft.item.ItemStack)

Example 5 with Button

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

the class WindowMineGuardModule method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    guardsList = findPaneOfTypeByID(LIST_GUARDS, ScrollingList.class);
    guardsList.setDataProvider(new ScrollingList.DataProvider() {

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

        @Override
        public void updateElement(final int i, final Pane pane) {
            final ICitizenDataView citizen = guardsInfo.get(i);
            if (citizen != null) {
                final IBuildingView building = buildingView.getColony().getBuilding(citizen.getWorkBuilding());
                if (building instanceof AbstractBuildingGuards.View) {
                    pane.findPaneOfTypeByID("guardName", Text.class).setText(citizen.getName());
                    final AbstractBuildingGuards.View guardbuilding = (AbstractBuildingGuards.View) building;
                    final Button button = pane.findPaneOfTypeByID("assignGuard", Button.class);
                    if (guardbuilding.getMinePos() == null) {
                        button.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonassign"));
                        if (assignedGuards >= getMaxGuards()) {
                            button.setEnabled(false);
                        } else {
                            button.setEnabled(true);
                        }
                    } else if (guardbuilding.getMinePos().equals(buildingView.getPosition())) {
                        button.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonunassign"));
                    } else {
                        button.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.hiring.buttonassign"));
                        button.setEnabled(false);
                    }
                }
            } else {
                final Button button = pane.findPaneOfTypeByID("assignGuard", Button.class);
                button.setEnabled(false);
            }
        }
    });
}
Also used : AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) Button(com.ldtteam.blockout.controls.Button) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) Pane(com.ldtteam.blockout.Pane) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) ICitizenDataView(com.minecolonies.api.colony.ICitizenDataView) SettingsModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.SettingsModuleView)

Aggregations

Button (com.ldtteam.blockout.controls.Button)19 Text (com.ldtteam.blockout.controls.Text)9 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)9 Pane (com.ldtteam.blockout.Pane)6 ScrollingList (com.ldtteam.blockout.views.ScrollingList)5 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)5 ItemIcon (com.ldtteam.blockout.controls.ItemIcon)4 SwitchView (com.ldtteam.blockout.views.SwitchView)4 BuildingBuilderResource (com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource)4 ItemStack (net.minecraft.item.ItemStack)4 StringTextComponent (net.minecraft.util.text.StringTextComponent)4 TextBuilder (com.ldtteam.blockout.controls.AbstractTextBuilder.TextBuilder)2 DropDownList (com.ldtteam.blockout.views.DropDownList)2 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)2 JobEntry (com.minecolonies.api.colony.jobs.registry.JobEntry)2 Rank (com.minecolonies.api.colony.permissions.Rank)2 Skill (com.minecolonies.api.entity.citizen.Skill)2 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)2 SettingsModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.SettingsModuleView)2 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)2