001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    
006    @SideOnly(Side.CLIENT)
007    public class GuiIngameMenu extends GuiScreen
008    {
009        /** Also counts the number of updates, not certain as to why yet. */
010        private int updateCounter2 = 0;
011    
012        /** Counts the number of screen updates. */
013        private int updateCounter = 0;
014    
015        /**
016         * Adds the buttons (and other controls) to the screen in question.
017         */
018        public void initGui()
019        {
020            this.updateCounter2 = 0;
021            this.controlList.clear();
022            byte var1 = -16;
023            this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + var1, StatCollector.translateToLocal("menu.returnToMenu")));
024    
025            if (!this.mc.isIntegratedServerRunning())
026            {
027                ((GuiButton)this.controlList.get(0)).displayString = StatCollector.translateToLocal("menu.disconnect");
028            }
029    
030            this.controlList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + var1, StatCollector.translateToLocal("menu.returnToGame")));
031            this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal("menu.options")));
032            GuiButton var3;
033            this.controlList.add(var3 = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal("menu.shareToLan")));
034            this.controlList.add(new GuiButton(5, this.width / 2 - 100, this.height / 4 + 48 + var1, 98, 20, StatCollector.translateToLocal("gui.achievements")));
035            this.controlList.add(new GuiButton(6, this.width / 2 + 2, this.height / 4 + 48 + var1, 98, 20, StatCollector.translateToLocal("gui.stats")));
036            var3.enabled = this.mc.isSingleplayer() && !this.mc.getIntegratedServer().getPublic();
037        }
038    
039        /**
040         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
041         */
042        protected void actionPerformed(GuiButton par1GuiButton)
043        {
044            switch (par1GuiButton.id)
045            {
046                case 0:
047                    this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
048                    break;
049                case 1:
050                    par1GuiButton.enabled = false;
051                    this.mc.statFileWriter.readStat(StatList.leaveGameStat, 1);
052                    this.mc.theWorld.sendQuittingDisconnectingPacket();
053                    this.mc.loadWorld((WorldClient)null);
054                    this.mc.displayGuiScreen(new GuiMainMenu());
055                case 2:
056                case 3:
057                default:
058                    break;
059                case 4:
060                    this.mc.displayGuiScreen((GuiScreen)null);
061                    this.mc.setIngameFocus();
062                    break;
063                case 5:
064                    this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter));
065                    break;
066                case 6:
067                    this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter));
068                    break;
069                case 7:
070                    this.mc.displayGuiScreen(new GuiShareToLan(this));
071            }
072        }
073    
074        /**
075         * Called from the main game loop to update the screen.
076         */
077        public void updateScreen()
078        {
079            super.updateScreen();
080            ++this.updateCounter;
081        }
082    
083        /**
084         * Draws the screen and all the components in it.
085         */
086        public void drawScreen(int par1, int par2, float par3)
087        {
088            this.drawDefaultBackground();
089            this.drawCenteredString(this.fontRenderer, "Game menu", this.width / 2, 40, 16777215);
090            super.drawScreen(par1, par2, par3);
091        }
092    }