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 java.util.List; 007 008 @SideOnly(Side.CLIENT) 009 public class GuiDisconnected extends GuiScreen 010 { 011 /** The error message. */ 012 private String errorMessage; 013 014 /** The details about the error. */ 015 private String errorDetail; 016 private Object[] field_74247_c; 017 private List field_74245_d; 018 019 public GuiDisconnected(String par1Str, String par2Str, Object ... par3ArrayOfObj) 020 { 021 StringTranslate var4 = StringTranslate.getInstance(); 022 this.errorMessage = var4.translateKey(par1Str); 023 this.errorDetail = par2Str; 024 this.field_74247_c = par3ArrayOfObj; 025 } 026 027 /** 028 * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). 029 */ 030 protected void keyTyped(char par1, int par2) {} 031 032 /** 033 * Adds the buttons (and other controls) to the screen in question. 034 */ 035 public void initGui() 036 { 037 StringTranslate var1 = StringTranslate.getInstance(); 038 this.controlList.clear(); 039 this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, var1.translateKey("gui.toMenu"))); 040 041 if (this.field_74247_c != null) 042 { 043 this.field_74245_d = this.fontRenderer.listFormattedStringToWidth(var1.translateKeyFormat(this.errorDetail, this.field_74247_c), this.width - 50); 044 } 045 else 046 { 047 this.field_74245_d = this.fontRenderer.listFormattedStringToWidth(var1.translateKey(this.errorDetail), this.width - 50); 048 } 049 } 050 051 /** 052 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). 053 */ 054 protected void actionPerformed(GuiButton par1GuiButton) 055 { 056 if (par1GuiButton.id == 0) 057 { 058 this.mc.displayGuiScreen(new GuiMainMenu()); 059 } 060 } 061 062 /** 063 * Draws the screen and all the components in it. 064 */ 065 public void drawScreen(int par1, int par2, float par3) 066 { 067 this.drawDefaultBackground(); 068 this.drawCenteredString(this.fontRenderer, this.errorMessage, this.width / 2, this.height / 2 - 50, 11184810); 069 int var4 = this.height / 2 - 30; 070 071 if (this.field_74245_d != null) 072 { 073 for (Iterator var5 = this.field_74245_d.iterator(); var5.hasNext(); var4 += this.fontRenderer.FONT_HEIGHT) 074 { 075 String var6 = (String)var5.next(); 076 this.drawCenteredString(this.fontRenderer, var6, this.width / 2, var4, 16777215); 077 } 078 } 079 080 super.drawScreen(par1, par2, par3); 081 } 082 }