use of mekanism.client.gui.element.button.ColorButton in project Mekanism by mekanism.
the class GuiLogisticalSorter method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiSlot(SlotType.NORMAL, this, 12, 136).setRenderAboveSlots());
addButton(new TranslationButton(this, 56, 136, 96, 20, MekanismLang.BUTTON_NEW_FILTER, () -> addWindow(new GuiSorterFilerSelect(this, tile))));
addButton(new MekanismImageButton(this, 12, 58, 14, getButtonLocation("single"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.SINGLE_ITEM_BUTTON, tile)), getOnHover(MekanismLang.SORTER_SINGLE_ITEM_DESCRIPTION)));
addButton(new MekanismImageButton(this, 12, 84, 14, getButtonLocation("round_robin"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.ROUND_ROBIN_BUTTON, tile)), getOnHover(MekanismLang.SORTER_ROUND_ROBIN_DESCRIPTION)));
addButton(new MekanismImageButton(this, 12, 110, 14, getButtonLocation("auto_eject"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.AUTO_EJECT_BUTTON, tile)), getOnHover(MekanismLang.SORTER_AUTO_EJECT_DESCRIPTION)));
addButton(new ColorButton(this, 13, 137, 16, 16, () -> tile.color, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.CHANGE_COLOR, tile, hasShiftDown() ? -1 : TransporterUtils.getColorIndex(TransporterUtils.increment(tile.color)))), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.CHANGE_COLOR, tile, TransporterUtils.getColorIndex(TransporterUtils.decrement(tile.color))))));
}
use of mekanism.client.gui.element.button.ColorButton 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);
}
}));
}
Aggregations