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