    001package net.minecraft.client.gui;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.renderer.Tessellator;
    006import org.lwjgl.opengl.GL11;
    007
    008@SideOnly(Side.CLIENT)
    009public class Gui
    010{
    011    protected float zLevel = 0.0F;
    012
    013    protected void drawHorizontalLine(int par1, int par2, int par3, int par4)
    014    {
    015        if (par2 < par1)
    016        {
    017            int var5 = par1;
    018            par1 = par2;
    019            par2 = var5;
    020        }
    021
    022        drawRect(par1, par3, par2 + 1, par3 + 1, par4);
    023    }
    024
    025    protected void drawVerticalLine(int par1, int par2, int par3, int par4)
    026    {
    027        if (par3 < par2)
    028        {
    029            int var5 = par2;
    030            par2 = par3;
    031            par3 = var5;
    032        }
    033
    034        drawRect(par1, par2 + 1, par1 + 1, par3, par4);
    035    }
    036
    037    /**
    038     * Draws a solid color rectangle with the specified coordinates and color. Args: x1, y1, x2, y2, color
    039     */
    040    public static void drawRect(int par0, int par1, int par2, int par3, int par4)
    041    {
    042        int var5;
    043
    044        if (par0 < par2)
    045        {
    046            var5 = par0;
    047            par0 = par2;
    048            par2 = var5;
    049        }
    050
    051        if (par1 < par3)
    052        {
    053            var5 = par1;
    054            par1 = par3;
    055            par3 = var5;
    056        }
    057
    058        float var10 = (float)(par4 >> 24 & 255) / 255.0F;
    059        float var6 = (float)(par4 >> 16 & 255) / 255.0F;
    060        float var7 = (float)(par4 >> 8 & 255) / 255.0F;
    061        float var8 = (float)(par4 & 255) / 255.0F;
    062        Tessellator var9 = Tessellator.instance;
    063        GL11.glEnable(GL11.GL_BLEND);
    064        GL11.glDisable(GL11.GL_TEXTURE_2D);
    065        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    066        GL11.glColor4f(var6, var7, var8, var10);
    067        var9.startDrawingQuads();
    068        var9.addVertex((double)par0, (double)par3, 0.0D);
    069        var9.addVertex((double)par2, (double)par3, 0.0D);
    070        var9.addVertex((double)par2, (double)par1, 0.0D);
    071        var9.addVertex((double)par0, (double)par1, 0.0D);
    072        var9.draw();
    073        GL11.glEnable(GL11.GL_TEXTURE_2D);
    074        GL11.glDisable(GL11.GL_BLEND);
    075    }
    076
    077    /**
    078     * Draws a rectangle with a vertical gradient between the specified colors.
    079     */
    080    protected void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6)
    081    {
    082        float var7 = (float)(par5 >> 24 & 255) / 255.0F;
    083        float var8 = (float)(par5 >> 16 & 255) / 255.0F;
    084        float var9 = (float)(par5 >> 8 & 255) / 255.0F;
    085        float var10 = (float)(par5 & 255) / 255.0F;
    086        float var11 = (float)(par6 >> 24 & 255) / 255.0F;
    087        float var12 = (float)(par6 >> 16 & 255) / 255.0F;
    088        float var13 = (float)(par6 >> 8 & 255) / 255.0F;
    089        float var14 = (float)(par6 & 255) / 255.0F;
    090        GL11.glDisable(GL11.GL_TEXTURE_2D);
    091        GL11.glEnable(GL11.GL_BLEND);
    092        GL11.glDisable(GL11.GL_ALPHA_TEST);
    093        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    094        GL11.glShadeModel(GL11.GL_SMOOTH);
    095        Tessellator var15 = Tessellator.instance;
    096        var15.startDrawingQuads();
    097        var15.setColorRGBA_F(var8, var9, var10, var7);
    098        var15.addVertex((double)par3, (double)par2, (double)this.zLevel);
    099        var15.addVertex((double)par1, (double)par2, (double)this.zLevel);
    100        var15.setColorRGBA_F(var12, var13, var14, var11);
    101        var15.addVertex((double)par1, (double)par4, (double)this.zLevel);
    102        var15.addVertex((double)par3, (double)par4, (double)this.zLevel);
    103        var15.draw();
    104        GL11.glShadeModel(GL11.GL_FLAT);
    105        GL11.glDisable(GL11.GL_BLEND);
    106        GL11.glEnable(GL11.GL_ALPHA_TEST);
    107        GL11.glEnable(GL11.GL_TEXTURE_2D);
    108    }
    109
    110    /**
    111     * Renders the specified text to the screen, center-aligned.
    112     */
    113    public void drawCenteredString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5)
    114    {
    115        par1FontRenderer.drawStringWithShadow(par2Str, par3 - par1FontRenderer.getStringWidth(par2Str) / 2, par4, par5);
    116    }
    117
    118    /**
    119     * Renders the specified text to the screen.
    120     */
    121    public void drawString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5)
    122    {
    123        par1FontRenderer.drawStringWithShadow(par2Str, par3, par4, par5);
    124    }
    125
    126    /**
    127     * Draws a textured rectangle at the stored z-value. Args: x, y, u, v, width, height
    128     */
    129    public void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6)
    130    {
    131        float var7 = 0.00390625F;
    132        float var8 = 0.00390625F;
    133        Tessellator var9 = Tessellator.instance;
    134        var9.startDrawingQuads();
    135        var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + par6) * var8));
    136        var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + par6) * var8));
    137        var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + 0) * var8));
    138        var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + 0) * var8));
    139        var9.draw();
    140    }
    141}