Search in sources :

Example 1 with IGuiWrapper

use of mekanism.client.gui.IGuiWrapper in project Mekanism by mekanism.

the class GuiMinerFilterHelper method addMinerDefaults.

default void addMinerDefaults(IGuiWrapper gui, MinerFilter<?> filter, int slotOffset, UnaryOperator<GuiElement> childAdder) {
    childAdder.apply(new GuiSlot(SlotType.NORMAL, gui, getRelativeX() + 148, getRelativeY() + slotOffset).setRenderHover(true).stored(() -> new ItemStack(filter.replaceTarget)).setGhostHandler((IGhostBlockItemConsumer) ingredient -> {
        filter.replaceTarget = ((ItemStack) ingredient).getItem();
        Minecraft.getInstance().getSoundManager().play(SimpleSound.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
    }));
    childAdder.apply(new MekanismImageButton(gui, getRelativeX() + 148, getRelativeY() + 45, 14, 16, MekanismUtils.getResource(ResourceType.GUI_BUTTON, "exclamation.png"), () -> filter.requiresReplacement = !filter.requiresReplacement, (onHover, matrix, xAxis, yAxis) -> gui.displayTooltip(matrix, MekanismLang.MINER_REQUIRE_REPLACE.translate(YesNo.of(filter.requiresReplacement)), xAxis, yAxis)));
}
Also used : GuiFilter(mekanism.client.gui.element.window.filter.GuiFilter) SimpleSound(net.minecraft.client.audio.SimpleSound) GuiElement(mekanism.client.gui.element.GuiElement) SlotType(mekanism.client.gui.element.slot.SlotType) ResourceType(mekanism.common.util.MekanismUtils.ResourceType) UnaryOperator(java.util.function.UnaryOperator) MinerFilter(mekanism.common.content.miner.MinerFilter) TileEntityDigitalMiner(mekanism.common.tile.machine.TileEntityDigitalMiner) SoundEvents(net.minecraft.util.SoundEvents) MekanismUtils(mekanism.common.util.MekanismUtils) ItemStack(net.minecraft.item.ItemStack) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) Minecraft(net.minecraft.client.Minecraft) IGuiWrapper(mekanism.client.gui.IGuiWrapper) YesNo(mekanism.common.util.text.BooleanStateDisplay.YesNo) GuiFilterHelper(mekanism.client.gui.element.window.filter.GuiFilterHelper) MekanismLang(mekanism.common.MekanismLang) IGhostBlockItemConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) IGhostBlockItemConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IGuiWrapper

use of mekanism.client.gui.IGuiWrapper in project Mekanism by mekanism.

the class GuiSorterFilterHelper method addSorterDefaults.

default void addSorterDefaults(IGuiWrapper gui, SorterFilter<?> filter, int slotOffset, UnaryOperator<GuiElement> childAdder, BooleanSupplier singleItem, BiConsumer<GuiTextField, GuiTextField> rangeSetter) {
    int relativeX = getRelativeX();
    int relativeY = getRelativeY();
    int slotX = relativeX + 7;
    int colorSlotY = relativeY + slotOffset + 25;
    childAdder.apply(new GuiSlot(SlotType.NORMAL, gui, slotX, colorSlotY));
    childAdder.apply(new ColorButton(gui, slotX + 1, colorSlotY + 1, 16, 16, () -> filter.color, () -> filter.color = Screen.hasShiftDown() ? null : TransporterUtils.increment(filter.color), () -> filter.color = TransporterUtils.decrement(filter.color)));
    childAdder.apply(new MekanismImageButton(gui, relativeX + 148, relativeY + 18, 11, MekanismUtils.getResource(ResourceType.GUI_BUTTON, "default.png"), () -> filter.allowDefault = !filter.allowDefault, (onHover, matrix, xAxis, yAxis) -> gui.displayTooltip(matrix, MekanismLang.FILTER_ALLOW_DEFAULT.translate(), xAxis, yAxis)));
    GuiTextField minField = new GuiTextField(gui, relativeX + 169, relativeY + 31, 20, 11);
    minField.setMaxStringLength(2);
    minField.setInputValidator(InputValidator.DIGIT);
    minField.setText("" + filter.min);
    childAdder.apply(minField);
    GuiTextField maxField = new GuiTextField(gui, relativeX + 169, relativeY + 43, 20, 11);
    maxField.setMaxStringLength(2);
    maxField.setInputValidator(InputValidator.DIGIT);
    maxField.setText("" + filter.max);
    childAdder.apply(maxField);
    rangeSetter.accept(minField, maxField);
    childAdder.apply(new MekanismImageButton(gui, relativeX + 148, relativeY + 56, 11, 14, MekanismUtils.getResource(ResourceType.GUI_BUTTON, "silk_touch.png"), () -> filter.sizeMode = !filter.sizeMode, (onHover, matrix, xAxis, yAxis) -> {
        if (singleItem.getAsBoolean() && filter.sizeMode) {
            gui.displayTooltip(matrix, MekanismLang.SORTER_SIZE_MODE_CONFLICT.translate(), xAxis, yAxis);
        } else {
            gui.displayTooltip(matrix, MekanismLang.SORTER_SIZE_MODE.translate(), xAxis, yAxis);
        }
    }));
}
Also used : GuiTextField(mekanism.client.gui.element.text.GuiTextField) SorterFilter(mekanism.common.content.transporter.SorterFilter) EnumColor(mekanism.api.text.EnumColor) GuiElement(mekanism.client.gui.element.GuiElement) OnOff(mekanism.common.util.text.BooleanStateDisplay.OnOff) SlotType(mekanism.client.gui.element.slot.SlotType) ResourceType(mekanism.common.util.MekanismUtils.ResourceType) UnaryOperator(java.util.function.UnaryOperator) BooleanSupplier(java.util.function.BooleanSupplier) MekanismUtils(mekanism.common.util.MekanismUtils) TransporterUtils(mekanism.common.util.TransporterUtils) IFancyFontRenderer(mekanism.client.render.IFancyFontRenderer) InputValidator(mekanism.common.util.text.InputValidator) TileEntityLogisticalSorter(mekanism.common.tile.TileEntityLogisticalSorter) Screen(net.minecraft.client.gui.screen.Screen) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) IGuiWrapper(mekanism.client.gui.IGuiWrapper) BiConsumer(java.util.function.BiConsumer) GuiFilterHelper(mekanism.client.gui.element.window.filter.GuiFilterHelper) MekanismLang(mekanism.common.MekanismLang) ColorButton(mekanism.client.gui.element.button.ColorButton) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) ColorButton(mekanism.client.gui.element.button.ColorButton) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) GuiTextField(mekanism.client.gui.element.text.GuiTextField)

Aggregations

UnaryOperator (java.util.function.UnaryOperator)2 IGuiWrapper (mekanism.client.gui.IGuiWrapper)2 GuiElement (mekanism.client.gui.element.GuiElement)2 MekanismImageButton (mekanism.client.gui.element.button.MekanismImageButton)2 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)2 SlotType (mekanism.client.gui.element.slot.SlotType)2 GuiFilterHelper (mekanism.client.gui.element.window.filter.GuiFilterHelper)2 MekanismLang (mekanism.common.MekanismLang)2 MekanismUtils (mekanism.common.util.MekanismUtils)2 ResourceType (mekanism.common.util.MekanismUtils.ResourceType)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 BiConsumer (java.util.function.BiConsumer)1 BooleanSupplier (java.util.function.BooleanSupplier)1 EnumColor (mekanism.api.text.EnumColor)1 ColorButton (mekanism.client.gui.element.button.ColorButton)1 GuiTextField (mekanism.client.gui.element.text.GuiTextField)1 GuiFilter (mekanism.client.gui.element.window.filter.GuiFilter)1 IGhostBlockItemConsumer (mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer)1 IFancyFontRenderer (mekanism.client.render.IFancyFontRenderer)1 MinerFilter (mekanism.common.content.miner.MinerFilter)1