Search in sources :

Example 1 with GuiTeleporterStatus

use of mekanism.client.gui.element.custom.GuiTeleporterStatus in project Mekanism by mekanism.

the class GuiTeleporter method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiTeleporterStatus(this, () -> getFrequency() != null, () -> tile.status));
    addButton(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 158, 26));
    addButton(new GuiFrequencySelector<>(this, 14));
}
Also used : GuiTeleporterStatus(mekanism.client.gui.element.custom.GuiTeleporterStatus) GuiVerticalPowerBar(mekanism.client.gui.element.bar.GuiVerticalPowerBar)

Example 2 with GuiTeleporterStatus

use of mekanism.client.gui.element.custom.GuiTeleporterStatus in project Mekanism by mekanism.

the class GuiPortableTeleporter method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiTeleporterStatus(this, () -> getFrequency() != null, menu::getStatus));
    addButton(new GuiVerticalPowerBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            IEnergyContainer container = StorageUtils.getEnergyContainer(menu.getStack(), 0);
            return container == null ? EnergyDisplay.ZERO.getTextComponent() : EnergyDisplay.of(container).getTextComponent();
        }

        @Override
        public double getLevel() {
            IEnergyContainer container = StorageUtils.getEnergyContainer(menu.getStack(), 0);
            return container == null ? 0 : container.getEnergy().divideToLevel(container.getMaxEnergy());
        }
    }, 158, 26));
    teleportButton = addButton(new TranslationButton(this, 42, 147, 92, 20, MekanismLang.BUTTON_TELEPORT, () -> {
        TeleporterFrequency frequency = getFrequency();
        if (frequency != null && menu.getStatus() == 1) {
            // This should always be true if the teleport button is active, but validate it just in case
            ClientTickHandler.portableTeleport(getMinecraft().player, menu.getHand(), frequency.getIdentity());
            getMinecraft().player.closeContainer();
        } else {
            // If something did go wrong make the teleport button not able to be pressed
            teleportButton.active = false;
        }
    }));
    // Teleporter button starts as deactivated until we have a frequency get synced
    teleportButton.active = false;
    addButton(new GuiFrequencySelector<>(this, 14));
}
Also used : IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) IEnergyContainer(mekanism.api.energy.IEnergyContainer) TranslationButton(mekanism.client.gui.element.button.TranslationButton) TeleporterFrequency(mekanism.common.content.teleporter.TeleporterFrequency) GuiTeleporterStatus(mekanism.client.gui.element.custom.GuiTeleporterStatus) GuiVerticalPowerBar(mekanism.client.gui.element.bar.GuiVerticalPowerBar)

Aggregations

GuiVerticalPowerBar (mekanism.client.gui.element.bar.GuiVerticalPowerBar)2 GuiTeleporterStatus (mekanism.client.gui.element.custom.GuiTeleporterStatus)2 IEnergyContainer (mekanism.api.energy.IEnergyContainer)1 IBarInfoHandler (mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler)1 TranslationButton (mekanism.client.gui.element.button.TranslationButton)1 TeleporterFrequency (mekanism.common.content.teleporter.TeleporterFrequency)1