Search in sources :

Example 1 with GuiQIOFrequencyTab

use of mekanism.client.gui.element.tab.GuiQIOFrequencyTab in project Mekanism by mekanism.

the class GuiQIOFilterHandler method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiQIOFrequencyTab(this, tile));
    addButton(new GuiInnerScreen(this, 9, 16, imageWidth - 18, 12, () -> {
        List<ITextComponent> list = new ArrayList<>();
        QIOFrequency freq = tile.getQIOFrequency();
        if (freq == null) {
            list.add(MekanismLang.NO_FREQUENCY.translate());
        } else {
            list.add(MekanismLang.FREQUENCY.translate(freq.getKey()));
        }
        return list;
    }).tooltip(() -> {
        List<ITextComponent> list = new ArrayList<>();
        QIOFrequency freq = tile.getQIOFrequency();
        if (freq != null) {
            list.add(MekanismLang.QIO_ITEMS_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemCount()), TextUtils.format(freq.getTotalItemCountCapacity())));
            list.add(MekanismLang.QIO_TYPES_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemTypes(true)), TextUtils.format(freq.getTotalItemTypeCapacity())));
        }
        return list;
    }));
    // Filter holder
    addButton(new GuiElementHolder(this, 9, 30, 144, 68));
    // new filter button border
    addButton(new GuiElementHolder(this, 9, 98, 144, 22));
    addButton(new TranslationButton(this, 10, 99, 142, 20, MekanismLang.BUTTON_NEW_FILTER, () -> addWindow(new GuiQIOFilerSelect(this, tile))));
    scrollBar = addButton(new GuiScrollBar(this, 153, 30, 90, () -> tile.getFilters().size(), () -> FILTER_COUNT));
    // 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 MovableFilterButton(this, 10, 31 + i * 22, 142, 22, i, scrollBar::getCurrentSelection, tile::getFilters, index -> {
            if (index > 0) {
                Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.MOVE_FILTER_UP, tile, index));
            }
        }, index -> {
            if (index < tile.getFilters().size() - 1) {
                Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.MOVE_FILTER_DOWN, tile, index));
            }
        }, this::onClick, filter -> {
            List<ItemStack> list = new ArrayList<>();
            if (filter != null) {
                if (filter instanceof IItemStackFilter) {
                    list.add(((IItemStackFilter<?>) filter).getItemStack());
                } else if (filter instanceof ITagFilter) {
                    String name = ((ITagFilter<?>) filter).getTagName();
                    if (name != null && !name.isEmpty()) {
                        list.addAll(TagCache.getItemTagStacks(((ITagFilter<?>) filter).getTagName()));
                    }
                } else if (filter instanceof IModIDFilter) {
                    list.addAll(TagCache.getModIDStacks(((IModIDFilter<?>) filter).getModID(), false));
                }
            }
            return list;
        }));
    }
}
Also used : EnumColor(mekanism.api.text.EnumColor) TextUtils(mekanism.common.util.text.TextUtils) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) QIOTagFilter(mekanism.common.content.qio.filter.QIOTagFilter) GuiQIOTagFilter(mekanism.client.gui.element.window.filter.qio.GuiQIOTagFilter) ArrayList(java.util.ArrayList) QIOItemStackFilter(mekanism.common.content.qio.filter.QIOItemStackFilter) ITextComponent(net.minecraft.util.text.ITextComponent) ItemStack(net.minecraft.item.ItemStack) GuiQIOFrequencyTab(mekanism.client.gui.element.tab.GuiQIOFrequencyTab) QIOFrequency(mekanism.common.content.qio.QIOFrequency) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) Nonnull(javax.annotation.Nonnull) MovableFilterButton(mekanism.client.gui.element.button.MovableFilterButton) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TileEntityQIOFilterHandler(mekanism.common.tile.qio.TileEntityQIOFilterHandler) TranslationButton(mekanism.client.gui.element.button.TranslationButton) Mekanism(mekanism.common.Mekanism) PlayerInventory(net.minecraft.entity.player.PlayerInventory) GuiQIOItemStackFilter(mekanism.client.gui.element.window.filter.qio.GuiQIOItemStackFilter) ITagFilter(mekanism.common.content.filter.ITagFilter) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) List(java.util.List) IItemStackFilter(mekanism.common.content.filter.IItemStackFilter) IModIDFilter(mekanism.common.content.filter.IModIDFilter) MekanismTileContainer(mekanism.common.inventory.container.tile.MekanismTileContainer) GuiInteraction(mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction) QIOModIDFilter(mekanism.common.content.qio.filter.QIOModIDFilter) MekanismLang(mekanism.common.MekanismLang) IFilter(mekanism.common.content.filter.IFilter) GuiQIOModIDFilter(mekanism.client.gui.element.window.filter.qio.GuiQIOModIDFilter) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile) TagCache(mekanism.common.base.TagCache) TranslationButton(mekanism.client.gui.element.button.TranslationButton) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) GuiQIOFrequencyTab(mekanism.client.gui.element.tab.GuiQIOFrequencyTab) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) MovableFilterButton(mekanism.client.gui.element.button.MovableFilterButton) ITagFilter(mekanism.common.content.filter.ITagFilter) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) IItemStackFilter(mekanism.common.content.filter.IItemStackFilter) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) ArrayList(java.util.ArrayList) List(java.util.List) IModIDFilter(mekanism.common.content.filter.IModIDFilter) QIOFrequency(mekanism.common.content.qio.QIOFrequency)

Example 2 with GuiQIOFrequencyTab

use of mekanism.client.gui.element.tab.GuiQIOFrequencyTab in project Mekanism by mekanism.

the class GuiQIODriveArray method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiQIOFrequencyTab(this, tile));
    addButton(new GuiQIOFrequencyDataScreen(this, 15, 19, imageWidth - 32, 46, () -> tile.getFrequency(FrequencyType.QIO)));
}
Also used : GuiQIOFrequencyDataScreen(mekanism.client.gui.element.custom.GuiQIOFrequencyDataScreen) GuiQIOFrequencyTab(mekanism.client.gui.element.tab.GuiQIOFrequencyTab)

Example 3 with GuiQIOFrequencyTab

use of mekanism.client.gui.element.tab.GuiQIOFrequencyTab in project Mekanism by mekanism.

the class GuiQIORedstoneAdapter method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiQIOFrequencyTab(this, tile));
    addButton(new GuiSlot(SlotType.NORMAL, this, 7, 30).setRenderHover(true)).setGhostHandler((IGhostItemConsumer) ingredient -> {
        Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteractionItem.QIO_REDSTONE_ADAPTER_STACK, tile, StackUtils.size((ItemStack) ingredient, 1)));
        minecraft.getSoundManager().play(SimpleSound.forUI(MekanismSounds.BEEP.get(), 1.0F));
    });
    addButton(new GuiInnerScreen(this, 7, 16, imageWidth - 15, 12, () -> {
        List<ITextComponent> list = new ArrayList<>();
        QIOFrequency freq = tile.getQIOFrequency();
        if (freq == null) {
            list.add(MekanismLang.NO_FREQUENCY.translate());
        } else {
            list.add(MekanismLang.FREQUENCY.translate(freq.getKey()));
        }
        return list;
    }).tooltip(() -> {
        List<ITextComponent> list = new ArrayList<>();
        QIOFrequency freq = tile.getQIOFrequency();
        if (freq != null) {
            list.add(MekanismLang.QIO_ITEMS_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemCount()), TextUtils.format(freq.getTotalItemCountCapacity())));
            list.add(MekanismLang.QIO_TYPES_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemTypes(true)), TextUtils.format(freq.getTotalItemTypeCapacity())));
        }
        return list;
    }));
    addButton(new GuiInnerScreen(this, 27, 30, imageWidth - 27 - 8, 54, () -> {
        List<ITextComponent> list = new ArrayList<>();
        list.add(!tile.getItemType().isEmpty() ? tile.getItemType().getStack().getHoverName() : MekanismLang.QIO_ITEM_TYPE_UNDEFINED.translate());
        list.add(MekanismLang.QIO_TRIGGER_COUNT.translate(TextUtils.format(tile.getCount())));
        if (!tile.getItemType().isEmpty() && tile.getQIOFrequency() != null) {
            list.add(MekanismLang.QIO_STORED_COUNT.translate(TextUtils.format(tile.getStoredCount())));
        }
        return list;
    }).clearFormat());
    text = addButton(new GuiTextField(this, 29, 70, imageWidth - 39, 12));
    text.setMaxStringLength(10);
    text.setInputValidator(InputValidator.DIGIT);
    text.setFocused(true);
    text.configureDigitalInput(this::setCount);
}
Also used : GuiTextField(mekanism.client.gui.element.text.GuiTextField) EnumColor(mekanism.api.text.EnumColor) TextUtils(mekanism.common.util.text.TextUtils) SimpleSound(net.minecraft.client.audio.SimpleSound) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) MekanismSounds(mekanism.common.registries.MekanismSounds) ArrayList(java.util.ArrayList) ITextComponent(net.minecraft.util.text.ITextComponent) InputValidator(mekanism.common.util.text.InputValidator) ItemStack(net.minecraft.item.ItemStack) IGhostItemConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostItemConsumer) GuiQIOFrequencyTab(mekanism.client.gui.element.tab.GuiQIOFrequencyTab) QIOFrequency(mekanism.common.content.qio.QIOFrequency) GuiInteractionItem(mekanism.common.network.to_server.PacketGuiInteract.GuiInteractionItem) TileEntityQIORedstoneAdapter(mekanism.common.tile.qio.TileEntityQIORedstoneAdapter) Nonnull(javax.annotation.Nonnull) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) Mekanism(mekanism.common.Mekanism) PlayerInventory(net.minecraft.entity.player.PlayerInventory) StackUtils(mekanism.common.util.StackUtils) SlotType(mekanism.client.gui.element.slot.SlotType) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) List(java.util.List) MekanismTileContainer(mekanism.common.inventory.container.tile.MekanismTileContainer) GuiInteraction(mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction) MekanismLang(mekanism.common.MekanismLang) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) GuiQIOFrequencyTab(mekanism.client.gui.element.tab.GuiQIOFrequencyTab) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) GuiTextField(mekanism.client.gui.element.text.GuiTextField) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) QIOFrequency(mekanism.common.content.qio.QIOFrequency)

Example 4 with GuiQIOFrequencyTab

use of mekanism.client.gui.element.tab.GuiQIOFrequencyTab in project Mekanism by mekanism.

the class GuiPortableQIODashboard method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiQIOFrequencyTab(this, menu.getHand()));
}
Also used : GuiQIOFrequencyTab(mekanism.client.gui.element.tab.GuiQIOFrequencyTab)

Example 5 with GuiQIOFrequencyTab

use of mekanism.client.gui.element.tab.GuiQIOFrequencyTab in project Mekanism by mekanism.

the class GuiQIODashboard method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiQIOFrequencyTab(this, tile));
    addButton(new GuiSecurityTab(this, tile));
}
Also used : GuiSecurityTab(mekanism.client.gui.element.tab.GuiSecurityTab) GuiQIOFrequencyTab(mekanism.client.gui.element.tab.GuiQIOFrequencyTab)

Aggregations

GuiQIOFrequencyTab (mekanism.client.gui.element.tab.GuiQIOFrequencyTab)5 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Nonnull (javax.annotation.Nonnull)2 EnumColor (mekanism.api.text.EnumColor)2 GuiMekanismTile (mekanism.client.gui.GuiMekanismTile)2 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)2 Mekanism (mekanism.common.Mekanism)2 MekanismLang (mekanism.common.MekanismLang)2 QIOFrequency (mekanism.common.content.qio.QIOFrequency)2 MekanismTileContainer (mekanism.common.inventory.container.tile.MekanismTileContainer)2 PacketGuiInteract (mekanism.common.network.to_server.PacketGuiInteract)2 GuiInteraction (mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction)2 TextUtils (mekanism.common.util.text.TextUtils)2 PlayerInventory (net.minecraft.entity.player.PlayerInventory)2 ItemStack (net.minecraft.item.ItemStack)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 GuiElementHolder (mekanism.client.gui.element.GuiElementHolder)1 MovableFilterButton (mekanism.client.gui.element.button.MovableFilterButton)1