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