use of mekanism.client.gui.element.GuiElementHolder in project Mekanism by mekanism.
the class GuiFusionReactorLogicAdapter method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiElementHolder(this, 16, 31, 130, 90));
addButton(new ToggleButton(this, 16, 19, 11, tile::isActiveCooled, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.NEXT_MODE, tile)), getOnHover(GeneratorsLang.REACTOR_LOGIC_TOGGLE_COOLING)));
scrollBar = addButton(new GuiScrollBar(this, 146, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
for (int i = 0; i < DISPLAY_COUNT; i++) {
int typeShift = 22 * i;
addButton(new ReactorLogicButton<>(this, 17, 32 + typeShift, i, tile, scrollBar::getCurrentSelection, tile::getModes, type -> {
if (type == null) {
return;
}
MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.LOGIC_TYPE, tile, type.ordinal()));
}));
}
}
use of mekanism.client.gui.element.GuiElementHolder 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.GuiElementHolder in project Mekanism by mekanism.
the class GuiInductionMatrix method addGuiElements.
@Override
protected void addGuiElements() {
// Add the side holder before the slots, as it holds a couple of the slots
addButton(GuiSideHolder.create(this, -26, 36, 98, true, true, SpecialColors.TAB_ARMOR_SLOTS));
addButton(new GuiElementHolder(this, 141, 16, 26, 56));
super.addGuiElements();
addButton(new GuiSlot(SlotType.INNER_HOLDER_SLOT, this, 145, 20));
addButton(new GuiSlot(SlotType.INNER_HOLDER_SLOT, this, 145, 50));
addButton(new GuiInnerScreen(this, 49, 21, 84, 46, () -> {
MatrixMultiblockData multiblock = tile.getMultiblock();
return Arrays.asList(MekanismLang.ENERGY.translate(EnergyDisplay.of(multiblock.getEnergy())), MekanismLang.CAPACITY.translate(EnergyDisplay.of(multiblock.getStorageCap())), MekanismLang.MATRIX_INPUT_AMOUNT.translate(MekanismLang.GENERIC_PER_TICK.translate(EnergyDisplay.of(multiblock.getLastInput()))), MekanismLang.MATRIX_OUTPUT_AMOUNT.translate(MekanismLang.GENERIC_PER_TICK.translate(EnergyDisplay.of(multiblock.getLastOutput()))));
}).spacing(2));
addButton(new GuiMatrixTab(this, tile, MatrixTab.STAT));
addButton(new GuiEnergyGauge(new IEnergyInfoHandler() {
@Override
public FloatingLong getEnergy() {
return tile.getMultiblock().getEnergy();
}
@Override
public FloatingLong getMaxEnergy() {
return tile.getMultiblock().getStorageCap();
}
}, GaugeType.MEDIUM, this, 7, 16, 34, 56));
addButton(new GuiEnergyTab(this, () -> {
MatrixMultiblockData multiblock = tile.getMultiblock();
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.getEnergy(), multiblock.getStorageCap())), MekanismLang.MATRIX_INPUT_RATE.translate(EnergyDisplay.of(multiblock.getLastInput())), MekanismLang.MATRIX_OUTPUT_RATE.translate(EnergyDisplay.of(multiblock.getLastOutput())));
}));
}
use of mekanism.client.gui.element.GuiElementHolder 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