Search in sources :

Example 6 with GuiElementHolder

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

the class GuiFusionReactorLogicAdapter method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiElementHolder(this, 16, 31, 130, 90));
    addButton(new ToggleButton(this, 16, 19, 11, tile::isActiveCooled, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.NEXT_MODE, tile)), getOnHover(GeneratorsLang.REACTOR_LOGIC_TOGGLE_COOLING)));
    scrollBar = addButton(new GuiScrollBar(this, 146, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
    for (int i = 0; i < DISPLAY_COUNT; i++) {
        int typeShift = 22 * i;
        addButton(new ReactorLogicButton<>(this, 17, 32 + typeShift, i, tile, scrollBar::getCurrentSelection, tile::getModes, type -> {
            if (type == null) {
                return;
            }
            MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.LOGIC_TYPE, tile, type.ordinal()));
        }));
    }
}
Also used : Mekanism(mekanism.common.Mekanism) EnumColor(mekanism.api.text.EnumColor) PlayerInventory(net.minecraft.entity.player.PlayerInventory) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) OnOff(mekanism.common.util.text.BooleanStateDisplay.OnOff) MekanismGenerators(mekanism.generators.common.MekanismGenerators) ToggleButton(mekanism.client.gui.element.button.ToggleButton) ReactorLogicButton(mekanism.generators.client.gui.element.button.ReactorLogicButton) EmptyTileContainer(mekanism.common.inventory.container.tile.EmptyTileContainer) ITextComponent(net.minecraft.util.text.ITextComponent) GeneratorsLang(mekanism.generators.common.GeneratorsLang) GuiInteraction(mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction) MekanismLang(mekanism.common.MekanismLang) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) Nonnull(javax.annotation.Nonnull) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract) TileEntityFusionReactorLogicAdapter(mekanism.generators.common.tile.fusion.TileEntityFusionReactorLogicAdapter) GeneratorsGuiInteraction(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract.GeneratorsGuiInteraction) ToggleButton(mekanism.client.gui.element.button.ToggleButton) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)

Example 7 with GuiElementHolder

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

the class GuiSecurityDesk method addGuiElements.

@Override
protected void addGuiElements() {
    addButton(new GuiElementHolder(this, 141, 13, 26, 37));
    addButton(new GuiElementHolder(this, 141, 54, 26, 34));
    addButton(new GuiElementHolder(this, 141, 92, 26, 37));
    super.addGuiElements();
    addButton(new GuiSlot(SlotType.INNER_HOLDER_SLOT, this, 145, 17));
    addButton(new GuiSlot(SlotType.INNER_HOLDER_SLOT, this, 145, 96));
    addButton(new GuiSecurityLight(this, 144, 77, () -> {
        SecurityFrequency frequency = tile.getFreq();
        return frequency == null || tile.ownerUUID == null || !tile.ownerUUID.equals(getMinecraft().player.getUUID()) ? 2 : frequency.isOverridden() ? 0 : 1;
    }));
    addButton(new GuiTextureOnlyElement(PUBLIC, this, 145, 32, 18, 18));
    addButton(new GuiTextureOnlyElement(PRIVATE, this, 145, 111, 18, 18));
    scrollList = addButton(new GuiTextScrollList(this, 13, 13, 122, 42));
    removeButton = addButton(new TranslationButton(this, 13, 81, 122, 20, MekanismLang.BUTTON_REMOVE, () -> {
        int selection = scrollList.getSelection();
        if (tile.getFreq() != null && selection != -1) {
            Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.REMOVE_TRUSTED, tile, selection));
            scrollList.clearSelection();
            updateButtons();
        }
    }));
    trustedField = addButton(new GuiTextField(this, 35, 68, 99, 11));
    trustedField.setMaxStringLength(PacketAddTrusted.MAX_NAME_LENGTH);
    trustedField.setBackground(BackgroundType.INNER_SCREEN);
    trustedField.setEnterHandler(this::setTrusted);
    trustedField.setInputValidator(InputValidator.USERNAME);
    trustedField.addCheckmarkButton(this::setTrusted);
    publicButton = addButton(new MekanismImageButton(this, 13, 113, 40, 16, 40, 16, getButtonLocation("public"), () -> {
        Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.SECURITY_DESK_MODE, tile, SecurityMode.PUBLIC.ordinal()));
        updateButtons();
    }, getOnHover(MekanismLang.PUBLIC_MODE)));
    privateButton = addButton(new MekanismImageButton(this, 54, 113, 40, 16, 40, 16, getButtonLocation("private"), () -> {
        Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.SECURITY_DESK_MODE, tile, SecurityMode.PRIVATE.ordinal()));
        updateButtons();
    }, getOnHover(MekanismLang.PRIVATE_MODE)));
    trustedButton = addButton(new MekanismImageButton(this, 95, 113, 40, 16, 40, 16, getButtonLocation("trusted"), () -> {
        Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.SECURITY_DESK_MODE, tile, SecurityMode.TRUSTED.ordinal()));
        updateButtons();
    }, getOnHover(MekanismLang.TRUSTED_MODE)));
    overrideButton = addButton(new MekanismImageButton(this, 146, 59, 16, 16, getButtonLocation("exclamation"), () -> {
        Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.OVERRIDE_BUTTON, tile));
        updateButtons();
    }, (onHover, matrix, xAxis, yAxis) -> {
        SecurityFrequency frequency = tile.getFreq();
        if (frequency != null) {
            displayTooltip(matrix, MekanismLang.SECURITY_OVERRIDE.translate(OnOff.of(frequency.isOverridden())), xAxis, yAxis);
        }
    }));
    updateButtons();
}
Also used : GuiSecurityLight(mekanism.client.gui.element.GuiSecurityLight) SecurityFrequency(mekanism.common.lib.security.SecurityFrequency) TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiTextScrollList(mekanism.client.gui.element.scroll.GuiTextScrollList) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) GuiTextureOnlyElement(mekanism.client.gui.element.GuiTextureOnlyElement) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) GuiTextField(mekanism.client.gui.element.text.GuiTextField)

Example 8 with GuiElementHolder

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

the class GuiInductionMatrix method addGuiElements.

@Override
protected void addGuiElements() {
    // Add the side holder before the slots, as it holds a couple of the slots
    addButton(GuiSideHolder.create(this, -26, 36, 98, true, true, SpecialColors.TAB_ARMOR_SLOTS));
    addButton(new GuiElementHolder(this, 141, 16, 26, 56));
    super.addGuiElements();
    addButton(new GuiSlot(SlotType.INNER_HOLDER_SLOT, this, 145, 20));
    addButton(new GuiSlot(SlotType.INNER_HOLDER_SLOT, this, 145, 50));
    addButton(new GuiInnerScreen(this, 49, 21, 84, 46, () -> {
        MatrixMultiblockData multiblock = tile.getMultiblock();
        return Arrays.asList(MekanismLang.ENERGY.translate(EnergyDisplay.of(multiblock.getEnergy())), MekanismLang.CAPACITY.translate(EnergyDisplay.of(multiblock.getStorageCap())), MekanismLang.MATRIX_INPUT_AMOUNT.translate(MekanismLang.GENERIC_PER_TICK.translate(EnergyDisplay.of(multiblock.getLastInput()))), MekanismLang.MATRIX_OUTPUT_AMOUNT.translate(MekanismLang.GENERIC_PER_TICK.translate(EnergyDisplay.of(multiblock.getLastOutput()))));
    }).spacing(2));
    addButton(new GuiMatrixTab(this, tile, MatrixTab.STAT));
    addButton(new GuiEnergyGauge(new IEnergyInfoHandler() {

        @Override
        public FloatingLong getEnergy() {
            return tile.getMultiblock().getEnergy();
        }

        @Override
        public FloatingLong getMaxEnergy() {
            return tile.getMultiblock().getStorageCap();
        }
    }, GaugeType.MEDIUM, this, 7, 16, 34, 56));
    addButton(new GuiEnergyTab(this, () -> {
        MatrixMultiblockData multiblock = tile.getMultiblock();
        return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.getEnergy(), multiblock.getStorageCap())), MekanismLang.MATRIX_INPUT_RATE.translate(EnergyDisplay.of(multiblock.getLastInput())), MekanismLang.MATRIX_OUTPUT_RATE.translate(EnergyDisplay.of(multiblock.getLastOutput())));
    }));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) MatrixMultiblockData(mekanism.common.content.matrix.MatrixMultiblockData) GuiMatrixTab(mekanism.client.gui.element.tab.GuiMatrixTab) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) IEnergyInfoHandler(mekanism.client.gui.element.gauge.GuiEnergyGauge.IEnergyInfoHandler) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) GuiEnergyGauge(mekanism.client.gui.element.gauge.GuiEnergyGauge) GuiEnergyTab(mekanism.client.gui.element.tab.GuiEnergyTab)

Example 9 with GuiElementHolder

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

GuiElementHolder (mekanism.client.gui.element.GuiElementHolder)9 ITextComponent (net.minecraft.util.text.ITextComponent)7 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)6 Nonnull (javax.annotation.Nonnull)6 PlayerInventory (net.minecraft.entity.player.PlayerInventory)6 GuiScrollBar (mekanism.client.gui.element.scroll.GuiScrollBar)5 MekanismLang (mekanism.common.MekanismLang)5 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)4 TranslationButton (mekanism.client.gui.element.button.TranslationButton)4 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)4 PacketGuiInteract (mekanism.common.network.to_server.PacketGuiInteract)4 ArrayList (java.util.ArrayList)3 EnumColor (mekanism.api.text.EnumColor)3 GuiMekanismTile (mekanism.client.gui.GuiMekanismTile)3 Mekanism (mekanism.common.Mekanism)3 IFilter (mekanism.common.content.filter.IFilter)3 MekanismTileContainer (mekanism.common.inventory.container.tile.MekanismTileContainer)3 GuiInteraction (mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction)3 ItemStack (net.minecraft.item.ItemStack)3 List (java.util.List)2