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