    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.client.Minecraft;
    006    import org.lwjgl.opengl.GL11;
    007    import org.lwjgl.opengl.GL12;
    008
    009    @SideOnly(Side.CLIENT)
    010    public class GuiStats extends GuiScreen
    011    {
    012        private static RenderItem renderItem = new RenderItem();
    013        protected GuiScreen parentGui;
    014
    015        /** The title of the stats screen. */
    016        protected String statsTitle = "Select world";
    017
    018        /** The slot for general stats. */
    019        private GuiSlotStatsGeneral slotGeneral;
    020
    021        /** The slot for item stats. */
    022        private GuiSlotStatsItem slotItem;
    023
    024        /** The slot for block stats. */
    025        private GuiSlotStatsBlock slotBlock;
    026        private StatFileWriter statFileWriter;
    027
    028        /** The currently-selected slot. */
    029        private GuiSlot selectedSlot = null;
    030
    031        public GuiStats(GuiScreen par1GuiScreen, StatFileWriter par2StatFileWriter)
    032        {
    033            this.parentGui = par1GuiScreen;
    034            this.statFileWriter = par2StatFileWriter;
    035        }
    036
    037        /**
    038         * Adds the buttons (and other controls) to the screen in question.
    039         */
    040        public void initGui()
    041        {
    042            this.statsTitle = StatCollector.translateToLocal("gui.stats");
    043            this.slotGeneral = new GuiSlotStatsGeneral(this);
    044            this.slotGeneral.registerScrollButtons(this.controlList, 1, 1);
    045            this.slotItem = new GuiSlotStatsItem(this);
    046            this.slotItem.registerScrollButtons(this.controlList, 1, 1);
    047            this.slotBlock = new GuiSlotStatsBlock(this);
    048            this.slotBlock.registerScrollButtons(this.controlList, 1, 1);
    049            this.selectedSlot = this.slotGeneral;
    050            this.addHeaderButtons();
    051        }
    052
    053        /**
    054         * Creates the buttons that appear at the top of the Stats GUI.
    055         */
    056        public void addHeaderButtons()
    057        {
    058            StringTranslate var1 = StringTranslate.getInstance();
    059            this.controlList.add(new GuiButton(0, this.width / 2 + 4, this.height - 28, 150, 20, var1.translateKey("gui.done")));
    060            this.controlList.add(new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, var1.translateKey("stat.generalButton")));
    061            GuiButton var2;
    062            this.controlList.add(var2 = new GuiButton(2, this.width / 2 - 46, this.height - 52, 100, 20, var1.translateKey("stat.blocksButton")));
    063            GuiButton var3;
    064            this.controlList.add(var3 = new GuiButton(3, this.width / 2 + 62, this.height - 52, 100, 20, var1.translateKey("stat.itemsButton")));
    065
    066            if (this.slotBlock.getSize() == 0)
    067            {
    068                var2.enabled = false;
    069            }
    070
    071            if (this.slotItem.getSize() == 0)
    072            {
    073                var3.enabled = false;
    074            }
    075        }
    076
    077        /**
    078         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    079         */
    080        protected void actionPerformed(GuiButton par1GuiButton)
    081        {
    082            if (par1GuiButton.enabled)
    083            {
    084                if (par1GuiButton.id == 0)
    085                {
    086                    this.mc.displayGuiScreen(this.parentGui);
    087                }
    088                else if (par1GuiButton.id == 1)
    089                {
    090                    this.selectedSlot = this.slotGeneral;
    091                }
    092                else if (par1GuiButton.id == 3)
    093                {
    094                    this.selectedSlot = this.slotItem;
    095                }
    096                else if (par1GuiButton.id == 2)
    097                {
    098                    this.selectedSlot = this.slotBlock;
    099                }
    100                else
    101                {
    102                    this.selectedSlot.actionPerformed(par1GuiButton);
    103                }
    104            }
    105        }
    106
    107        /**
    108         * Draws the screen and all the components in it.
    109         */
    110        public void drawScreen(int par1, int par2, float par3)
    111        {
    112            this.selectedSlot.drawScreen(par1, par2, par3);
    113            this.drawCenteredString(this.fontRenderer, this.statsTitle, this.width / 2, 20, 16777215);
    114            super.drawScreen(par1, par2, par3);
    115        }
    116
    117        /**
    118         * Draws the item sprite on top of the background sprite.
    119         */
    120        private void drawItemSprite(int par1, int par2, int par3)
    121        {
    122            this.drawButtonBackground(par1 + 1, par2 + 1);
    123            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    124            RenderHelper.enableGUIStandardItemLighting();
    125            renderItem.drawItemIntoGui(this.fontRenderer, this.mc.renderEngine, par3, 0, Item.itemsList[par3].getIconFromDamage(0), par1 + 2, par2 + 2);
    126            RenderHelper.disableStandardItemLighting();
    127            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    128        }
    129
    130        /**
    131         * Draws a gray box that serves as a button background.
    132         */
    133        private void drawButtonBackground(int par1, int par2)
    134        {
    135            this.drawSprite(par1, par2, 0, 0);
    136        }
    137
    138        /**
    139         * Draws a sprite from /gui/slot.png.
    140         */
    141        private void drawSprite(int par1, int par2, int par3, int par4)
    142        {
    143            int var5 = this.mc.renderEngine.getTexture("/gui/slot.png");
    144            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    145            this.mc.renderEngine.bindTexture(var5);
    146            Tessellator var10 = Tessellator.instance;
    147            var10.startDrawingQuads();
    148            var10.addVertexWithUV((double)(par1 + 0), (double)(par2 + 18), (double)this.zLevel, (double)((float)(par3 + 0) * 0.0078125F), (double)((float)(par4 + 18) * 0.0078125F));
    149            var10.addVertexWithUV((double)(par1 + 18), (double)(par2 + 18), (double)this.zLevel, (double)((float)(par3 + 18) * 0.0078125F), (double)((float)(par4 + 18) * 0.0078125F));
    150            var10.addVertexWithUV((double)(par1 + 18), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + 18) * 0.0078125F), (double)((float)(par4 + 0) * 0.0078125F));
    151            var10.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + 0) * 0.0078125F), (double)((float)(par4 + 0) * 0.0078125F));
    152            var10.draw();
    153        }
    154
    155        static Minecraft getMinecraft(GuiStats par0GuiStats)
    156        {
    157            return par0GuiStats.mc;
    158        }
    159
    160        /**
    161         * there are 11 identical methods like this
    162         */
    163        static FontRenderer getFontRenderer1(GuiStats par0GuiStats)
    164        {
    165            return par0GuiStats.fontRenderer;
    166        }
    167
    168        static StatFileWriter getStatsFileWriter(GuiStats par0GuiStats)
    169        {
    170            return par0GuiStats.statFileWriter;
    171        }
    172
    173        /**
    174         * there are 11 identical methods like this
    175         */
    176        static FontRenderer getFontRenderer2(GuiStats par0GuiStats)
    177        {
    178            return par0GuiStats.fontRenderer;
    179        }
    180
    181        /**
    182         * there are 11 identical methods like this
    183         */
    184        static FontRenderer getFontRenderer3(GuiStats par0GuiStats)
    185        {
    186            return par0GuiStats.fontRenderer;
    187        }
    188
    189        /**
    190         * exactly the same as 27141
    191         */
    192        static Minecraft getMinecraft1(GuiStats par0GuiStats)
    193        {
    194            return par0GuiStats.mc;
    195        }
    196
    197        /**
    198         * Draws a sprite from /gui/slot.png.
    199         */
    200        static void drawSprite(GuiStats par0GuiStats, int par1, int par2, int par3, int par4)
    201        {
    202            par0GuiStats.drawSprite(par1, par2, par3, par4);
    203        }
    204
    205        /**
    206         * exactly the same as 27141 and 27143
    207         */
    208        static Minecraft getMinecraft2(GuiStats par0GuiStats)
    209        {
    210            return par0GuiStats.mc;
    211        }
    212
    213        /**
    214         * there are 11 identical methods like this
    215         */
    216        static FontRenderer getFontRenderer4(GuiStats par0GuiStats)
    217        {
    218            return par0GuiStats.fontRenderer;
    219        }
    220
    221        /**
    222         * there are 11 identical methods like this
    223         */
    224        static FontRenderer getFontRenderer5(GuiStats par0GuiStats)
    225        {
    226            return par0GuiStats.fontRenderer;
    227        }
    228
    229        /**
    230         * there are 11 identical methods like this
    231         */
    232        static FontRenderer getFontRenderer6(GuiStats par0GuiStats)
    233        {
    234            return par0GuiStats.fontRenderer;
    235        }
    236
    237        /**
    238         * there are 11 identical methods like this
    239         */
    240        static FontRenderer getFontRenderer7(GuiStats par0GuiStats)
    241        {
    242            return par0GuiStats.fontRenderer;
    243        }
    244
    245        /**
    246         * there are 11 identical methods like this
    247         */
    248        static FontRenderer getFontRenderer8(GuiStats par0GuiStats)
    249        {
    250            return par0GuiStats.fontRenderer;
    251        }
    252
    253        static void drawGradientRect(GuiStats par0GuiStats, int par1, int par2, int par3, int par4, int par5, int par6)
    254        {
    255            par0GuiStats.drawGradientRect(par1, par2, par3, par4, par5, par6);
    256        }
    257
    258        /**
    259         * there are 11 identical methods like this
    260         */
    261        static FontRenderer getFontRenderer9(GuiStats par0GuiStats)
    262        {
    263            return par0GuiStats.fontRenderer;
    264        }
    265
    266        /**
    267         * there are 11 identical methods like this
    268         */
    269        static FontRenderer getFontRenderer10(GuiStats par0GuiStats)
    270        {
    271            return par0GuiStats.fontRenderer;
    272        }
    273
    274        /**
    275         * exactly the same as 27129
    276         */
    277        static void drawGradientRect1(GuiStats par0GuiStats, int par1, int par2, int par3, int par4, int par5, int par6)
    278        {
    279            par0GuiStats.drawGradientRect(par1, par2, par3, par4, par5, par6);
    280        }
    281
    282        /**
    283         * there are 11 identical methods like this
    284         */
    285        static FontRenderer getFontRenderer11(GuiStats par0GuiStats)
    286        {
    287            return par0GuiStats.fontRenderer;
    288        }
    289
    290        /**
    291         * Draws the item sprite on top of the background sprite.
    292         */
    293        static void drawItemSprite(GuiStats par0GuiStats, int par1, int par2, int par3)
    294        {
    295            par0GuiStats.drawItemSprite(par1, par2, par3);
    296        }
    297    }