Search in sources :

Example 1 with FilterButton

use of mekanism.client.gui.element.button.FilterButton in project Mekanism by mekanism.

the class GuiOredictionificator method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    // Filter holder
    addButton(new GuiElementHolder(this, 9, 17, 144, 68));
    // new filter button border
    addButton(new GuiElementHolder(this, 9, 85, 144, 22));
    scrollBar = addButton(new GuiScrollBar(this, 153, 17, 90, () -> tile.getFilters().size(), () -> FILTER_COUNT));
    addButton(new GuiProgress(() -> tile.didProcess, ProgressType.LARGE_RIGHT, this, 64, 119));
    addButton(new TranslationButton(this, 10, 86, 142, 20, MekanismLang.BUTTON_NEW_FILTER, () -> addWindow(GuiOredictionificatorFilter.create(this, tile))));
    // Add each of the buttons and then just change visibility state to match filter info
    for (int i = 0; i < FILTER_COUNT; i++) {
        addButton(new FilterButton(this, 10, 18 + i * 22, 142, 22, i, scrollBar::getCurrentSelection, tile::getFilters, this::onClick, filter -> {
            if (filter instanceof OredictionificatorItemFilter) {
                return Collections.singletonList(((OredictionificatorItemFilter) filter).getResult());
            }
            return Collections.emptyList();
        })).warning(WarningType.INVALID_OREDICTIONIFICATOR_FILTER, filter -> filter != null && !filter.hasFilter());
    }
    // While we track and show warnings on the slots themselves we also need to track the warning
    // for if any of the set filters have it even if one of them is not visible
    // Note: We add this after all the buttons have their warnings added so that it is further down the tracker
    // so the tracker can short circuit on this type of warning and not have to check all the filters if one of
    // the ones that are currently being shown has the warning
    trackWarning(WarningType.INVALID_OREDICTIONIFICATOR_FILTER, () -> tile.getFilters().stream().anyMatch(filter -> !filter.hasFilter()));
}
Also used : TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiOredictionificatorFilter(mekanism.client.gui.element.window.filter.GuiOredictionificatorFilter) GuiProgress(mekanism.client.gui.element.progress.GuiProgress) PlayerInventory(net.minecraft.entity.player.PlayerInventory) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) FilterButton(mekanism.client.gui.element.button.FilterButton) GuiConfigurableTile(mekanism.client.gui.GuiConfigurableTile) ITextComponent(net.minecraft.util.text.ITextComponent) WarningType(mekanism.client.gui.warning.WarningTracker.WarningType) OredictionificatorItemFilter(mekanism.common.content.oredictionificator.OredictionificatorItemFilter) ProgressType(mekanism.client.gui.element.progress.ProgressType) TileEntityOredictionificator(mekanism.common.tile.machine.TileEntityOredictionificator) MekanismTileContainer(mekanism.common.inventory.container.tile.MekanismTileContainer) MekanismLang(mekanism.common.MekanismLang) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) IFilter(mekanism.common.content.filter.IFilter) Collections(java.util.Collections) Nonnull(javax.annotation.Nonnull) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiProgress(mekanism.client.gui.element.progress.GuiProgress) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) FilterButton(mekanism.client.gui.element.button.FilterButton) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) OredictionificatorItemFilter(mekanism.common.content.oredictionificator.OredictionificatorItemFilter)

Aggregations

MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 Collections (java.util.Collections)1 Nonnull (javax.annotation.Nonnull)1 GuiConfigurableTile (mekanism.client.gui.GuiConfigurableTile)1 GuiElementHolder (mekanism.client.gui.element.GuiElementHolder)1 FilterButton (mekanism.client.gui.element.button.FilterButton)1 TranslationButton (mekanism.client.gui.element.button.TranslationButton)1 GuiProgress (mekanism.client.gui.element.progress.GuiProgress)1 ProgressType (mekanism.client.gui.element.progress.ProgressType)1 GuiScrollBar (mekanism.client.gui.element.scroll.GuiScrollBar)1 GuiOredictionificatorFilter (mekanism.client.gui.element.window.filter.GuiOredictionificatorFilter)1 WarningType (mekanism.client.gui.warning.WarningTracker.WarningType)1 MekanismLang (mekanism.common.MekanismLang)1 IFilter (mekanism.common.content.filter.IFilter)1 OredictionificatorItemFilter (mekanism.common.content.oredictionificator.OredictionificatorItemFilter)1 MekanismTileContainer (mekanism.common.inventory.container.tile.MekanismTileContainer)1 TileEntityOredictionificator (mekanism.common.tile.machine.TileEntityOredictionificator)1 PlayerInventory (net.minecraft.entity.player.PlayerInventory)1 ITextComponent (net.minecraft.util.text.ITextComponent)1