    001package net.minecraft.client.gui;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.Minecraft;
    006import net.minecraft.client.mco.McoServer;
    007import net.minecraft.util.StringTranslate;
    008import org.lwjgl.input.Keyboard;
    009
    010@SideOnly(Side.CLIENT)
    011public class GuiScreenResetWorld extends GuiScreen
    012{
    013    private GuiScreen field_96152_a;
    014    private McoServer field_96150_b;
    015    private GuiTextField field_96151_c;
    016    private final int field_96149_d = 1;
    017    private final int field_96153_n = 2;
    018    private GuiButton field_96154_o;
    019
    020    public GuiScreenResetWorld(GuiScreen par1, McoServer par2)
    021    {
    022        this.field_96152_a = par1;
    023        this.field_96150_b = par2;
    024    }
    025
    026    /**
    027     * Called from the main game loop to update the screen.
    028     */
    029    public void updateScreen()
    030    {
    031        this.field_96151_c.updateCursorCounter();
    032    }
    033
    034    /**
    035     * Adds the buttons (and other controls) to the screen in question.
    036     */
    037    public void initGui()
    038    {
    039        StringTranslate stringtranslate = StringTranslate.getInstance();
    040        Keyboard.enableRepeatEvents(true);
    041        this.buttonList.clear();
    042        this.buttonList.add(this.field_96154_o = new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96 + 12, stringtranslate.translateKey("mco.configure.world.buttons.reset")));
    043        this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 120 + 12, stringtranslate.translateKey("gui.cancel")));
    044        this.field_96151_c = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 109, 200, 20);
    045        this.field_96151_c.setFocused(true);
    046        this.field_96151_c.setMaxStringLength(32);
    047        this.field_96151_c.setText("");
    048    }
    049
    050    /**
    051     * Called when the screen is unloaded. Used to disable keyboard repeat events
    052     */
    053    public void onGuiClosed()
    054    {
    055        Keyboard.enableRepeatEvents(false);
    056    }
    057
    058    /**
    059     * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
    060     */
    061    protected void keyTyped(char par1, int par2)
    062    {
    063        this.field_96151_c.textboxKeyTyped(par1, par2);
    064    }
    065
    066    /**
    067     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    068     */
    069    protected void actionPerformed(GuiButton par1GuiButton)
    070    {
    071        if (par1GuiButton.enabled)
    072        {
    073            if (par1GuiButton.id == 2)
    074            {
    075                this.mc.displayGuiScreen(this.field_96152_a);
    076            }
    077            else if (par1GuiButton.id == 1)
    078            {
    079                TaskResetWorld taskresetworld = new TaskResetWorld(this, this.field_96150_b.field_96408_a);
    080                GuiScreenLongRunningTask guiscreenlongrunningtask = new GuiScreenLongRunningTask(this.mc, this.field_96152_a, taskresetworld);
    081                guiscreenlongrunningtask.func_98117_g();
    082                this.mc.displayGuiScreen(guiscreenlongrunningtask);
    083            }
    084        }
    085    }
    086
    087    /**
    088     * Called when the mouse is clicked.
    089     */
    090    protected void mouseClicked(int par1, int par2, int par3)
    091    {
    092        super.mouseClicked(par1, par2, par3);
    093        this.field_96151_c.mouseClicked(par1, par2, par3);
    094    }
    095
    096    /**
    097     * Draws the screen and all the components in it.
    098     */
    099    public void drawScreen(int par1, int par2, float par3)
    100    {
    101        StringTranslate stringtranslate = StringTranslate.getInstance();
    102        this.drawDefaultBackground();
    103        this.drawCenteredString(this.fontRenderer, stringtranslate.translateKey("mco.reset.world.title"), this.width / 2, 17, 16777215);
    104        this.drawCenteredString(this.fontRenderer, stringtranslate.translateKey("mco.reset.world.warning"), this.width / 2, 66, 16711680);
    105        this.drawString(this.fontRenderer, stringtranslate.translateKey("mco.reset.world.seed"), this.width / 2 - 100, 96, 10526880);
    106        this.field_96151_c.drawTextBox();
    107        super.drawScreen(par1, par2, par3);
    108    }
    109
    110    static GuiScreen func_96148_a(GuiScreenResetWorld par0GuiScreenResetWorld)
    111    {
    112        return par0GuiScreenResetWorld.field_96152_a;
    113    }
    114
    115    static Minecraft func_96147_b(GuiScreenResetWorld par0GuiScreenResetWorld)
    116    {
    117        return par0GuiScreenResetWorld.mc;
    118    }
    119}