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));
}
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));
}
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();
}
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));
}
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()));
}
Aggregations