Search in sources :

Example 1 with IBarInfoHandler

use of mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler in project Mekanism by mekanism.

the class GuiSPS method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiGasGauge(() -> tile.getMultiblock().inputTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 7, 17));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().outputTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 151, 17));
    addButton(new GuiInnerScreen(this, 27, 17, 122, 60, () -> {
        List<ITextComponent> list = new ArrayList<>();
        SPSMultiblockData multiblock = tile.getMultiblock();
        boolean active = multiblock.lastProcessed > 0;
        list.add(MekanismLang.STATUS.translate(active ? MekanismLang.ACTIVE : MekanismLang.IDLE));
        if (active) {
            list.add(MekanismLang.SPS_ENERGY_INPUT.translate(EnergyDisplay.of(multiblock.lastReceivedEnergy)));
            list.add(MekanismLang.PROCESS_RATE_MB.translate(multiblock.getProcessRate()));
        }
        return list;
    }).jeiCategories(MekanismBlocks.SPS_CASING.getRegistryName()));
    addButton(new GuiDynamicHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return MekanismLang.PROGRESS.translate(TextUtils.getPercent(tile.getMultiblock().getScaledProgress()));
        }

        @Override
        public double getLevel() {
            return Math.min(1, tile.getMultiblock().getScaledProgress());
        }
    }, 7, 79, 160, ColorFunction.scale(Color.rgbi(60, 45, 74), Color.rgbi(100, 30, 170))));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) GuiDynamicHorizontalRateBar(mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar) SPSMultiblockData(mekanism.common.content.sps.SPSMultiblockData)

Example 2 with IBarInfoHandler

use of mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler in project Mekanism by mekanism.

the class GuiThermalEvaporationController method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiInnerScreen(this, 48, 19, 80, 40, () -> {
        EvaporationMultiblockData multiblock = tile.getMultiblock();
        return Arrays.asList(MekanismLang.MULTIBLOCK_FORMED.translate(), MekanismLang.EVAPORATION_HEIGHT.translate(multiblock.height()), MekanismLang.TEMPERATURE.translate(MekanismUtils.getTemperatureDisplay(multiblock.getTemperature(), TemperatureUnit.KELVIN, true)), MekanismLang.FLUID_PRODUCTION.translate(Math.round(multiblock.lastGain * 100D) / 100D));
    }).spacing(1).jeiCategory(tile));
    addButton(new GuiDownArrow(this, 32, 39));
    addButton(new GuiDownArrow(this, 136, 39));
    addButton(new GuiHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return MekanismUtils.getTemperatureDisplay(tile.getMultiblock().getTemperature(), TemperatureUnit.KELVIN, true);
        }

        @Override
        public double getLevel() {
            return Math.min(1, tile.getMultiblock().getTemperature() / EvaporationMultiblockData.MAX_MULTIPLIER_TEMP);
        }
    }, 48, 63));
    addButton(new GuiFluidGauge(() -> tile.getMultiblock().inputTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 6, 13));
    addButton(new GuiFluidGauge(() -> tile.getMultiblock().outputTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 152, 13));
    addButton(new GuiHeatTab(this, () -> {
        ITextComponent environment = MekanismUtils.getTemperatureDisplay(tile.getMultiblock().lastEnvironmentLoss, TemperatureUnit.KELVIN, false);
        return Collections.singletonList(MekanismLang.DISSIPATED_RATE.translate(environment));
    }));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) GuiFluidGauge(mekanism.client.gui.element.gauge.GuiFluidGauge) GuiDownArrow(mekanism.client.gui.element.GuiDownArrow) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiHorizontalRateBar(mekanism.client.gui.element.bar.GuiHorizontalRateBar) ITextComponent(net.minecraft.util.text.ITextComponent) EvaporationMultiblockData(mekanism.common.content.evaporation.EvaporationMultiblockData) GuiHeatTab(mekanism.client.gui.element.tab.GuiHeatTab)

Example 3 with IBarInfoHandler

use of mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler in project Mekanism by mekanism.

the class GuiFissionReactor method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiFissionReactorTab(this, tile, FissionReactorTab.STAT));
    addButton(new GuiInnerScreen(this, 45, 17, 105, 56, () -> {
        FissionReactorMultiblockData multiblock = tile.getMultiblock();
        return Arrays.asList(MekanismLang.STATUS.translate(multiblock.isActive() ? EnumColor.BRIGHT_GREEN : EnumColor.RED, ActiveDisabled.of(multiblock.isActive())), GeneratorsLang.GAS_BURN_RATE.translate(multiblock.lastBurnRate), GeneratorsLang.FISSION_HEATING_RATE.translate(TextUtils.format(multiblock.lastBoilRate)), MekanismLang.TEMPERATURE.translate(tile.getTempColor(), MekanismUtils.getTemperatureDisplay(multiblock.heatCapacitor.getTemperature(), TemperatureUnit.KELVIN, true)), GeneratorsLang.FISSION_DAMAGE.translate(tile.getDamageColor(), tile.getDamageString()));
    }).spacing(2).jeiCategories(JEI_LOCATION));
    addButton(new GuiHybridGauge(() -> tile.getMultiblock().gasCoolantTank, () -> tile.getMultiblock().getGasTanks(null), () -> tile.getMultiblock().fluidCoolantTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 6, 13).setLabel(GeneratorsLang.FISSION_COOLANT_TANK.translateColored(EnumColor.AQUA)));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().fuelTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 25, 13).setLabel(GeneratorsLang.FISSION_FUEL_TANK.translateColored(EnumColor.DARK_GREEN)));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().heatedCoolantTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 152, 13).setLabel(GeneratorsLang.FISSION_HEATED_COOLANT_TANK.translateColored(EnumColor.ORANGE)));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().wasteTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 171, 13).setLabel(GeneratorsLang.FISSION_WASTE_TANK.translateColored(EnumColor.BROWN)));
    addButton(new GuiHeatTab(this, () -> {
        ITextComponent environment = MekanismUtils.getTemperatureDisplay(tile.getMultiblock().lastEnvironmentLoss, TemperatureUnit.KELVIN, false);
        return Collections.singletonList(MekanismLang.DISSIPATED_RATE.translate(environment));
    }));
    activateButton = addButton(new TranslationButton(this, 6, 75, 81, 16, GeneratorsLang.FISSION_ACTIVATE, () -> MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.FISSION_ACTIVE, tile, 1)), null, () -> EnumColor.DARK_GREEN) {

        @Override
        public void renderForeground(MatrixStack matrix, int mouseX, int mouseY) {
            super.renderForeground(matrix, mouseX, mouseY);
            if (!active && tile.getMultiblock().isForceDisabled()) {
                active = true;
                // Temporarily set active to true, so we can easily check if the mouse is over the button
                if (isMouseOverCheckWindows(mouseX, mouseY)) {
                    displayTooltip(matrix, GeneratorsLang.FISSION_FORCE_DISABLED.translate(), mouseX - getGuiLeft(), mouseY - getGuiTop());
                }
                active = false;
            }
        }
    });
    scramButton = addButton(new TranslationButton(this, 89, 75, 81, 16, GeneratorsLang.FISSION_SCRAM, () -> MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.FISSION_ACTIVE, tile, 0)), null, () -> EnumColor.DARK_RED));
    addButton(new GuiBigLight(this, 173, 76, tile.getMultiblock()::isActive));
    addButton(new GuiDynamicHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return MekanismUtils.getTemperatureDisplay(tile.getMultiblock().heatCapacitor.getTemperature(), TemperatureUnit.KELVIN, true);
        }

        @Override
        public double getLevel() {
            return Math.min(1, tile.getMultiblock().heatCapacitor.getTemperature() / FissionReactorMultiblockData.MAX_DAMAGE_TEMPERATURE);
        }
    }, 5, 102, imageWidth - 12));
    heatGraph = addButton(new GuiGraph(this, 5, 123, imageWidth - 10, 38, temp -> MekanismUtils.getTemperatureDisplay(temp, TemperatureUnit.KELVIN, true)));
    heatGraph.setMinScale(1_600);
    updateButtons();
}
Also used : GuiFissionReactorTab(mekanism.generators.client.gui.element.GuiFissionReactorTab) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiGraph(mekanism.client.gui.element.GuiGraph) TranslationButton(mekanism.client.gui.element.button.TranslationButton) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ITextComponent(net.minecraft.util.text.ITextComponent) FissionReactorMultiblockData(mekanism.generators.common.content.fission.FissionReactorMultiblockData) GuiHeatTab(mekanism.client.gui.element.tab.GuiHeatTab) GuiHybridGauge(mekanism.client.gui.element.gauge.GuiHybridGauge) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) GuiDynamicHorizontalRateBar(mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar) GuiBigLight(mekanism.client.gui.element.GuiBigLight)

Example 4 with IBarInfoHandler

use of mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler in project Mekanism by mekanism.

the class GuiIndustrialTurbine method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiInnerScreen(this, 50, 18, 112, 50, () -> {
        List<ITextComponent> list = new ArrayList<>();
        TurbineMultiblockData multiblock = tile.getMultiblock();
        if (multiblock.isFormed()) {
            list.add(GeneratorsLang.TURBINE_PRODUCTION_AMOUNT.translate(EnergyDisplay.of(multiblock.getProductionRate())));
            list.add(GeneratorsLang.TURBINE_FLOW_RATE.translate(TextUtils.format(multiblock.clientFlow)));
            list.add(GeneratorsLang.TURBINE_CAPACITY.translate(TextUtils.format(multiblock.getSteamCapacity())));
            list.add(GeneratorsLang.TURBINE_MAX_FLOW.translate(TextUtils.format(multiblock.getMaxFlowRate())));
        }
        return list;
    }));
    addButton(new GuiTurbineTab(this, tile, TurbineTab.STAT));
    addButton(new GuiVerticalPowerBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            TurbineMultiblockData multiblock = tile.getMultiblock();
            if (multiblock.isFormed()) {
                return EnergyDisplay.of(multiblock.energyContainer).getTextComponent();
            }
            return EnergyDisplay.ZERO.getTextComponent();
        }

        @Override
        public double getLevel() {
            TurbineMultiblockData multiblock = tile.getMultiblock();
            if (multiblock.isFormed()) {
                return multiblock.energyContainer.getEnergy().divideToLevel(multiblock.energyContainer.getMaxEnergy());
            }
            return 1;
        }
    }, 164, 16));
    addButton(new GuiVerticalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return GeneratorsLang.TURBINE_STEAM_INPUT_RATE.translate(TextUtils.format(tile.getMultiblock().lastSteamInput));
        }

        @Override
        public double getLevel() {
            TurbineMultiblockData multiblock = tile.getMultiblock();
            if (!multiblock.isFormed()) {
                return 0;
            }
            double rate = Math.min(multiblock.lowerVolume * multiblock.getDispersers() * MekanismGeneratorsConfig.generators.turbineDisperserGasFlow.get(), multiblock.vents * MekanismGeneratorsConfig.generators.turbineVentGasFlow.get());
            if (rate == 0) {
                return 0;
            }
            return Math.min(1, multiblock.lastSteamInput / rate);
        }
    }, 40, 13));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().gasTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.MEDIUM, this, 6, 13));
    addButton(new GuiEnergyTab(this, () -> {
        EnergyDisplay storing;
        EnergyDisplay producing;
        TurbineMultiblockData multiblock = tile.getMultiblock();
        if (multiblock.isFormed()) {
            storing = EnergyDisplay.of(multiblock.energyContainer);
            producing = EnergyDisplay.of(MekanismConfig.general.maxEnergyPerSteam.get().divide(TurbineValidator.MAX_BLADES).multiply(multiblock.clientFlow * Math.min(multiblock.blades, multiblock.coils * MekanismGeneratorsConfig.generators.turbineBladesPerCoil.get())));
        } else {
            storing = EnergyDisplay.ZERO;
            producing = EnergyDisplay.ZERO;
        }
        return Arrays.asList(MekanismLang.STORING.translate(storing), GeneratorsLang.PRODUCING_AMOUNT.translate(producing));
    }));
    addButton(new GuiGasMode(this, 159, 72, true, () -> tile.getMultiblock().dumpMode, tile.getBlockPos(), 0));
}
Also used : TurbineMultiblockData(mekanism.generators.common.content.turbine.TurbineMultiblockData) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiTurbineTab(mekanism.generators.client.gui.element.GuiTurbineTab) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) GuiVerticalPowerBar(mekanism.client.gui.element.bar.GuiVerticalPowerBar) GuiEnergyTab(mekanism.client.gui.element.tab.GuiEnergyTab) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) GuiVerticalRateBar(mekanism.client.gui.element.bar.GuiVerticalRateBar) EnergyDisplay(mekanism.common.util.text.EnergyDisplay) ArrayList(java.util.ArrayList) List(java.util.List) GuiGasMode(mekanism.client.gui.element.button.GuiGasMode)

Example 5 with IBarInfoHandler

use of mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler in project Mekanism by mekanism.

the class GuiFissionReactorStats method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiFissionReactorTab(this, tile, FissionReactorTab.MAIN));
    addButton(new GuiDynamicHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return GeneratorsLang.GAS_BURN_RATE.translate(tile.getMultiblock().lastBurnRate);
        }

        @Override
        public double getLevel() {
            FissionReactorMultiblockData multiblock = tile.getMultiblock();
            return Math.min(1, multiblock.lastBurnRate / multiblock.getMaxBurnRate());
        }
    }, 5, 114, imageWidth - 12));
    rateLimitField = addButton(new GuiTextField(this, 77, 128, 49, 12));
    rateLimitField.setEnterHandler(this::setRateLimit);
    rateLimitField.setInputValidator(InputValidator.DECIMAL);
    rateLimitField.setMaxStringLength(4);
    rateLimitField.addCheckmarkButton(this::setRateLimit);
}
Also used : GuiFissionReactorTab(mekanism.generators.client.gui.element.GuiFissionReactorTab) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiDynamicHorizontalRateBar(mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar) FissionReactorMultiblockData(mekanism.generators.common.content.fission.FissionReactorMultiblockData) GuiTextField(mekanism.client.gui.element.text.GuiTextField)

Aggregations

IBarInfoHandler (mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler)9 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)6 GuiGasGauge (mekanism.client.gui.element.gauge.GuiGasGauge)5 GuiDynamicHorizontalRateBar (mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar)4 ITextComponent (net.minecraft.util.text.ITextComponent)4 GuiVerticalRateBar (mekanism.client.gui.element.bar.GuiVerticalRateBar)3 GuiEnergyTab (mekanism.client.gui.element.tab.GuiEnergyTab)3 GuiHeatTab (mekanism.client.gui.element.tab.GuiHeatTab)3 ArrayList (java.util.ArrayList)2 GuiVerticalPowerBar (mekanism.client.gui.element.bar.GuiVerticalPowerBar)2 TranslationButton (mekanism.client.gui.element.button.TranslationButton)2 GuiEnergyGauge (mekanism.client.gui.element.gauge.GuiEnergyGauge)2 GuiFluidGauge (mekanism.client.gui.element.gauge.GuiFluidGauge)2 GuiFissionReactorTab (mekanism.generators.client.gui.element.GuiFissionReactorTab)2 FissionReactorMultiblockData (mekanism.generators.common.content.fission.FissionReactorMultiblockData)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 List (java.util.List)1 IEnergyContainer (mekanism.api.energy.IEnergyContainer)1 GuiBigLight (mekanism.client.gui.element.GuiBigLight)1 GuiDownArrow (mekanism.client.gui.element.GuiDownArrow)1