Example usage for org.lwjgl.opengl GL11 glColor4f

List of usage examples for org.lwjgl.opengl GL11 glColor4f

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glColor4f.

Prototype

public static native void glColor4f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha);

Source Link

Document

Float version of #glColor4b Color4b

Usage

From source file:com.kaijin.AdvPowerMan.gui.GuiBatteryStation.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine//w  w w  . java 2 s.c o  m
            .bindTexture(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_BATTERY_STATION));

    this.drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Draw title text
    Utils.drawCenteredText(fontRendererObj, I18n.format(tile.getInventoryName()), xCenter, yLoc + 8, 4210752);

    if (mode != ((ContainerBatteryStation) inventorySlots).opMode) {
        mode = ((ContainerBatteryStation) inventorySlots).opMode;
        if (mode == 0) {
            button.vLoc = 200;
            button.vHoverLoc = 200;
        } else {
            button.vLoc = 185;
            button.vHoverLoc = 185;
        }
    }

    Utils.drawLeftAlignedText(fontRendererObj, I18n.format(Info.KEY_DISCHARGER_MODE_LINE1), xLoc + 7, yLoc + 59,
            4210752);
    Utils.drawLeftAlignedText(fontRendererObj, I18n.format(Info.KEY_DISCHARGER_MODE_LINE2), xLoc + 7, yLoc + 70,
            4210752);
    Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_STATS_AVERAGE_EU), xLoc + 144, yLoc + 27,
            4210752);
    Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_STATS_TIME_REMAINING), xLoc + 144, yLoc + 65,
            4210752);

    // Factor of 100 because data is in fixed point (x100)
    final float rate = (float) (((ContainerBatteryStation) inventorySlots).average) / 100F;
    Utils.drawRightAlignedGlowingText(fontRendererObj, fraction.format(rate), xLoc + 166, yLoc + 41, GREEN,
            GREENGLOW);

    String clock;
    if (rate > 0) {
        // Rate * 20 to convert per tick to per second
        int timeScratch = (int) ((float) (((ContainerBatteryStation) inventorySlots).itemsEnergyTotal)
                / (rate * 20));
        if (timeScratch <= 345600) // 60 * 60 * 96 or 4 days
        {
            final int sec = timeScratch % 60;
            timeScratch /= 60;
            final int min = timeScratch % 60;
            timeScratch /= 60;
            clock = time.format(timeScratch) + ":" + time.format(min) + ":" + time.format(sec);
        } else {
            float dayScratch = ((float) timeScratch) / 86400F; // 60 * 60 *
            // 24 or 1
            // day
            clock = (dayScratch < 10F ? dayFrac.format(dayScratch)
                    : dayScratch < 100 ? days.format((int) dayScratch) : "??")
                    + I18n.format(Info.KEY_STATS_DISPLAY_DAYS);
        }
    } else
        clock = I18n.format(Info.KEY_STATS_DISPLAY_UNKNOWN);
    Utils.drawRightAlignedGlowingText(fontRendererObj, clock, xLoc + 166, yLoc + 51, GREEN, GREENGLOW);

    button.drawButton(mc, mouseX, mouseY);
}

From source file:com.kaijin.AdvPowerMan.gui.GuiChargingBench.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine// w ww.ja va 2s  .  co  m
            .bindTexture(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_CHARGING_BENCH));

    // Draw GUI background
    drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Energy bar
    if (tile.currentEnergy > 0) {
        // Make each box light up all at once like a LED instead of
        // gradually using barLength = tile.gaugeEnergyScaled(66);
        int barLength = 5 * tile.gaugeEnergyScaled(13);
        if (barLength > 0)
            barLength++;
        drawTexturedModalRect(xLoc + 32, yLoc + 136 - barLength, 176, 66 - barLength, 12, barLength);
    }

    // Redstone power indicator
    drawTexturedModalRect(xLoc + 129, yLoc + 48, tile.receivingRedstoneSignal() ? 188 : 206, 0, 18, 15);

    // Draw labels
    Utils.drawCenteredText(fontRendererObj, I18n.format(tile.getInventoryName()), xCenter, yLoc + 7, 4210752);

    Utils.drawRightAlignedText(fontRendererObj, I18n.format(Info.KEY_EU), xLoc + 25, yLoc + 23, 4210752);
    Utils.drawLeftAlignedText(fontRendererObj, I18n.format(Info.KEY_CHARGER_MAX), xLoc + 151, yLoc + 23,
            4210752);

    Utils.drawRightAlignedText(fontRendererObj, I18n.format(Info.KEY_CHARGER_REQ), xLoc + 25, yLoc + 33,
            4210752);
    Utils.drawLeftAlignedText(fontRendererObj, I18n.format(Info.KEY_CHARGER_ETC), xLoc + 151, yLoc + 33,
            4210752);

    Utils.drawRightAlignedText(fontRendererObj, I18n.format(Info.KEY_CHARGER_AVG), xLoc + 70, yLoc + 52,
            4210752);
    Utils.drawLeftAlignedText(fontRendererObj, I18n.format(Info.KEY_CHARGER_PWR), xLoc + 151, yLoc + 52,
            4210752);

    // Draw current and max storage
    Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.currentEnergy), xCenter - 7,
            yLoc + 23, GREEN, GREENGLOW);
    Utils.drawGlowingText(fontRendererObj, " / " + Integer.toString(tile.adjustedStorage), xCenter - 7,
            yLoc + 23, GREEN, GREENGLOW);

    // Factor of 100 because data is in fixed point (x100)
    final float rate = (float) (((ContainerChargingBench) inventorySlots).averageInput) / 100F;
    Utils.drawRightAlignedGlowingText(fontRendererObj, fraction.format(rate), xLoc + 122, yLoc + 52, GREEN,
            GREENGLOW);

    // Charging stats (only displayed while charging items)
    if (tile.energyRequired > 0) {
        final String clock;
        if (tile.ticksRequired > 0) {
            int timeScratch = tile.ticksRequired / 20;
            if (timeScratch <= 345600) // 60 * 60 * 96 or 4 days
            {
                final int sec = timeScratch % 60;
                timeScratch /= 60;
                final int min = timeScratch % 60;
                timeScratch /= 60;
                clock = time.format(timeScratch) + ":" + time.format(min) + ":" + time.format(sec);
            } else {
                float dayScratch = ((float) timeScratch) / 86400F; // 60 *
                // 60 *
                // 24 or
                // 1 day
                clock = (dayScratch < 10F ? dayFrac.format(dayScratch)
                        : dayScratch < 100 ? days.format((int) dayScratch) : "??")
                        + I18n.format(Info.KEY_STATS_DISPLAY_DAYS);
            }
        } else
            clock = I18n.format(Info.KEY_STATS_DISPLAY_UNKNOWN);
        final String energyReq = tile.energyRequired > 9999999
                ? dayFrac.format(((float) tile.energyRequired) / 1000000F) + "M"
                : Integer.toString(tile.energyRequired);
        Utils.drawRightAlignedGlowingText(fontRendererObj, energyReq, xCenter - 7, yLoc + 33, GREEN, GREENGLOW);
        Utils.drawRightAlignedGlowingText(fontRendererObj, clock, xLoc + 144, yLoc + 33, GREEN, GREENGLOW);
    }
}

From source file:com.kaijin.AdvPowerMan.gui.GuiStorageMonitor.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine/*from  www.j a  v a2s  .com*/
            .bindTexture(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_STORAGE_MONITOR));

    // Draw GUI background
    drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Draw energy meter
    if (tile.energyStored > 0) {
        // Which color energy meter should be used?
        final int offset = tile.isPowering ? 12 : 0;

        // Make each box light up all at once like a LED instead of
        // gradually using barLength = this.tile.gaugeEnergyScaled(66);
        int barLength = 5 * tile.gaugeEnergyScaled(13);
        if (barLength > 0)
            barLength++;

        drawTexturedModalRect(xLoc + 10, yLoc + 100 - barLength, 176 + offset, 66 - barLength, 12, barLength);
    }

    // Draw title text
    Utils.drawCenteredText(fontRendererObj, I18n.format(tile.getInventoryName()), xLoc + 96, yLoc + 12,
            4210752);

    if (tile.energyCapacity <= 0) {
        // Error message: No card or storage unit not found
        Utils.drawCenteredGlowingText(fontRendererObj, I18n.format(Info.KEY_MONITOR_INVALID), xLoc + 96,
                yLoc + 35, RED, REDGLOW);
    } else {
        // Draw right-aligned current energy number
        Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.energyStored), xLoc + 90,
                yLoc + 35, GREEN, GREENGLOW);

        // Draw separator and left-aligned max energy number
        Utils.drawGlowingText(fontRendererObj, " / " + Integer.toString(tile.energyCapacity), xLoc + 90,
                yLoc + 35, GREEN, GREENGLOW);

        // Test strings
        // Utils.drawCenteredGlowingText(fontRenderer, " / ", xLoc + 96,
        // yLoc + 35, 0x55FF55, glowFactor);
        // Utils.drawRightAlignedGlowingText(fontRenderer, "123456789", xLoc
        // + 90, yLoc + 35, 0x55FF55, 0.15F);
        // Utils.drawGlowingText(fontRenderer, " / 123456789", xLoc + 90,
        // yLoc + 35, 0x55FF55, 0.15F);
    }

    // Draw control section labels and readouts
    Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_MONITOR_UPPER), xLoc + 96, yLoc + 49,
            0xB00000);
    Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.upperBoundary) + "%", xLoc + 109,
            yLoc + 63, GREEN, GREENGLOW);

    Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_MONITOR_LOWER), xLoc + 96, yLoc + 78,
            0xB00000);
    Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.lowerBoundary) + "%", xLoc + 109,
            yLoc + 92, GREEN, GREENGLOW);

    for (CButton button : /* Who's got the */buttons) {
        // Draw ALL of the things?! :o
        button.drawButton(mc, mouseX, mouseY);
    }
}

From source file:com.kaijin.AdvPowerMan.GuiAdjustableTransformer.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine/* ww w  .  ja  v a  2s  .com*/
            .func_110577_a(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_ADJ_TRANSFORMER));

    // Draw GUI background graphic
    drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Draw title text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(tile.getInvName()), width / 2, yLoc + 6, 4210752);

    // Draw stats text
    Utils.drawRightAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_STATS_AVERAGE_EU), xLoc + 180,
            yLoc + 26, 4210752);
    Utils.drawRightAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_STATS_AVERAGE_INPUT), xLoc + 180,
            yLoc + 36, 4210752);
    Utils.drawLeftAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_EU_BUFFERED), xLoc + 49, yLoc + 26,
            4210752);

    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.energyBuffer), xLoc + 44, yLoc + 26,
            GREEN, GREENGLOW);
    // Factor of 100 because data is in fixed point (x100)
    final float outAvg = (float) (((ContainerAdjustableTransformer) inventorySlots).outputAvg) / 100F;
    final float inAvg = (float) (((ContainerAdjustableTransformer) inventorySlots).inputAvg) / 100F;
    Utils.drawRightAlignedGlowingText(fontRenderer, fraction.format(outAvg), xLoc + 230, yLoc + 26, GREEN,
            GREENGLOW);
    Utils.drawRightAlignedGlowingText(fontRenderer, fraction.format(inAvg), xLoc + 230, yLoc + 36, GREEN,
            GREENGLOW);

    // Packet size section text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_EMITTER_PACKET), xLoc + 88,
            yLoc + yOff + 21, 0xB00000);
    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.packetSize), xLoc + 146,
            yLoc + yOff + 49, GREEN, GREENGLOW);
    fontRenderer.drawString(Info.AE_PACKET_RANGE, xLoc + 110, yLoc + yOff + 35, 4210752);
    fontRenderer.drawString(I18n.func_135053_a(Info.KEY_EU), xLoc + 152, yLoc + yOff + 49, 4210752);

    // Transfer rate section text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_TRANSFORMER_OUTPUT), xLoc + 88,
            yLoc + yOff + 64, 0xB00000);
    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.outputRate), xLoc + 146,
            yLoc + yOff + 92, GREEN, GREENGLOW);
    fontRenderer.drawString(Info.AE_OUTPUT_RANGE, xLoc + 110, yLoc + yOff + 78, 4210752);
    fontRenderer.drawString(I18n.func_135053_a(Info.KEY_EU), xLoc + 152, yLoc + yOff + 92, 4210752);

    // Side input/output settings text
    for (int i = 0; i < 6; i++) {
        Utils.drawGlowingText(fontRenderer,
                I18n.func_135053_a((tile.sideSettings[i] & 1) == 0 ? Info.KEY_IN : Info.KEY_OUT), xLoc + 214,
                yLoc + yOff + 27 + 13 * i, GREEN, GREENGLOW);
    }

    //Buttons MUST be drawn after other texture stuff or it will not draw the battery meter correctly
    for (CButton button : buttons) {
        button.drawButton(mc, mouseX, mouseY);
    }
    for (CButton button : dirButtons) {
        button.drawButton(mc, mouseX, mouseY);
    }
}

From source file:com.kaijin.AdvPowerMan.GuiAdvEmitter.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.func_110577_a(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_EMITTER));

    // Draw GUI background graphic
    drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Draw title text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(tile.getInvName()), width / 2, yLoc + 7, 4210752);

    // Packet size section text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_EMITTER_PACKET), width / 2, yLoc + 21,
            0xB00000);/* w w  w  .j  a  v  a2s.c om*/
    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.packetSize), xLoc + 146, yLoc + 49,
            GREEN, GREENGLOW);
    fontRenderer.drawString(Info.AE_PACKET_RANGE, xLoc + 110, yLoc + 35, 4210752);
    fontRenderer.drawString(I18n.func_135053_a(Info.KEY_EU), xLoc + 152, yLoc + 49, 4210752);

    // Output rate section text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_EMITTER_OUTPUT), width / 2, yLoc + 64,
            0xB00000);
    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.outputRate), xLoc + 146, yLoc + 92,
            GREEN, GREENGLOW);
    fontRenderer.drawString(Info.AE_OUTPUT_RANGE, xLoc + 110, yLoc + 78, 4210752);
    fontRenderer.drawString(I18n.func_135053_a(Info.KEY_EU), xLoc + 152, yLoc + 92, 4210752);

    //Buttons MUST be drawn after other texture stuff or it will not draw the battery meter correctly
    for (CButton button : buttons) {
        button.drawButton(mc, mouseX, mouseY);
    }
}

From source file:com.kaijin.AdvPowerMan.GuiBatteryStation.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine/*from  w  w  w . jav a  2s.  c o  m*/
            .func_110577_a(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_BATTERY_STATION));

    this.drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Draw title text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(tile.getInvName()), xCenter, yLoc + 8, 4210752);

    if (mode != ((ContainerBatteryStation) inventorySlots).opMode) {
        mode = ((ContainerBatteryStation) inventorySlots).opMode;
        if (mode == 0) {
            button.vLoc = 200;
            button.vHoverLoc = 200;
        } else {
            button.vLoc = 185;
            button.vHoverLoc = 185;
        }
    }

    Utils.drawLeftAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_DISCHARGER_MODE_LINE1), xLoc + 7,
            yLoc + 59, 4210752);
    Utils.drawLeftAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_DISCHARGER_MODE_LINE2), xLoc + 7,
            yLoc + 70, 4210752);
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_STATS_AVERAGE_EU), xLoc + 144, yLoc + 27,
            4210752);
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_STATS_TIME_REMAINING), xLoc + 144,
            yLoc + 65, 4210752);

    // Factor of 100 because data is in fixed point (x100)
    final float rate = (float) (((ContainerBatteryStation) inventorySlots).average) / 100F;
    Utils.drawRightAlignedGlowingText(fontRenderer, fraction.format(rate), xLoc + 166, yLoc + 41, GREEN,
            GREENGLOW);

    String clock;
    if (rate > 0) {
        // Rate * 20 to convert per tick to per second
        int timeScratch = (int) ((float) (((ContainerBatteryStation) inventorySlots).itemsEnergyTotal)
                / (rate * 20));
        if (timeScratch <= 345600) // 60 * 60 * 96 or 4 days
        {
            final int sec = timeScratch % 60;
            timeScratch /= 60;
            final int min = timeScratch % 60;
            timeScratch /= 60;
            clock = time.format(timeScratch) + ":" + time.format(min) + ":" + time.format(sec);
        } else {
            float dayScratch = ((float) timeScratch) / 86400F; // 60 * 60 * 24 or 1 day
            clock = (dayScratch < 10F ? dayFrac.format(dayScratch)
                    : dayScratch < 100 ? days.format((int) dayScratch) : "??")
                    + I18n.func_135053_a(Info.KEY_STATS_DISPLAY_DAYS);
        }
    } else
        clock = I18n.func_135053_a(Info.KEY_STATS_DISPLAY_UNKNOWN);
    Utils.drawRightAlignedGlowingText(fontRenderer, clock, xLoc + 166, yLoc + 51, GREEN, GREENGLOW);

    button.drawButton(mc, mouseX, mouseY);
}

From source file:com.kaijin.AdvPowerMan.GuiChargingBench.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine/*w  w  w  . j a  v a 2 s  . com*/
            .func_110577_a(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_CHARGING_BENCH));

    // Draw GUI background
    drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Energy bar
    if (tile.currentEnergy > 0) {
        // Make each box light up all at once like a LED instead of gradually using barLength = tile.gaugeEnergyScaled(66); 
        int barLength = 5 * tile.gaugeEnergyScaled(13);
        if (barLength > 0)
            barLength++;
        drawTexturedModalRect(xLoc + 32, yLoc + 136 - barLength, 176, 66 - barLength, 12, barLength);
    }

    // Redstone power indicator
    drawTexturedModalRect(xLoc + 129, yLoc + 48, tile.receivingRedstoneSignal() ? 188 : 206, 0, 18, 15);

    // Draw labels
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(tile.getInvName()), xCenter, yLoc + 7, 4210752);

    Utils.drawRightAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_EU), xLoc + 25, yLoc + 23, 4210752);
    Utils.drawLeftAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_CHARGER_MAX), xLoc + 151, yLoc + 23,
            4210752);

    Utils.drawRightAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_CHARGER_REQ), xLoc + 25, yLoc + 33,
            4210752);
    Utils.drawLeftAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_CHARGER_ETC), xLoc + 151, yLoc + 33,
            4210752);

    Utils.drawRightAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_CHARGER_AVG), xLoc + 70, yLoc + 52,
            4210752);
    Utils.drawLeftAlignedText(fontRenderer, I18n.func_135053_a(Info.KEY_CHARGER_PWR), xLoc + 151, yLoc + 52,
            4210752);

    // Draw current and max storage
    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.currentEnergy), xCenter - 7,
            yLoc + 23, GREEN, GREENGLOW);
    Utils.drawGlowingText(fontRenderer, " / " + Integer.toString(tile.adjustedStorage), xCenter - 7, yLoc + 23,
            GREEN, GREENGLOW);

    // Factor of 100 because data is in fixed point (x100)
    final float rate = (float) (((ContainerChargingBench) inventorySlots).averageInput) / 100F;
    Utils.drawRightAlignedGlowingText(fontRenderer, fraction.format(rate), xLoc + 122, yLoc + 52, GREEN,
            GREENGLOW);

    // Charging stats (only displayed while charging items)
    if (tile.energyRequired > 0) {
        final String clock;
        if (tile.ticksRequired > 0) {
            int timeScratch = tile.ticksRequired / 20;
            if (timeScratch <= 345600) // 60 * 60 * 96 or 4 days
            {
                final int sec = timeScratch % 60;
                timeScratch /= 60;
                final int min = timeScratch % 60;
                timeScratch /= 60;
                clock = time.format(timeScratch) + ":" + time.format(min) + ":" + time.format(sec);
            } else {
                float dayScratch = ((float) timeScratch) / 86400F; // 60 * 60 * 24 or 1 day
                clock = (dayScratch < 10F ? dayFrac.format(dayScratch)
                        : dayScratch < 100 ? days.format((int) dayScratch) : "??")
                        + I18n.func_135053_a(Info.KEY_STATS_DISPLAY_DAYS);
            }
        } else
            clock = I18n.func_135053_a(Info.KEY_STATS_DISPLAY_UNKNOWN);
        final String energyReq = tile.energyRequired > 9999999
                ? dayFrac.format(((float) tile.energyRequired) / 1000000F) + "M"
                : Integer.toString(tile.energyRequired);
        Utils.drawRightAlignedGlowingText(fontRenderer, energyReq, xCenter - 7, yLoc + 33, GREEN, GREENGLOW);
        Utils.drawRightAlignedGlowingText(fontRenderer, clock, xLoc + 144, yLoc + 33, GREEN, GREENGLOW);
    }
}

From source file:com.kaijin.AdvPowerMan.GuiStorageMonitor.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine//from   w w  w.java  2s  . co m
            .func_110577_a(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_STORAGE_MONITOR));

    // Draw GUI background
    drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize);

    // Draw energy meter
    if (tile.energyStored > 0) {
        // Which color energy meter should be used?
        final int offset = tile.isPowering ? 12 : 0;

        // Make each box light up all at once like a LED instead of gradually using barLength = this.tile.gaugeEnergyScaled(66); 
        int barLength = 5 * tile.gaugeEnergyScaled(13);
        if (barLength > 0)
            barLength++;

        drawTexturedModalRect(xLoc + 10, yLoc + 100 - barLength, 176 + offset, 66 - barLength, 12, barLength);
    }

    // Draw title text
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(tile.getInvName()), xLoc + 96, yLoc + 12, 4210752);

    if (tile.energyCapacity <= 0) {
        // Error message: No card or storage unit not found
        Utils.drawCenteredGlowingText(fontRenderer, I18n.func_135053_a(Info.KEY_MONITOR_INVALID), xLoc + 96,
                yLoc + 35, RED, REDGLOW);
    } else {
        // Draw right-aligned current energy number
        Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.energyStored), xLoc + 90,
                yLoc + 35, GREEN, GREENGLOW);

        // Draw separator and left-aligned max energy number
        Utils.drawGlowingText(fontRenderer, " / " + Integer.toString(tile.energyCapacity), xLoc + 90, yLoc + 35,
                GREEN, GREENGLOW);

        // Test strings
        //Utils.drawCenteredGlowingText(fontRenderer, " / ", xLoc + 96, yLoc + 35, 0x55FF55, glowFactor);
        //Utils.drawRightAlignedGlowingText(fontRenderer, "123456789", xLoc + 90, yLoc + 35, 0x55FF55, 0.15F);
        //Utils.drawGlowingText(fontRenderer, " / 123456789", xLoc + 90, yLoc + 35, 0x55FF55, 0.15F);
    }

    // Draw control section labels and readouts
    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_MONITOR_UPPER), xLoc + 96, yLoc + 49,
            0xB00000);
    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.upperBoundary) + "%", xLoc + 109,
            yLoc + 63, GREEN, GREENGLOW);

    Utils.drawCenteredText(fontRenderer, I18n.func_135053_a(Info.KEY_MONITOR_LOWER), xLoc + 96, yLoc + 78,
            0xB00000);
    Utils.drawRightAlignedGlowingText(fontRenderer, Integer.toString(tile.lowerBoundary) + "%", xLoc + 109,
            yLoc + 92, GREEN, GREENGLOW);

    for (CButton button : /* Who's got the */ buttons) {
        // Draw ALL of the things?! :o
        button.drawButton(mc, mouseX, mouseY);
    }
}

From source file:com.kaijin.GenericMod.GuiGenericMod.java

License:Open Source License

/**
 * Draw the background layer for the GuiContainer (everything behind the items)
 *//*from  w  w  w .  j  a v  a2s . co  m*/
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY) {
    int GuiTex = this.mc.renderEngine.getTexture("/com/kaijin/GenericMod/textures/GenericMod.png");
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.renderEngine.bindTexture(GuiTex);
    int XOffset = (width - xSize) / 2; // X offset = Half the difference between screen width and GUI width
    int YOffset = (height - ySize) / 2; // Y offset = half the difference between screen height and GUI height
    this.drawTexturedModalRect(XOffset, YOffset, 0, 0, xSize, ySize);

    //GuiButton(int ID, int XOffset, int YOffset, int Width, int Height, string Text)
    //button definition is the full one with width and height
    //defining button below, setting it look enabled and drawing it
    //If you make changes to the button state, you must call .drawButton(mc, XOffset, YOffset)
}

From source file:com.kanbekotori.keycraft.renderer.BlockTrapRenderer.java

License:Open Source License

@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;

    if (renderer.useInventoryTint) {
        int j = block.getRenderColor(metadata);

        float f1 = (float) (j >> 16 & 255) / 255.0F;
        float f2 = (float) (j >> 8 & 255) / 255.0F;
        float f3 = (float) (j & 255) / 255.0F;
        GL11.glColor4f(f1, f2, f3, 1.0F);
    }//from w  w  w .  ja  va  2  s. c om
    renderer.setRenderBoundsFromBlock(block);

    block.setBlockBoundsForItemRender();
    renderer.setRenderBoundsFromBlock(block);
    GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D,
            renderer.getBlockIconFromSideAndMetadata(block, 0, metadata));
    tessellator.draw();

    if (renderer.useInventoryTint) {
        int k = block.getRenderColor(metadata);
        float f2 = (float) (k >> 16 & 255) / 255.0F;
        float f3 = (float) (k >> 8 & 255) / 255.0F;
        float f4 = (float) (k & 255) / 255.0F;
        GL11.glColor4f(f2, f3, f4, 1.0F);
    }

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D,
            renderer.getBlockIconFromSideAndMetadata(block, 1, metadata));
    tessellator.draw();

    if (renderer.useInventoryTint) {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D,
            renderer.getBlockIconFromSideAndMetadata(block, 2, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D,
            renderer.getBlockIconFromSideAndMetadata(block, 3, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D,
            renderer.getBlockIconFromSideAndMetadata(block, 4, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D,
            renderer.getBlockIconFromSideAndMetadata(block, 5, metadata));
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}