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