Search in sources :

Example 1 with GuiInnerScreen

use of mekanism.client.gui.element.GuiInnerScreen 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 GuiInnerScreen

use of mekanism.client.gui.element.GuiInnerScreen in project Mekanism by mekanism.

the class GuiQIOItemViewer method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    int slotsY = MekanismConfig.client.qioItemViewerSlotsY.get();
    getMinecraft().keyboardHandler.setSendRepeatsToGui(true);
    addButton(new GuiInnerScreen(this, 7, 15, imageWidth - 16, 12, () -> {
        List<ITextComponent> list = new ArrayList<>();
        FrequencyIdentity freq = getFrequency();
        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<>();
        if (getFrequency() != null) {
            list.add(MekanismLang.QIO_ITEMS_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(menu.getTotalItems()), TextUtils.format(menu.getCountCapacity())));
            list.add(MekanismLang.QIO_TYPES_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(menu.getTotalTypes()), TextUtils.format(menu.getTypeCapacity())));
        }
        return list;
    }));
    searchField = addButton(new GuiTextField(this, 50, 15 + 12 + 3, imageWidth - 50 - 10, 10));
    searchField.setOffset(0, -1);
    searchField.setInputValidator(this::isValidSearchChar);
    searchField.setResponder(menu::updateSearch);
    searchField.setMaxStringLength(50);
    searchField.setBackground(BackgroundType.ELEMENT_HOLDER);
    searchField.setVisible(true);
    searchField.setTextColor(0xFFFFFF);
    searchField.setFocused(true);
    addButton(new GuiSlotScroll(this, 7, QIOItemViewerContainer.SLOTS_START_Y, MekanismConfig.client.qioItemViewerSlotsX.get(), slotsY, menu::getQIOItemList, menu));
    addButton(new GuiDropdown<>(this, imageWidth - 9 - 54, QIOItemViewerContainer.SLOTS_START_Y + slotsY * 18 + 1, 41, ListSortType.class, menu::getSortType, menu::setSortType));
    addButton(new GuiDigitalIconToggle<>(this, imageWidth - 9 - 12, QIOItemViewerContainer.SLOTS_START_Y + slotsY * 18 + 1, 12, 12, SortDirection.class, menu::getSortDirection, menu::setSortDirection));
    addButton(new GuiResizeControls(this, (getMinecraft().getWindow().getGuiScaledHeight() / 2) - 20 - topPos, this::resize));
    craftingWindowTab = addButton(new GuiCraftingWindowTab(this, () -> craftingWindowTab, menu));
}
Also used : ListSortType(mekanism.common.inventory.container.QIOItemViewerContainer.ListSortType) GuiSlotScroll(mekanism.client.gui.element.scroll.GuiSlotScroll) FrequencyIdentity(mekanism.common.lib.frequency.Frequency.FrequencyIdentity) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) GuiTextField(mekanism.client.gui.element.text.GuiTextField) GuiResizeControls(mekanism.client.gui.element.custom.GuiResizeControls) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) SortDirection(mekanism.common.inventory.container.QIOItemViewerContainer.SortDirection) ArrayList(java.util.ArrayList) List(java.util.List) GuiCraftingWindowTab(mekanism.client.gui.element.tab.window.GuiCraftingWindowTab)

Example 3 with GuiInnerScreen

use of mekanism.client.gui.element.GuiInnerScreen in project Mekanism by mekanism.

the class GuiRobitMain method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiSecurityTab(this, robit, 120));
    addButton(GuiSideHolder.create(this, 176, 6, 106, false, false, SpecialColors.TAB_ROBIT_MENU));
    addButton(new GuiInnerScreen(this, 27, 16, 122, 56));
    addButton(new GuiHorizontalPowerBar(this, robit.getEnergyContainer(), 27, 74, 120));
    addButton(new MekanismImageButton(this, 6, 16, 18, getButtonLocation("home"), () -> {
        Mekanism.packetHandler.sendToServer(new PacketRobit(RobitPacketType.GO_HOME, robit));
        getMinecraft().setScreen(null);
    }, getOnHover(MekanismLang.ROBIT_TELEPORT)));
    renameButton = addButton(new MekanismImageButton(this, 6, 35, 18, getButtonLocation("rename"), () -> openWindow(new GuiRobitRename(this, 27, 16, robit), () -> renameButton), getOnHover(MekanismLang.ROBIT_RENAME)));
    skinButton = addButton(new MekanismImageButton(this, 6, 54, 18, getButtonLocation("skin"), () -> openWindow(new GuiRobitSkinSelect(this, 4, -12, robit), () -> skinButton), getOnHover(MekanismLang.ROBIT_SKIN_SELECT)));
    addButton(new MekanismImageButton(this, 152, 35, 18, getButtonLocation("drop"), () -> Mekanism.packetHandler.sendToServer(new PacketRobit(RobitPacketType.DROP_PICKUP, robit)), getOnHover(MekanismLang.ROBIT_TOGGLE_PICKUP)));
    addButton(new MekanismImageButton(this, 152, 54, 18, getButtonLocation("follow"), () -> Mekanism.packetHandler.sendToServer(new PacketRobit(RobitPacketType.FOLLOW, robit)), getOnHover(MekanismLang.ROBIT_TOGGLE_FOLLOW)));
    addButton(new MekanismImageButton(this, 179, 10, 18, getButtonLocation("main"), () -> {
    // Clicking main button doesn't do anything while already on the main GUI
    }, getOnHover(MekanismLang.ROBIT)));
    addButton(new MekanismImageButton(this, 179, 30, 18, getButtonLocation("crafting"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_CRAFTING, robit)), getOnHover(MekanismLang.ROBIT_CRAFTING)));
    addButton(new MekanismImageButton(this, 179, 50, 18, getButtonLocation("inventory"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_INVENTORY, robit)), getOnHover(MekanismLang.ROBIT_INVENTORY)));
    addButton(new MekanismImageButton(this, 179, 70, 18, getButtonLocation("smelting"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_SMELTING, robit)), getOnHover(MekanismLang.ROBIT_SMELTING)));
    addButton(new MekanismImageButton(this, 179, 90, 18, getButtonLocation("repair"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_REPAIR, robit)), getOnHover(MekanismLang.ROBIT_REPAIR)));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) GuiRobitSkinSelect(mekanism.client.gui.element.window.GuiRobitSkinSelect) PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) GuiSecurityTab(mekanism.client.gui.element.tab.GuiSecurityTab) GuiHorizontalPowerBar(mekanism.client.gui.element.bar.GuiHorizontalPowerBar) PacketRobit(mekanism.common.network.to_server.PacketRobit) GuiRobitRename(mekanism.client.gui.element.window.GuiRobitRename) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton)

Example 4 with GuiInnerScreen

use of mekanism.client.gui.element.GuiInnerScreen in project Mekanism by mekanism.

the class GuiResistiveHeater method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiInnerScreen(this, 48, 23, 80, 42, () -> Arrays.asList(MekanismLang.TEMPERATURE.translate(MekanismUtils.getTemperatureDisplay(tile.getTotalTemperature(), TemperatureUnit.KELVIN, true)), MekanismLang.RESISTIVE_HEATER_USAGE.translate(EnergyDisplay.of(tile.getEnergyContainer().getEnergyPerTick())))).clearFormat());
    addButton(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 164, 15));
    addButton(new GuiEnergyTab(this, tile.getEnergyContainer()));
    addButton(new GuiHeatTab(this, () -> {
        ITextComponent environment = MekanismUtils.getTemperatureDisplay(tile.getLastEnvironmentLoss(), TemperatureUnit.KELVIN, false);
        return Collections.singletonList(MekanismLang.DISSIPATED_RATE.translate(environment));
    }));
    energyUsageField = addButton(new GuiTextField(this, 50, 51, 76, 12));
    energyUsageField.setText(energyUsageField.getText());
    energyUsageField.setMaxStringLength(7);
    energyUsageField.setInputValidator(InputValidator.DIGIT);
    energyUsageField.configureDigitalInput(this::setEnergyUsage);
    energyUsageField.setFocused(true);
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) ITextComponent(net.minecraft.util.text.ITextComponent) GuiVerticalPowerBar(mekanism.client.gui.element.bar.GuiVerticalPowerBar) GuiEnergyTab(mekanism.client.gui.element.tab.GuiEnergyTab) GuiTextField(mekanism.client.gui.element.text.GuiTextField) GuiHeatTab(mekanism.client.gui.element.tab.GuiHeatTab)

Example 5 with GuiInnerScreen

use of mekanism.client.gui.element.GuiInnerScreen in project Mekanism by mekanism.

the class GuiSPS method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiGasGauge(() -> tile.getMultiblock().inputTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 7, 17));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().outputTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 151, 17));
    addButton(new GuiInnerScreen(this, 27, 17, 122, 60, () -> {
        List<ITextComponent> list = new ArrayList<>();
        SPSMultiblockData multiblock = tile.getMultiblock();
        boolean active = multiblock.lastProcessed > 0;
        list.add(MekanismLang.STATUS.translate(active ? MekanismLang.ACTIVE : MekanismLang.IDLE));
        if (active) {
            list.add(MekanismLang.SPS_ENERGY_INPUT.translate(EnergyDisplay.of(multiblock.lastReceivedEnergy)));
            list.add(MekanismLang.PROCESS_RATE_MB.translate(multiblock.getProcessRate()));
        }
        return list;
    }).jeiCategories(MekanismBlocks.SPS_CASING.getRegistryName()));
    addButton(new GuiDynamicHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return MekanismLang.PROGRESS.translate(TextUtils.getPercent(tile.getMultiblock().getScaledProgress()));
        }

        @Override
        public double getLevel() {
            return Math.min(1, tile.getMultiblock().getScaledProgress());
        }
    }, 7, 79, 160, ColorFunction.scale(Color.rgbi(60, 45, 74), Color.rgbi(100, 30, 170))));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) GuiDynamicHorizontalRateBar(mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar) SPSMultiblockData(mekanism.common.content.sps.SPSMultiblockData)

Aggregations

GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)26 ArrayList (java.util.ArrayList)12 GuiEnergyTab (mekanism.client.gui.element.tab.GuiEnergyTab)12 ITextComponent (net.minecraft.util.text.ITextComponent)11 List (java.util.List)10 GuiVerticalPowerBar (mekanism.client.gui.element.bar.GuiVerticalPowerBar)10 IBarInfoHandler (mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler)6 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)6 GuiGasGauge (mekanism.client.gui.element.gauge.GuiGasGauge)5 GuiHeatTab (mekanism.client.gui.element.tab.GuiHeatTab)5 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)4 GuiDownArrow (mekanism.client.gui.element.GuiDownArrow)4 GuiElementHolder (mekanism.client.gui.element.GuiElementHolder)4 TranslationButton (mekanism.client.gui.element.button.TranslationButton)4 GuiFluidGauge (mekanism.client.gui.element.gauge.GuiFluidGauge)4 Nonnull (javax.annotation.Nonnull)3 GuiDynamicHorizontalRateBar (mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar)3 GuiScrollBar (mekanism.client.gui.element.scroll.GuiScrollBar)3 GuiTextField (mekanism.client.gui.element.text.GuiTextField)3 Mekanism (mekanism.common.Mekanism)3