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