Search in sources :

Example 6 with TranslationButton

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

the class GuiFilter method init.

protected void init() {
    int screenTop = relativeY + 18;
    int screenBottom = screenTop + getScreenHeight();
    addChild(new GuiInnerScreen(gui(), relativeX + 29, screenTop, getScreenWidth(), getScreenHeight(), this::getScreenText).clearFormat());
    addChild(new TranslationButton(gui(), getLeftButtonX(), screenBottom + 2, 60, 20, isNew ? MekanismLang.BUTTON_CANCEL : MekanismLang.BUTTON_DELETE, () -> {
        if (origFilter != null) {
            Mekanism.packetHandler.sendToServer(new PacketEditFilter(tile.getBlockPos(), true, origFilter, null));
        }
        close();
    }));
    addChild(new TranslationButton(gui(), getLeftButtonX() + 62, screenBottom + 2, 60, 20, MekanismLang.BUTTON_SAVE, this::validateAndSave));
    addChild(new GuiSlot(SlotType.NORMAL, gui(), relativeX + 7, relativeY + getSlotOffset()).setRenderHover(true).setGhostHandler(getGhostHandler()));
    slotDisplay = addChild(new GuiSequencedSlotDisplay(gui(), relativeX + 8, relativeY + getSlotOffset() + 1, this::getRenderStacks));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) PacketEditFilter(mekanism.common.network.to_server.PacketEditFilter) TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) GuiSequencedSlotDisplay(mekanism.client.gui.element.slot.GuiSequencedSlotDisplay)

Example 7 with TranslationButton

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

the class GuiModificationStation method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 154, 40));
    addButton(new GuiEnergyTab(this, tile.getEnergyContainer()));
    addButton(new GuiProgress(tile::getScaledProgress, ProgressType.LARGE_RIGHT, this, 65, 123));
    removeButton = addButton(new TranslationButton(this, 34, 96, 108, 17, MekanismLang.BUTTON_REMOVE, () -> Mekanism.packetHandler.sendToServer(new PacketRemoveModule(tile.getBlockPos(), selectedModule.getData()))));
    removeButton.active = false;
    addButton(new GuiModuleScrollList(this, 34, 20, 108, 74, () -> tile.containerSlot.getStack().copy(), this::onModuleSelected));
}
Also used : TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiProgress(mekanism.client.gui.element.progress.GuiProgress) GuiVerticalPowerBar(mekanism.client.gui.element.bar.GuiVerticalPowerBar) GuiEnergyTab(mekanism.client.gui.element.tab.GuiEnergyTab) PacketRemoveModule(mekanism.common.network.to_server.PacketRemoveModule) GuiModuleScrollList(mekanism.client.gui.element.scroll.GuiModuleScrollList)

Example 8 with TranslationButton

use of mekanism.client.gui.element.button.TranslationButton 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 9 with TranslationButton

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

the class GuiDigitalMinerConfig method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new TranslationButton(this, 56, 136, 96, 20, MekanismLang.BUTTON_NEW_FILTER, () -> addWindow(new GuiMinerFilerSelect(this, tile))));
    addButton(new MekanismImageButton(this, 5, 5, 11, 14, getButtonLocation("back"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedTileButton.BACK_BUTTON, tile))));
    addButton(new GuiDigitalSwitch(this, 10, 115, INVERSE, tile::getInverse, MekanismLang.MINER_INVERSE.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.INVERSE_BUTTON, tile)), SwitchType.LEFT_ICON));
    addButton(new GuiSlot(SlotType.NORMAL, this, 13, 135)).setRenderAboveSlots().setRenderHover(true).stored(() -> new ItemStack(tile.getInverseReplaceTarget())).click((element, mouseX, mouseY) -> {
        if (Screen.hasShiftDown()) {
            updateInverseReplaceTarget(Items.AIR);
        } else {
            ItemStack stack = minecraft.player.inventory.getCarried();
            if (!stack.isEmpty() && stack.getItem() instanceof BlockItem) {
                updateInverseReplaceTarget(stack.getItem());
            }
        }
    }).setGhostHandler((IGhostBlockItemConsumer) ingredient -> updateInverseReplaceTarget(((ItemStack) ingredient).getItem()));
    addButton(new MekanismImageButton(this, 35, 137, 14, 16, getButtonLocation("exclamation"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.INVERSE_REQUIRES_REPLACEMENT_BUTTON, tile)), getOnHover(() -> MekanismLang.MINER_REQUIRE_REPLACE_INVERSE.translate(YesNo.of(tile.getInverseRequiresReplacement())))));
    radiusField = addButton(new GuiTextField(this, 13, 49, 38, 11));
    radiusField.setMaxStringLength(Integer.toString(MekanismConfig.general.minerMaxRadius.get()).length());
    radiusField.setInputValidator(InputValidator.DIGIT);
    radiusField.configureDigitalBorderInput(() -> setText(radiusField, GuiInteraction.SET_RADIUS));
    minField = addButton(new GuiTextField(this, 13, 74, 38, 11));
    minField.setMaxStringLength(3);
    minField.setInputValidator(InputValidator.DIGIT);
    minField.configureDigitalBorderInput(() -> setText(minField, GuiInteraction.SET_MIN_Y));
    maxField = addButton(new GuiTextField(this, 13, 99, 38, 11));
    maxField.setMaxStringLength(3);
    maxField.setInputValidator(InputValidator.DIGIT);
    maxField.configureDigitalBorderInput(() -> setText(maxField, GuiInteraction.SET_MAX_Y));
    // 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.FILTER_HAS_BLACKLISTED_ELEMENT, () -> tile.getFilters().stream().anyMatch(MinerFilter::hasBlacklistedElement));
}
Also used : GuiTextField(mekanism.client.gui.element.text.GuiTextField) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) Item(net.minecraft.item.Item) FilterButton(mekanism.client.gui.element.button.FilterButton) PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) ResourceType(mekanism.common.util.MekanismUtils.ResourceType) InputValidator(mekanism.common.util.text.InputValidator) YesNo(mekanism.common.util.text.BooleanStateDisplay.YesNo) GuiMinerTagFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerTagFilter) MinerModIDFilter(mekanism.common.content.miner.MinerModIDFilter) TranslationButton(mekanism.client.gui.element.button.TranslationButton) ClickedTileButton(mekanism.common.network.to_server.PacketGuiButtonPress.ClickedTileButton) SlotType(mekanism.client.gui.element.slot.SlotType) ITagFilter(mekanism.common.content.filter.ITagFilter) GuiMinerModIDFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerModIDFilter) MekanismUtils(mekanism.common.util.MekanismUtils) GuiFilterHolder(mekanism.client.gui.GuiFilterHolder) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) IModIDFilter(mekanism.common.content.filter.IModIDFilter) BlockItem(net.minecraft.item.BlockItem) GuiInteraction(mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction) MekanismLang(mekanism.common.MekanismLang) IFilter(mekanism.common.content.filter.IFilter) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) MinerItemStackFilter(mekanism.common.content.miner.MinerItemStackFilter) SimpleSound(net.minecraft.client.audio.SimpleSound) GuiMinerItemStackFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerItemStackFilter) TileEntityDigitalMiner(mekanism.common.tile.machine.TileEntityDigitalMiner) ITextComponent(net.minecraft.util.text.ITextComponent) WarningType(mekanism.client.gui.warning.WarningTracker.WarningType) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) GuiInteractionItem(mekanism.common.network.to_server.PacketGuiInteract.GuiInteractionItem) IGhostBlockItemConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer) Nonnull(javax.annotation.Nonnull) GuiMinerMaterialFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerMaterialFilter) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) GuiDigitalSwitch(mekanism.client.gui.element.GuiDigitalSwitch) Mekanism(mekanism.common.Mekanism) PlayerInventory(net.minecraft.entity.player.PlayerInventory) GuiMinerFilerSelect(mekanism.client.gui.element.window.filter.miner.GuiMinerFilerSelect) IMaterialFilter(mekanism.common.content.filter.IMaterialFilter) SwitchType(mekanism.client.gui.element.GuiDigitalSwitch.SwitchType) MinerFilter(mekanism.common.content.miner.MinerFilter) Items(net.minecraft.item.Items) SoundEvents(net.minecraft.util.SoundEvents) IItemStackFilter(mekanism.common.content.filter.IItemStackFilter) MekanismTileContainer(mekanism.common.inventory.container.tile.MekanismTileContainer) ResourceLocation(net.minecraft.util.ResourceLocation) MinerMaterialFilter(mekanism.common.content.miner.MinerMaterialFilter) MekanismConfig(mekanism.common.config.MekanismConfig) MinerTagFilter(mekanism.common.content.miner.MinerTagFilter) TagCache(mekanism.common.base.TagCache) PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiDigitalSwitch(mekanism.client.gui.element.GuiDigitalSwitch) GuiMinerFilerSelect(mekanism.client.gui.element.window.filter.miner.GuiMinerFilerSelect) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) ItemStack(net.minecraft.item.ItemStack) GuiTextField(mekanism.client.gui.element.text.GuiTextField) BlockItem(net.minecraft.item.BlockItem)

Example 10 with TranslationButton

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

TranslationButton (mekanism.client.gui.element.button.TranslationButton)11 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)6 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)5 PacketGuiInteract (mekanism.common.network.to_server.PacketGuiInteract)5 ITextComponent (net.minecraft.util.text.ITextComponent)5 Nonnull (javax.annotation.Nonnull)4 GuiElementHolder (mekanism.client.gui.element.GuiElementHolder)4 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)4 MekanismLang (mekanism.common.MekanismLang)4 PlayerInventory (net.minecraft.entity.player.PlayerInventory)4 List (java.util.List)3 GuiVerticalPowerBar (mekanism.client.gui.element.bar.GuiVerticalPowerBar)3 MekanismImageButton (mekanism.client.gui.element.button.MekanismImageButton)3 ArrayList (java.util.ArrayList)2 GuiDigitalSwitch (mekanism.client.gui.element.GuiDigitalSwitch)2 IBarInfoHandler (mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler)2 FilterButton (mekanism.client.gui.element.button.FilterButton)2 GuiProgress (mekanism.client.gui.element.progress.GuiProgress)2 GuiModuleScrollList (mekanism.client.gui.element.scroll.GuiModuleScrollList)2 GuiScrollBar (mekanism.client.gui.element.scroll.GuiScrollBar)2