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