    001package net.minecraft.client.gui;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.Iterator;
    006import net.minecraft.client.multiplayer.WorldClient;
    007import net.minecraft.util.StatCollector;
    008import org.lwjgl.opengl.GL11;
    009
    010@SideOnly(Side.CLIENT)
    011public class GuiGameOver extends GuiScreen
    012{
    013    /**
    014     * The cooldown timer for the buttons, increases every tick and enables all buttons when reaching 20.
    015     */
    016    private int cooldownTimer;
    017
    018    /**
    019     * Adds the buttons (and other controls) to the screen in question.
    020     */
    021    public void initGui()
    022    {
    023        this.controlList.clear();
    024
    025        if (this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled())
    026        {
    027            if (this.mc.isIntegratedServerRunning())
    028            {
    029                this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, StatCollector.translateToLocal("deathScreen.deleteWorld")));
    030            }
    031            else
    032            {
    033                this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, StatCollector.translateToLocal("deathScreen.leaveServer")));
    034            }
    035        }
    036        else
    037        {
    038            this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 72, StatCollector.translateToLocal("deathScreen.respawn")));
    039            this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 96, StatCollector.translateToLocal("deathScreen.titleScreen")));
    040
    041            if (this.mc.session == null)
    042            {
    043                ((GuiButton)this.controlList.get(1)).enabled = false;
    044            }
    045        }
    046
    047        GuiButton var2;
    048
    049        for (Iterator var1 = this.controlList.iterator(); var1.hasNext(); var2.enabled = false)
    050        {
    051            var2 = (GuiButton)var1.next();
    052        }
    053    }
    054
    055    /**
    056     * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
    057     */
    058    protected void keyTyped(char par1, int par2) {}
    059
    060    /**
    061     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    062     */
    063    protected void actionPerformed(GuiButton par1GuiButton)
    064    {
    065        switch (par1GuiButton.id)
    066        {
    067            case 1:
    068                this.mc.thePlayer.respawnPlayer();
    069                this.mc.displayGuiScreen((GuiScreen)null);
    070                break;
    071            case 2:
    072                this.mc.theWorld.sendQuittingDisconnectingPacket();
    073                this.mc.loadWorld((WorldClient)null);
    074                this.mc.displayGuiScreen(new GuiMainMenu());
    075        }
    076    }
    077
    078    /**
    079     * Draws the screen and all the components in it.
    080     */
    081    public void drawScreen(int par1, int par2, float par3)
    082    {
    083        this.drawGradientRect(0, 0, this.width, this.height, 1615855616, -1602211792);
    084        GL11.glPushMatrix();
    085        GL11.glScalef(2.0F, 2.0F, 2.0F);
    086        boolean var4 = this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled();
    087        String var5 = var4 ? StatCollector.translateToLocal("deathScreen.title.hardcore") : StatCollector.translateToLocal("deathScreen.title");
    088        this.drawCenteredString(this.fontRenderer, var5, this.width / 2 / 2, 30, 16777215);
    089        GL11.glPopMatrix();
    090
    091        if (var4)
    092        {
    093            this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("deathScreen.hardcoreInfo"), this.width / 2, 144, 16777215);
    094        }
    095
    096        this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("deathScreen.score") + ": \u00a7e" + this.mc.thePlayer.getScore(), this.width / 2, 100, 16777215);
    097        super.drawScreen(par1, par2, par3);
    098    }
    099
    100    /**
    101     * Returns true if this GUI should pause the game when it is displayed in single-player
    102     */
    103    public boolean doesGuiPauseGame()
    104    {
    105        return false;
    106    }
    107
    108    /**
    109     * Called from the main game loop to update the screen.
    110     */
    111    public void updateScreen()
    112    {
    113        super.updateScreen();
    114        ++this.cooldownTimer;
    115        GuiButton var2;
    116
    117        if (this.cooldownTimer == 20)
    118        {
    119            for (Iterator var1 = this.controlList.iterator(); var1.hasNext(); var2.enabled = true)
    120            {
    121                var2 = (GuiButton)var1.next();
    122            }
    123        }
    124    }
    125}