use of mekanism.client.gui.element.GuiDigitalSwitch in project Mekanism by mekanism.
the class GuiDigitalMiner method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiInnerScreen(this, 7, 19, 77, 69, () -> {
List<ITextComponent> list = new ArrayList<>();
ILangEntry runningType;
if (tile.getEnergyContainer().getEnergyPerTick().greaterThan(tile.getEnergyContainer().getMaxEnergy())) {
runningType = MekanismLang.MINER_LOW_POWER;
} else if (tile.isRunning()) {
runningType = MekanismLang.MINER_RUNNING;
} else {
runningType = MekanismLang.IDLE;
}
list.add(runningType.translate());
list.add(tile.searcher.state.getTextComponent());
list.add(MekanismLang.MINER_TO_MINE.translate(TextUtils.format(tile.getToMine())));
return list;
}).spacing(1).clearFormat());
addButton(new GuiDigitalSwitch(this, 19, 56, EJECT, tile::getDoEject, MekanismLang.AUTO_EJECT.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.AUTO_EJECT_BUTTON, tile)), SwitchType.LOWER_ICON));
addButton(new GuiDigitalSwitch(this, 38, 56, INPUT, tile::getDoPull, MekanismLang.AUTO_PULL.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.AUTO_PULL_BUTTON, tile)), SwitchType.LOWER_ICON));
addButton(new GuiDigitalSwitch(this, 57, 56, SILK, tile::getSilkTouch, MekanismLang.MINER_SILK.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.SILK_TOUCH_BUTTON, tile)), SwitchType.LOWER_ICON));
addButton(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 157, 39, 47));
addButton(new GuiVisualsTab(this, tile));
addButton(new GuiSlot(SlotType.DIGITAL, this, 64, 21).setRenderAboveSlots().validity(() -> tile.missingStack).with(() -> tile.missingStack.isEmpty() ? SlotOverlay.CHECK : null).hover(getOnHover(() -> tile.missingStack.isEmpty() ? MekanismLang.MINER_WELL.translate() : MekanismLang.MINER_MISSING_BLOCK.translate())));
addButton(new GuiEnergyTab(this, () -> {
MinerEnergyContainer energyContainer = tile.getEnergyContainer();
FloatingLong perTick = energyContainer.getEnergyPerTick();
ArrayList<ITextComponent> ret = new ArrayList<>(4);
ret.add(MekanismLang.MINER_ENERGY_CAPACITY.translate(EnergyDisplay.of(energyContainer.getMaxEnergy())));
ret.add(MekanismLang.NEEDED_PER_TICK.translate(EnergyDisplay.of(perTick)));
if (perTick.greaterThan(energyContainer.getMaxEnergy())) {
ret.add(MekanismLang.MINER_INSUFFICIENT_BUFFER.translateColored(EnumColor.RED));
}
ret.add(MekanismLang.MINER_BUFFER_FREE.translate(EnergyDisplay.of(energyContainer.getNeeded())));
return ret;
}));
int buttonStart = 19;
startButton = addButton(new TranslationButton(this, 87, buttonStart, 61, 18, MekanismLang.BUTTON_START, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.START_BUTTON, tile))));
stopButton = addButton(new TranslationButton(this, 87, buttonStart + 17, 61, 18, MekanismLang.BUTTON_STOP, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.STOP_BUTTON, tile))));
configButton = addButton(new TranslationButton(this, 87, buttonStart + 34, 61, 18, MekanismLang.BUTTON_CONFIG, () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedTileButton.DIGITAL_MINER_CONFIG, tile))));
addButton(new TranslationButton(this, 87, buttonStart + 51, 61, 18, MekanismLang.MINER_RESET, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.RESET_BUTTON, tile))));
updateEnabledButtons();
trackWarning(WarningType.FILTER_HAS_BLACKLISTED_ELEMENT, () -> tile.getFilters().stream().anyMatch(MinerFilter::hasBlacklistedElement));
}
use of mekanism.client.gui.element.GuiDigitalSwitch 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));
}
Aggregations